diff --git a/.changes/api-is-decorated.md b/.changes/api-is-decorated.md new file mode 100644 index 00000000000..0806cdf8982 --- /dev/null +++ b/.changes/api-is-decorated.md @@ -0,0 +1,5 @@ +--- +"api": patch +--- + +Adds `isDecorated` getter on the window API. diff --git a/.changes/is-decorated.md b/.changes/is-decorated.md new file mode 100644 index 00000000000..0cfb498166e --- /dev/null +++ b/.changes/is-decorated.md @@ -0,0 +1,7 @@ +--- +"tauri": patch +"tauri-runtime": patch +"tauri-runtime-wry": patch +--- + +Adds `is_decorated` getter on Window. diff --git a/core/tauri-runtime-wry/src/lib.rs b/core/tauri-runtime-wry/src/lib.rs index ffe0caaee9d..0847ce24cdf 100644 --- a/core/tauri-runtime-wry/src/lib.rs +++ b/core/tauri-runtime-wry/src/lib.rs @@ -399,6 +399,7 @@ enum WindowMessage { OuterSize(Sender>), IsFullscreen(Sender), IsMaximized(Sender), + IsDecorated(Sender), CurrentMonitor(Sender>), PrimaryMonitor(Sender>), AvailableMonitors(Sender>), @@ -531,6 +532,11 @@ impl Dispatch for WryDispatcher { Ok(dispatcher_getter!(self, WindowMessage::IsMaximized)) } + /// Gets the window’s current decoration state. + fn is_decorated(&self) -> Result { + Ok(dispatcher_getter!(self, WindowMessage::IsDecorated)) + } + fn current_monitor(&self) -> Result> { Ok( dispatcher_getter!(self, WindowMessage::CurrentMonitor) @@ -1133,6 +1139,7 @@ fn handle_event_loop( .unwrap(), 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::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 14fa87016d1..e07a3ad2e32 100644 --- a/core/tauri-runtime/src/lib.rs +++ b/core/tauri-runtime/src/lib.rs @@ -207,6 +207,9 @@ pub trait Dispatch: Clone + Send + Sized + 'static { /// Gets the window's current maximized state. fn is_maximized(&self) -> crate::Result; + /// Gets the window’s current decoration state. + fn is_decorated(&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 feee5ab7d72..2af5549da97 100644 --- a/core/tauri/src/endpoints/window.rs +++ b/core/tauri/src/endpoints/window.rs @@ -46,6 +46,7 @@ pub enum Cmd { OuterSize, IsFullscreen, IsMaximized, + IsDecorated, CurrentMonitor, PrimaryMonitor, AvailableMonitors, @@ -129,6 +130,7 @@ impl Cmd { Self::OuterSize => return Ok(window.outer_size()?.into()), 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::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 a29476a3062..107118b666c 100644 --- a/core/tauri/src/window.rs +++ b/core/tauri/src/window.rs @@ -351,6 +351,11 @@ impl Window

{ self.window.dispatcher.is_maximized().map_err(Into::into) } + /// Gets the window’s current decoration state. + pub fn is_decorated(&self) -> crate::Result { + self.window.dispatcher.is_decorated().map_err(Into::into) + } + /// Returns the monitor on which the window currently resides. /// /// Returns None if current monitor can't be detected. diff --git a/tooling/api/src/window.ts b/tooling/api/src/window.ts index 66a0d13cb3d..368c8f9226d 100644 --- a/tooling/api/src/window.ts +++ b/tooling/api/src/window.ts @@ -362,6 +362,16 @@ class WindowManager { }) } + /** Gets the window's current decorated state. */ + async isDecorated(): Promise { + return invokeTauriCommand({ + __tauriModule: 'Window', + message: { + cmd: 'isDecorated' + } + }) + } + // Setters /**