add WindowUrgencyChanged ipc event
Browse files at this commita8259b4ceae521311f5152980287ff88d0b984e7Parent: 9d3d7cb4 changed files +26 -0
- niri-ipc/src/lib.rs +9 -0
- niri-ipc/src/state.rs +8 -0
- src/ipc/client.rs +3 -0
- src/ipc/server.rs +6 -0
niri-ipc/src/lib.rsmodified+9 -0
| @@ -1129,6 +1129,8 @@ pub struct Window { | ||
| 1129 | 1129 | /// |
| 1130 | 1130 | /// If the window isn't floating then it is in the tiling layout. |
| 1131 | 1131 | pub is_floating: bool, |
| 1132 | + /// Whether this window requests your attention. | |
| 1133 | + pub is_urgent: bool, | |
| 1132 | 1134 | } |
| 1133 | 1135 | |
| 1134 | 1136 | /// Output configuration change result. |
| @@ -1298,6 +1300,13 @@ pub enum Event { | ||
| 1298 | 1300 | /// Id of the newly focused window, or `None` if no window is now focused. |
| 1299 | 1301 | id: Option<u64>, |
| 1300 | 1302 | }, |
| 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 | + }, | |
| 1301 | 1310 | /// The configured keyboard layouts have changed. |
| 1302 | 1311 | KeyboardLayoutsChanged { |
| 1303 | 1312 | /// The new keyboard layout configuration. |
niri-ipc/src/state.rsmodified+8 -0
| @@ -181,6 +181,14 @@ impl EventStreamStatePart for WindowsState { | ||
| 181 | 181 | win.is_focused = Some(win.id) == id; |
| 182 | 182 | } |
| 183 | 183 | } |
| 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 | + } | |
| 184 | 192 | event => return Some(event), |
| 185 | 193 | } |
| 186 | 194 | None |
src/ipc/client.rsmodified+3 -0
| @@ -433,6 +433,9 @@ pub fn handle_msg(msg: Msg, json: bool) -> anyhow::Result<()> { | ||
| 433 | 433 | Event::WindowFocusChanged { id } => { |
| 434 | 434 | println!("Window focus changed: {id:?}"); |
| 435 | 435 | } |
| 436 | + Event::WindowUrgencyChanged { id, urgent } => { | |
| 437 | + println!("Window {id}: urgency changed to {urgent}"); | |
| 438 | + } | |
| 436 | 439 | Event::KeyboardLayoutsChanged { keyboard_layouts } => { |
| 437 | 440 | println!("Keyboard layouts changed: {keyboard_layouts:?}"); |
| 438 | 441 | } |
src/ipc/server.rsmodified+6 -0
| @@ -476,6 +476,7 @@ fn make_ipc_window(mapped: &Mapped, workspace_id: Option<WorkspaceId>) -> niri_i | ||
| 476 | 476 | workspace_id: workspace_id.map(|id| id.get()), |
| 477 | 477 | is_focused: mapped.is_focused(), |
| 478 | 478 | is_floating: mapped.is_floating(), |
| 479 | + is_urgent: mapped.is_urgent(), | |
| 479 | 480 | }) |
| 480 | 481 | } |
| 481 | 482 | |
| @@ -680,6 +681,11 @@ impl State { | ||
| 680 | 681 | if mapped.is_focused() && !ipc_win.is_focused { |
| 681 | 682 | events.push(Event::WindowFocusChanged { id: Some(id) }); |
| 682 | 683 | } |
| 684 | + | |
| 685 | + let urgent = mapped.is_urgent(); | |
| 686 | + if urgent != ipc_win.is_urgent { | |
| 687 | + events.push(Event::WindowUrgencyChanged { id, urgent }) | |
| 688 | + } | |
| 683 | 689 | }); |
| 684 | 690 | |
| 685 | 691 | // Check for closed windows. |