mirror of
https://github.com/wez/wezterm.git
synced 2024-11-23 15:04:36 +03:00
macos: refactor set_window_level
This commit is contained in:
parent
0080fec63d
commit
86e42e1c58
@ -2507,7 +2507,6 @@ impl TermWindow {
|
|||||||
ToggleFullScreen => {
|
ToggleFullScreen => {
|
||||||
self.window.as_ref().unwrap().toggle_fullscreen();
|
self.window.as_ref().unwrap().toggle_fullscreen();
|
||||||
}
|
}
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
ToggleFloatingWindow => {
|
ToggleFloatingWindow => {
|
||||||
let window = self.window.clone().unwrap();
|
let window = self.window.clone().unwrap();
|
||||||
|
|
||||||
|
@ -294,9 +294,10 @@ pub trait WindowOps {
|
|||||||
/// Set some text in the clipboard
|
/// Set some text in the clipboard
|
||||||
fn set_clipboard(&self, clipboard: Clipboard, text: String);
|
fn set_clipboard(&self, clipboard: Clipboard, text: String);
|
||||||
|
|
||||||
/// Set window level (macos only!)
|
/// Set window level. Depending on the environment and user preferences
|
||||||
fn set_level(&self, level: WindowLevel);
|
fn set_window_level(&self, level: WindowLevel) {
|
||||||
|
// default implementation does nothing
|
||||||
|
}
|
||||||
|
|
||||||
/// Set the icon for the window.
|
/// Set the icon for the window.
|
||||||
/// Depending on the system this may be shown in its titlebar
|
/// Depending on the system this may be shown in its titlebar
|
||||||
|
@ -745,7 +745,7 @@ impl WindowOps for Window {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_level(&self, level: WindowLevel) {
|
fn set_window_level(&self, level: WindowLevel) {
|
||||||
Connection::with_window_inner(self.id, move |inner| {
|
Connection::with_window_inner(self.id, move |inner| {
|
||||||
inner.set_level(level as i64);
|
inner.set_level(level as i64);
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -1081,19 +1081,11 @@ impl WindowInner {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum WindowLevel {
|
pub enum WindowLevel {
|
||||||
|
AlwaysOnBottom = -1,
|
||||||
Normal = 0,
|
Normal = 0,
|
||||||
Floating = 22,
|
AlwaysOnTop = 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<i64> for WindowLevel {
|
|
||||||
fn from(value: i64) -> Self {
|
|
||||||
match value {
|
|
||||||
int_value if int_value == Self::Floating as i64 => Self::Floating,
|
|
||||||
int_value if int_value == Self::Normal as i64 => Self::Normal,
|
|
||||||
_ => Self::Normal,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl WindowInner {
|
impl WindowInner {
|
||||||
fn show(&mut self) {
|
fn show(&mut self) {
|
||||||
@ -1175,9 +1167,13 @@ impl WindowInner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_level(&mut self, level: i64) {
|
fn set_level(&mut self, level: WindowLevel) {
|
||||||
unsafe {
|
unsafe {
|
||||||
NSWindow::setLevel_(*self.window, level);
|
NSWindow::setLevel_(*self.window, match level {
|
||||||
|
WindowLevel::AlwaysOnBottom => -1,
|
||||||
|
WindowLevel::Normal => 0,
|
||||||
|
WindowLevel::AlwaysOnTop => 3,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user