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
|
|
@ -25,6 +25,7 @@ use std::sync::Weak;
|
|||
use std::cell::{Cell, RefCell};
|
||||
|
||||
use super::events_loop::{EventsLoop, Shared};
|
||||
use platform::platform::ffi;
|
||||
use platform::platform::util;
|
||||
use platform::platform::view::{new_view, set_ime_spot};
|
||||
|
||||
|
|
@ -774,6 +775,10 @@ impl Window2 {
|
|||
if pl_attrs.movable_by_window_background {
|
||||
window.setMovableByWindowBackground_(YES);
|
||||
}
|
||||
|
||||
if attrs.always_on_top {
|
||||
let _: () = msg_send![*window, setLevel:ffi::NSWindowLevel::NSFloatingWindowLevel];
|
||||
}
|
||||
|
||||
if let Some((x, y)) = pl_attrs.resize_increments {
|
||||
if x >= 1 && y >= 1 {
|
||||
|
|
@ -1066,6 +1071,18 @@ impl Window2 {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_always_on_top(&self, always_on_top: bool) {
|
||||
unsafe {
|
||||
let level = if always_on_top {
|
||||
ffi::NSWindowLevel::NSFloatingWindowLevel
|
||||
} else {
|
||||
ffi::NSWindowLevel::NSNormalWindowLevel
|
||||
};
|
||||
let _: () = msg_send![*self.window, setLevel:level];
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_window_icon(&self, _icon: Option<::Icon>) {
|
||||
// macOS doesn't have window icons. Though, there is `setRepresentedFilename`, but that's
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue