Skip to content

Commit

Permalink
feat(wm): listen to event_object_locationchange
Browse files Browse the repository at this point in the history
This commit adds a new WindowManagerEvent, LocationChange, which allows
komorebi to listen to and dispatch events to border_manager when
EVENT_OBJECT_LOCATIONCHANGE is emitted by the operating system.

This is required because there is no other event which fires on window
maximize/unmaximize.

fix #1137
  • Loading branch information
LGUG2Z committed Nov 27, 2024
1 parent 46b81e4 commit 1ef0630
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions komorebi/src/process_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,7 @@ impl WindowManager {
}
WindowManagerEvent::MouseCapture(..)
| WindowManagerEvent::Cloak(..)
| WindowManagerEvent::LocationChange(..)
| WindowManagerEvent::TitleUpdate(..) => {}
};

Expand Down Expand Up @@ -714,6 +715,7 @@ impl WindowManager {
if !matches!(
event,
WindowManagerEvent::Show(WinEvent::ObjectNameChange, _)
| WindowManagerEvent::LocationChange(_, _)
) {
tracing::info!("processed: {}", event.window().to_string());
} else {
Expand Down
10 changes: 9 additions & 1 deletion komorebi/src/window_manager_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub enum WindowManagerEvent {
Unmanage(Window),
Raise(Window),
TitleUpdate(WinEvent, Window),
LocationChange(WinEvent, Window),
}

impl Display for WindowManagerEvent {
Expand Down Expand Up @@ -78,6 +79,9 @@ impl Display for WindowManagerEvent {
Self::TitleUpdate(winevent, window) => {
write!(f, "TitleUpdate (WinEvent: {winevent}, Window: {window})")
}
Self::LocationChange(winevent, window) => {
write!(f, "LocationChange (WinEvent: {winevent}, Window: {window})")
}
}
}
}
Expand All @@ -98,7 +102,8 @@ impl WindowManagerEvent {
| Self::Raise(window)
| Self::Manage(window)
| Self::Unmanage(window)
| Self::TitleUpdate(_, window) => window,
| Self::TitleUpdate(_, window)
| Self::LocationChange(_, window) => window,
}
}

Expand All @@ -122,6 +127,7 @@ impl WindowManagerEvent {
WindowManagerEvent::Unmanage(_) => "Unmanage",
WindowManagerEvent::Raise(_) => "Raise",
WindowManagerEvent::TitleUpdate(_, _) => "TitleUpdate",
WindowManagerEvent::LocationChange(_, _) => "LocationChange",
}
}

Expand All @@ -137,6 +143,7 @@ impl WindowManagerEvent {
| WindowManagerEvent::MoveResizeStart(event, _)
| WindowManagerEvent::MoveResizeEnd(event, _)
| WindowManagerEvent::MouseCapture(event, _)
| WindowManagerEvent::LocationChange(event, _)
| WindowManagerEvent::TitleUpdate(event, _) => Some(event.to_string()),
WindowManagerEvent::Manage(_)
| WindowManagerEvent::Unmanage(_)
Expand Down Expand Up @@ -202,6 +209,7 @@ impl WindowManagerEvent {
Option::from(Self::TitleUpdate(winevent, window))
}
}
WinEvent::ObjectLocationChange => Option::from(Self::LocationChange(winevent, window)),
_ => None,
}
}
Expand Down

0 comments on commit 1ef0630

Please sign in to comment.