1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-24 13:52:55 +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,
// ----------------- Window
ToggleFullScreen,
#[cfg(target_os = "macos")]
ToggleFloatingWindow,
Hide,
Search(Pattern::CurrentSelectionOrEmptyString),

View File

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

View File

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

View File

@ -747,11 +747,17 @@ impl WindowOps for Window {
fn set_window_level(&self, level: WindowLevel) {
Connection::with_window_inner(self.id, move |inner| {
inner.set_level(level as i64);
inner.set_window_level(level);
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) {
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 {
NSWindow::setLevel_(*self.window, match level {
WindowLevel::AlwaysOnBottom => -1,