mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-01 03:02:28 +03:00
feat(core): add is_resizable
Window getter
This commit is contained in:
parent
f58a2114fb
commit
1e8af280c2
5
.changes/api-is-resizable.md
Normal file
5
.changes/api-is-resizable.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"api": patch
|
||||
---
|
||||
|
||||
Adds `isResizable` getter on the window API.
|
7
.changes/is-resizable.md
Normal file
7
.changes/is-resizable.md
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
"tauri": patch
|
||||
"tauri-runtime": patch
|
||||
"tauri-runtime-wry": patch
|
||||
---
|
||||
|
||||
Adds `is_resizable` getter on Window.
|
@ -400,6 +400,7 @@ enum WindowMessage {
|
||||
IsFullscreen(Sender<bool>),
|
||||
IsMaximized(Sender<bool>),
|
||||
IsDecorated(Sender<bool>),
|
||||
IsResizable(Sender<bool>),
|
||||
CurrentMonitor(Sender<Option<MonitorHandle>>),
|
||||
PrimaryMonitor(Sender<Option<MonitorHandle>>),
|
||||
AvailableMonitors(Sender<Vec<MonitorHandle>>),
|
||||
@ -537,6 +538,11 @@ impl Dispatch for WryDispatcher {
|
||||
Ok(dispatcher_getter!(self, WindowMessage::IsDecorated))
|
||||
}
|
||||
|
||||
/// Gets the window’s current resizable state.
|
||||
fn is_resizable(&self) -> Result<bool> {
|
||||
Ok(dispatcher_getter!(self, WindowMessage::IsResizable))
|
||||
}
|
||||
|
||||
fn current_monitor(&self) -> Result<Option<Monitor>> {
|
||||
Ok(
|
||||
dispatcher_getter!(self, WindowMessage::CurrentMonitor)
|
||||
@ -1140,6 +1146,7 @@ fn handle_event_loop(
|
||||
WindowMessage::IsFullscreen(tx) => tx.send(window.fullscreen().is_some()).unwrap(),
|
||||
WindowMessage::IsMaximized(tx) => tx.send(window.is_maximized()).unwrap(),
|
||||
WindowMessage::IsDecorated(tx) => tx.send(window.is_decorated()).unwrap(),
|
||||
WindowMessage::IsResizable(tx) => tx.send(window.is_resizable()).unwrap(),
|
||||
WindowMessage::CurrentMonitor(tx) => tx.send(window.current_monitor()).unwrap(),
|
||||
WindowMessage::PrimaryMonitor(tx) => tx.send(window.primary_monitor()).unwrap(),
|
||||
WindowMessage::AvailableMonitors(tx) => {
|
||||
|
@ -210,6 +210,9 @@ pub trait Dispatch: Clone + Send + Sized + 'static {
|
||||
/// Gets the window’s current decoration state.
|
||||
fn is_decorated(&self) -> crate::Result<bool>;
|
||||
|
||||
/// Gets the window’s current resizable state.
|
||||
fn is_resizable(&self) -> crate::Result<bool>;
|
||||
|
||||
/// Returns the monitor on which the window currently resides.
|
||||
///
|
||||
/// Returns None if current monitor can't be detected.
|
||||
|
@ -47,6 +47,7 @@ pub enum Cmd {
|
||||
IsFullscreen,
|
||||
IsMaximized,
|
||||
IsDecorated,
|
||||
IsResizable,
|
||||
CurrentMonitor,
|
||||
PrimaryMonitor,
|
||||
AvailableMonitors,
|
||||
@ -131,6 +132,7 @@ impl Cmd {
|
||||
Self::IsFullscreen => return Ok(window.is_fullscreen()?.into()),
|
||||
Self::IsMaximized => return Ok(window.is_maximized()?.into()),
|
||||
Self::IsDecorated => return Ok(window.is_decorated()?.into()),
|
||||
Self::IsResizable => return Ok(window.is_resizable()?.into()),
|
||||
Self::CurrentMonitor => return Ok(window.current_monitor()?.into()),
|
||||
Self::PrimaryMonitor => return Ok(window.primary_monitor()?.into()),
|
||||
Self::AvailableMonitors => return Ok(window.available_monitors()?.into()),
|
||||
|
@ -356,6 +356,11 @@ impl<P: Params> Window<P> {
|
||||
self.window.dispatcher.is_decorated().map_err(Into::into)
|
||||
}
|
||||
|
||||
/// Gets the window’s current resizable state.
|
||||
pub fn is_resizable(&self) -> crate::Result<bool> {
|
||||
self.window.dispatcher.is_resizable().map_err(Into::into)
|
||||
}
|
||||
|
||||
/// Returns the monitor on which the window currently resides.
|
||||
///
|
||||
/// Returns None if current monitor can't be detected.
|
||||
|
Loading…
Reference in New Issue
Block a user