forge
Explore
Log in

Don't you dare go Hollow

Add a reset-window-height action

Browse files at this commit

1c14a0a2a97867878c65ea33fa8b927618efb555Ivan MolodetskikhParent: 2fd9a03
niri-config/src/lib.rsmodified+2 -0
@@ -898,6 +898,7 @@ pub enum Action {
898 MoveColumnToMonitorDown,898 MoveColumnToMonitorDown,
899 MoveColumnToMonitorUp,899 MoveColumnToMonitorUp,
900 SetWindowHeight(#[knuffel(argument, str)] SizeChange),900 SetWindowHeight(#[knuffel(argument, str)] SizeChange),
901+ ResetWindowHeight,
901 SwitchPresetColumnWidth,902 SwitchPresetColumnWidth,
902 MaximizeColumn,903 MaximizeColumn,
903 SetColumnWidth(#[knuffel(argument, str)] SizeChange),904 SetColumnWidth(#[knuffel(argument, str)] SizeChange),
@@ -969,6 +970,7 @@ impl From<niri_ipc::Action> for Action {
969 niri_ipc::Action::MoveColumnToMonitorDown => Self::MoveColumnToMonitorDown,970 niri_ipc::Action::MoveColumnToMonitorDown => Self::MoveColumnToMonitorDown,
970 niri_ipc::Action::MoveColumnToMonitorUp => Self::MoveColumnToMonitorUp,971 niri_ipc::Action::MoveColumnToMonitorUp => Self::MoveColumnToMonitorUp,
971 niri_ipc::Action::SetWindowHeight { change } => Self::SetWindowHeight(change),972 niri_ipc::Action::SetWindowHeight { change } => Self::SetWindowHeight(change),
973+ niri_ipc::Action::ResetWindowHeight => Self::ResetWindowHeight,
972 niri_ipc::Action::SwitchPresetColumnWidth => Self::SwitchPresetColumnWidth,974 niri_ipc::Action::SwitchPresetColumnWidth => Self::SwitchPresetColumnWidth,
973 niri_ipc::Action::MaximizeColumn => Self::MaximizeColumn,975 niri_ipc::Action::MaximizeColumn => Self::MaximizeColumn,
974 niri_ipc::Action::SetColumnWidth { change } => Self::SetColumnWidth(change),976 niri_ipc::Action::SetColumnWidth { change } => Self::SetColumnWidth(change),
niri-ipc/src/lib.rsmodified+2 -0
@@ -208,6 +208,8 @@ pub enum Action {
208 #[cfg_attr(feature = "clap", arg())]208 #[cfg_attr(feature = "clap", arg())]
209 change: SizeChange,209 change: SizeChange,
210 },210 },
211+ /// Reset the height of the focused window back to automatic.
212+ ResetWindowHeight,
211 /// Switch between preset column widths.213 /// Switch between preset column widths.
212 SwitchPresetColumnWidth,214 SwitchPresetColumnWidth,
213 /// Toggle the maximized state of the focused column.215 /// Toggle the maximized state of the focused column.
resources/default-config.kdlmodified+1 -0
@@ -418,6 +418,7 @@ binds {
418 // Mod+BracketRight { consume-or-expel-window-right; }418 // Mod+BracketRight { consume-or-expel-window-right; }
419 419
420 Mod+R { switch-preset-column-width; }420 Mod+R { switch-preset-column-width; }
421+ Mod+Shift+R { reset-window-height; }
421 Mod+F { maximize-column; }422 Mod+F { maximize-column; }
422 Mod+Shift+F { fullscreen-window; }423 Mod+Shift+F { fullscreen-window; }
423 Mod+C { center-column; }424 Mod+C { center-column; }
src/input.rsmodified+3 -0
@@ -780,6 +780,9 @@ impl State {
780 Action::SetWindowHeight(change) => {780 Action::SetWindowHeight(change) => {
781 self.niri.layout.set_window_height(change);781 self.niri.layout.set_window_height(change);
782 }782 }
783+ Action::ResetWindowHeight => {
784+ self.niri.layout.reset_window_height();
785+ }
783 Action::ShowHotkeyOverlay => {786 Action::ShowHotkeyOverlay => {
784 if self.niri.hotkey_overlay.show() {787 if self.niri.hotkey_overlay.show() {
785 self.niri.queue_redraw_all();788 self.niri.queue_redraw_all();
src/layout/mod.rsmodified+9 -0
@@ -1477,6 +1477,13 @@ impl<W: LayoutElement> Layout<W> {
1477 monitor.set_window_height(change);1477 monitor.set_window_height(change);
1478 }1478 }
1479 1479
1480+ pub fn reset_window_height(&mut self) {
1481+ let Some(monitor) = self.active_monitor() else {
1482+ return;
1483+ };
1484+ monitor.reset_window_height();
1485+ }
1486+
1480 pub fn focus_output(&mut self, output: &Output) {1487 pub fn focus_output(&mut self, output: &Output) {
1481 if let MonitorSet::Normal {1488 if let MonitorSet::Normal {
1482 monitors,1489 monitors,
@@ -2335,6 +2342,7 @@ mod tests {
2335 MaximizeColumn,2342 MaximizeColumn,
2336 SetColumnWidth(#[proptest(strategy = "arbitrary_size_change()")] SizeChange),2343 SetColumnWidth(#[proptest(strategy = "arbitrary_size_change()")] SizeChange),
2337 SetWindowHeight(#[proptest(strategy = "arbitrary_size_change()")] SizeChange),2344 SetWindowHeight(#[proptest(strategy = "arbitrary_size_change()")] SizeChange),
2345+ ResetWindowHeight,
2338 Communicate(#[proptest(strategy = "1..=5usize")] usize),2346 Communicate(#[proptest(strategy = "1..=5usize")] usize),
2339 MoveWorkspaceToOutput(#[proptest(strategy = "1..=5u8")] u8),2347 MoveWorkspaceToOutput(#[proptest(strategy = "1..=5u8")] u8),
2340 ViewOffsetGestureBegin {2348 ViewOffsetGestureBegin {
@@ -2563,6 +2571,7 @@ mod tests {
2563 Op::MaximizeColumn => layout.toggle_full_width(),2571 Op::MaximizeColumn => layout.toggle_full_width(),
2564 Op::SetColumnWidth(change) => layout.set_column_width(change),2572 Op::SetColumnWidth(change) => layout.set_column_width(change),
2565 Op::SetWindowHeight(change) => layout.set_window_height(change),2573 Op::SetWindowHeight(change) => layout.set_window_height(change),
2574+ Op::ResetWindowHeight => layout.reset_window_height(),
2566 Op::Communicate(id) => {2575 Op::Communicate(id) => {
2567 let mut update = false;2576 let mut update = false;
2568 match &mut layout.monitor_set {2577 match &mut layout.monitor_set {
src/layout/monitor.rsmodified+4 -0
@@ -614,6 +614,10 @@ impl<W: LayoutElement> Monitor<W> {
614 self.active_workspace().set_window_height(change);614 self.active_workspace().set_window_height(change);
615 }615 }
616 616
617+ pub fn reset_window_height(&mut self) {
618+ self.active_workspace().reset_window_height();
619+ }
620+
617 pub fn move_workspace_down(&mut self) {621 pub fn move_workspace_down(&mut self) {
618 let new_idx = min(self.active_workspace_idx + 1, self.workspaces.len() - 1);622 let new_idx = min(self.active_workspace_idx + 1, self.workspaces.len() - 1);
619 if new_idx == self.active_workspace_idx {623 if new_idx == self.active_workspace_idx {
src/layout/workspace.rsmodified+17 -0
@@ -1988,6 +1988,17 @@ impl<W: LayoutElement> Workspace<W> {
1988 cancel_resize_if_this_column(&mut self.interactive_resize, col);1988 cancel_resize_if_this_column(&mut self.interactive_resize, col);
1989 }1989 }
1990 1990
1991+ pub fn reset_window_height(&mut self) {
1992+ if self.columns.is_empty() {
1993+ return;
1994+ }
1995+
1996+ let col = &mut self.columns[self.active_column_idx];
1997+ col.reset_window_height(None, true);
1998+
1999+ cancel_resize_if_this_column(&mut self.interactive_resize, col);
2000+ }
2001+
1991 pub fn set_fullscreen(&mut self, window: &W::Id, is_fullscreen: bool) {2002 pub fn set_fullscreen(&mut self, window: &W::Id, is_fullscreen: bool) {
1992 let (mut col_idx, tile_idx) = self2003 let (mut col_idx, tile_idx) = self
1993 .columns2004 .columns
@@ -3091,6 +3102,12 @@ impl<W: LayoutElement> Column<W> {
3091 self.update_tile_sizes(animate);3102 self.update_tile_sizes(animate);
3092 }3103 }
3093 3104
3105+ fn reset_window_height(&mut self, tile_idx: Option<usize>, animate: bool) {
3106+ let tile_idx = tile_idx.unwrap_or(self.active_tile_idx);
3107+ self.heights[tile_idx] = WindowHeight::Auto;
3108+ self.update_tile_sizes(animate);
3109+ }
3110+
3094 fn set_fullscreen(&mut self, is_fullscreen: bool) {3111 fn set_fullscreen(&mut self, is_fullscreen: bool) {
3095 assert_eq!(self.tiles.len(), 1);3112 assert_eq!(self.tiles.len(), 1);
3096 self.is_fullscreen = is_fullscreen;3113 self.is_fullscreen = is_fullscreen;