diff options
| -rw-r--r-- | src/handlers/compositor.rs | 5 | ||||
| -rw-r--r-- | src/handlers/xdg_shell.rs | 49 |
2 files changed, 28 insertions, 26 deletions
diff --git a/src/handlers/compositor.rs b/src/handlers/compositor.rs index fba025e8..de92d17c 100644 --- a/src/handlers/compositor.rs +++ b/src/handlers/compositor.rs @@ -16,7 +16,6 @@ use smithay::wayland::dmabuf::get_dmabuf; use smithay::wayland::shm::{ShmHandler, ShmState}; use smithay::{delegate_compositor, delegate_shm}; -use super::xdg_shell; use crate::niri::{ClientState, State}; use crate::utils::clone2; @@ -131,8 +130,8 @@ impl CompositorHandler for State { } // The toplevel remains unmapped. - let window = entry.get(); - xdg_shell::send_initial_configure_if_needed(window.toplevel()); + let window = entry.get().clone(); + self.send_initial_configure_if_needed(&window); return; } diff --git a/src/handlers/xdg_shell.rs b/src/handlers/xdg_shell.rs index 2a1b1d0b..397bdbdc 100644 --- a/src/handlers/xdg_shell.rs +++ b/src/handlers/xdg_shell.rs @@ -35,23 +35,6 @@ impl XdgShellHandler for State { let wl_surface = surface.wl_surface().clone(); let window = Window::new(surface); - // Tell the surface the preferred size and bounds for its likely output. - if let Some(ws) = self.niri.layout.active_workspace() { - ws.configure_new_window(&window); - } - - // If the user prefers no CSD, it's a reasonable assumption that they would prefer to get - // rid of the various client-side rounded corners also by using the tiled state. - let config = self.niri.config.borrow(); - if config.prefer_no_csd { - window.toplevel().with_pending_state(|state| { - state.states.set(xdg_toplevel::State::TiledLeft); - state.states.set(xdg_toplevel::State::TiledRight); - state.states.set(xdg_toplevel::State::TiledTop); - state.states.set(xdg_toplevel::State::TiledBottom); - }); - } - // At the moment of creation, xdg toplevels must have no buffer. let existing = self.niri.unmapped_windows.insert(wl_surface, window); assert!(existing.is_none()); @@ -350,12 +333,6 @@ impl KdeDecorationHandler for State { delegate_kde_decoration!(State); -pub fn send_initial_configure_if_needed(toplevel: &ToplevelSurface) { - if !initial_configure_sent(toplevel) { - toplevel.send_configure(); - } -} - fn initial_configure_sent(toplevel: &ToplevelSurface) -> bool { with_states(toplevel.wl_surface(), |states| { states @@ -369,6 +346,32 @@ fn initial_configure_sent(toplevel: &ToplevelSurface) -> bool { } impl State { + pub fn send_initial_configure_if_needed(&mut self, window: &Window) { + let toplevel = window.toplevel(); + if initial_configure_sent(toplevel) { + return; + } + + // Tell the surface the preferred size and bounds for its likely output. + if let Some(ws) = self.niri.layout.active_workspace() { + ws.configure_new_window(window); + } + + // If the user prefers no CSD, it's a reasonable assumption that they would prefer to get + // rid of the various client-side rounded corners also by using the tiled state. + let config = self.niri.config.borrow(); + if config.prefer_no_csd { + toplevel.with_pending_state(|state| { + state.states.set(xdg_toplevel::State::TiledLeft); + state.states.set(xdg_toplevel::State::TiledRight); + state.states.set(xdg_toplevel::State::TiledTop); + state.states.set(xdg_toplevel::State::TiledBottom); + }); + } + + toplevel.send_configure(); + } + /// Should be called on `WlSurface::commit` pub fn popups_handle_commit(&mut self, surface: &WlSurface) { self.niri.popups.commit(surface); |
