Skip to content

Commit

Permalink
feat(wm): handle OBJECT_NAMECHANGE for all apps
Browse files Browse the repository at this point in the history
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
  • Loading branch information
LGUG2Z committed May 22, 2024
1 parent c4d62fc commit 47f0ab1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
7 changes: 3 additions & 4 deletions komorebi/src/process_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions komorebi/src/window_manager_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub enum WindowManagerEvent {
Manage(Window),
Unmanage(Window),
Raise(Window),
ForceUpdate(Window),
TitleUpdate(WinEvent, Window),
}

impl Display for WindowManagerEvent {
Expand Down Expand Up @@ -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})")
}
}
}
Expand All @@ -98,7 +98,7 @@ impl WindowManagerEvent {
| Self::Raise(window)
| Self::Manage(window)
| Self::Unmanage(window)
| Self::ForceUpdate(window) => window,
| Self::TitleUpdate(_, window) => window,
}
}

Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
13 changes: 12 additions & 1 deletion komorebi/src/windows_callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down

0 comments on commit 47f0ab1

Please sign in to comment.