From 3769e5da46064b1bd85d7791fc767bcfc36d5a1c Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Sun, 16 Nov 2025 11:22:55 +0300 Subject: ipc: Add focus_timestsamp and WindowFocusTimestampChanged --- src/ipc/client.rs | 6 ++++++ src/ipc/server.rs | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ipc/client.rs b/src/ipc/client.rs index 8fea1d2b..ef4bdf51 100644 --- a/src/ipc/client.rs +++ b/src/ipc/client.rs @@ -458,6 +458,12 @@ pub fn handle_msg(mut msg: Msg, json: bool) -> anyhow::Result<()> { Event::WindowFocusChanged { id } => { println!("Window focus changed: {id:?}"); } + Event::WindowFocusTimestampChanged { + id, + focus_timestamp, + } => { + println!("Window {id}: focus timestamp changed to {focus_timestamp:?}"); + } Event::WindowUrgencyChanged { id, urgent } => { println!("Window {id}: urgency changed to {urgent}"); } diff --git a/src/ipc/server.rs b/src/ipc/server.rs index ade57de1..95176ce3 100644 --- a/src/ipc/server.rs +++ b/src/ipc/server.rs @@ -18,7 +18,7 @@ use niri_config::OutputName; use niri_ipc::state::{EventStreamState, EventStreamStatePart as _}; use niri_ipc::{ Action, Event, KeyboardLayouts, OutputConfigChanged, Overview, Reply, Request, Response, - WindowLayout, Workspace, + Timestamp, WindowLayout, Workspace, }; use smithay::desktop::layer_map_for_output; use smithay::input::pointer::{ @@ -514,6 +514,7 @@ fn make_ipc_window( is_floating: mapped.is_floating(), is_urgent: mapped.is_urgent(), layout, + focus_timestamp: mapped.get_focus_timestamp().map(Timestamp::from), }) } @@ -725,6 +726,14 @@ impl State { events.push(Event::WindowFocusChanged { id: Some(id) }); } + let focus_timestamp = mapped.get_focus_timestamp().map(Timestamp::from); + if focus_timestamp != ipc_win.focus_timestamp { + events.push(Event::WindowFocusTimestampChanged { + id, + focus_timestamp, + }); + } + let urgent = mapped.is_urgent(); if urgent != ipc_win.is_urgent { events.push(Event::WindowUrgencyChanged { id, urgent }) -- cgit