Add Mod+F to maximize
Browse files at this commitc05326d1b6dba32bc681b24ca178f471ae9e8044Parent: 2a163bb3 changed files +37 -1
- README.md +1 -0
- src/input.rs +6 -1
- src/layout.rs +30 -0
README.mdmodified+1 -0
| @@ -66,6 +66,7 @@ The general system is: if a hotkey switches somewhere, then adding <kbd>Ctrl</kb | |||
| 66 | | <kbd>Mod</kbd><kbd>,</kbd> | Consume the window to the right into the focused column | | 66 | | <kbd>Mod</kbd><kbd>,</kbd> | Consume the window to the right into the focused column | |
| 67 | | <kbd>Mod</kbd><kbd>.</kbd> | Expel the focused window into its own column | | 67 | | <kbd>Mod</kbd><kbd>.</kbd> | Expel the focused window into its own column | |
| 68 | | <kbd>Mod</kbd><kbd>R</kbd> | Toggle between preset window widths | | 68 | | <kbd>Mod</kbd><kbd>R</kbd> | Toggle between preset window widths | |
| 69 | +| <kbd>Mod</kbd><kbd>F</kbd> | Maximize window | | ||
| 69 | | <kbd>Mod</kbd><kbd>Shift</kbd><kbd>E</kbd> | Exit niri | | 70 | | <kbd>Mod</kbd><kbd>Shift</kbd><kbd>E</kbd> | Exit niri | |
| 70 | 71 | ||
| 71 | [PaperWM]: https://github.com/paperwm/PaperWM | 72 | [PaperWM]: https://github.com/paperwm/PaperWM |
src/input.rsmodified+6 -1
| @@ -33,6 +33,7 @@ enum Action { | |||
| 33 | MoveToWorkspaceDown, | 33 | MoveToWorkspaceDown, |
| 34 | MoveToWorkspaceUp, | 34 | MoveToWorkspaceUp, |
| 35 | ToggleWidth, | 35 | ToggleWidth, |
| 36 | + ToggleFullWidth, | ||
| 36 | } | 37 | } |
| 37 | 38 | ||
| 38 | pub enum CompositorMod { | 39 | pub enum CompositorMod { |
| @@ -74,7 +75,7 @@ fn action(comp_mod: CompositorMod, keysym: KeysymHandle, mods: ModifiersState) - | |||
| 74 | KEY_E => Action::Quit, | 75 | KEY_E => Action::Quit, |
| 75 | KEY_t => Action::SpawnTerminal, | 76 | KEY_t => Action::SpawnTerminal, |
| 76 | KEY_q => Action::CloseWindow, | 77 | KEY_q => Action::CloseWindow, |
| 77 | - KEY_f => Action::ToggleFullscreen, | 78 | + KEY_F => Action::ToggleFullscreen, |
| 78 | KEY_h | KEY_Left if mods.ctrl => Action::MoveLeft, | 79 | KEY_h | KEY_Left if mods.ctrl => Action::MoveLeft, |
| 79 | KEY_l | KEY_Right if mods.ctrl => Action::MoveRight, | 80 | KEY_l | KEY_Right if mods.ctrl => Action::MoveRight, |
| 80 | KEY_j | KEY_Down if mods.ctrl => Action::MoveDown, | 81 | KEY_j | KEY_Down if mods.ctrl => Action::MoveDown, |
| @@ -90,6 +91,7 @@ fn action(comp_mod: CompositorMod, keysym: KeysymHandle, mods: ModifiersState) - | |||
| 90 | KEY_comma => Action::ConsumeIntoColumn, | 91 | KEY_comma => Action::ConsumeIntoColumn, |
| 91 | KEY_period => Action::ExpelFromColumn, | 92 | KEY_period => Action::ExpelFromColumn, |
| 92 | KEY_r => Action::ToggleWidth, | 93 | KEY_r => Action::ToggleWidth, |
| 94 | + KEY_f => Action::ToggleFullWidth, | ||
| 93 | _ => Action::None, | 95 | _ => Action::None, |
| 94 | } | 96 | } |
| 95 | } | 97 | } |
| @@ -230,6 +232,9 @@ impl Niri { | |||
| 230 | Action::ToggleWidth => { | 232 | Action::ToggleWidth => { |
| 231 | self.monitor_set.toggle_width(); | 233 | self.monitor_set.toggle_width(); |
| 232 | } | 234 | } |
| 235 | + Action::ToggleFullWidth => { | ||
| 236 | + self.monitor_set.toggle_full_width(); | ||
| 237 | + } | ||
| 233 | } | 238 | } |
| 234 | } | 239 | } |
| 235 | } | 240 | } |
src/layout.rsmodified+30 -0
| @@ -759,6 +759,13 @@ impl<W: LayoutElement> MonitorSet<W> { | |||
| 759 | }; | 759 | }; |
| 760 | monitor.toggle_width(); | 760 | monitor.toggle_width(); |
| 761 | } | 761 | } |
| 762 | + | ||
| 763 | + pub fn toggle_full_width(&mut self) { | ||
| 764 | + let Some(monitor) = self.active_monitor() else { | ||
| 765 | + return; | ||
| 766 | + }; | ||
| 767 | + monitor.toggle_full_width(); | ||
| 768 | + } | ||
| 762 | } | 769 | } |
| 763 | 770 | ||
| 764 | impl MonitorSet<Window> { | 771 | impl MonitorSet<Window> { |
| @@ -976,6 +983,10 @@ impl<W: LayoutElement> Monitor<W> { | |||
| 976 | fn toggle_width(&mut self) { | 983 | fn toggle_width(&mut self) { |
| 977 | self.active_workspace().toggle_width(); | 984 | self.active_workspace().toggle_width(); |
| 978 | } | 985 | } |
| 986 | + | ||
| 987 | + fn toggle_full_width(&mut self) { | ||
| 988 | + self.active_workspace().toggle_full_width(); | ||
| 989 | + } | ||
| 979 | } | 990 | } |
| 980 | 991 | ||
| 981 | impl Monitor<Window> { | 992 | impl Monitor<Window> { |
| @@ -1392,6 +1403,14 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1392 | 1403 | ||
| 1393 | self.columns[self.active_column_idx].toggle_width(self.view_size); | 1404 | self.columns[self.active_column_idx].toggle_width(self.view_size); |
| 1394 | } | 1405 | } |
| 1406 | + | ||
| 1407 | + fn toggle_full_width(&mut self) { | ||
| 1408 | + if self.columns.is_empty() { | ||
| 1409 | + return; | ||
| 1410 | + } | ||
| 1411 | + | ||
| 1412 | + self.columns[self.active_column_idx].toggle_full_width(self.view_size); | ||
| 1413 | + } | ||
| 1395 | } | 1414 | } |
| 1396 | 1415 | ||
| 1397 | impl Workspace<Window> { | 1416 | impl Workspace<Window> { |
| @@ -1555,6 +1574,17 @@ impl<W: LayoutElement> Column<W> { | |||
| 1555 | let width = ColumnWidth::PresetProportion(idx); | 1574 | let width = ColumnWidth::PresetProportion(idx); |
| 1556 | self.set_width(view_size, width); | 1575 | self.set_width(view_size, width); |
| 1557 | } | 1576 | } |
| 1577 | + | ||
| 1578 | + fn toggle_full_width(&mut self, view_size: Size<i32, Logical>) { | ||
| 1579 | + let width = match self.width { | ||
| 1580 | + ColumnWidth::Proportion(1.) => { | ||
| 1581 | + // FIXME: would be good to restore to previous width here. | ||
| 1582 | + ColumnWidth::default() | ||
| 1583 | + } | ||
| 1584 | + _ => ColumnWidth::Proportion(1.), | ||
| 1585 | + }; | ||
| 1586 | + self.set_width(view_size, width); | ||
| 1587 | + } | ||
| 1558 | } | 1588 | } |
| 1559 | 1589 | ||
| 1560 | pub fn output_size(output: &Output) -> Size<i32, Logical> { | 1590 | pub fn output_size(output: &Output) -> Size<i32, Logical> { |