Skip to content

Commit

Permalink
Merge pull request #58 from tauri-apps/feat/is-resizable
Browse files Browse the repository at this point in the history
add `is_resizable` getter to `Window`
  • Loading branch information
Ngo Iok Ui (Wu Yu Wei) authored May 17, 2021
2 parents ab25c6c + 039a61f commit 78f16f7
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changes/is-resizable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tao": patch
---

Add `is_resizable` getter on `Window`
5 changes: 5 additions & 0 deletions src/platform_impl/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,11 @@ impl Window {
false
}

pub fn is_resizable(&self) -> bool {
warn!("`Window::is_resizable` is ignored on android");
false
}

pub fn is_decorated(&self) -> bool {
warn!("`Window::is_decorated` is ignored on Android");
false
Expand Down
5 changes: 5 additions & 0 deletions src/platform_impl/ios/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ impl Inner {
false
}

pub fn is_resizable(&self) -> bool {
warn!("`Window::is_resizable` is ignored on iOS");
false
}

pub fn is_decorated(&self) -> bool {
warn!("`Window::is_decorated` is ignored on iOS");
false
Expand Down
4 changes: 4 additions & 0 deletions src/platform_impl/linux/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,10 @@ impl Window {
self.maximized.load(Ordering::Acquire)
}

pub fn is_resizable(&self) -> bool {
self.window.get_resizable()
}

pub fn is_decorated(&self) -> bool {
self.window.get_decorated()
}
Expand Down
5 changes: 5 additions & 0 deletions src/platform_impl/macos/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,11 @@ impl UnownedWindow {
}

#[inline]
pub fn is_resizable(&self) -> bool {
let is_resizable: BOOL = unsafe { msg_send![*self.ns_window, isResizable] };
is_resizable == YES
}

pub fn is_decorated(&self) -> bool {
let current_mask = unsafe { self.ns_window.styleMask() };
if current_mask
Expand Down
5 changes: 5 additions & 0 deletions src/platform_impl/windows/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,11 @@ impl Window {
}

#[inline]
pub fn is_resizable(&self) -> bool {
let window_state = self.window_state.lock();
window_state.window_flags.contains(WindowFlags::RESIZABLE)
}

pub fn is_decorated(&self) -> bool {
let window_state = self.window_state.lock();
window_state.window_flags.contains(WindowFlags::DECORATIONS)
Expand Down
11 changes: 10 additions & 1 deletion src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,12 +660,21 @@ impl Window {
self.window.is_maximized()
}

/// Gets the window's current decoration state.
/// Gets the window's current resizable state.
///
/// ## Platform-specific
///
/// - **iOS / Android:** Unsupported.
#[inline]
pub fn is_resizable(&self) -> bool {
self.window.is_resizable()
}

/// Gets the window's current decoration state.
///
/// ## Platform-specific
///
/// - **iOS / Android:** Unsupported.
pub fn is_decorated(&self) -> bool {
self.window.is_decorated()
}
Expand Down

0 comments on commit 78f16f7

Please sign in to comment.