From 24791f0ce5471acf19d286a9b32fe3d3a0791f94 Mon Sep 17 00:00:00 2001 From: alex-ds13 <145657253+alex-ds13@users.noreply.github.com> Date: Thu, 20 Mar 2025 19:13:46 +0000 Subject: [PATCH] fix(wm): change when floating windows are centered This commit changes the behaviour of when floating windows are centered by making them only center when we are on a `WorkspaceLayer::Floating` and the window doesn't match a `floating_windows` rule and the workspace is not a floating workspace. --- komorebi/src/process_event.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index cca26f22..bb34ed31 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -395,10 +395,19 @@ impl WindowManager { && !matches!(event, WindowManagerEvent::Manage(_))); if behaviour.float_override { + // Center floating windows if we are already on the `Floating` + // layer and the window doesn't match a `floating_windows` rule and + // the workspace is not a floating workspace + let center_spawned_floats = + matches!(workspace.layer, WorkspaceLayer::Floating) + && !should_float + && workspace.tile; workspace.floating_windows_mut().push(window); workspace.set_layer(WorkspaceLayer::Floating); - let mut floating_window = window; - floating_window.center(&workspace.globals().work_area)?; + if center_spawned_floats { + let mut floating_window = window; + floating_window.center(&workspace.globals().work_area)?; + } self.update_focused_workspace(false, false)?; } else { match behaviour.current_behaviour {