diff --git a/.changes/api-is-resizable.md b/.changes/api-is-resizable.md new file mode 100644 index 000000000..c81d120a9 --- /dev/null +++ b/.changes/api-is-resizable.md @@ -0,0 +1,5 @@ +--- +"api": patch +--- + +Adds `isResizable` getter on the window API. diff --git a/.changes/is-resizable.md b/.changes/is-resizable.md new file mode 100644 index 000000000..45a084327 --- /dev/null +++ b/.changes/is-resizable.md @@ -0,0 +1,7 @@ +--- +"tauri": patch +"tauri-runtime": patch +"tauri-runtime-wry": patch +--- + +Adds `is_resizable` getter on Window. diff --git a/core/tauri-runtime-wry/src/lib.rs b/core/tauri-runtime-wry/src/lib.rs index 0847ce24c..f42079db7 100644 --- a/core/tauri-runtime-wry/src/lib.rs +++ b/core/tauri-runtime-wry/src/lib.rs @@ -400,6 +400,7 @@ enum WindowMessage { IsFullscreen(Sender), IsMaximized(Sender), IsDecorated(Sender), + IsResizable(Sender), CurrentMonitor(Sender>), PrimaryMonitor(Sender>), AvailableMonitors(Sender>), @@ -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 { + Ok(dispatcher_getter!(self, WindowMessage::IsResizable)) + } + fn current_monitor(&self) -> Result> { 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) => { diff --git a/core/tauri-runtime/src/lib.rs b/core/tauri-runtime/src/lib.rs index e07a3ad2e..1a4f1a422 100644 --- a/core/tauri-runtime/src/lib.rs +++ b/core/tauri-runtime/src/lib.rs @@ -210,6 +210,9 @@ pub trait Dispatch: Clone + Send + Sized + 'static { /// Gets the window’s current decoration state. fn is_decorated(&self) -> crate::Result; + /// Gets the window’s current resizable state. + fn is_resizable(&self) -> crate::Result; + /// Returns the monitor on which the window currently resides. /// /// Returns None if current monitor can't be detected. diff --git a/core/tauri/src/endpoints/window.rs b/core/tauri/src/endpoints/window.rs index 2af5549da..e17996656 100644 --- a/core/tauri/src/endpoints/window.rs +++ b/core/tauri/src/endpoints/window.rs @@ -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()), diff --git a/core/tauri/src/window.rs b/core/tauri/src/window.rs index 107118b66..c0613f9b3 100644 --- a/core/tauri/src/window.rs +++ b/core/tauri/src/window.rs @@ -356,6 +356,11 @@ impl Window

{ self.window.dispatcher.is_decorated().map_err(Into::into) } + /// Gets the window’s current resizable state. + pub fn is_resizable(&self) -> crate::Result { + 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.