diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-12-29 22:44:19 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-12-30 20:12:37 +0300 |
| commit | 6c897d520165bfcaf3833b6e3d4bdbd836d26063 (patch) | |
| tree | 29fa7697f53facfe8bca4d12cbff1cca7e9065e7 /src/layout/workspace.rs | |
| parent | 6cb5135f3477e63ed1738e19ba95a07ce52093ae (diff) | |
| download | niri-6c897d520165bfcaf3833b6e3d4bdbd836d26063.tar.gz niri-6c897d520165bfcaf3833b6e3d4bdbd836d26063.tar.bz2 niri-6c897d520165bfcaf3833b6e3d4bdbd836d26063.zip | |
Add center-window by-id action
Diffstat (limited to 'src/layout/workspace.rs')
| -rw-r--r-- | src/layout/workspace.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs index 991e7e42..0e67f3b3 100644 --- a/src/layout/workspace.rs +++ b/src/layout/workspace.rs @@ -971,12 +971,22 @@ impl<W: LayoutElement> Workspace<W> { pub fn center_column(&mut self) { if self.floating_is_active.get() { - self.floating.center_window(); + self.floating.center_window(None); } else { self.scrolling.center_column(); } } + pub fn center_window(&mut self, id: Option<&W::Id>) { + if id.map_or(self.floating_is_active.get(), |id| { + self.floating.has_window(id) + }) { + self.floating.center_window(id); + } else { + self.scrolling.center_window(id); + } + } + pub fn toggle_width(&mut self) { if self.floating_is_active.get() { self.floating.toggle_window_width(None); |
