Add option to make window "always on top" (#528)
* macOS: always_on_top * Windows: always_on_top * X11: always_on_top * Stub set_always_on_top on other platforms
This commit is contained in:
parent
f6d26df64d
commit
f51f7c0ca8
11 changed files with 161 additions and 4 deletions
|
|
@ -302,6 +302,14 @@ impl Window {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_always_on_top(&self, always_on_top: bool) {
|
||||
match self {
|
||||
&Window::X(ref w) => w.set_always_on_top(always_on_top),
|
||||
&Window::Wayland(_) => (),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_window_icon(&self, window_icon: Option<Icon>) {
|
||||
match self {
|
||||
|
|
|
|||
|
|
@ -299,8 +299,15 @@ impl Window2 {
|
|||
}.queue();
|
||||
|
||||
// These properties must be set after mapping
|
||||
window.set_maximized_inner(window_attrs.maximized).queue();
|
||||
window.set_fullscreen_inner(window_attrs.fullscreen.clone()).queue();
|
||||
if window_attrs.maximized {
|
||||
window.set_maximized_inner(window_attrs.maximized).queue();
|
||||
}
|
||||
if window_attrs.fullscreen.is_some() {
|
||||
window.set_fullscreen_inner(window_attrs.fullscreen.clone()).queue();
|
||||
}
|
||||
if window_attrs.always_on_top {
|
||||
window.set_always_on_top_inner(window_attrs.always_on_top).queue();
|
||||
}
|
||||
|
||||
if window_attrs.visible {
|
||||
unsafe {
|
||||
|
|
@ -498,6 +505,27 @@ impl Window2 {
|
|||
self.invalidate_cached_frame_extents();
|
||||
}
|
||||
|
||||
fn set_always_on_top_inner(&self, always_on_top: bool) -> util::Flusher {
|
||||
let xconn = &self.x.display;
|
||||
|
||||
let above_atom = unsafe { util::get_atom(xconn, b"_NET_WM_STATE_ABOVE\0") }
|
||||
.expect("Failed to call XInternAtom (_NET_WM_STATE_ABOVE)");
|
||||
|
||||
Window2::set_netwm(
|
||||
xconn,
|
||||
self.x.window,
|
||||
self.x.root,
|
||||
(above_atom as c_long, 0, 0, 0),
|
||||
always_on_top.into(),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn set_always_on_top(&self, always_on_top: bool) {
|
||||
self.set_always_on_top_inner(always_on_top)
|
||||
.flush()
|
||||
.expect("Failed to set always-on-top state");
|
||||
}
|
||||
|
||||
fn set_icon_inner(&self, icon: Icon) -> util::Flusher {
|
||||
let xconn = &self.x.display;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue