mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-03-21 00:49:25 +01:00
perf(wm): reduce border jank on ws switch
This commit introduces a few changes to reduce border jank, especially when switching workspaces: - The border is hidden before the windows start to reorganize when a workspace switching command is received instead of after - Avoid unncessary window.focus() call when switching workspace - Use WindowManager.focused_window() instead of the window received from the WindowManagerEvent when updating or setting the active border position as it more accurately matches user expectations when switching back to a workspace to find the focused window being the one that you left when you switched away
This commit is contained in:
@@ -90,6 +90,20 @@ impl WindowManager {
|
||||
}
|
||||
}
|
||||
|
||||
match message {
|
||||
SocketMessage::CycleFocusMonitor(_)
|
||||
| SocketMessage::CycleFocusWorkspace(_)
|
||||
| SocketMessage::FocusMonitorNumber(_)
|
||||
| SocketMessage::FocusMonitorWorkspaceNumber(_, _)
|
||||
| SocketMessage::FocusWorkspaceNumber(_) => {
|
||||
if self.focused_workspace()?.visible_windows().is_empty() {
|
||||
let border = Border::from(BORDER_HWND.load(Ordering::SeqCst));
|
||||
border.hide()?;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
|
||||
match message {
|
||||
SocketMessage::Promote => self.promote_container_to_front()?,
|
||||
SocketMessage::FocusWindow(direction) => {
|
||||
@@ -782,16 +796,6 @@ impl WindowManager {
|
||||
let border = Border::from(BORDER_HWND.load(Ordering::SeqCst));
|
||||
border.set_position(foreground_window, &self.invisible_borders, false)?;
|
||||
}
|
||||
SocketMessage::CycleFocusMonitor(_)
|
||||
| SocketMessage::CycleFocusWorkspace(_)
|
||||
| SocketMessage::FocusMonitorNumber(_)
|
||||
| SocketMessage::FocusMonitorWorkspaceNumber(_, _)
|
||||
| SocketMessage::FocusWorkspaceNumber(_) => {
|
||||
if self.focused_workspace()?.visible_windows().is_empty() {
|
||||
let border = Border::from(BORDER_HWND.load(Ordering::SeqCst));
|
||||
border.hide()?;
|
||||
}
|
||||
}
|
||||
SocketMessage::TogglePause => {
|
||||
let is_paused = self.is_paused;
|
||||
let border = Border::from(BORDER_HWND.load(Ordering::SeqCst));
|
||||
|
||||
@@ -481,9 +481,10 @@ impl WindowManager {
|
||||
border.hide()?;
|
||||
BORDER_HIDDEN.store(true, Ordering::SeqCst);
|
||||
}
|
||||
WindowManagerEvent::MoveResizeEnd(_, window)
|
||||
| WindowManagerEvent::Show(_, window)
|
||||
| WindowManagerEvent::FocusChange(_, window) => {
|
||||
WindowManagerEvent::MoveResizeEnd(_, _)
|
||||
| WindowManagerEvent::Show(_, _)
|
||||
| WindowManagerEvent::FocusChange(_, _) => {
|
||||
let window = self.focused_window()?;
|
||||
let mut rect = WindowsApi::window_rect(window.hwnd())?;
|
||||
rect.top -= self.invisible_borders.bottom;
|
||||
rect.bottom += self.invisible_borders.bottom;
|
||||
|
||||
@@ -1911,7 +1911,7 @@ impl WindowManager {
|
||||
monitor.focus_workspace(idx)?;
|
||||
monitor.load_focused_workspace(mouse_follows_focus)?;
|
||||
|
||||
self.update_focused_workspace(mouse_follows_focus)
|
||||
self.update_focused_workspace(false)
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
|
||||
@@ -93,7 +93,7 @@ use windows::Win32::UI::WindowsAndMessaging::SW_HIDE;
|
||||
use windows::Win32::UI::WindowsAndMessaging::SW_MAXIMIZE;
|
||||
use windows::Win32::UI::WindowsAndMessaging::SW_MINIMIZE;
|
||||
use windows::Win32::UI::WindowsAndMessaging::SW_NORMAL;
|
||||
use windows::Win32::UI::WindowsAndMessaging::SW_RESTORE;
|
||||
use windows::Win32::UI::WindowsAndMessaging::SW_SHOWNOACTIVATE;
|
||||
use windows::Win32::UI::WindowsAndMessaging::SYSTEM_PARAMETERS_INFO_ACTION;
|
||||
use windows::Win32::UI::WindowsAndMessaging::SYSTEM_PARAMETERS_INFO_UPDATE_FLAGS;
|
||||
use windows::Win32::UI::WindowsAndMessaging::WINDOW_LONG_PTR_INDEX;
|
||||
@@ -332,7 +332,7 @@ impl WindowsApi {
|
||||
}
|
||||
|
||||
pub fn restore_window(hwnd: HWND) {
|
||||
Self::show_window(hwnd, SW_RESTORE);
|
||||
Self::show_window(hwnd, SW_SHOWNOACTIVATE);
|
||||
}
|
||||
|
||||
pub fn unmaximize_window(hwnd: HWND) {
|
||||
|
||||
Reference in New Issue
Block a user