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:
LGUG2Z committed 2026-10-28 07:20:37 -07:00
1 parent 189aeb1005
commit ac265de1e3
10 files changed
+198 -15

No files matched your search

+44 -4
View File
@@ -47,10 +47,11 @@
//! `cross-monitor-move-behaviour` and `toggle-cross-monitor-move-behaviour` set what `move` does
//! at the edge of a monitor, and `display-index-preference` gives a monitor an index.
//! `eager-focus` focuses the first window of an executable, on any workspace of any monitor.
//! - `workspace-name` names a workspace, which `focus-named-workspace`, `named-workspace-layout`
//! and `named-workspace-tiling` find by its name; `workspace-layout` and `workspace-tiling` set
//! the layout and the tiling of a workspace by its index, and `ensure-workspaces` and
//! `ensure-named-workspaces` give a monitor workspaces up to a number, or with names.
//! - `workspace-name` names a workspace, which `focus-named-workspace`, `named-workspace-layout`,
//! `named-workspace-tiling`, `named-workspace-padding` and `named-workspace-container-padding`
//! find by its name; `workspace-layout` and `workspace-tiling` set the layout and the tiling of
//! a workspace by its index, and `ensure-workspaces` and `ensure-named-workspaces` give a
//! monitor workspaces up to a number, or with names.
//!
//! `ignore-rule` and `manage-rule` add a rule that keeps an application out of the layout or
//! always in it, `session-float-rule` floats the focused window and every window like it until the
@@ -297,6 +298,27 @@ gen_padding_subcommand_args! {
WorkspacePadding,
}
macro_rules! gen_named_padding_subcommand_args {
// SubCommand Pattern
( $( $name:ident ),+ $(,)? ) => {
$(
#[derive(clap::Parser)]
pub struct $name {
/// Target workspace name
workspace: String,
/// Pixels to pad with as an integer
size: i32,
}
)+
};
}
gen_named_padding_subcommand_args! {
NamedWorkspaceContainerPadding,
NamedWorkspacePadding,
}
macro_rules! gen_padding_adjustment_subcommand_args {
// SubCommand Pattern
( $( $name:ident ),+ $(,)? ) => {
@@ -773,9 +795,15 @@ enum SubCommand {
/// Set the container padding for the specified workspace
#[clap(arg_required_else_help = true)]
ContainerPadding(ContainerPadding),
/// Set the container padding for the specified workspace
#[clap(arg_required_else_help = true)]
NamedWorkspaceContainerPadding(NamedWorkspaceContainerPadding),
/// Set the workspace padding for the specified workspace
#[clap(arg_required_else_help = true)]
WorkspacePadding(WorkspacePadding),
/// Set the workspace padding for the specified workspace
#[clap(arg_required_else_help = true)]
NamedWorkspacePadding(NamedWorkspacePadding),
/// Set the layout for the specified workspace
#[clap(arg_required_else_help = true)]
WorkspaceLayout(WorkspaceLayout),
@@ -1223,6 +1251,12 @@ fn main() -> eyre::Result<()> {
args.size,
))?;
}
SubCommand::NamedWorkspaceContainerPadding(args) => {
send_message(&SocketMessage::NamedWorkspaceContainerPadding(
args.workspace,
args.size,
))?;
}
SubCommand::WorkspacePadding(args) => {
send_message(&SocketMessage::WorkspacePadding(
args.monitor,
@@ -1230,6 +1264,12 @@ fn main() -> eyre::Result<()> {
args.size,
))?;
}
SubCommand::NamedWorkspacePadding(args) => {
send_message(&SocketMessage::NamedWorkspacePadding(
args.workspace,
args.size,
))?;
}
SubCommand::FocusedWorkspacePadding(args) => {
send_message(&SocketMessage::FocusedWorkspacePadding(args.size))?;
}