diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-02-13 17:46:37 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-02-14 08:32:14 +0400 |
| commit | befdebfa03399eeed7869fb0788d553f7aa4dcdb (patch) | |
| tree | 4b59f51b62611570f7c92227ce8f6836ab06dab9 /src/handlers/compositor.rs | |
| parent | 7960a73e9dda9f82c67e2f7b37766c88f5889c14 (diff) | |
| download | niri-befdebfa03399eeed7869fb0788d553f7aa4dcdb.tar.gz niri-befdebfa03399eeed7869fb0788d553f7aa4dcdb.tar.bz2 niri-befdebfa03399eeed7869fb0788d553f7aa4dcdb.zip | |
Add the beginnings of window rules
Diffstat (limited to 'src/handlers/compositor.rs')
| -rw-r--r-- | src/handlers/compositor.rs | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/src/handlers/compositor.rs b/src/handlers/compositor.rs index de92d17c..2d6a6406 100644 --- a/src/handlers/compositor.rs +++ b/src/handlers/compositor.rs @@ -16,6 +16,7 @@ use smithay::wayland::dmabuf::get_dmabuf; use smithay::wayland::shm::{ShmHandler, ShmState}; use smithay::{delegate_compositor, delegate_shm}; +use super::xdg_shell::{initial_configure_sent, resolve_window_rules}; use crate::niri::{ClientState, State}; use crate::utils::clone2; @@ -113,13 +114,28 @@ impl CompositorHandler for State { .and_then(|parent| self.niri.layout.find_window_and_output(&parent)) .map(|(win, _)| win.clone()); + let (width, output) = { + let config = self.niri.config.borrow(); + let rules = resolve_window_rules(&config.window_rules, window.toplevel()); + let output = rules + .open_on_output + .and_then(|name| self.niri.output_by_name.get(name)) + .cloned(); + (rules.default_width, output) + }; + let win = window.clone(); // Open dialogs immediately to the right of their parent window. let output = if let Some(p) = parent { - self.niri.layout.add_window_right_of(&p, win, None, false) + self.niri.layout.add_window_right_of(&p, win, width, false) + } else if let Some(output) = &output { + self.niri + .layout + .add_window_on_output(output, win, width, false); + Some(output) } else { - self.niri.layout.add_window(win, None, false) + self.niri.layout.add_window(win, width, false) }; if let Some(output) = output.cloned() { @@ -131,7 +147,17 @@ impl CompositorHandler for State { // The toplevel remains unmapped. let window = entry.get().clone(); - self.send_initial_configure_if_needed(&window); + + // Send the initial configure in an idle, in case the client sent some more info + // after the initial commit. + if !initial_configure_sent(window.toplevel()) { + self.niri.event_loop.insert_idle(move |state| { + if !window.toplevel().alive() { + return; + } + state.send_initial_configure_if_needed(&window); + }); + } return; } |
