diff --git a/crates/gpui_linux/src/linux/x11/window.rs b/crates/gpui_linux/src/linux/x11/window.rs index 4fde66f06ca858..c7264918861a86 100644 --- a/crates/gpui_linux/src/linux/x11/window.rs +++ b/crates/gpui_linux/src/linux/x11/window.rs @@ -1280,6 +1280,10 @@ impl X11WindowStatePtr { } pub fn set_active(&self, focus: bool) { + if focus { + self.clear_attention().log_err(); + } + let callback = self.callbacks.borrow_mut().active_status_change.take(); if let Some(mut fun) = callback { fun(focus); @@ -1290,6 +1294,27 @@ impl X11WindowStatePtr { } } + fn clear_attention(&self) -> anyhow::Result<()> { + let Some(mut hints) = WmHints::get(&*self.xcb, self.x_window) + .context("X11 request for WM_HINTS urgency failed")? + .reply() + .context("X11 reply for WM_HINTS urgency failed")? + else { + return Ok(()); + }; + + if hints.urgent { + hints.urgent = false; + check_reply( + || "X11 ChangeProperty for WM_HINTS urgency failed.", + hints.set(&*self.xcb, self.x_window), + )?; + xcb_flush(&self.xcb); + } + + Ok(()) + } + pub fn set_hovered(&self, focus: bool) { let callback = self.callbacks.borrow_mut().hovered_status_change.take(); if let Some(mut fun) = callback {