ipc: Clarify some things in the docs
Browse files at this commit96083847fb8776ca4f0ed613148e2e6540690cb3Parent: d25d6ce1 changed file +25 -0
- niri-ipc/src/lib.rs +25 -0
niri-ipc/src/lib.rsmodified+25 -0
| @@ -64,6 +64,16 @@ pub enum Request { | |||
| 64 | /// | 64 | /// |
| 65 | /// The compositor should reply with `Reply::Ok(Response::Handled)`, then continuously send | 65 | /// The compositor should reply with `Reply::Ok(Response::Handled)`, then continuously send |
| 66 | /// [`Event`]s, one per line. | 66 | /// [`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`]. | ||
| 67 | EventStream, | 77 | EventStream, |
| 68 | /// Respond with an error (for testing error handling). | 78 | /// Respond with an error (for testing error handling). |
| 69 | ReturnError, | 79 | ReturnError, |
| @@ -630,6 +640,12 @@ pub enum Transform { | |||
| 630 | #[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))] | 640 | #[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))] |
| 631 | pub struct Window { | 641 | pub struct Window { |
| 632 | /// Unique id of this window. | 642 | /// 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. | ||
| 633 | pub id: u64, | 649 | pub id: u64, |
| 634 | /// Title, if set. | 650 | /// Title, if set. |
| 635 | pub title: Option<String>, | 651 | pub title: Option<String>, |
| @@ -660,10 +676,19 @@ pub struct Workspace { | |||
| 660 | /// Unique id of this workspace. | 676 | /// Unique id of this workspace. |
| 661 | /// | 677 | /// |
| 662 | /// This id remains constant regardless of the workspace moving around and across monitors. | 678 | /// 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. | ||
| 663 | pub id: u64, | 683 | pub id: u64, |
| 664 | /// Index of the workspace on its monitor. | 684 | /// Index of the workspace on its monitor. |
| 665 | /// | 685 | /// |
| 666 | /// This is the same index you can use for requests like `niri msg action focus-workspace`. | 686 | /// 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`]. | ||
| 667 | pub idx: u8, | 692 | pub idx: u8, |
| 668 | /// Optional name of the workspace. | 693 | /// Optional name of the workspace. |
| 669 | pub name: Option<String>, | 694 | pub name: Option<String>, |