mirror of
https://github.com/wez/wezterm.git
synced 2024-12-23 13:21:38 +03:00
fix: moved window level state update
This commit is contained in:
parent
209d039c5d
commit
163606afec
@ -7,3 +7,20 @@ pub enum WindowLevel {
|
||||
Normal = 0,
|
||||
AlwaysOnTop = 3,
|
||||
}
|
||||
|
||||
impl Default for WindowLevel {
|
||||
fn default() -> Self {
|
||||
WindowLevel::Normal
|
||||
}
|
||||
}
|
||||
|
||||
impl From<i64> for WindowLevel {
|
||||
fn from(level: i64) -> Self {
|
||||
match level {
|
||||
-1 => WindowLevel::AlwaysOnBottom,
|
||||
0 => WindowLevel::Normal,
|
||||
3 => WindowLevel::AlwaysOnTop,
|
||||
_ => panic!("Invalid window level: {}", level),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2514,16 +2514,9 @@ impl TermWindow {
|
||||
|
||||
match current_level {
|
||||
WindowLevel::AlwaysOnTop => {
|
||||
self.window_state -= WindowState::ALWAYS_ON_TOP;
|
||||
window.set_window_level(WindowLevel::Normal);
|
||||
}
|
||||
WindowLevel::AlwaysOnBottom => {
|
||||
self.window_state -= WindowState::ALWAYS_ON_BOTTOM;
|
||||
self.window_state = self.window_state | WindowState::ALWAYS_ON_TOP;
|
||||
window.set_window_level(WindowLevel::AlwaysOnTop);
|
||||
}
|
||||
WindowLevel::Normal => {
|
||||
self.window_state = self.window_state | WindowState::ALWAYS_ON_TOP;
|
||||
WindowLevel::AlwaysOnBottom | WindowLevel::Normal => {
|
||||
window.set_window_level(WindowLevel::AlwaysOnTop);
|
||||
}
|
||||
}
|
||||
@ -2533,49 +2526,17 @@ impl TermWindow {
|
||||
let current_level = self.window_state.as_window_level();
|
||||
|
||||
match current_level {
|
||||
WindowLevel::AlwaysOnTop => {
|
||||
self.window_state -= WindowState::ALWAYS_ON_TOP;
|
||||
self.window_state = self.window_state | WindowState::ALWAYS_ON_BOTTOM;
|
||||
window.set_window_level(WindowLevel::AlwaysOnBottom);
|
||||
}
|
||||
WindowLevel::AlwaysOnBottom => {
|
||||
self.window_state -= WindowState::ALWAYS_ON_BOTTOM;
|
||||
window.set_window_level(WindowLevel::Normal);
|
||||
}
|
||||
WindowLevel::Normal => {
|
||||
self.window_state = self.window_state | WindowState::ALWAYS_ON_BOTTOM;
|
||||
WindowLevel::AlwaysOnTop | WindowLevel::Normal => {
|
||||
window.set_window_level(WindowLevel::AlwaysOnBottom);
|
||||
}
|
||||
}
|
||||
}
|
||||
SetWindowLevel(level) => {
|
||||
let window = self.window.clone().unwrap();
|
||||
let current_level = self.window_state.as_window_level();
|
||||
|
||||
// reset level state if needed
|
||||
match current_level {
|
||||
WindowLevel::AlwaysOnTop => {
|
||||
self.window_state -= WindowState::ALWAYS_ON_TOP;
|
||||
}
|
||||
WindowLevel::AlwaysOnBottom => {
|
||||
self.window_state -= WindowState::ALWAYS_ON_BOTTOM;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
match level {
|
||||
WindowLevel::AlwaysOnTop => {
|
||||
window.set_window_level(WindowLevel::AlwaysOnTop);
|
||||
self.window_state = self.window_state | WindowState::ALWAYS_ON_TOP;
|
||||
}
|
||||
WindowLevel::AlwaysOnBottom => {
|
||||
window.set_window_level(WindowLevel::AlwaysOnBottom);
|
||||
self.window_state = self.window_state | WindowState::ALWAYS_ON_BOTTOM;
|
||||
}
|
||||
WindowLevel::Normal => {
|
||||
window.set_window_level(WindowLevel::Normal);
|
||||
}
|
||||
}
|
||||
window.set_window_level(level.clone());
|
||||
},
|
||||
CopyTo(dest) => {
|
||||
let text = self.selection_text(pane);
|
||||
|
@ -1160,12 +1160,15 @@ impl WindowInner {
|
||||
}
|
||||
|
||||
fn set_window_level(&mut self, level: WindowLevel) {
|
||||
|
||||
unsafe {
|
||||
NSWindow::setLevel_(*self.window, match level {
|
||||
WindowLevel::AlwaysOnBottom => -1,
|
||||
WindowLevel::Normal => 0,
|
||||
WindowLevel::AlwaysOnTop => 3,
|
||||
});
|
||||
|
||||
WindowView::did_resize(&mut** self.view, sel!(windowDidResize:), nil);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2772,6 +2775,20 @@ impl WindowView {
|
||||
unsafe { msg_send![*window, isZoomed] }
|
||||
});
|
||||
|
||||
let window_level = inner.window.as_ref().map_or(WindowLevel::Normal, |w| unsafe { w.load().level().into() });
|
||||
|
||||
let level_state = match window_level {
|
||||
WindowLevel::AlwaysOnBottom => WindowState::ALWAYS_ON_BOTTOM,
|
||||
WindowLevel::AlwaysOnTop => WindowState::ALWAYS_ON_TOP,
|
||||
WindowLevel::Normal => WindowState::default(),
|
||||
};
|
||||
|
||||
let screen_state = match (is_full_screen, is_zoomed) {
|
||||
(true, _) => WindowState::FULL_SCREEN,
|
||||
(_, true) => WindowState::MAXIMIZED,
|
||||
_ => WindowState::default(),
|
||||
};
|
||||
|
||||
let dpi = inner
|
||||
.window
|
||||
.as_ref()
|
||||
@ -2788,13 +2805,7 @@ impl WindowView {
|
||||
pixel_height: height as usize,
|
||||
dpi,
|
||||
},
|
||||
window_state: if is_full_screen {
|
||||
WindowState::FULL_SCREEN
|
||||
} else if is_zoomed {
|
||||
WindowState::MAXIMIZED
|
||||
} else {
|
||||
WindowState::default()
|
||||
},
|
||||
window_state: screen_state | level_state,
|
||||
live_resizing,
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user