Possibly fix some unsync subsurfaces not redrawing output
Browse files at this commit70fa38fadfe3ad5305ac450d801b425f4262a7d4Parent: 3514cd22 changed files +58 -38
- src/handlers/compositor.rs +12 -5
- src/handlers/layer_shell.rs +46 -33
src/handlers/compositor.rsmodified+12 -5
| @@ -284,22 +284,29 @@ impl CompositorHandler for State { | ||
| 284 | 284 | if let Some(output) = self.output_for_popup(&popup) { |
| 285 | 285 | self.niri.queue_redraw(&output.clone()); |
| 286 | 286 | } |
| 287 | + return; | |
| 287 | 288 | } |
| 288 | 289 | |
| 289 | 290 | // This might be a layer-shell surface. |
| 290 | - self.layer_shell_handle_commit(surface); | |
| 291 | + if self.layer_shell_handle_commit(surface) { | |
| 292 | + return; | |
| 293 | + } | |
| 291 | 294 | |
| 292 | 295 | // This might be a cursor surface. |
| 293 | - if matches!(&self.niri.cursor_manager.cursor_image(), CursorImageStatus::Surface(s) if s == surface) | |
| 294 | - { | |
| 296 | + if matches!( | |
| 297 | + &self.niri.cursor_manager.cursor_image(), | |
| 298 | + CursorImageStatus::Surface(s) if s == &root_surface | |
| 299 | + ) { | |
| 295 | 300 | // FIXME: granular redraws for cursors. |
| 296 | 301 | self.niri.queue_redraw_all(); |
| 302 | + return; | |
| 297 | 303 | } |
| 298 | 304 | |
| 299 | 305 | // This might be a DnD icon surface. |
| 300 | - if self.niri.dnd_icon.as_ref() == Some(surface) { | |
| 306 | + if self.niri.dnd_icon.as_ref() == Some(&root_surface) { | |
| 301 | 307 | // FIXME: granular redraws for cursors. |
| 302 | 308 | self.niri.queue_redraw_all(); |
| 309 | + return; | |
| 303 | 310 | } |
| 304 | 311 | |
| 305 | 312 | // This might be a lock surface. |
| @@ -308,7 +315,7 @@ impl CompositorHandler for State { | ||
| 308 | 315 | if let Some(lock_surface) = &state.lock_surface { |
| 309 | 316 | if lock_surface.wl_surface() == &root_surface { |
| 310 | 317 | self.niri.queue_redraw(&output.clone()); |
| 311 | - break; | |
| 318 | + return; | |
| 312 | 319 | } |
| 313 | 320 | } |
| 314 | 321 | } |
src/handlers/layer_shell.rsmodified+46 -33
| @@ -3,7 +3,7 @@ use smithay::desktop::{layer_map_for_output, LayerSurface, PopupKind, WindowSurf | ||
| 3 | 3 | use smithay::output::Output; |
| 4 | 4 | use smithay::reexports::wayland_server::protocol::wl_output::WlOutput; |
| 5 | 5 | use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; |
| 6 | -use smithay::wayland::compositor::with_states; | |
| 6 | +use smithay::wayland::compositor::{get_parent, with_states}; | |
| 7 | 7 | use smithay::wayland::shell::wlr_layer::{ |
| 8 | 8 | Layer, LayerSurface as WlrLayerSurface, LayerSurfaceData, WlrLayerShellHandler, |
| 9 | 9 | WlrLayerShellState, |
| @@ -68,52 +68,65 @@ impl WlrLayerShellHandler for State { | ||
| 68 | 68 | delegate_layer_shell!(State); |
| 69 | 69 | |
| 70 | 70 | impl State { |
| 71 | - pub fn layer_shell_handle_commit(&mut self, surface: &WlSurface) { | |
| 72 | - let Some(output) = self | |
| 71 | + pub fn layer_shell_handle_commit(&mut self, surface: &WlSurface) -> bool { | |
| 72 | + let mut root_surface = surface.clone(); | |
| 73 | + while let Some(parent) = get_parent(&root_surface) { | |
| 74 | + root_surface = parent; | |
| 75 | + } | |
| 76 | + | |
| 77 | + let output = self | |
| 73 | 78 | .niri |
| 74 | 79 | .layout |
| 75 | 80 | .outputs() |
| 76 | 81 | .find(|o| { |
| 77 | 82 | let map = layer_map_for_output(o); |
| 78 | - map.layer_for_surface(surface, WindowSurfaceType::TOPLEVEL) | |
| 83 | + map.layer_for_surface(&root_surface, WindowSurfaceType::TOPLEVEL) | |
| 79 | 84 | .is_some() |
| 80 | 85 | }) |
| 81 | - .cloned() | |
| 82 | - else { | |
| 83 | - return; | |
| 86 | + .cloned(); | |
| 87 | + let Some(output) = output else { | |
| 88 | + return false; | |
| 84 | 89 | }; |
| 85 | 90 | |
| 86 | - let initial_configure_sent = with_states(surface, |states| { | |
| 87 | - states | |
| 88 | - .data_map | |
| 89 | - .get::<LayerSurfaceData>() | |
| 90 | - .unwrap() | |
| 91 | - .lock() | |
| 92 | - .unwrap() | |
| 93 | - .initial_configure_sent | |
| 94 | - }); | |
| 91 | + if surface == &root_surface { | |
| 92 | + let initial_configure_sent = with_states(surface, |states| { | |
| 93 | + states | |
| 94 | + .data_map | |
| 95 | + .get::<LayerSurfaceData>() | |
| 96 | + .unwrap() | |
| 97 | + .lock() | |
| 98 | + .unwrap() | |
| 99 | + .initial_configure_sent | |
| 100 | + }); | |
| 95 | 101 | |
| 96 | - let mut map = layer_map_for_output(&output); | |
| 102 | + let mut map = layer_map_for_output(&output); | |
| 97 | 103 | |
| 98 | - // arrange the layers before sending the initial configure | |
| 99 | - // to respect any size the client may have sent | |
| 100 | - map.arrange(); | |
| 101 | - // send the initial configure if relevant | |
| 102 | - if !initial_configure_sent { | |
| 103 | - let layer = map | |
| 104 | - .layer_for_surface(surface, WindowSurfaceType::TOPLEVEL) | |
| 105 | - .unwrap(); | |
| 104 | + // arrange the layers before sending the initial configure | |
| 105 | + // to respect any size the client may have sent | |
| 106 | + map.arrange(); | |
| 107 | + // send the initial configure if relevant | |
| 108 | + if !initial_configure_sent { | |
| 109 | + let layer = map | |
| 110 | + .layer_for_surface(surface, WindowSurfaceType::TOPLEVEL) | |
| 111 | + .unwrap(); | |
| 106 | 112 | |
| 107 | - let scale = output.current_scale(); | |
| 108 | - let transform = output.current_transform(); | |
| 109 | - with_states(surface, |data| { | |
| 110 | - send_scale_transform(surface, data, scale, transform); | |
| 111 | - }); | |
| 113 | + let scale = output.current_scale(); | |
| 114 | + let transform = output.current_transform(); | |
| 115 | + with_states(surface, |data| { | |
| 116 | + send_scale_transform(surface, data, scale, transform); | |
| 117 | + }); | |
| 118 | + | |
| 119 | + layer.layer_surface().send_configure(); | |
| 120 | + } | |
| 121 | + drop(map); | |
| 112 | 122 | |
| 113 | - layer.layer_surface().send_configure(); | |
| 123 | + // This will call queue_redraw() inside. | |
| 124 | + self.niri.output_resized(&output); | |
| 125 | + } else { | |
| 126 | + // This is an unsync layer-shell subsurface. | |
| 127 | + self.niri.queue_redraw(&output); | |
| 114 | 128 | } |
| 115 | - drop(map); | |
| 116 | 129 | |
| 117 | - self.niri.output_resized(&output); | |
| 130 | + true | |
| 118 | 131 | } |
| 119 | 132 | } |