Skip to content

Commit 1e8af28

Browse files
committed
feat(core): add is_resizable Window getter
1 parent f58a211 commit 1e8af28

File tree

6 files changed

+29
-0
lines changed

6 files changed

+29
-0
lines changed

.changes/api-is-resizable.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 `isResizable` getter on the window API.

.changes/is-resizable.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_resizable` getter on Window.

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ enum WindowMessage {
400400
IsFullscreen(Sender<bool>),
401401
IsMaximized(Sender<bool>),
402402
IsDecorated(Sender<bool>),
403+
IsResizable(Sender<bool>),
403404
CurrentMonitor(Sender<Option<MonitorHandle>>),
404405
PrimaryMonitor(Sender<Option<MonitorHandle>>),
405406
AvailableMonitors(Sender<Vec<MonitorHandle>>),
@@ -537,6 +538,11 @@ impl Dispatch for WryDispatcher {
537538
Ok(dispatcher_getter!(self, WindowMessage::IsDecorated))
538539
}
539540

541+
/// Gets the window’s current resizable state.
542+
fn is_resizable(&self) -> Result<bool> {
543+
Ok(dispatcher_getter!(self, WindowMessage::IsResizable))
544+
}
545+
540546
fn current_monitor(&self) -> Result<Option<Monitor>> {
541547
Ok(
542548
dispatcher_getter!(self, WindowMessage::CurrentMonitor)
@@ -1140,6 +1146,7 @@ fn handle_event_loop(
11401146
WindowMessage::IsFullscreen(tx) => tx.send(window.fullscreen().is_some()).unwrap(),
11411147
WindowMessage::IsMaximized(tx) => tx.send(window.is_maximized()).unwrap(),
11421148
WindowMessage::IsDecorated(tx) => tx.send(window.is_decorated()).unwrap(),
1149+
WindowMessage::IsResizable(tx) => tx.send(window.is_resizable()).unwrap(),
11431150
WindowMessage::CurrentMonitor(tx) => tx.send(window.current_monitor()).unwrap(),
11441151
WindowMessage::PrimaryMonitor(tx) => tx.send(window.primary_monitor()).unwrap(),
11451152
WindowMessage::AvailableMonitors(tx) => {

core/tauri-runtime/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ pub trait Dispatch: Clone + Send + Sized + 'static {
210210
/// Gets the window’s current decoration state.
211211
fn is_decorated(&self) -> crate::Result<bool>;
212212

213+
/// Gets the window’s current resizable state.
214+
fn is_resizable(&self) -> crate::Result<bool>;
215+
213216
/// Returns the monitor on which the window currently resides.
214217
///
215218
/// 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
@@ -47,6 +47,7 @@ pub enum Cmd {
4747
IsFullscreen,
4848
IsMaximized,
4949
IsDecorated,
50+
IsResizable,
5051
CurrentMonitor,
5152
PrimaryMonitor,
5253
AvailableMonitors,
@@ -131,6 +132,7 @@ impl Cmd {
131132
Self::IsFullscreen => return Ok(window.is_fullscreen()?.into()),
132133
Self::IsMaximized => return Ok(window.is_maximized()?.into()),
133134
Self::IsDecorated => return Ok(window.is_decorated()?.into()),
135+
Self::IsResizable => return Ok(window.is_resizable()?.into()),
134136
Self::CurrentMonitor => return Ok(window.current_monitor()?.into()),
135137
Self::PrimaryMonitor => return Ok(window.primary_monitor()?.into()),
136138
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
@@ -356,6 +356,11 @@ impl<P: Params> Window<P> {
356356
self.window.dispatcher.is_decorated().map_err(Into::into)
357357
}
358358

359+
/// Gets the window’s current resizable state.
360+
pub fn is_resizable(&self) -> crate::Result<bool> {
361+
self.window.dispatcher.is_resizable().map_err(Into::into)
362+
}
363+
359364
/// Returns the monitor on which the window currently resides.
360365
///
361366
/// Returns None if current monitor can't be detected.

0 commit comments

Comments
 (0)