From 47f0ab1ef324dfd649cf1e86e7956914ef41e7e9 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Wed, 22 May 2024 11:37:47 -0700 Subject: [PATCH] feat(wm): handle OBJECT_NAMECHANGE for all apps This commit ensures that EVENT_OBJECT_NAMECHANGE is handled for all windows. Previously this was mapped to WindowManagerEvent::Show, as this is the event that apps like Firefox and JetBrains IDEs sent on launch instead of EVENT_OBJECT_SHOW like normal apps. Now that we are using EVENT_OBJECT_NAMECHANGE to update titles on stackbar tabs, when a window which is not in the whitelist of object_name_change_applications sends this event, it will be handled by the new WindowManagerEvent::TitleUpdate variant. This ensures that a stackbar_manager::Notification is sent at the end of process_event to update stackbar tabs when application titles are changing. resolve #842 --- komorebi/src/process_event.rs | 7 +++---- komorebi/src/window_manager_event.rs | 14 +++++++------- komorebi/src/windows_callbacks.rs | 13 ++++++++++++- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 5337aa7c1..d175efe7f 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -571,10 +571,9 @@ impl WindowManager { } } } - WindowManagerEvent::ForceUpdate(_) => { - self.update_focused_workspace(false, true)?; - } - WindowManagerEvent::MouseCapture(..) | WindowManagerEvent::Cloak(..) => {} + WindowManagerEvent::MouseCapture(..) + | WindowManagerEvent::Cloak(..) + | WindowManagerEvent::TitleUpdate(..) => {} }; // If we unmanaged a window, it shouldn't be immediately hidden behind managed windows diff --git a/komorebi/src/window_manager_event.rs b/komorebi/src/window_manager_event.rs index 42d91ae5d..01d0e2393 100644 --- a/komorebi/src/window_manager_event.rs +++ b/komorebi/src/window_manager_event.rs @@ -27,7 +27,7 @@ pub enum WindowManagerEvent { Manage(Window), Unmanage(Window), Raise(Window), - ForceUpdate(Window), + TitleUpdate(WinEvent, Window), } impl Display for WindowManagerEvent { @@ -75,8 +75,8 @@ impl Display for WindowManagerEvent { Self::Raise(window) => { write!(f, "Raise (Window: {window})") } - Self::ForceUpdate(window) => { - write!(f, "ForceUpdate (Window: {window})") + Self::TitleUpdate(winevent, window) => { + write!(f, "TitleUpdate (WinEvent: {winevent}, Window: {window})") } } } @@ -98,7 +98,7 @@ impl WindowManagerEvent { | Self::Raise(window) | Self::Manage(window) | Self::Unmanage(window) - | Self::ForceUpdate(window) => window, + | Self::TitleUpdate(_, window) => window, } } @@ -141,7 +141,7 @@ impl WindowManagerEvent { let class = &window.class().ok()?; let path = &window.path().ok()?; - let should_trigger = should_act( + let should_trigger_show = should_act( title, exe_name, class, @@ -151,10 +151,10 @@ impl WindowManagerEvent { ) .is_some(); - if should_trigger { + if should_trigger_show { Option::from(Self::Show(winevent, window)) } else { - None + Option::from(Self::TitleUpdate(winevent, window)) } } _ => None, diff --git a/komorebi/src/windows_callbacks.rs b/komorebi/src/windows_callbacks.rs index 1eb24085d..de2e1950f 100644 --- a/komorebi/src/windows_callbacks.rs +++ b/komorebi/src/windows_callbacks.rs @@ -80,8 +80,19 @@ pub extern "system" fn win_event_hook( Ok(event) => event, Err(_) => return, }; + let event_type = match WindowManagerEvent::from_win_event(winevent, window) { - None => return, + None => { + tracing::trace!( + "Unhandled WinEvent: {winevent} (hwnd: {}, exe: {}, title: {}, class: {})", + window.hwnd, + window.exe().unwrap_or_default(), + window.title().unwrap_or_default(), + window.class().unwrap_or_default() + ); + + return; + } Some(event) => event, };