mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-21 02:01:55 +07:00
Add a reset-window-height action
This commit is contained in:
@@ -898,6 +898,7 @@ pub enum Action {
|
||||
MoveColumnToMonitorDown,
|
||||
MoveColumnToMonitorUp,
|
||||
SetWindowHeight(#[knuffel(argument, str)] SizeChange),
|
||||
ResetWindowHeight,
|
||||
SwitchPresetColumnWidth,
|
||||
MaximizeColumn,
|
||||
SetColumnWidth(#[knuffel(argument, str)] SizeChange),
|
||||
@@ -969,6 +970,7 @@ impl From<niri_ipc::Action> for Action {
|
||||
niri_ipc::Action::MoveColumnToMonitorDown => Self::MoveColumnToMonitorDown,
|
||||
niri_ipc::Action::MoveColumnToMonitorUp => Self::MoveColumnToMonitorUp,
|
||||
niri_ipc::Action::SetWindowHeight { change } => Self::SetWindowHeight(change),
|
||||
niri_ipc::Action::ResetWindowHeight => Self::ResetWindowHeight,
|
||||
niri_ipc::Action::SwitchPresetColumnWidth => Self::SwitchPresetColumnWidth,
|
||||
niri_ipc::Action::MaximizeColumn => Self::MaximizeColumn,
|
||||
niri_ipc::Action::SetColumnWidth { change } => Self::SetColumnWidth(change),
|
||||
|
||||
@@ -208,6 +208,8 @@ pub enum Action {
|
||||
#[cfg_attr(feature = "clap", arg())]
|
||||
change: SizeChange,
|
||||
},
|
||||
/// Reset the height of the focused window back to automatic.
|
||||
ResetWindowHeight,
|
||||
/// Switch between preset column widths.
|
||||
SwitchPresetColumnWidth,
|
||||
/// Toggle the maximized state of the focused column.
|
||||
|
||||
@@ -418,6 +418,7 @@ binds {
|
||||
// Mod+BracketRight { consume-or-expel-window-right; }
|
||||
|
||||
Mod+R { switch-preset-column-width; }
|
||||
Mod+Shift+R { reset-window-height; }
|
||||
Mod+F { maximize-column; }
|
||||
Mod+Shift+F { fullscreen-window; }
|
||||
Mod+C { center-column; }
|
||||
|
||||
@@ -780,6 +780,9 @@ impl State {
|
||||
Action::SetWindowHeight(change) => {
|
||||
self.niri.layout.set_window_height(change);
|
||||
}
|
||||
Action::ResetWindowHeight => {
|
||||
self.niri.layout.reset_window_height();
|
||||
}
|
||||
Action::ShowHotkeyOverlay => {
|
||||
if self.niri.hotkey_overlay.show() {
|
||||
self.niri.queue_redraw_all();
|
||||
|
||||
@@ -1477,6 +1477,13 @@ impl<W: LayoutElement> Layout<W> {
|
||||
monitor.set_window_height(change);
|
||||
}
|
||||
|
||||
pub fn reset_window_height(&mut self) {
|
||||
let Some(monitor) = self.active_monitor() else {
|
||||
return;
|
||||
};
|
||||
monitor.reset_window_height();
|
||||
}
|
||||
|
||||
pub fn focus_output(&mut self, output: &Output) {
|
||||
if let MonitorSet::Normal {
|
||||
monitors,
|
||||
@@ -2335,6 +2342,7 @@ mod tests {
|
||||
MaximizeColumn,
|
||||
SetColumnWidth(#[proptest(strategy = "arbitrary_size_change()")] SizeChange),
|
||||
SetWindowHeight(#[proptest(strategy = "arbitrary_size_change()")] SizeChange),
|
||||
ResetWindowHeight,
|
||||
Communicate(#[proptest(strategy = "1..=5usize")] usize),
|
||||
MoveWorkspaceToOutput(#[proptest(strategy = "1..=5u8")] u8),
|
||||
ViewOffsetGestureBegin {
|
||||
@@ -2563,6 +2571,7 @@ mod tests {
|
||||
Op::MaximizeColumn => layout.toggle_full_width(),
|
||||
Op::SetColumnWidth(change) => layout.set_column_width(change),
|
||||
Op::SetWindowHeight(change) => layout.set_window_height(change),
|
||||
Op::ResetWindowHeight => layout.reset_window_height(),
|
||||
Op::Communicate(id) => {
|
||||
let mut update = false;
|
||||
match &mut layout.monitor_set {
|
||||
|
||||
@@ -614,6 +614,10 @@ impl<W: LayoutElement> Monitor<W> {
|
||||
self.active_workspace().set_window_height(change);
|
||||
}
|
||||
|
||||
pub fn reset_window_height(&mut self) {
|
||||
self.active_workspace().reset_window_height();
|
||||
}
|
||||
|
||||
pub fn move_workspace_down(&mut self) {
|
||||
let new_idx = min(self.active_workspace_idx + 1, self.workspaces.len() - 1);
|
||||
if new_idx == self.active_workspace_idx {
|
||||
|
||||
@@ -1988,6 +1988,17 @@ impl<W: LayoutElement> Workspace<W> {
|
||||
cancel_resize_if_this_column(&mut self.interactive_resize, col);
|
||||
}
|
||||
|
||||
pub fn reset_window_height(&mut self) {
|
||||
if self.columns.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
let col = &mut self.columns[self.active_column_idx];
|
||||
col.reset_window_height(None, true);
|
||||
|
||||
cancel_resize_if_this_column(&mut self.interactive_resize, col);
|
||||
}
|
||||
|
||||
pub fn set_fullscreen(&mut self, window: &W::Id, is_fullscreen: bool) {
|
||||
let (mut col_idx, tile_idx) = self
|
||||
.columns
|
||||
@@ -3091,6 +3102,12 @@ impl<W: LayoutElement> Column<W> {
|
||||
self.update_tile_sizes(animate);
|
||||
}
|
||||
|
||||
fn reset_window_height(&mut self, tile_idx: Option<usize>, animate: bool) {
|
||||
let tile_idx = tile_idx.unwrap_or(self.active_tile_idx);
|
||||
self.heights[tile_idx] = WindowHeight::Auto;
|
||||
self.update_tile_sizes(animate);
|
||||
}
|
||||
|
||||
fn set_fullscreen(&mut self, is_fullscreen: bool) {
|
||||
assert_eq!(self.tiles.len(), 1);
|
||||
self.is_fullscreen = is_fullscreen;
|
||||
|
||||
Reference in New Issue
Block a user