From 33c319ef61f8cde98aaddf3eacef914acb0b625c Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 26 Sep 2025 14:33:49 -0700 Subject: [PATCH] fix(wm): ensure floating layer behaviour is respected This commit ensures that the floating layer behaviour configured by the user at the top level of the config is propagated properly, and also that it is respected during FocusChange events. --- komorebi/src/process_event.rs | 6 +- komorebi/src/static_config.rs | 107 ++++++++++++++-------------------- 2 files changed, 48 insertions(+), 65 deletions(-) diff --git a/komorebi/src/process_event.rs b/komorebi/src/process_event.rs index 9cad66b2..e86cca7d 100644 --- a/komorebi/src/process_event.rs +++ b/komorebi/src/process_event.rs @@ -132,6 +132,7 @@ impl WindowManager { WindowManagerEvent::FocusChange(notification, process_id, _) => { let application = self.application(process_id)?; let application_name = application.name().unwrap_or_default().clone(); + let mut should_switch_workspace_layer_to_tiling = true; let mut tabbed_window = false; if let Some(window_id) = application.main_window_id() @@ -284,13 +285,16 @@ impl WindowManager { window_manager_event_listener::send_notification( event, ); + should_switch_workspace_layer_to_tiling = false; } } } else if is_on_current_workspace { workspace.focus_container_by_window(window_id)?; } - workspace.layer = WorkspaceLayer::Tiling; + if should_switch_workspace_layer_to_tiling { + workspace.layer = WorkspaceLayer::Tiling; + } if matches!(self.focused_workspace()?.layout, Layout::Default(DefaultLayout::Scrolling)) && !self.focused_workspace()?.containers().is_empty() { diff --git a/komorebi/src/static_config.rs b/komorebi/src/static_config.rs index 0fb87c49..268b17a5 100644 --- a/komorebi/src/static_config.rs +++ b/komorebi/src/static_config.rs @@ -1135,7 +1135,7 @@ impl StaticConfig { .unwrap_or(WindowContainerBehaviour::Create), float_override: value.float_override.unwrap_or_default(), floating_layer_override: false, // this value is always automatically calculated - floating_layer_behaviour: FloatingLayerBehaviour::default(), + floating_layer_behaviour: value.floating_layer_behaviour.unwrap_or_default(), toggle_float_placement: value .toggle_float_placement .unwrap_or(Placement::CenterAndResize), @@ -1155,28 +1155,14 @@ impl StaticConfig { .unmanaged_window_operation_behaviour .unwrap_or(OperationBehaviour::Op), resize_delta: value.resize_delta.unwrap_or(50), - // focus_follows_mouse: value.focus_follows_mouse, mouse_follows_focus: value.mouse_follows_focus.unwrap_or(true), hotwatch: Hotwatch::new()?, - // has_pending_raise_op: false, - // pending_move_op: Arc::new(None), - // already_moved_window_handles: Arc::new(Mutex::new(HashSet::new())), - // uncloack_to_ignore: 0, - // known_hwnds: HashMap::new(), run_loop: CoreFoundationRunLoop(run_loop.clone()), - minimized_windows: Default::default(), + minimized_windows: HashMap::new(), already_moved_window_handles: Default::default(), - known_window_ids: Default::default(), + known_window_ids: HashMap::new(), }; - // match value.focus_follows_mouse { - // None => WindowsApi::disable_focus_follows_mouse()?, - // Some(FocusFollowsMouseImplementation::Windows) => { - // WindowsApi::enable_focus_follows_mouse()?; - // } - // Some(FocusFollowsMouseImplementation::Komorebi) => {} - // }; - let bytes = SocketMessage::ReloadStaticConfiguration(path.clone()).as_bytes()?; wm.hotwatch.watch(path, move |event| match event.kind { @@ -1473,53 +1459,46 @@ impl StaticConfig { // Check for configs that should be tied to a specific display that isn't loaded right now // and cache a monitor with those configs with the specific `serial_number_id` so that when // those devices are connected later we can use the correct config from the cache. - // if configs_with_preference.len() > configs_used.len() { - // for i in configs_with_preference - // .iter() - // .filter(|i| !configs_used.contains(i)) - // { - // let id = { - // let display_index_preferences = DISPLAY_INDEX_PREFERENCES.read(); - // display_index_preferences.get(i).cloned() - // }; - // if let (Some(id), Some(monitor_config)) = - // (id, value.monitors.as_ref().and_then(|ms| ms.get(*i))) - // { - // // The name, device, device_id and serial_number_id can be empty here since - // // once the monitor with this preferred index actually connects the - // // `load_monitor_information` function will update these fields. - // let mut m = monitor::new( - // 0, - // Rect::default(), - // Rect::default(), - // "".into(), - // "".into(), - // "".into(), - // None, - // ); - // - // m.ensure_workspace_count(monitor_config.workspaces.len()); - // m.work_area_offset = monitor_config.work_area_offset; - // m.window_based_work_area_offset = monitor_config.window_based_work_area_offset; - // m.window_based_work_area_offset_limit = monitor_config - // .window_based_work_area_offset_limit - // .unwrap_or(1); - // m.container_padding = monitor_config.container_padding; - // m.workspace_padding = monitor_config.workspace_padding; - // m.floating_layer_behaviour = monitor_config.floating_layer_behaviour; - // - // m.update_workspaces_globals(offset); - // - // for (j, ws) in m.workspaces_mut().iter_mut().enumerate() { - // if let Some(workspace_config) = monitor_config.workspaces.get(j) { - // ws.load_static_config(workspace_config)?; - // } - // } - // - // monitor_reconciliator::insert_in_monitor_cache(&id, m); - // } - // } - // } + if configs_with_preference.len() > configs_used.len() { + for i in configs_with_preference + .iter() + .filter(|i| !configs_used.contains(i)) + { + let id = { + let display_index_preferences = DISPLAY_INDEX_PREFERENCES.read(); + display_index_preferences.get(i).cloned() + }; + if let (Some(id), Some(monitor_config)) = + (id, value.monitors.as_ref().and_then(|ms| ms.get(*i))) + { + // The name, device, device_id and serial_number_id can be empty here since + // once the monitor with this preferred index actually connects the + // `load_monitor_information` function will update these fields. + let mut m = + monitor::new(0, Rect::default(), Rect::default(), "".into(), "".into()); + + m.ensure_workspace_count(monitor_config.workspaces.len()); + m.work_area_offset = monitor_config.work_area_offset; + m.window_based_work_area_offset = monitor_config.window_based_work_area_offset; + m.window_based_work_area_offset_limit = monitor_config + .window_based_work_area_offset_limit + .unwrap_or(1); + m.container_padding = monitor_config.container_padding; + m.workspace_padding = monitor_config.workspace_padding; + m.floating_layer_behaviour = monitor_config.floating_layer_behaviour; + + m.update_workspaces_globals(offset); + + for (j, ws) in m.workspaces_mut().iter_mut().enumerate() { + if let Some(workspace_config) = monitor_config.workspaces.get(j) { + ws.load_static_config(workspace_config)?; + } + } + + monitor_reconciliator::insert_in_monitor_cache(&id, m); + } + } + } wm.enforce_workspace_rules()?;