GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
fix: ignore focus events from windows that aren't the foreground window (#725)
lars-berger9e581d48295b
diff --git a/packages/wm/src/common/events/handle_window_focused.rs b/packages/wm/src/common/events/handle_window_focused.rsindex 842f082a..26a3efac 100644--- a/packages/wm/src/common/events/handle_window_focused.rs+++ b/packages/wm/src/common/events/handle_window_focused.rs@@ -2,7 +2,10 @@ use anyhow::Context;use tracing::info;use crate::{- common::{platform::NativeWindow, DisplayState},+ common::{+ platform::{NativeWindow, Platform},+ DisplayState,+ },containers::{commands::set_focused_descendant, traits::CommonGetters},user_config::{UserConfig, WindowRuleEvent},windows::{commands::run_window_rules, traits::WindowGetters},@@ -19,19 +22,20 @@ pub fn handle_window_focused(let found_window = state.window_from_native(&native_window);if let Some(window) = found_window {- // Ignore event if window is being hidden by the WM.- if window.display_state() == DisplayState::Hiding {+ // Ignore the focus event if:+ // 1. Window is being hidden by the WM.+ // 2. Focus is already set to the WM's focused container.+ // 3. Window is not actually the foreground window.+ if window.display_state() == DisplayState::Hiding+ || state.focused_container() == Some(window.clone().into())+ || Platform::foreground_window() != native_window+ {return Ok(());}// TODO: Log window details.info!("Window focused");- // Focus is already set to the WM's focused container.- if state.focused_container() == Some(window.clone().into()) {- return Ok(());- }-// Handle overriding focus on close/minimize. After a window is closed// or minimized, the OS or the closed application might automatically// switch focus to a different window. To force focus to go to the WM's