aboutsummaryrefslogtreecommitdiff
path: root/niri-ipc
diff options
context:
space:
mode:
authorCharlie Le <20309750+CharlieQLe@users.noreply.github.com>2025-05-09 11:01:01 -0400
committerGitHub <noreply@github.com>2025-05-09 18:01:01 +0300
commit3cc67897afeabe6e0b1a6d035fde6f81010372d1 (patch)
treec9cbf0f465885460700bfa2de1f3a57bda3f0055 /niri-ipc
parenta99489c6c0e2ccf27825fd8ed1b68466c1eebb24 (diff)
downloadniri-3cc67897afeabe6e0b1a6d035fde6f81010372d1.tar.gz
niri-3cc67897afeabe6e0b1a6d035fde6f81010372d1.tar.bz2
niri-3cc67897afeabe6e0b1a6d035fde6f81010372d1.zip
Implement IPC for the overview state (#1526)
* Implement IPC for the overview state * Update Overview IPC to maintain naming consistency, renamed OverviewToggled to be more clear, simplify overview state request on the server, consolidate ipc refresh * Fix Overview is_open in IPC client * Change opened to is_open * Update niri-ipc/src/lib.rs Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com> * Update niri-ipc/src/state.rs Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com> * Update src/ipc/client.rs Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com> * Update src/ipc/client.rs Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com> * Add overview state to EventStreamStatePart replicate and apply * Fix formatting * Rename Overview to OverviewState --------- Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
Diffstat (limited to 'niri-ipc')
-rw-r--r--niri-ipc/src/lib.rs17
-rw-r--r--niri-ipc/src/state.rs30
2 files changed, 47 insertions, 0 deletions
diff --git a/niri-ipc/src/lib.rs b/niri-ipc/src/lib.rs
index 325cdef0..75d9a543 100644
--- a/niri-ipc/src/lib.rs
+++ b/niri-ipc/src/lib.rs
@@ -97,6 +97,8 @@ pub enum Request {
EventStream,
/// Respond with an error (for testing error handling).
ReturnError,
+ /// Request information about the overview.
+ OverviewState,
}
/// Reply from niri to client.
@@ -139,6 +141,16 @@ pub enum Response {
PickedColor(Option<PickedColor>),
/// Output configuration change result.
OutputConfigChanged(OutputConfigChanged),
+ /// Information about the overview.
+ OverviewState(Overview),
+}
+
+/// Overview information.
+#[derive(Serialize, Deserialize, Debug, Clone)]
+#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
+pub struct Overview {
+ /// Whether the overview is currently open.
+ pub is_open: bool,
}
/// Color picked from the screen.
@@ -1269,6 +1281,11 @@ pub enum Event {
/// Index of the newly active layout.
idx: u8,
},
+ /// The overview was opened or closed.
+ OverviewOpenedOrClosed {
+ /// The new state of the overview.
+ is_open: bool,
+ },
}
impl FromStr for WorkspaceReferenceArg {
diff --git a/niri-ipc/src/state.rs b/niri-ipc/src/state.rs
index 2ab58fc3..0689104d 100644
--- a/niri-ipc/src/state.rs
+++ b/niri-ipc/src/state.rs
@@ -40,6 +40,9 @@ pub struct EventStreamState {
/// State of the keyboard layouts.
pub keyboard_layouts: KeyboardLayoutsState,
+
+ /// State of the overview.
+ pub overview: OverviewState,
}
/// The workspaces state communicated over the event stream.
@@ -63,12 +66,20 @@ pub struct KeyboardLayoutsState {
pub keyboard_layouts: Option<KeyboardLayouts>,
}
+/// The overview state communicated over the event stream.
+#[derive(Debug, Default)]
+pub struct OverviewState {
+ /// Whether the overview is currently open.
+ pub is_open: bool,
+}
+
impl EventStreamStatePart for EventStreamState {
fn replicate(&self) -> Vec<Event> {
let mut events = Vec::new();
events.extend(self.workspaces.replicate());
events.extend(self.windows.replicate());
events.extend(self.keyboard_layouts.replicate());
+ events.extend(self.overview.replicate());
events
}
@@ -76,6 +87,7 @@ impl EventStreamStatePart for EventStreamState {
let event = self.workspaces.apply(event)?;
let event = self.windows.apply(event)?;
let event = self.keyboard_layouts.apply(event)?;
+ let event = self.overview.apply(event)?;
Some(event)
}
}
@@ -192,3 +204,21 @@ impl EventStreamStatePart for KeyboardLayoutsState {
None
}
}
+
+impl EventStreamStatePart for OverviewState {
+ fn replicate(&self) -> Vec<Event> {
+ vec![Event::OverviewOpenedOrClosed {
+ is_open: self.is_open,
+ }]
+ }
+
+ fn apply(&mut self, event: Event) -> Option<Event> {
+ match event {
+ Event::OverviewOpenedOrClosed { is_open } => {
+ self.is_open = is_open;
+ }
+ event => return Some(event),
+ }
+ None
+ }
+}