mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-27 03:56:33 +11:00
feat: add Window::is_resizable
(#2171)
* feat: add `Window::is_resizable` * move it right after `set_resizable`
This commit is contained in:
parent
fa14863284
commit
daf0d6b9a7
10 changed files with 52 additions and 0 deletions
|
@ -8,6 +8,7 @@ And please only add new entries to the top of this list, right below the `# Unre
|
||||||
|
|
||||||
# Unreleased
|
# Unreleased
|
||||||
|
|
||||||
|
- Added `Window::is_resizable`.
|
||||||
- Added `Window::is_decorated`.
|
- Added `Window::is_decorated`.
|
||||||
- On X11, fix for repeated event loop iteration when `ControlFlow` was `Wait`
|
- On X11, fix for repeated event loop iteration when `ControlFlow` was `Wait`
|
||||||
- On Wayland, report unaccelerated mouse deltas in `DeviceEvent::MouseMotion`.
|
- On Wayland, report unaccelerated mouse deltas in `DeviceEvent::MouseMotion`.
|
||||||
|
|
|
@ -543,6 +543,10 @@ impl Window {
|
||||||
|
|
||||||
pub fn set_resizable(&self, _resizeable: bool) {}
|
pub fn set_resizable(&self, _resizeable: bool) {}
|
||||||
|
|
||||||
|
pub fn is_resizable(&self) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_minimized(&self, _minimized: bool) {}
|
pub fn set_minimized(&self, _minimized: bool) {}
|
||||||
|
|
||||||
pub fn set_maximized(&self, _maximized: bool) {}
|
pub fn set_maximized(&self, _maximized: bool) {}
|
||||||
|
|
|
@ -159,6 +159,11 @@ impl Inner {
|
||||||
warn!("`Window::set_resizable` is ignored on iOS")
|
warn!("`Window::set_resizable` is ignored on iOS")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_resizable(&self) -> bool {
|
||||||
|
warn!("`Window::is_resizable` is ignored on iOS");
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
pub fn scale_factor(&self) -> f64 {
|
pub fn scale_factor(&self) -> f64 {
|
||||||
unsafe {
|
unsafe {
|
||||||
let hidpi: CGFloat = msg_send![self.view, contentScaleFactor];
|
let hidpi: CGFloat = msg_send![self.view, contentScaleFactor];
|
||||||
|
|
|
@ -366,6 +366,11 @@ impl Window {
|
||||||
x11_or_wayland!(match self; Window(w) => w.set_resizable(resizable))
|
x11_or_wayland!(match self; Window(w) => w.set_resizable(resizable))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn is_resizable(&self) -> bool {
|
||||||
|
x11_or_wayland!(match self; Window(w) => w.is_resizable())
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_cursor_icon(&self, cursor: CursorIcon) {
|
pub fn set_cursor_icon(&self, cursor: CursorIcon) {
|
||||||
x11_or_wayland!(match self; Window(w) => w.set_cursor_icon(cursor))
|
x11_or_wayland!(match self; Window(w) => w.set_cursor_icon(cursor))
|
||||||
|
|
|
@ -336,6 +336,11 @@ impl Window {
|
||||||
self.send_request(WindowRequest::Resizeable(resizable));
|
self.send_request(WindowRequest::Resizeable(resizable));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn is_resizable(&self) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn scale_factor(&self) -> u32 {
|
pub fn scale_factor(&self) -> u32 {
|
||||||
// The scale factor from `get_surface_scale_factor` is always greater than zero, so
|
// The scale factor from `get_surface_scale_factor` is always greater than zero, so
|
||||||
|
|
|
@ -1211,6 +1211,11 @@ impl UnownedWindow {
|
||||||
.expect("Failed to call `XSetWMNormalHints`");
|
.expect("Failed to call `XSetWMNormalHints`");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn is_resizable(&self) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn xlib_display(&self) -> *mut c_void {
|
pub fn xlib_display(&self) -> *mut c_void {
|
||||||
self.xconn.display as _
|
self.xconn.display as _
|
||||||
|
|
|
@ -602,6 +602,12 @@ impl UnownedWindow {
|
||||||
} // Otherwise, we don't change the mask until we exit fullscreen.
|
} // Otherwise, we don't change the mask until we exit fullscreen.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn is_resizable(&self) -> bool {
|
||||||
|
let is_resizable: BOOL = unsafe { msg_send![*self.ns_window, isResizable] };
|
||||||
|
is_resizable == YES
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_cursor_icon(&self, cursor: CursorIcon) {
|
pub fn set_cursor_icon(&self, cursor: CursorIcon) {
|
||||||
let cursor = util::Cursor::from(cursor);
|
let cursor = util::Cursor::from(cursor);
|
||||||
if let Some(cursor_access) = self.cursor_state.upgrade() {
|
if let Some(cursor_access) = self.cursor_state.upgrade() {
|
||||||
|
|
|
@ -151,6 +151,10 @@ impl Window {
|
||||||
// Intentionally a no-op: users can't resize canvas elements
|
// Intentionally a no-op: users can't resize canvas elements
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_resizable(&self) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn scale_factor(&self) -> f64 {
|
pub fn scale_factor(&self) -> f64 {
|
||||||
super::backend::scale_factor()
|
super::backend::scale_factor()
|
||||||
|
|
|
@ -225,6 +225,12 @@ impl Window {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn is_resizable(&self) -> bool {
|
||||||
|
let window_state = self.window_state.lock();
|
||||||
|
window_state.window_flags.contains(WindowFlags::RESIZABLE)
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the `hwnd` of this window.
|
/// Returns the `hwnd` of this window.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn hwnd(&self) -> HWND {
|
pub fn hwnd(&self) -> HWND {
|
||||||
|
|
|
@ -669,6 +669,17 @@ impl Window {
|
||||||
self.window.set_resizable(resizable)
|
self.window.set_resizable(resizable)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Gets the window's current resizable state.
|
||||||
|
///
|
||||||
|
/// ## Platform-specific
|
||||||
|
///
|
||||||
|
/// - **Wayland / X11:** Not implemented.
|
||||||
|
/// - **iOS / Android / Web:** Unsupported.
|
||||||
|
#[inline]
|
||||||
|
pub fn is_resizable(&self) -> bool {
|
||||||
|
self.window.is_resizable()
|
||||||
|
}
|
||||||
|
|
||||||
/// Sets the window to minimized or back
|
/// Sets the window to minimized or back
|
||||||
///
|
///
|
||||||
/// ## Platform-specific
|
/// ## Platform-specific
|
||||||
|
|
Loading…
Add table
Reference in a new issue