wiki: Add edge cases to design principles
Browse files at this commitfda56e0cdfa261e70ba4a8b44e4dbb1a656686beParent: 1697ba51 changed file +23 -0
docs/wiki/Development:-Design-Principles.mdmodified+23 -0
| @@ -48,6 +48,29 @@ This is niri state that is not immediately apparent from looking at the screen. | |||
| 48 | - For example, when a monitor disconnects, all its workspaces move to another connected monitor. In order to be able to restore these workspaces when the first monitor connects again, these workspaces keep the knowledge of which was their *original monitor*—this is an example of invisible state, since you can't tell it in any way by looking at the screen. This can have surprising consequences: imagine disconnecting a monitor at home, going to work, completely rearranging the windows there, then coming back home, and suddenly some random workspaces end up on your home monitor. In order to reduce this surprise factor, whenever a new window appears on a workspace, that workspace resets its *original monitor* to its current monitor. This way, the workspaces you actively worked on remain where they were. | 48 | - For example, when a monitor disconnects, all its workspaces move to another connected monitor. In order to be able to restore these workspaces when the first monitor connects again, these workspaces keep the knowledge of which was their *original monitor*—this is an example of invisible state, since you can't tell it in any way by looking at the screen. This can have surprising consequences: imagine disconnecting a monitor at home, going to work, completely rearranging the windows there, then coming back home, and suddenly some random workspaces end up on your home monitor. In order to reduce this surprise factor, whenever a new window appears on a workspace, that workspace resets its *original monitor* to its current monitor. This way, the workspaces you actively worked on remain where they were. |
| 49 | - For example, niri preserves the view position whenever a window appears, or whenever a window goes full-screen, to restore it afterward. This way, dealing with temporary things like dialogs opening and closing, or toggling full-screen, becomes less annoying, since it doesn't mess up the view position. This is also invisible state, as you cannot tell by looking at the screen where closing a window will restore the view position. If taken to the extreme (previous view position saved forever for every open window), this can be surprising, as closing long-running windows would result in the view shifting around pretty much randomly. To reduce this surprise factor, niri remembers only one last view position per workspace, and forgets this stored view position upon window focus change. | 49 | - For example, niri preserves the view position whenever a window appears, or whenever a window goes full-screen, to restore it afterward. This way, dealing with temporary things like dialogs opening and closing, or toggling full-screen, becomes less annoying, since it doesn't mess up the view position. This is also invisible state, as you cannot tell by looking at the screen where closing a window will restore the view position. If taken to the extreme (previous view position saved forever for every open window), this can be surprising, as closing long-running windows would result in the view shifting around pretty much randomly. To reduce this surprise factor, niri remembers only one last view position per workspace, and forgets this stored view position upon window focus change. |
| 50 | 50 | ||
| 51 | +### Consider all edge cases. | ||
| 52 | + | ||
| 53 | +A Wayland compositor sits between the user and everything they do with their computer. | ||
| 54 | +Generally, the user wants to do their work, and not think about the Wayland compositor in the middle. | ||
| 55 | + | ||
| 56 | +Any sort of breakage in a compositor can prevent users from doing what they want. | ||
| 57 | +Since *everything* runs through the compositor, all sorts of weird setups and edge cases do show up in practice. | ||
| 58 | +We cannot ignore them in niri. | ||
| 59 | + | ||
| 60 | +Not every edge case needs to be *supported*. | ||
| 61 | +For example, what if you move a window with a mouse cursor, and at the same time try to move another window from a touchscreen? | ||
| 62 | +You *could* make it work, but for simplicity, niri only supports moving a single window at a time, and that's fine. | ||
| 63 | +I considered this edge case while implementing window movement and made this decision. | ||
| 64 | + | ||
| 65 | +Thankfully, Rust makes corner cases easy to see and gets you to deal with them. | ||
| 66 | +You can't forget to handle an enum variant, or forget to check if an `Option` is `None`—it won't compile. | ||
| 67 | +All that's left is considering when these conditions can happen in practice and thinking of the best way to deal with them. | ||
| 68 | + | ||
| 69 | +Of course, not all state combinations are bound by Rust types. | ||
| 70 | +When working on niri, actively try to come up with unexpected interactions, and try them to see that they work reasonably. | ||
| 71 | +Try to break the code that you wrote and check that it behaves well. | ||
| 72 | +Try different input devices: keyboard, mouse, trackpad, tablet, touchscreen, and their combinations. | ||
| 73 | + | ||
| 51 | ## Window layout | 74 | ## Window layout |
| 52 | 75 | ||
| 53 | Here are some design considerations for the window layout logic. | 76 | Here are some design considerations for the window layout logic. |