From bda6054044ce8916b4b2a4c8f4db7cf234386e0d Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 11 Feb 2023 16:07:53 -0800 Subject: [PATCH] perf(border): reduce redraws on workspace change --- komorebi/src/process_command.rs | 22 ++++++++++++++++++++++ komorebi/src/process_event.rs | 2 -- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 32b9d16f..383d8a91 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -395,6 +395,13 @@ impl WindowManager { self.clear_workspace_layout_rules(monitor_idx, workspace_idx)?; } SocketMessage::CycleFocusWorkspace(direction) => { + let reenable_border = if BORDER_ENABLED.load(Ordering::SeqCst) { + self.hide_border()?; + true + } else { + false + }; + // This is to ensure that even on an empty workspace on a secondary monitor, the // secondary monitor where the cursor is focused will be used as the target for // the workspace switch op @@ -416,8 +423,19 @@ impl WindowManager { ); self.focus_workspace(workspace_idx)?; + + if reenable_border { + self.show_border()?; + } } SocketMessage::FocusWorkspaceNumber(workspace_idx) => { + let reenable_border = if BORDER_ENABLED.load(Ordering::SeqCst) { + self.hide_border()?; + true + } else { + false + }; + // This is to ensure that even on an empty workspace on a secondary monitor, the // secondary monitor where the cursor is focused will be used as the target for // the workspace switch op @@ -426,6 +444,10 @@ impl WindowManager { } self.focus_workspace(workspace_idx)?; + + if reenable_border { + self.show_border()?; + } } SocketMessage::FocusMonitorWorkspaceNumber(monitor_idx, workspace_idx) => { self.focus_monitor(monitor_idx)?; diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index f0fe286a..89562a49 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -505,8 +505,6 @@ impl WindowManager { } WindowManagerEvent::MoveResizeEnd(_, window) | WindowManagerEvent::Show(_, window) - | WindowManagerEvent::Cloak(_, window) - | WindowManagerEvent::Uncloak(_, window) | WindowManagerEvent::FocusChange(_, window) | WindowManagerEvent::Hide(_, window) | WindowManagerEvent::Minimize(_, window) => {