From 4d8afc96c996adeecbcd58eea165ad7bce2156be Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 11 Aug 2022 10:50:16 -0700 Subject: [PATCH] fix(wm): enforce active border enabled checks This commit enforces a check to ensure that the active-window-border configuration is enabled before trying to redraw a border than has been hidden by a drag or move event. --- komorebi/src/main.rs | 3 ++- komorebi/src/process_command.rs | 5 ++++- komorebi/src/process_event.rs | 7 +++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index 465303ba..a4fb4a6e 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -37,10 +37,10 @@ use which::which; use winreg::enums::HKEY_CURRENT_USER; use winreg::RegKey; -use crate::border::Border; use komorebi_core::HidingBehaviour; use komorebi_core::SocketMessage; +use crate::border::Border; use crate::process_command::listen_for_commands; use crate::process_event::listen_for_events; use crate::process_movement::listen_for_movements; @@ -156,6 +156,7 @@ lazy_static! { pub static INITIAL_CONFIGURATION_LOADED: AtomicBool = AtomicBool::new(false); pub static CUSTOM_FFM: AtomicBool = AtomicBool::new(false); pub static SESSION_ID: AtomicU32 = AtomicU32::new(0); +pub static BORDER_ENABLED: AtomicBool = AtomicBool::new(false); pub static BORDER_HWND: AtomicIsize = AtomicIsize::new(0); pub static BORDER_HIDDEN: AtomicBool = AtomicBool::new(false); diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index cc67ce4e..abb6f528 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -15,7 +15,6 @@ use parking_lot::Mutex; use schemars::schema_for; use uds_windows::UnixStream; -use crate::border::Border; use komorebi_core::ApplicationIdentifier; use komorebi_core::Axis; use komorebi_core::FocusFollowsMouseImplementation; @@ -28,6 +27,7 @@ use komorebi_core::SocketMessage; use komorebi_core::StateQuery; use komorebi_core::WindowContainerBehaviour; +use crate::border::Border; use crate::current_virtual_desktop; use crate::notify_subscribers; use crate::window::Window; @@ -36,6 +36,7 @@ use crate::window_manager::WindowManager; use crate::windows_api::WindowsApi; use crate::Notification; use crate::NotificationEvent; +use crate::BORDER_ENABLED; use crate::BORDER_HWND; use crate::BORDER_OVERFLOW_IDENTIFIERS; use crate::CUSTOM_FFM; @@ -750,8 +751,10 @@ impl WindowManager { } SocketMessage::ActiveWindowBorder(enable) => { if enable { + BORDER_ENABLED.store(true, Ordering::SeqCst); self.show_border()?; } else { + BORDER_ENABLED.store(false, Ordering::SeqCst); self.hide_border()?; } } diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 65385ce5..fbebe4e4 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -5,15 +5,14 @@ use std::sync::Arc; use color_eyre::eyre::anyhow; use color_eyre::Result; use crossbeam_channel::select; - use parking_lot::Mutex; -use crate::border::Border; use komorebi_core::OperationDirection; use komorebi_core::Rect; use komorebi_core::Sizing; use komorebi_core::WindowContainerBehaviour; +use crate::border::Border; use crate::current_virtual_desktop; use crate::notify_subscribers; use crate::window_manager::WindowManager; @@ -21,9 +20,9 @@ use crate::window_manager_event::WindowManagerEvent; use crate::windows_api::WindowsApi; use crate::Notification; use crate::NotificationEvent; +use crate::BORDER_ENABLED; use crate::BORDER_HIDDEN; use crate::BORDER_HWND; - use crate::DATA_DIR; use crate::HIDDEN_HWNDS; use crate::TRAY_AND_MULTI_WINDOW_IDENTIFIERS; @@ -475,7 +474,7 @@ impl WindowManager { WindowManagerEvent::MonitorPoll(..) | WindowManagerEvent::MouseCapture(..) => {} }; - if *self.focused_workspace()?.tile() { + if *self.focused_workspace()?.tile() && BORDER_ENABLED.load(Ordering::SeqCst) { match event { WindowManagerEvent::MoveResizeStart(_, _) => { let border = Border::from(BORDER_HWND.load(Ordering::SeqCst));