forge
Explore
Log in

Don't you dare go Hollow

Do initial configuration right before sending initial configure

Browse files at this commit

749ee5d627d99a5e42967bb308e365ed2017bfd5Ivan MolodetskikhParent: 952dd48
Let the toplevel fill in some details about itself.
src/handlers/compositor.rsmodified+2 -3
@@ -16,7 +16,6 @@ use smithay::wayland::dmabuf::get_dmabuf;
16 use smithay::wayland::shm::{ShmHandler, ShmState};16 use smithay::wayland::shm::{ShmHandler, ShmState};
17 use smithay::{delegate_compositor, delegate_shm};17 use smithay::{delegate_compositor, delegate_shm};
18 18
19-use super::xdg_shell;
20 use crate::niri::{ClientState, State};19 use crate::niri::{ClientState, State};
21 use crate::utils::clone2;20 use crate::utils::clone2;
22 21
@@ -131,8 +130,8 @@ impl CompositorHandler for State {
131 }130 }
132 131
133 // The toplevel remains unmapped.132 // The toplevel remains unmapped.
134- let window = entry.get();133+ let window = entry.get().clone();
135- xdg_shell::send_initial_configure_if_needed(window.toplevel());134+ self.send_initial_configure_if_needed(&window);
136 return;135 return;
137 }136 }
138 137
src/handlers/xdg_shell.rsmodified+26 -23
@@ -35,23 +35,6 @@ impl XdgShellHandler for State {
35 let wl_surface = surface.wl_surface().clone();35 let wl_surface = surface.wl_surface().clone();
36 let window = Window::new(surface);36 let window = Window::new(surface);
37 37
38- // Tell the surface the preferred size and bounds for its likely output.
39- if let Some(ws) = self.niri.layout.active_workspace() {
40- ws.configure_new_window(&window);
41- }
42-
43- // If the user prefers no CSD, it's a reasonable assumption that they would prefer to get
44- // rid of the various client-side rounded corners also by using the tiled state.
45- let config = self.niri.config.borrow();
46- if config.prefer_no_csd {
47- window.toplevel().with_pending_state(|state| {
48- state.states.set(xdg_toplevel::State::TiledLeft);
49- state.states.set(xdg_toplevel::State::TiledRight);
50- state.states.set(xdg_toplevel::State::TiledTop);
51- state.states.set(xdg_toplevel::State::TiledBottom);
52- });
53- }
54-
55 // At the moment of creation, xdg toplevels must have no buffer.38 // At the moment of creation, xdg toplevels must have no buffer.
56 let existing = self.niri.unmapped_windows.insert(wl_surface, window);39 let existing = self.niri.unmapped_windows.insert(wl_surface, window);
57 assert!(existing.is_none());40 assert!(existing.is_none());
@@ -350,12 +333,6 @@ impl KdeDecorationHandler for State {
350 333
351 delegate_kde_decoration!(State);334 delegate_kde_decoration!(State);
352 335
353-pub fn send_initial_configure_if_needed(toplevel: &ToplevelSurface) {
354- if !initial_configure_sent(toplevel) {
355- toplevel.send_configure();
356- }
357-}
358-
359 fn initial_configure_sent(toplevel: &ToplevelSurface) -> bool {336 fn initial_configure_sent(toplevel: &ToplevelSurface) -> bool {
360 with_states(toplevel.wl_surface(), |states| {337 with_states(toplevel.wl_surface(), |states| {
361 states338 states
@@ -369,6 +346,32 @@ fn initial_configure_sent(toplevel: &ToplevelSurface) -> bool {
369 }346 }
370 347
371 impl State {348 impl State {
349+ pub fn send_initial_configure_if_needed(&mut self, window: &Window) {
350+ let toplevel = window.toplevel();
351+ if initial_configure_sent(toplevel) {
352+ return;
353+ }
354+
355+ // Tell the surface the preferred size and bounds for its likely output.
356+ if let Some(ws) = self.niri.layout.active_workspace() {
357+ ws.configure_new_window(window);
358+ }
359+
360+ // If the user prefers no CSD, it's a reasonable assumption that they would prefer to get
361+ // rid of the various client-side rounded corners also by using the tiled state.
362+ let config = self.niri.config.borrow();
363+ if config.prefer_no_csd {
364+ toplevel.with_pending_state(|state| {
365+ state.states.set(xdg_toplevel::State::TiledLeft);
366+ state.states.set(xdg_toplevel::State::TiledRight);
367+ state.states.set(xdg_toplevel::State::TiledTop);
368+ state.states.set(xdg_toplevel::State::TiledBottom);
369+ });
370+ }
371+
372+ toplevel.send_configure();
373+ }
374+
372 /// Should be called on `WlSurface::commit`375 /// Should be called on `WlSurface::commit`
373 pub fn popups_handle_commit(&mut self, surface: &WlSurface) {376 pub fn popups_handle_commit(&mut self, surface: &WlSurface) {
374 self.niri.popups.commit(surface);377 self.niri.popups.commit(surface);