forge
Explore
Log in

Don't you dare go Hollow

add WindowUrgencyChanged ipc event

Browse files at this commit

a8259b4ceae521311f5152980287ff88d0b984e7Duncan OverbruckParent: 9d3d7cb
niri-ipc/src/lib.rsmodified+9 -0
@@ -1129,6 +1129,8 @@ pub struct Window {
11291129 ///
11301130 /// If the window isn't floating then it is in the tiling layout.
11311131 pub is_floating: bool,
1132+ /// Whether this window requests your attention.
1133+ pub is_urgent: bool,
11321134 }
11331135
11341136 /// Output configuration change result.
@@ -1298,6 +1300,13 @@ pub enum Event {
12981300 /// Id of the newly focused window, or `None` if no window is now focused.
12991301 id: Option<u64>,
13001302 },
1303+ /// Window urgency changed.
1304+ WindowUrgencyChanged {
1305+ /// Id of the window.
1306+ id: u64,
1307+ /// The new urgency state of the window.
1308+ urgent: bool,
1309+ },
13011310 /// The configured keyboard layouts have changed.
13021311 KeyboardLayoutsChanged {
13031312 /// The new keyboard layout configuration.
niri-ipc/src/state.rsmodified+8 -0
@@ -181,6 +181,14 @@ impl EventStreamStatePart for WindowsState {
181181 win.is_focused = Some(win.id) == id;
182182 }
183183 }
184+ Event::WindowUrgencyChanged { id, urgent } => {
185+ for win in self.windows.values_mut() {
186+ if win.id == id {
187+ win.is_urgent = urgent;
188+ break;
189+ }
190+ }
191+ }
184192 event => return Some(event),
185193 }
186194 None
src/ipc/client.rsmodified+3 -0
@@ -433,6 +433,9 @@ pub fn handle_msg(msg: Msg, json: bool) -> anyhow::Result<()> {
433433 Event::WindowFocusChanged { id } => {
434434 println!("Window focus changed: {id:?}");
435435 }
436+ Event::WindowUrgencyChanged { id, urgent } => {
437+ println!("Window {id}: urgency changed to {urgent}");
438+ }
436439 Event::KeyboardLayoutsChanged { keyboard_layouts } => {
437440 println!("Keyboard layouts changed: {keyboard_layouts:?}");
438441 }
src/ipc/server.rsmodified+6 -0
@@ -476,6 +476,7 @@ fn make_ipc_window(mapped: &Mapped, workspace_id: Option<WorkspaceId>) -> niri_i
476476 workspace_id: workspace_id.map(|id| id.get()),
477477 is_focused: mapped.is_focused(),
478478 is_floating: mapped.is_floating(),
479+ is_urgent: mapped.is_urgent(),
479480 })
480481 }
481482
@@ -680,6 +681,11 @@ impl State {
680681 if mapped.is_focused() && !ipc_win.is_focused {
681682 events.push(Event::WindowFocusChanged { id: Some(id) });
682683 }
684+
685+ let urgent = mapped.is_urgent();
686+ if urgent != ipc_win.is_urgent {
687+ events.push(Event::WindowUrgencyChanged { id, urgent })
688+ }
683689 });
684690
685691 // Check for closed windows.