forge
Explore
Log in

Don't you dare go Hollow

Fix fullscreen handling before initial configure

Browse files at this commit

2b5eeb61620363a325a5c76c4a5d25e45f2a6054Ivan MolodetskikhParent: 85be5f7
src/handlers/xdg_shell.rsmodified+24 -7
@@ -257,9 +257,11 @@ impl XdgShellHandler for State {
257257 fn maximize_request(&mut self, surface: ToplevelSurface) {
258258 // FIXME
259259
260- // The protocol demands us to always reply with a configure,
261- // regardless of we fulfilled the request or not
262- surface.send_configure();
260+ // A configure is required in response to this event. However, if an initial configure
261+ // wasn't sent, then we will send this as part of the initial configure later.
262+ if initial_configure_sent(&surface) {
263+ surface.send_configure();
264+ }
263265 }
264266
265267 fn unmaximize_request(&mut self, _surface: ToplevelSurface) {
@@ -293,7 +295,20 @@ impl XdgShellHandler for State {
293295
294296 self.niri.layout.set_fullscreen(&window, true);
295297 } else if let Some(window) = self.niri.unmapped_windows.get(surface.wl_surface()) {
296- if let Some(ws) = self.niri.layout.active_workspace() {
298+ let config = self.niri.config.borrow();
299+ let rules = resolve_window_rules(&config.window_rules, window.toplevel());
300+
301+ // FIXME: take requested output into account (will need to thread this through to
302+ // send_initial_configure_if_needed and commit handler).
303+ let output = rules
304+ .open_on_output
305+ .and_then(|name| self.niri.output_by_name.get(name));
306+ let mon = output.map(|o| self.niri.layout.monitor_for_output(o).unwrap());
307+ let ws = mon
308+ .map(|mon| mon.active_workspace_ref())
309+ .or_else(|| self.niri.layout.active_workspace());
310+
311+ if let Some(ws) = ws {
297312 window.toplevel().with_pending_state(|state| {
298313 state.size = Some(ws.view_size());
299314 state.states.set(xdg_toplevel::State::Fullscreen);
@@ -302,9 +317,11 @@ impl XdgShellHandler for State {
302317 }
303318 }
304319
305- // The protocol demands us to always reply with a configure,
306- // regardless of we fulfilled the request or not
307- surface.send_configure();
320+ // A configure is required in response to this event. However, if an initial configure
321+ // wasn't sent, then we will send this as part of the initial configure later.
322+ if initial_configure_sent(&surface) {
323+ surface.send_configure();
324+ }
308325 }
309326
310327 fn unfullscreen_request(&mut self, surface: ToplevelSurface) {
src/layout/workspace.rsmodified+8 -5
@@ -8,6 +8,7 @@ use niri_ipc::SizeChange;
88 use smithay::desktop::space::SpaceElement;
99 use smithay::desktop::{layer_map_for_output, Window};
1010 use smithay::output::Output;
11+use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel;
1112 use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;
1213 use smithay::utils::{Logical, Point, Rectangle, Scale, Size};
1314
@@ -354,16 +355,18 @@ impl<W: LayoutElement> Workspace<W> {
354355 window: &Window,
355356 default_width: Option<Option<ColumnWidth>>,
356357 ) {
357- let size = self.new_window_size(default_width);
358- let bounds = self.toplevel_bounds();
359-
360358 if let Some(output) = self.output.as_ref() {
361359 set_preferred_scale_transform(window, output);
362360 }
363361
364362 window.toplevel().with_pending_state(|state| {
365- state.size = Some(size);
366- state.bounds = Some(bounds);
363+ if state.states.contains(xdg_toplevel::State::Fullscreen) {
364+ state.size = Some(self.view_size);
365+ } else {
366+ state.size = Some(self.new_window_size(default_width));
367+ }
368+
369+ state.bounds = Some(self.toplevel_bounds());
367370 });
368371 }
369372