mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-23 13:51:30 +11:00
feat: add Window::is_visible
(#2169)
* feat: add `Window::is_visible` * use `Option<bool>` * update doc * move it right after `set_visible`
This commit is contained in:
parent
ac1c9b1218
commit
f9643917d3
|
@ -8,6 +8,7 @@ And please only add new entries to the top of this list, right below the `# Unre
|
|||
|
||||
# Unreleased
|
||||
|
||||
- Added `Window::is_visible`.
|
||||
- Added `Window::is_resizable`.
|
||||
- Added `Window::is_decorated`.
|
||||
- On X11, fix for repeated event loop iteration when `ControlFlow` was `Wait`
|
||||
|
|
|
@ -543,6 +543,10 @@ impl Window {
|
|||
|
||||
pub fn set_visible(&self, _visibility: bool) {}
|
||||
|
||||
pub fn is_visible(&self) -> Option<bool> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn set_resizable(&self, _resizeable: bool) {}
|
||||
|
||||
pub fn is_resizable(&self) -> bool {
|
||||
|
|
|
@ -60,6 +60,11 @@ impl Inner {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn is_visible(&self) -> Option<bool> {
|
||||
warn!("`Window::is_visible` is ignored on iOS");
|
||||
None
|
||||
}
|
||||
|
||||
pub fn request_redraw(&self) {
|
||||
unsafe {
|
||||
if self.gl_or_metal_backed {
|
||||
|
|
|
@ -321,6 +321,11 @@ impl Window {
|
|||
x11_or_wayland!(match self; Window(w) => w.set_visible(visible))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_visible(&self) -> Option<bool> {
|
||||
x11_or_wayland!(match self; Window(w) => w.is_visible())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn outer_position(&self) -> Result<PhysicalPosition<i32>, NotSupportedError> {
|
||||
x11_or_wayland!(match self; Window(w) => w.outer_position())
|
||||
|
|
|
@ -270,6 +270,11 @@ impl Window {
|
|||
// Not possible on Wayland.
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_visible(&self) -> Option<bool> {
|
||||
None
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn outer_position(&self) -> Result<PhysicalPosition<i32>, NotSupportedError> {
|
||||
Err(NotSupportedError::new())
|
||||
|
|
|
@ -984,6 +984,11 @@ impl UnownedWindow {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_visible(&self) -> Option<bool> {
|
||||
None
|
||||
}
|
||||
|
||||
fn update_cached_frame_extents(&self) {
|
||||
let extents = self
|
||||
.xconn
|
||||
|
|
|
@ -502,6 +502,12 @@ impl UnownedWindow {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_visible(&self) -> Option<bool> {
|
||||
let is_visible: BOOL = unsafe { msg_send![*self.ns_window, isVisible] };
|
||||
Some(is_visible == YES)
|
||||
}
|
||||
|
||||
pub fn request_redraw(&self) {
|
||||
AppState::queue_redraw(RootWindowId(self.id()));
|
||||
}
|
||||
|
|
|
@ -89,6 +89,11 @@ impl Window {
|
|||
// Intentionally a no-op
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_visible(&self) -> Option<bool> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn request_redraw(&self) {
|
||||
(self.register_redraw_request)();
|
||||
}
|
||||
|
|
|
@ -97,6 +97,11 @@ impl Window {
|
|||
});
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_visible(&self) -> Option<bool> {
|
||||
Some(unsafe { winuser::IsWindowVisible(self.window.0) == 1 })
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn request_redraw(&self) {
|
||||
unsafe {
|
||||
|
|
|
@ -650,6 +650,19 @@ impl Window {
|
|||
self.window.set_visible(visible)
|
||||
}
|
||||
|
||||
/// Gets the window's current vibility state.
|
||||
///
|
||||
/// If `None` means it couldn't be determined so it is not recommended to use this to drive your rendering backend.
|
||||
///
|
||||
/// ## Platform-specific
|
||||
///
|
||||
/// - **X11:** Not implemented.
|
||||
/// - **Wayland / iOS / Android / Web:** Unsupported.
|
||||
#[inline]
|
||||
pub fn is_visible(&self) -> Option<bool> {
|
||||
self.window.is_visible()
|
||||
}
|
||||
|
||||
/// Sets whether the window is resizable or not.
|
||||
///
|
||||
/// Note that making the window unresizable doesn't exempt you from handling `Resized`, as that event can still be
|
||||
|
|
Loading…
Reference in a new issue