From 8afad7246fde6e00c1b1136a295e5078cfb93be1 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Wed, 29 Nov 2023 21:44:25 -0800 Subject: [PATCH] fix(config): make win32 calls for windows ffm This commit ensures that the required calls are made to the system to enable and disable the Windows focus-follows-mouse implementation when users make changes to the focus_follows_mouse option in the static config file. fix #603 --- komorebi/src/static_config.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/komorebi/src/static_config.rs b/komorebi/src/static_config.rs index c37a2f31..1b3e6e8d 100644 --- a/komorebi/src/static_config.rs +++ b/komorebi/src/static_config.rs @@ -4,6 +4,7 @@ use crate::monitor::Monitor; use crate::ring::Ring; use crate::window_manager::WindowManager; use crate::window_manager_event::WindowManagerEvent; +use crate::windows_api::WindowsApi; use crate::workspace::Workspace; use crate::ALT_FOCUS_HACK; use crate::BORDER_COLOUR_CURRENT; @@ -801,6 +802,14 @@ impl StaticConfig { already_moved_window_handles: Arc::new(Mutex::new(HashSet::new())), }; + match value.focus_follows_mouse { + None => WindowsApi::disable_focus_follows_mouse()?, + Some(FocusFollowsMouseImplementation::Windows) => { + WindowsApi::enable_focus_follows_mouse()?; + } + Some(FocusFollowsMouseImplementation::Komorebi) => {} + }; + let bytes = SocketMessage::ReloadStaticConfiguration(path.clone()).as_bytes()?; wm.hotwatch.watch(path, move |event| match event { @@ -944,6 +953,15 @@ impl StaticConfig { } wm.work_area_offset = value.global_work_area_offset; + + match value.focus_follows_mouse { + None => WindowsApi::disable_focus_follows_mouse()?, + Some(FocusFollowsMouseImplementation::Windows) => { + WindowsApi::enable_focus_follows_mouse()?; + } + Some(FocusFollowsMouseImplementation::Komorebi) => {} + }; + wm.focus_follows_mouse = value.focus_follows_mouse; Ok(())