mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-23 02:05:33 +07:00
Add toggle-window-width by-id action
This commit is contained in:
@@ -2607,6 +2607,29 @@ impl<W: LayoutElement> Layout<W> {
|
||||
monitor.toggle_width();
|
||||
}
|
||||
|
||||
pub fn toggle_window_width(&mut self, window: Option<&W::Id>) {
|
||||
if let Some(InteractiveMoveState::Moving(move_)) = &mut self.interactive_move {
|
||||
if window.is_none() || window == Some(move_.tile.window().id()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let workspace = if let Some(window) = window {
|
||||
Some(
|
||||
self.workspaces_mut()
|
||||
.find(|ws| ws.has_window(window))
|
||||
.unwrap(),
|
||||
)
|
||||
} else {
|
||||
self.active_workspace_mut()
|
||||
};
|
||||
|
||||
let Some(workspace) = workspace else {
|
||||
return;
|
||||
};
|
||||
workspace.toggle_window_width(window);
|
||||
}
|
||||
|
||||
pub fn toggle_window_height(&mut self, window: Option<&W::Id>) {
|
||||
if let Some(InteractiveMoveState::Moving(move_)) = &mut self.interactive_move {
|
||||
if window.is_none() || window == Some(move_.tile.window().id()) {
|
||||
@@ -4474,6 +4497,10 @@ mod tests {
|
||||
},
|
||||
MoveColumnToOutput(#[proptest(strategy = "1..=5usize")] usize),
|
||||
SwitchPresetColumnWidth,
|
||||
SwitchPresetWindowWidth {
|
||||
#[proptest(strategy = "proptest::option::of(1..=5usize)")]
|
||||
id: Option<usize>,
|
||||
},
|
||||
SwitchPresetWindowHeight {
|
||||
#[proptest(strategy = "proptest::option::of(1..=5usize)")]
|
||||
id: Option<usize>,
|
||||
@@ -5009,6 +5036,10 @@ mod tests {
|
||||
Op::MoveWorkspaceDown => layout.move_workspace_down(),
|
||||
Op::MoveWorkspaceUp => layout.move_workspace_up(),
|
||||
Op::SwitchPresetColumnWidth => layout.toggle_width(),
|
||||
Op::SwitchPresetWindowWidth { id } => {
|
||||
let id = id.filter(|id| layout.has_window(id));
|
||||
layout.toggle_window_width(id.as_ref());
|
||||
}
|
||||
Op::SwitchPresetWindowHeight { id } => {
|
||||
let id = id.filter(|id| layout.has_window(id));
|
||||
layout.toggle_window_height(id.as_ref());
|
||||
|
||||
Reference in New Issue
Block a user