From 86f57c2ec775d4aa08bf310c94b22ea266eaa9e9 Mon Sep 17 00:00:00 2001 From: Duncan Overbruck Date: Fri, 21 Mar 2025 17:31:27 +0100 Subject: add window urgency through xdg-activation-v1 urgency is done through activation requests without a serial from a previous interaction. https://gitlab.freedesktop.org/wayland/wayland-protocols/-/issues/150 --- src/handlers/mod.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/handlers') diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs index f2613d19..ffbf2439 100644 --- a/src/handlers/mod.rs +++ b/src/handlers/mod.rs @@ -707,6 +707,8 @@ impl GammaControlHandler for State { } delegate_gamma_control!(State); +struct UrgentOnlyMarker; + impl XdgActivationHandler for State { fn activation_state(&mut self) -> &mut XdgActivationState { &mut self.niri.activation_state @@ -716,11 +718,10 @@ impl XdgActivationHandler for State { // Tokens without a serial are urgency-only. This is not specified, but it seems to be the // common client behavior. // - // We don't have urgency yet, so just ignore such tokens. - // // See also: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/issues/150 let Some((serial, seat)) = data.serial else { - return false; + data.user_data.insert_if_missing(|| UrgentOnlyMarker); + return true; }; let Some(seat) = Seat::::from_resource(&seat) else { return false; @@ -760,11 +761,16 @@ impl XdgActivationHandler for State { surface: WlSurface, ) { if token_data.timestamp.elapsed() < XDG_ACTIVATION_TOKEN_TIMEOUT { - if let Some((mapped, _)) = self.niri.layout.find_window_and_output(&surface) { + if let Some((mapped, _)) = self.niri.layout.find_window_and_output_mut(&surface) { let window = mapped.window.clone(); - self.niri.layout.activate_window(&window); - self.niri.layer_shell_on_demand_focus = None; - self.niri.queue_redraw_all(); + if token_data.user_data.get::().is_some() { + mapped.set_urgent(true); + self.niri.queue_redraw_all(); + } else { + self.niri.layout.activate_window(&window); + self.niri.layer_shell_on_demand_focus = None; + self.niri.queue_redraw_all(); + } } else if let Some(unmapped) = self.niri.unmapped_windows.get_mut(&surface) { unmapped.activation_token_data = Some(token_data); } -- cgit