1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-25 06:12:16 +03:00

macos: cleanup

This commit is contained in:
Federico Vitale 2023-11-28 00:59:00 +01:00 committed by Wez Furlong
parent 86e42e1c58
commit a1f0dca655
4 changed files with 20 additions and 7 deletions

View File

@ -2024,7 +2024,6 @@ fn compute_default_actions() -> Vec<KeyAssignment> {
ScrollToBottom, ScrollToBottom,
// ----------------- Window // ----------------- Window
ToggleFullScreen, ToggleFullScreen,
#[cfg(target_os = "macos")]
ToggleFloatingWindow, ToggleFloatingWindow,
Hide, Hide,
Search(Pattern::CurrentSelectionOrEmptyString), Search(Pattern::CurrentSelectionOrEmptyString),

View File

@ -2514,8 +2514,8 @@ impl TermWindow {
match window.level().await { match window.level().await {
Ok(level) => { Ok(level) => {
match level { match level {
WindowLevel::Floating => window.set_level(WindowLevel::Normal), WindowLevel::AlwaysOnTop => window.set_level(WindowLevel::Normal),
_ => window.set_level(WindowLevel::Floating), _ => window.set_level(WindowLevel::AlwaysOnTop),
}; };
} }
Err(e) => { Err(e) => {

View File

@ -295,8 +295,10 @@ pub trait WindowOps {
fn set_clipboard(&self, clipboard: Clipboard, text: String); fn set_clipboard(&self, clipboard: Clipboard, text: String);
/// Set window level. Depending on the environment and user preferences /// Set window level. Depending on the environment and user preferences
fn set_window_level(&self, level: WindowLevel) { fn set_window_level(&self, _level: WindowLevel) {}
// default implementation does nothing
fn get_window_level(&self) -> Future<WindowLevel> {
WindowLevel::Normal
} }
/// Set the icon for the window. /// Set the icon for the window.

View File

@ -747,11 +747,17 @@ impl WindowOps for Window {
fn set_window_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_window_level(level);
Ok(()) Ok(())
}); });
} }
fn level(&self) -> Future<WindowLevel> {
Connection::with_window_inner(self.id, move |inner| {
Ok(inner.level())
})
}
fn set_inner_size(&self, width: usize, height: usize) { fn set_inner_size(&self, width: usize, height: usize) {
Connection::with_window_inner(self.id, move |inner| { Connection::with_window_inner(self.id, move |inner| {
@ -1167,7 +1173,13 @@ impl WindowInner {
} }
} }
fn set_level(&mut self, level: WindowLevel) { fn level(&self) -> WindowLevel {
unsafe {
NSWindow::level(*self.window).into()
}
}
fn set_window_level(&mut self, level: WindowLevel) {
unsafe { unsafe {
NSWindow::setLevel_(*self.window, match level { NSWindow::setLevel_(*self.window, match level {
WindowLevel::AlwaysOnBottom => -1, WindowLevel::AlwaysOnBottom => -1,