diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2023-10-05 09:25:07 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2023-10-05 09:25:07 +0400 |
| commit | 6fcdb4192275a8112fd45a91eb3e4b70c5ac684f (patch) | |
| tree | bcd857c8e96952f81c5a049eeaec571c23b6febf /src/handlers | |
| parent | 3ac16074063db2cccdb10d9e5b832aaec0492bb4 (diff) | |
| download | niri-6fcdb4192275a8112fd45a91eb3e4b70c5ac684f.tar.gz niri-6fcdb4192275a8112fd45a91eb3e4b70c5ac684f.tar.bz2 niri-6fcdb4192275a8112fd45a91eb3e4b70c5ac684f.zip | |
Refactor layout for configurability, add preset-column-widths option
layout.rs finally gets a struct actually named Layout.
Diffstat (limited to 'src/handlers')
| -rw-r--r-- | src/handlers/compositor.rs | 14 | ||||
| -rw-r--r-- | src/handlers/layer_shell.rs | 6 | ||||
| -rw-r--r-- | src/handlers/mod.rs | 2 | ||||
| -rw-r--r-- | src/handlers/xdg_shell.rs | 25 |
4 files changed, 23 insertions, 24 deletions
diff --git a/src/handlers/compositor.rs b/src/handlers/compositor.rs index b77ef829..d8d93d9c 100644 --- a/src/handlers/compositor.rs +++ b/src/handlers/compositor.rs @@ -87,7 +87,7 @@ impl CompositorHandler for State { let window = entry.remove(); window.on_commit(); - if let Some(output) = self.niri.monitor_set.add_window(window, true).cloned() { + if let Some(output) = self.niri.layout.add_window(window, true).cloned() { self.niri.queue_redraw(output); } return; @@ -100,7 +100,7 @@ impl CompositorHandler for State { } // This is a commit of a previously-mapped root or a non-toplevel root. - if let Some((window, output)) = self.niri.monitor_set.find_window_and_output(surface) { + if let Some((window, output)) = self.niri.layout.find_window_and_output(surface) { // This is a commit of a previously-mapped toplevel. window.on_commit(); @@ -110,14 +110,14 @@ impl CompositorHandler for State { if !is_mapped { // The toplevel got unmapped. - self.niri.monitor_set.remove_window(&window); + self.niri.layout.remove_window(&window); self.niri.unmapped_windows.insert(surface.clone(), window); self.niri.queue_redraw(output); return; } // The toplevel remains mapped. - self.niri.monitor_set.update_window(&window); + self.niri.layout.update_window(&window); self.niri.queue_redraw(output); return; @@ -127,10 +127,10 @@ impl CompositorHandler for State { } // This is a commit of a non-root or a non-toplevel root. - let root_window_output = self.niri.monitor_set.find_window_and_output(&root_surface); + let root_window_output = self.niri.layout.find_window_and_output(&root_surface); if let Some((window, output)) = root_window_output { window.on_commit(); - self.niri.monitor_set.update_window(&window); + self.niri.layout.update_window(&window); self.niri.queue_redraw(output); return; } @@ -139,7 +139,7 @@ impl CompositorHandler for State { self.popups_handle_commit(surface); if let Some(popup) = self.niri.popups.find_popup(surface) { if let Ok(root) = find_popup_root_surface(&popup) { - let root_window_output = self.niri.monitor_set.find_window_and_output(&root); + let root_window_output = self.niri.layout.find_window_and_output(&root); if let Some((_window, output)) = root_window_output { self.niri.queue_redraw(output); } diff --git a/src/handlers/layer_shell.rs b/src/handlers/layer_shell.rs index c426d321..6e0ef318 100644 --- a/src/handlers/layer_shell.rs +++ b/src/handlers/layer_shell.rs @@ -26,7 +26,7 @@ impl WlrLayerShellHandler for State { let output = wl_output .as_ref() .and_then(Output::from_resource) - .or_else(|| self.niri.monitor_set.active_output().cloned()) + .or_else(|| self.niri.layout.active_output().cloned()) .unwrap(); let mut map = layer_map_for_output(&output); map.map_layer(&LayerSurface::new(surface, namespace)) @@ -35,7 +35,7 @@ impl WlrLayerShellHandler for State { fn layer_destroyed(&mut self, surface: WlrLayerSurface) { let output = if let Some((output, mut map, layer)) = - self.niri.monitor_set.outputs().find_map(|o| { + self.niri.layout.outputs().find_map(|o| { let map = layer_map_for_output(o); let layer = map .layers() @@ -59,7 +59,7 @@ impl State { pub fn layer_shell_handle_commit(&mut self, surface: &WlSurface) { let Some(output) = self .niri - .monitor_set + .layout .outputs() .find(|o| { let map = layer_map_for_output(o); diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs index 546d22e0..87d4af4d 100644 --- a/src/handlers/mod.rs +++ b/src/handlers/mod.rs @@ -65,7 +65,7 @@ impl InputMethodHandler for State { } fn parent_geometry(&self, parent: &WlSurface) -> Rectangle<i32, Logical> { self.niri - .monitor_set + .layout .find_window_and_output(parent) .map(|(window, _)| window.geometry()) .unwrap_or_default() diff --git a/src/handlers/xdg_shell.rs b/src/handlers/xdg_shell.rs index e8cee1b5..c5af09a9 100644 --- a/src/handlers/xdg_shell.rs +++ b/src/handlers/xdg_shell.rs @@ -1,4 +1,4 @@ -use smithay::desktop::{find_popup_root_surface, layer_map_for_output, PopupKind, Window}; +use smithay::desktop::{find_popup_root_surface, PopupKind, Window}; use smithay::output::Output; use smithay::reexports::wayland_protocols::xdg::decoration::zv1::server::zxdg_toplevel_decoration_v1; use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel::{self, ResizeEdge}; @@ -15,7 +15,6 @@ use smithay::wayland::shell::xdg::{ }; use smithay::{delegate_kde_decoration, delegate_xdg_decoration, delegate_xdg_shell}; -use crate::layout::configure_new_window; use crate::niri::State; impl XdgShellHandler for State { @@ -28,9 +27,9 @@ impl XdgShellHandler for State { let window = Window::new(surface); // Tell the surface the preferred size and bounds for its likely output. - let output = self.niri.monitor_set.active_output().unwrap(); - let working_area = layer_map_for_output(output).non_exclusive_zone(); - configure_new_window(working_area, &window); + if let Some(ws) = self.niri.layout.active_workspace() { + ws.configure_new_window(&window); + } // At the moment of creation, xdg toplevels must have no buffer. let existing = self.niri.unmapped_windows.insert(wl_surface, window); @@ -106,18 +105,18 @@ impl XdgShellHandler for State { // independently from its buffer size if let Some((window, current_output)) = self .niri - .monitor_set + .layout .find_window_and_output(surface.wl_surface()) { if let Some(requested_output) = wl_output.as_ref().and_then(Output::from_resource) { if requested_output != current_output { self.niri - .monitor_set + .layout .move_window_to_output(window.clone(), &requested_output); } } - self.niri.monitor_set.set_fullscreen(&window, true); + self.niri.layout.set_fullscreen(&window, true); } } @@ -129,10 +128,10 @@ impl XdgShellHandler for State { fn unfullscreen_request(&mut self, surface: ToplevelSurface) { if let Some((window, _)) = self .niri - .monitor_set + .layout .find_window_and_output(surface.wl_surface()) { - self.niri.monitor_set.set_fullscreen(&window, false); + self.niri.layout.set_fullscreen(&window, false); } } @@ -149,16 +148,16 @@ impl XdgShellHandler for State { let (window, output) = self .niri - .monitor_set + .layout .find_window_and_output(surface.wl_surface()) .unwrap(); - self.niri.monitor_set.remove_window(&window); + self.niri.layout.remove_window(&window); self.niri.queue_redraw(output); } fn popup_destroyed(&mut self, surface: PopupSurface) { if let Ok(root) = find_popup_root_surface(&surface.into()) { - let root_window_output = self.niri.monitor_set.find_window_and_output(&root); + let root_window_output = self.niri.layout.find_window_and_output(&root); if let Some((_window, output)) = root_window_output { self.niri.queue_redraw(output); } |
