Skip to content

Commit f58a211

Browse files
committed
feat(core): add is_decorated Window getter
1 parent f63925e commit f58a211

File tree

7 files changed

+39
-0
lines changed

7 files changed

+39
-0
lines changed

.changes/api-is-decorated.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"api": patch
3+
---
4+
5+
Adds `isDecorated` getter on the window API.

.changes/is-decorated.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"tauri": patch
3+
"tauri-runtime": patch
4+
"tauri-runtime-wry": patch
5+
---
6+
7+
Adds `is_decorated` getter on Window.

core/tauri-runtime-wry/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ enum WindowMessage {
399399
OuterSize(Sender<PhysicalSize<u32>>),
400400
IsFullscreen(Sender<bool>),
401401
IsMaximized(Sender<bool>),
402+
IsDecorated(Sender<bool>),
402403
CurrentMonitor(Sender<Option<MonitorHandle>>),
403404
PrimaryMonitor(Sender<Option<MonitorHandle>>),
404405
AvailableMonitors(Sender<Vec<MonitorHandle>>),
@@ -531,6 +532,11 @@ impl Dispatch for WryDispatcher {
531532
Ok(dispatcher_getter!(self, WindowMessage::IsMaximized))
532533
}
533534

535+
/// Gets the window’s current decoration state.
536+
fn is_decorated(&self) -> Result<bool> {
537+
Ok(dispatcher_getter!(self, WindowMessage::IsDecorated))
538+
}
539+
534540
fn current_monitor(&self) -> Result<Option<Monitor>> {
535541
Ok(
536542
dispatcher_getter!(self, WindowMessage::CurrentMonitor)
@@ -1133,6 +1139,7 @@ fn handle_event_loop(
11331139
.unwrap(),
11341140
WindowMessage::IsFullscreen(tx) => tx.send(window.fullscreen().is_some()).unwrap(),
11351141
WindowMessage::IsMaximized(tx) => tx.send(window.is_maximized()).unwrap(),
1142+
WindowMessage::IsDecorated(tx) => tx.send(window.is_decorated()).unwrap(),
11361143
WindowMessage::CurrentMonitor(tx) => tx.send(window.current_monitor()).unwrap(),
11371144
WindowMessage::PrimaryMonitor(tx) => tx.send(window.primary_monitor()).unwrap(),
11381145
WindowMessage::AvailableMonitors(tx) => {

core/tauri-runtime/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ pub trait Dispatch: Clone + Send + Sized + 'static {
207207
/// Gets the window's current maximized state.
208208
fn is_maximized(&self) -> crate::Result<bool>;
209209

210+
/// Gets the window’s current decoration state.
211+
fn is_decorated(&self) -> crate::Result<bool>;
212+
210213
/// Returns the monitor on which the window currently resides.
211214
///
212215
/// Returns None if current monitor can't be detected.

core/tauri/src/endpoints/window.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ pub enum Cmd {
4646
OuterSize,
4747
IsFullscreen,
4848
IsMaximized,
49+
IsDecorated,
4950
CurrentMonitor,
5051
PrimaryMonitor,
5152
AvailableMonitors,
@@ -129,6 +130,7 @@ impl Cmd {
129130
Self::OuterSize => return Ok(window.outer_size()?.into()),
130131
Self::IsFullscreen => return Ok(window.is_fullscreen()?.into()),
131132
Self::IsMaximized => return Ok(window.is_maximized()?.into()),
133+
Self::IsDecorated => return Ok(window.is_decorated()?.into()),
132134
Self::CurrentMonitor => return Ok(window.current_monitor()?.into()),
133135
Self::PrimaryMonitor => return Ok(window.primary_monitor()?.into()),
134136
Self::AvailableMonitors => return Ok(window.available_monitors()?.into()),

core/tauri/src/window.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,11 @@ impl<P: Params> Window<P> {
351351
self.window.dispatcher.is_maximized().map_err(Into::into)
352352
}
353353

354+
/// Gets the window’s current decoration state.
355+
pub fn is_decorated(&self) -> crate::Result<bool> {
356+
self.window.dispatcher.is_decorated().map_err(Into::into)
357+
}
358+
354359
/// Returns the monitor on which the window currently resides.
355360
///
356361
/// Returns None if current monitor can't be detected.

tooling/api/src/window.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,16 @@ class WindowManager {
362362
})
363363
}
364364

365+
/** Gets the window's current decorated state. */
366+
async isDecorated(): Promise<boolean> {
367+
return invokeTauriCommand({
368+
__tauriModule: 'Window',
369+
message: {
370+
cmd: 'isDecorated'
371+
}
372+
})
373+
}
374+
365375
// Setters
366376

367377
/**

0 commit comments

Comments
 (0)