Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions crates/gpui_linux/src/linux/x11/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 {
Expand Down
Loading