mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-16 05:41:16 +01:00
feat(workspace): make retile put the widths of scrolling columns back
retile already forgot the resize adjustments of the layouts that are made of splits, and the widths of the columns of the Scrolling layout are the same kind of thing. The focused workspace of each monitor gets its columns back to what scrolling-layout-columns gives, and the focused column stays where it is unless it has to scroll. The variant of retile that keeps resize dimensions keeps the widths.
This commit is contained in:
1 parent
65265c95f3
commit
2fb9dfdffa
5 files changed
+66
-1
No files matched your search
+4
-1
@@ -3,10 +3,13 @@
|
||||
```
|
||||
Force the retiling of all managed windows
|
||||
|
||||
Every column of a workspace in the Scrolling layout goes back to the width that
|
||||
scrolling-layout-columns gives.
|
||||
|
||||
Usage: komorebic retile
|
||||
|
||||
Options:
|
||||
-h, --help
|
||||
Print help
|
||||
Print help (see a summary with '-h')
|
||||
|
||||
```
|
||||
@@ -72,6 +72,10 @@ the focused column, by half of the [resize delta](../cli/resize-delta.md) for ea
|
||||
changes the width by the whole delta. Dragging an edge with the mouse does the same. Columns are as tall as the screen,
|
||||
so resizing a height does nothing.
|
||||
|
||||
[`komorebic retile`](../cli/retile.md) puts every column back to the width that
|
||||
[`scrolling-layout-columns`](../cli/scrolling-layout-columns.md) gives, on the focused workspace of each monitor. The
|
||||
focused column stays where it is on screen, unless it has to scroll to stay in view.
|
||||
|
||||
## Windows that are out of view
|
||||
|
||||
A window that scrolls out of view comes to rest at the edge of the screen that it left by, with 5 pixels of it still on
|
||||
|
||||
@@ -182,6 +182,16 @@ impl Workspace {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Put every column back to the width that the `columns` option gives, which forgets every
|
||||
/// width that was set by resizing, by a preset, or by taking the full width.
|
||||
///
|
||||
/// The focused column stays where it is on screen unless it has to scroll to stay in view.
|
||||
pub(crate) fn reset_scrolling_widths(&mut self) {
|
||||
if let Some(space) = self.scrolling.as_mut() {
|
||||
space.reset_widths();
|
||||
}
|
||||
}
|
||||
|
||||
/// Make the focused column wider or narrower. Only the horizontal edges mean anything, since
|
||||
/// a column is as tall as the viewport.
|
||||
///
|
||||
@@ -503,6 +513,47 @@ mod tests {
|
||||
assert!(workspace.scrolling.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resetting_the_widths_puts_every_column_back_to_what_the_columns_option_gives() {
|
||||
let mut workspace = workspace(3, 4);
|
||||
workspace.layout_scrolling(&AREA, 0);
|
||||
|
||||
workspace.resize_scrolling_column(OperationDirection::Left, Sizing::Increase, 200);
|
||||
workspace.focus_container(1);
|
||||
workspace.resize_scrolling_column(OperationDirection::Right, Sizing::Decrease, 100);
|
||||
let resized = widths(&workspace.layout_scrolling(&AREA, 0));
|
||||
assert_ne!(resized, [400; 4]);
|
||||
|
||||
workspace.reset_scrolling_widths();
|
||||
|
||||
assert_eq!(widths(&workspace.layout_scrolling(&AREA, 0)), [400; 4]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resetting_the_widths_keeps_the_focused_column_where_it_is() {
|
||||
let mut workspace = workspace(3, 6);
|
||||
workspace.focus_container(3);
|
||||
workspace.layout_scrolling(&AREA, 0);
|
||||
workspace.focus_container(1);
|
||||
workspace.resize_scrolling_column(OperationDirection::Left, Sizing::Increase, 200);
|
||||
workspace.focus_container(3);
|
||||
let before = workspace.layout_scrolling(&AREA, 0)[3].rect.left;
|
||||
|
||||
workspace.reset_scrolling_widths();
|
||||
|
||||
assert_eq!(workspace.layout_scrolling(&AREA, 0)[3].rect.left, before);
|
||||
assert_eq!(workspace.focused_container_idx(), 3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resetting_the_widths_before_there_is_a_layout_does_nothing() {
|
||||
let mut workspace = workspace(3, 2);
|
||||
|
||||
workspace.reset_scrolling_widths();
|
||||
|
||||
assert!(workspace.scrolling.is_none());
|
||||
}
|
||||
|
||||
/// A workspace with a window in every container, which is how closing a window finds a container.
|
||||
fn workspace_of_windows(columns: usize, count: u32) -> Workspace {
|
||||
let mut workspace = Workspace {
|
||||
|
||||
@@ -1807,6 +1807,10 @@ impl WindowManager {
|
||||
for resize in &mut workspace.resize_dimensions {
|
||||
*resize = None;
|
||||
}
|
||||
|
||||
// and the widths of the columns of the Scrolling layout, which are resize
|
||||
// adjustments too
|
||||
workspace.reset_scrolling_widths();
|
||||
}
|
||||
|
||||
if (workspace.wallpaper.is_some() || monitor_wp.is_some())
|
||||
|
||||
@@ -1004,6 +1004,9 @@ enum SubCommand {
|
||||
/// Promote the window in the specified direction
|
||||
PromoteWindow(PromoteWindow),
|
||||
/// Force the retiling of all managed windows
|
||||
///
|
||||
/// Every column of a workspace in the Scrolling layout goes back to the width that
|
||||
/// scrolling-layout-columns gives.
|
||||
Retile,
|
||||
// /// Set the monitor index preference for a monitor identified using its size
|
||||
// #[clap(arg_required_else_help = true)]
|
||||
|
||||
Reference in new issue
Block a user