forge
Explore
Log in

Don't you dare go Hollow

layout: Update module comment

Browse files at this commit

6f2f7fa2599c76517ba8908c1b559db2c4dacc2fIvan MolodetskikhParent: 49ddf66
src/layout/mod.rsmodified+15 -13
@@ -1,9 +1,18 @@
1 //! Window layout logic.1 //! Window layout logic.
2 //!2 //!
3-//! Niri implements scrollable tiling with workspaces. There's one primary output, and potentially3+//! Niri implements scrollable tiling with dynamic workspaces. The scrollable tiling is mostly
4-//! multiple other outputs.4+//! orthogonal to any particular workspace system, though outputs living in separate coordinate
5+//! spaces suggest per-output workspaces.
5 //!6 //!
6-//! Our layout has the following invariants:7+//! I chose a dynamic workspace system because I think it works very well. In particular, it works
8+//! naturally across outputs getting added and removed, since workspaces can move between outputs
9+//! as necessary.
10+//!
11+//! In the layout, one output (the first one to be added) is designated as *primary*. This is where
12+//! workspaces from disconnected outputs will move. Currently, the primary output has no other
13+//! distinction from other outputs.
14+//!
15+//! Where possible, niri tries to follow these principles with regards to outputs:
7 //!16 //!
8 //! 1. Disconnecting and reconnecting the same output must not change the layout.17 //! 1. Disconnecting and reconnecting the same output must not change the layout.
9 //! * This includes both secondary outputs and the primary output.18 //! * This includes both secondary outputs and the primary output.
@@ -11,10 +20,9 @@
11 //! output.20 //! output.
12 //!21 //!
13 //! Therefore, we implement the following logic: every workspace keeps track of which output it22 //! Therefore, we implement the following logic: every workspace keeps track of which output it
14-//! originated on. When an output disconnects, its workspace (or workspaces, in case of the primary23+//! originated on—its *original output*. When an output disconnects, its workspaces are appended to
15-//! output disconnecting) are appended to the (potentially new) primary output, but remember their24+//! the (potentially new) primary output, but remember their original output. Then, if the original
16-//! original output. Then, if the original output connects again, all workspaces originally from25+//! output connects again, all workspaces originally from there move back to that output.
17-//! there move back to that output.
18 //!26 //!
19 //! In order to avoid surprising behavior, if the user creates or moves any new windows onto a27 //! In order to avoid surprising behavior, if the user creates or moves any new windows onto a
20 //! workspace, it forgets its original output, and its current output becomes its original output.28 //! workspace, it forgets its original output, and its current output becomes its original output.
@@ -22,12 +30,6 @@
22 //! with them, disconnecting the monitor, and keeps working as normal, using the second monitor's30 //! with them, disconnecting the monitor, and keeps working as normal, using the second monitor's
23 //! workspace just like any other. Then they come back, reconnect the second monitor, and now we31 //! workspace just like any other. Then they come back, reconnect the second monitor, and now we
24 //! don't want an unassuming workspace to end up on it.32 //! don't want an unassuming workspace to end up on it.
25-//!
26-//! ## Workspaces-only-on-primary considerations
27-//!
28-//! If this logic results in more than one workspace present on a secondary output, then as a
29-//! compromise we only keep the first workspace there, and move the rest to the primary output,
30-//! making the primary output their original output.
31 33
32 use std::cmp::min;34 use std::cmp::min;
33 use std::collections::HashMap;35 use std::collections::HashMap;