mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-12-06 15:06:37 +01:00
feat(wm): padding for named workspaces
workspace-padding and container-padding take the index of a workspace's monitor and its own index, so a script that names its workspaces still has to count them to pad one, while focus-named-workspace, named-workspace-layout and named-workspace-tiling already take the name. named-workspace-padding and named-workspace-container-padding take the name instead. They look the workspace up on every monitor the way the other named commands do, set the same padding the commands by index set, and change nothing for a name no workspace has. The tests check the messages the subcommands send, that a named workspace takes its paddings and the tile in front follows, and that a name nobody has changes nothing. The commands sweep of the VM suite sends both commands to a real session.
This commit is contained in:
1 parent
189aeb1005
commit
ac265de1e3
10 files changed
+198
-15
No files matched your search
@@ -88,6 +88,17 @@ fn one_window_without_padding(id: u32) -> (Arc<FakeBackend>, WindowManager) {
|
||||
(fake, wm)
|
||||
}
|
||||
|
||||
/// The workspace padding and the container padding each workspace of the focused monitor has of
|
||||
/// its own
|
||||
fn paddings(wm: &WindowManager) -> Vec<(Option<i32>, Option<i32>)> {
|
||||
wm.focused_monitor()
|
||||
.unwrap()
|
||||
.workspaces()
|
||||
.iter()
|
||||
.map(|workspace| (workspace.workspace_padding, workspace.container_padding))
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_paddings_of_the_focused_workspace_are_set_and_adjusted() {
|
||||
let (fake, mut wm) = desktop_with(&[28_001]);
|
||||
@@ -156,6 +167,63 @@ fn the_paddings_of_a_workspace_are_set_by_its_indices() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_paddings_of_a_workspace_are_set_by_its_name_and_a_name_nobody_has_changes_nothing() {
|
||||
let (fake, mut wm) = desktop_with(&[28_041]);
|
||||
send(
|
||||
&fake,
|
||||
&mut wm,
|
||||
SocketMessage::EnsureNamedWorkspaces(0, vec![String::from("main"), String::from("side")]),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
// the workspace in front is tiled again at once
|
||||
send(
|
||||
&fake,
|
||||
&mut wm,
|
||||
SocketMessage::NamedWorkspacePadding(String::from("main"), 20),
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(fake.rect_of(28_041), Some(rect(25, 25, 1870, 1000)));
|
||||
send(
|
||||
&fake,
|
||||
&mut wm,
|
||||
SocketMessage::NamedWorkspaceContainerPadding(String::from("main"), 0),
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(fake.rect_of(28_041), Some(rect(20, 20, 1880, 1010)));
|
||||
|
||||
// another workspace takes its own paddings, and the one in front keeps its tile
|
||||
send(
|
||||
&fake,
|
||||
&mut wm,
|
||||
SocketMessage::NamedWorkspacePadding(String::from("side"), 7),
|
||||
)
|
||||
.unwrap();
|
||||
send(
|
||||
&fake,
|
||||
&mut wm,
|
||||
SocketMessage::NamedWorkspaceContainerPadding(String::from("side"), 3),
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(fake.rect_of(28_041), Some(rect(20, 20, 1880, 1010)));
|
||||
assert_eq!(paddings(&wm), [(Some(20), Some(0)), (Some(7), Some(3))]);
|
||||
|
||||
send(
|
||||
&fake,
|
||||
&mut wm,
|
||||
SocketMessage::NamedWorkspacePadding(String::from("nowhere"), 99),
|
||||
)
|
||||
.unwrap();
|
||||
send(
|
||||
&fake,
|
||||
&mut wm,
|
||||
SocketMessage::NamedWorkspaceContainerPadding(String::from("nowhere"), 99),
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(paddings(&wm), [(Some(20), Some(0)), (Some(7), Some(3))]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_workspaces_offset_wins_over_the_monitors_which_wins_over_the_global_one() {
|
||||
let (fake, mut wm) = one_window_without_padding(28_021);
|
||||
|
||||
Reference in new issue
Block a user