forge
Explore
Log in

Don't you dare go Hollow

ipc: Clarify some things in the docs

Browse files at this commit

96083847fb8776ca4f0ed613148e2e6540690cb3Ivan MolodetskikhParent: d25d6ce
niri-ipc/src/lib.rsmodified+25 -0
@@ -64,6 +64,16 @@ pub enum Request {
6464 ///
6565 /// The compositor should reply with `Reply::Ok(Response::Handled)`, then continuously send
6666 /// [`Event`]s, one per line.
67+ ///
68+ /// The event stream will always give you the full current state up-front. For example, the
69+ /// first workspace-related event you will receive will be [`Event::WorkspacesChanged`]
70+ /// containing the full current workspaces state. You *do not* need to separately send
71+ /// [`Request::Workspaces`] when using the event stream.
72+ ///
73+ /// Where reasonable, event stream state updates are atomic, though this is not always the
74+ /// case. For example, a window may end up with a workspace id for a workspace that had already
75+ /// been removed. This can happen if the corresponding [`Event::WorkspacesChanged`] arrives
76+ /// before the corresponding [`Event::WindowOpenedOrChanged`].
6777 EventStream,
6878 /// Respond with an error (for testing error handling).
6979 ReturnError,
@@ -630,6 +640,12 @@ pub enum Transform {
630640 #[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
631641 pub struct Window {
632642 /// Unique id of this window.
643+ ///
644+ /// This id remains constant while this window is open.
645+ ///
646+ /// Do not assume that window ids will always increase without wrapping, or start at 1. That is
647+ /// an implementation detail subject to change. For example, ids may change to be randomly
648+ /// generated for each new window.
633649 pub id: u64,
634650 /// Title, if set.
635651 pub title: Option<String>,
@@ -660,10 +676,19 @@ pub struct Workspace {
660676 /// Unique id of this workspace.
661677 ///
662678 /// This id remains constant regardless of the workspace moving around and across monitors.
679+ ///
680+ /// Do not assume that workspace ids will always increase without wrapping, or start at 1. That
681+ /// is an implementation detail subject to change. For example, ids may change to be randomly
682+ /// generated for each new workspace.
663683 pub id: u64,
664684 /// Index of the workspace on its monitor.
665685 ///
666686 /// This is the same index you can use for requests like `niri msg action focus-workspace`.
687+ ///
688+ /// This index *will change* as you move and re-order workspace. It is merely the workspace's
689+ /// current position on its monitor. Workspaces on different monitors can have the same index.
690+ ///
691+ /// If you need a unique workspace id that doesn't change, see [`Self::id`].
667692 pub idx: u8,
668693 /// Optional name of the workspace.
669694 pub name: Option<String>,