Fix fullscreen handling before initial configure
Browse files at this commit2b5eeb61620363a325a5c76c4a5d25e45f2a6054Parent: 85be5f72 changed files +32 -12
- src/handlers/xdg_shell.rs +24 -7
- src/layout/workspace.rs +8 -5
src/handlers/xdg_shell.rsmodified+24 -7
| @@ -257,9 +257,11 @@ impl XdgShellHandler for State { | |||
| 257 | fn maximize_request(&mut self, surface: ToplevelSurface) { | 257 | fn maximize_request(&mut self, surface: ToplevelSurface) { |
| 258 | // FIXME | 258 | // FIXME |
| 259 | 259 | ||
| 260 | - // The protocol demands us to always reply with a configure, | 260 | + // A configure is required in response to this event. However, if an initial configure |
| 261 | - // regardless of we fulfilled the request or not | 261 | + // wasn't sent, then we will send this as part of the initial configure later. |
| 262 | - surface.send_configure(); | 262 | + if initial_configure_sent(&surface) { |
| 263 | + surface.send_configure(); | ||
| 264 | + } | ||
| 263 | } | 265 | } |
| 264 | 266 | ||
| 265 | fn unmaximize_request(&mut self, _surface: ToplevelSurface) { | 267 | fn unmaximize_request(&mut self, _surface: ToplevelSurface) { |
| @@ -293,7 +295,20 @@ impl XdgShellHandler for State { | |||
| 293 | 295 | ||
| 294 | self.niri.layout.set_fullscreen(&window, true); | 296 | self.niri.layout.set_fullscreen(&window, true); |
| 295 | } else if let Some(window) = self.niri.unmapped_windows.get(surface.wl_surface()) { | 297 | } 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 { | ||
| 297 | window.toplevel().with_pending_state(|state| { | 312 | window.toplevel().with_pending_state(|state| { |
| 298 | state.size = Some(ws.view_size()); | 313 | state.size = Some(ws.view_size()); |
| 299 | state.states.set(xdg_toplevel::State::Fullscreen); | 314 | state.states.set(xdg_toplevel::State::Fullscreen); |
| @@ -302,9 +317,11 @@ impl XdgShellHandler for State { | |||
| 302 | } | 317 | } |
| 303 | } | 318 | } |
| 304 | 319 | ||
| 305 | - // The protocol demands us to always reply with a configure, | 320 | + // A configure is required in response to this event. However, if an initial configure |
| 306 | - // regardless of we fulfilled the request or not | 321 | + // wasn't sent, then we will send this as part of the initial configure later. |
| 307 | - surface.send_configure(); | 322 | + if initial_configure_sent(&surface) { |
| 323 | + surface.send_configure(); | ||
| 324 | + } | ||
| 308 | } | 325 | } |
| 309 | 326 | ||
| 310 | fn unfullscreen_request(&mut self, surface: ToplevelSurface) { | 327 | fn unfullscreen_request(&mut self, surface: ToplevelSurface) { |
src/layout/workspace.rsmodified+8 -5
| @@ -8,6 +8,7 @@ use niri_ipc::SizeChange; | |||
| 8 | use smithay::desktop::space::SpaceElement; | 8 | use smithay::desktop::space::SpaceElement; |
| 9 | use smithay::desktop::{layer_map_for_output, Window}; | 9 | use smithay::desktop::{layer_map_for_output, Window}; |
| 10 | use smithay::output::Output; | 10 | use smithay::output::Output; |
| 11 | +use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel; | ||
| 11 | use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; | 12 | use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; |
| 12 | use smithay::utils::{Logical, Point, Rectangle, Scale, Size}; | 13 | use smithay::utils::{Logical, Point, Rectangle, Scale, Size}; |
| 13 | 14 | ||
| @@ -354,16 +355,18 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 354 | window: &Window, | 355 | window: &Window, |
| 355 | default_width: Option<Option<ColumnWidth>>, | 356 | default_width: Option<Option<ColumnWidth>>, |
| 356 | ) { | 357 | ) { |
| 357 | - let size = self.new_window_size(default_width); | ||
| 358 | - let bounds = self.toplevel_bounds(); | ||
| 359 | - | ||
| 360 | if let Some(output) = self.output.as_ref() { | 358 | if let Some(output) = self.output.as_ref() { |
| 361 | set_preferred_scale_transform(window, output); | 359 | set_preferred_scale_transform(window, output); |
| 362 | } | 360 | } |
| 363 | 361 | ||
| 364 | window.toplevel().with_pending_state(|state| { | 362 | window.toplevel().with_pending_state(|state| { |
| 365 | - state.size = Some(size); | 363 | + if state.states.contains(xdg_toplevel::State::Fullscreen) { |
| 366 | - state.bounds = Some(bounds); | 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()); | ||
| 367 | }); | 370 | }); |
| 368 | } | 371 | } |
| 369 | 372 | ||