Add 'request_user_attention' to Window
This commit introduces a cross platform way to request a user attention to the window via a 'request_user_attention' method on a Window struct. This method is inspired by macOS's 'request_user_attention' method and thus reuses its signature and semantics to some extent.
This commit is contained in:
parent
f79efec7ef
commit
0861a353d6
11 changed files with 136 additions and 79 deletions
|
|
@ -22,7 +22,7 @@ use crate::{
|
|||
MonitorHandle as PlatformMonitorHandle, OsError, PlatformSpecificWindowBuilderAttributes,
|
||||
VideoMode as PlatformVideoMode,
|
||||
},
|
||||
window::{CursorIcon, Fullscreen, Icon, WindowAttributes},
|
||||
window::{CursorIcon, Fullscreen, Icon, UserAttentionType, WindowAttributes},
|
||||
};
|
||||
|
||||
use super::{ffi, util, EventLoopWindowTarget, ImeSender, WindowId, XConnection, XError};
|
||||
|
|
@ -523,23 +523,6 @@ impl UnownedWindow {
|
|||
)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_urgent(&self, is_urgent: bool) {
|
||||
let mut wm_hints = self
|
||||
.xconn
|
||||
.get_wm_hints(self.xwindow)
|
||||
.expect("`XGetWMHints` failed");
|
||||
if is_urgent {
|
||||
(*wm_hints).flags |= ffi::XUrgencyHint;
|
||||
} else {
|
||||
(*wm_hints).flags &= !ffi::XUrgencyHint;
|
||||
}
|
||||
self.xconn
|
||||
.set_wm_hints(self.xwindow, wm_hints)
|
||||
.flush()
|
||||
.expect("Failed to set urgency hint");
|
||||
}
|
||||
|
||||
fn set_netwm(
|
||||
&self,
|
||||
operation: util::StateOperation,
|
||||
|
|
@ -1306,6 +1289,23 @@ impl UnownedWindow {
|
|||
self.set_ime_position_physical(x, y);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn request_user_attention(&self, request_type: Option<UserAttentionType>) {
|
||||
let mut wm_hints = self
|
||||
.xconn
|
||||
.get_wm_hints(self.xwindow)
|
||||
.expect("`XGetWMHints` failed");
|
||||
if request_type.is_some() {
|
||||
(*wm_hints).flags |= ffi::XUrgencyHint;
|
||||
} else {
|
||||
(*wm_hints).flags &= !ffi::XUrgencyHint;
|
||||
}
|
||||
self.xconn
|
||||
.set_wm_hints(self.xwindow, wm_hints)
|
||||
.flush()
|
||||
.expect("Failed to set urgency hint");
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn id(&self) -> WindowId {
|
||||
WindowId(self.xwindow)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue