diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2025-02-05 09:33:44 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2025-02-05 09:36:58 +0300 |
| commit | ddcac86d1d568463ef828bf370d8989bbf12c9fd (patch) | |
| tree | 40a6b35be3a4c1a66b0f0dd81264d5b8768b8926 /src/handlers | |
| parent | 734e3a6d3cea277e56baf4531695e989b2d1bdda (diff) | |
| download | niri-ddcac86d1d568463ef828bf370d8989bbf12c9fd.tar.gz niri-ddcac86d1d568463ef828bf370d8989bbf12c9fd.tar.bz2 niri-ddcac86d1d568463ef828bf370d8989bbf12c9fd.zip | |
mapped: Add needs_configure flag
Allows to de-duplicate configures from requests that require one.
Diffstat (limited to 'src/handlers')
| -rw-r--r-- | src/handlers/xdg_shell.rs | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/src/handlers/xdg_shell.rs b/src/handlers/xdg_shell.rs index 5cac5d29..840dd599 100644 --- a/src/handlers/xdg_shell.rs +++ b/src/handlers/xdg_shell.rs @@ -433,8 +433,12 @@ impl XdgShellHandler for State { if let Some((mapped, current_output)) = self .niri .layout - .find_window_and_output(toplevel.wl_surface()) + .find_window_and_output_mut(toplevel.wl_surface()) { + // A configure is required in response to this event regardless if there are pending + // changes. + mapped.set_needs_configure(); + let window = mapped.window.clone(); if let Some(requested_output) = requested_output { @@ -446,10 +450,6 @@ impl XdgShellHandler for State { } self.niri.layout.set_fullscreen(&window, true); - - // A configure is required in response to this event regardless if there are pending - // changes. - toplevel.send_configure(); } else if let Some(unmapped) = self.niri.unmapped_windows.get_mut(toplevel.wl_surface()) { match &mut unmapped.state { InitialConfigureState::NotConfigured { wants_fullscreen } => { @@ -513,17 +513,14 @@ impl XdgShellHandler for State { if let Some((mapped, _)) = self .niri .layout - .find_window_and_output(toplevel.wl_surface()) + .find_window_and_output_mut(toplevel.wl_surface()) { - let window = mapped.window.clone(); - self.niri.layout.set_fullscreen(&window, false); - // A configure is required in response to this event regardless if there are pending // changes. - // - // FIXME: when unfullscreening to floating, this will send an extra configure with - // scrolling layout bounds. We should probably avoid it. - toplevel.send_configure(); + mapped.set_needs_configure(); + + let window = mapped.window.clone(); + self.niri.layout.set_fullscreen(&window, false); } else if let Some(unmapped) = self.niri.unmapped_windows.get_mut(toplevel.wl_surface()) { match &mut unmapped.state { InitialConfigureState::NotConfigured { wants_fullscreen } => { @@ -744,7 +741,13 @@ impl XdgDecorationHandler for State { // A configure is required in response to this event. However, if an initial configure // wasn't sent, then we will send this as part of the initial configure later. if toplevel.is_initial_configure_sent() { - toplevel.send_configure(); + // If this is a mapped window, flag it as needs configure to avoid duplicate configures. + let surface = toplevel.wl_surface(); + if let Some((mapped, _)) = self.niri.layout.find_window_and_output_mut(surface) { + mapped.set_needs_configure(); + } else { + toplevel.send_configure(); + } } } @@ -757,7 +760,13 @@ impl XdgDecorationHandler for State { // A configure is required in response to this event. However, if an initial configure // wasn't sent, then we will send this as part of the initial configure later. if toplevel.is_initial_configure_sent() { - toplevel.send_configure(); + // If this is a mapped window, flag it as needs configure to avoid duplicate configures. + let surface = toplevel.wl_surface(); + if let Some((mapped, _)) = self.niri.layout.find_window_and_output_mut(surface) { + mapped.set_needs_configure(); + } else { + toplevel.send_configure(); + } } } } |
