소스 검색

feat(core): add `is_resizable` Window getter

Lucas Nogueira 4 년 전
부모
커밋
1e8af280c2
6개의 변경된 파일29개의 추가작업 그리고 0개의 파일을 삭제
  1. 5 0
      .changes/api-is-resizable.md
  2. 7 0
      .changes/is-resizable.md
  3. 7 0
      core/tauri-runtime-wry/src/lib.rs
  4. 3 0
      core/tauri-runtime/src/lib.rs
  5. 2 0
      core/tauri/src/endpoints/window.rs
  6. 5 0
      core/tauri/src/window.rs

+ 5 - 0
.changes/api-is-resizable.md

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

+ 7 - 0
.changes/is-resizable.md

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

+ 7 - 0
core/tauri-runtime-wry/src/lib.rs

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

+ 3 - 0
core/tauri-runtime/src/lib.rs

@@ -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.

+ 2 - 0
core/tauri/src/endpoints/window.rs

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

+ 5 - 0
core/tauri/src/window.rs

@@ -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.