feat(core): add is_resizable Window getter

This commit is contained in:
Lucas Nogueira 2021-05-30 17:23:52 -03:00
parent f58a2114fb
commit 1e8af280c2
No known key found for this signature in database
GPG Key ID: 2714B66BCFB01F7F
6 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,5 @@
---
"api": patch
---
Adds `isResizable` getter on the window API.

7
.changes/is-resizable.md Normal file
View File

@ -0,0 +1,7 @@
---
"tauri": patch
"tauri-runtime": patch
"tauri-runtime-wry": patch
---
Adds `is_resizable` getter on Window.

View File

@ -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 windows 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) => {

View File

@ -210,6 +210,9 @@ pub trait Dispatch: Clone + Send + Sized + 'static {
/// Gets the windows current decoration state.
fn is_decorated(&self) -> crate::Result<bool>;
/// Gets the windows 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.

View File

@ -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()),

View File

@ -356,6 +356,11 @@ impl<P: Params> Window<P> {
self.window.dispatcher.is_decorated().map_err(Into::into)
}
/// Gets the windows 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.