Skip to content

Commit

Permalink
feat(core): add is_resizable Window getter
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed May 30, 2021
1 parent f58a211 commit 1e8af28
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changes/api-is-resizable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"api": patch
---

Adds `isResizable` getter on the window API.
7 changes: 7 additions & 0 deletions .changes/is-resizable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"tauri": patch
"tauri-runtime": patch
"tauri-runtime-wry": patch
---

Adds `is_resizable` getter on Window.
7 changes: 7 additions & 0 deletions core/tauri-runtime-wry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>>),
Expand Down Expand Up @@ -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<bool> {
Ok(dispatcher_getter!(self, WindowMessage::IsResizable))
}

fn current_monitor(&self) -> Result<Option<Monitor>> {
Ok(
dispatcher_getter!(self, WindowMessage::CurrentMonitor)
Expand Down Expand Up @@ -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) => {
Expand Down
3 changes: 3 additions & 0 deletions core/tauri-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ pub trait Dispatch: Clone + Send + Sized + 'static {
/// Gets the window’s current decoration state.
fn is_decorated(&self) -> crate::Result<bool>;

/// Gets the window’s 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.
Expand Down
2 changes: 2 additions & 0 deletions core/tauri/src/endpoints/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub enum Cmd {
IsFullscreen,
IsMaximized,
IsDecorated,
IsResizable,
CurrentMonitor,
PrimaryMonitor,
AvailableMonitors,
Expand Down Expand Up @@ -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()),
Expand Down
5 changes: 5 additions & 0 deletions core/tauri/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,11 @@ impl<P: Params> Window<P> {
self.window.dispatcher.is_decorated().map_err(Into::into)
}

/// Gets the window’s 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.
Expand Down

0 comments on commit 1e8af28

Please sign in to comment.