forge
Explore
Log in

Don't you dare go Hollow

add workspace urgency ipc event

Browse files at this commit

caa6189448cbf338c18fe6afe313f577c8378b31Duncan OverbruckParent: 86f57c2
niri-ipc/src/lib.rsmodified+9 -0
@@ -1150,6 +1150,8 @@ pub struct Workspace {
11501150 ///
11511151 /// Can be `None` if no outputs are currently connected.
11521152 pub output: Option<String>,
1153+ /// Whether the workspace currently has an urgent window in its output.
1154+ pub is_urgent: bool,
11531155 /// Whether the workspace is currently active on its output.
11541156 ///
11551157 /// Every output has one active workspace, the one that is currently visible on that output.
@@ -1224,6 +1226,13 @@ pub enum Event {
12241226 /// workspaces are missing from here, then they were deleted.
12251227 workspaces: Vec<Workspace>,
12261228 },
1229+ /// The workspace urgency changed.
1230+ WorkspaceUrgencyChanged {
1231+ /// Id of the workspace.
1232+ id: u64,
1233+ /// Whether this workspace has an urgent window.
1234+ urgent: bool,
1235+ },
12271236 /// A workspace was activated on an output.
12281237 ///
12291238 /// This doesn't always mean the workspace became focused, just that it's now the active
niri-ipc/src/state.rsmodified+7 -0
@@ -103,6 +103,13 @@ impl EventStreamStatePart for WorkspacesState {
103103 Event::WorkspacesChanged { workspaces } => {
104104 self.workspaces = workspaces.into_iter().map(|ws| (ws.id, ws)).collect();
105105 }
106+ Event::WorkspaceUrgencyChanged { id, urgent } => {
107+ for ws in self.workspaces.values_mut() {
108+ if ws.id == id {
109+ ws.is_urgent = urgent;
110+ }
111+ }
112+ }
106113 Event::WorkspaceActivated { id, focused } => {
107114 let ws = self.workspaces.get(&id);
108115 let ws = ws.expect("activated workspace was missing from the map");
src/ipc/client.rsmodified+3 -0
@@ -405,6 +405,9 @@ pub fn handle_msg(msg: Msg, json: bool) -> anyhow::Result<()> {
405405 Event::WorkspacesChanged { workspaces } => {
406406 println!("Workspaces changed: {workspaces:?}");
407407 }
408+ Event::WorkspaceUrgencyChanged { id, urgent } => {
409+ println!("Workspace {id}: urgency changed to {urgent}");
410+ }
408411 Event::WorkspaceActivated { id, focused } => {
409412 let word = if focused { "focused" } else { "activated" };
410413 println!("Workspace {word}: {id}");
src/ipc/server.rsmodified+7 -0
@@ -579,6 +579,12 @@ impl State {
579579 });
580580 }
581581
582+ // Check if this workspace urgent state changed.
583+ let urgent = ws.is_urgent();
584+ if urgent != ipc_ws.is_urgent {
585+ events.push(Event::WorkspaceUrgencyChanged { id, urgent });
586+ }
587+
582588 // Check if this workspace became focused.
583589 let is_focused = Some(id) == focused_ws_id;
584590 if is_focused && !ipc_ws.is_focused {
@@ -610,6 +616,7 @@ impl State {
610616 idx: u8::try_from(ws_idx + 1).unwrap_or(u8::MAX),
611617 name: ws.name().cloned(),
612618 output: mon.map(|mon| mon.output_name().clone()),
619+ is_urgent: ws.is_urgent(),
613620 is_active: mon.is_some_and(|mon| mon.active_workspace_idx() == ws_idx),
614621 is_focused: Some(id) == focused_ws_id,
615622 active_window_id: ws.active_window().map(|win| win.id().get()),
src/layout/workspace.rsmodified+4 -0
@@ -1608,6 +1608,10 @@ impl<W: LayoutElement> Workspace<W> {
16081608 self.scrolling.scroll_amount_to_activate(window)
16091609 }
16101610
1611+ pub fn is_urgent(&self) -> bool {
1612+ self.windows().any(|win| win.is_urgent())
1613+ }
1614+
16111615 pub fn activate_window(&mut self, window: &W::Id) -> bool {
16121616 if self.floating.activate_window(window) {
16131617 self.floating_is_active = FloatingActive::Yes;