Skip to content

Commit

Permalink
fix(wm): hide border when unmanged windows are focused
Browse files Browse the repository at this point in the history
Previously we were dropping events that don't pertain to managed
windows, with one exception in should_manage that could probably do with
further cleanup (DisplayChange).

This first step fixes the latent border window problem, where we would
retain a border window when the last managed window was closed and focus
transitioned to an unmanaged window.
  • Loading branch information
raggi authored and LGUG2Z committed Apr 13, 2024
1 parent 16cb811 commit b61146e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
20 changes: 20 additions & 0 deletions komorebi/src/process_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,26 @@ impl WindowManager {
return Ok(());
}

let should_manage = event.window().should_manage(Some(*event))?;

// Hide or reposition the window based on whether the target is managed.
if BORDER_ENABLED.load(Ordering::SeqCst) {
if let WindowManagerEvent::FocusChange(_, window) = event {
let border_window = Border::from(BORDER_HWND.load(Ordering::SeqCst));
if should_manage {
border_window.set_position(*window, true)?;
} else {
border_window.hide()?;
}
}
}

// All event handlers below this point should only be processed if the event is
// related to a window that should be managed by the WindowManager.
if !should_manage {
return Ok(());
}

if let Some(virtual_desktop_id) = &self.virtual_desktop_id {
if let Some(id) = current_virtual_desktop() {
if id != *virtual_desktop_id {
Expand Down
10 changes: 3 additions & 7 deletions komorebi/src/windows_callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,9 @@ pub extern "system" fn win_event_hook(
Some(event) => event,
};

if let Ok(should_manage) = window.should_manage(Option::from(event_type)) {
if should_manage {
winevent_listener::event_tx()
.send(event_type)
.expect("could not send message on winevent_listener::event_tx");
}
}
winevent_listener::event_tx()
.send(event_type)
.expect("could not send message on winevent_listener::event_tx");
}

pub extern "system" fn border_window(
Expand Down

0 comments on commit b61146e

Please sign in to comment.