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 | if let Some(output) = self.output_for_popup(&popup) { | 284 | if let Some(output) = self.output_for_popup(&popup) { |
| 285 | self.niri.queue_redraw(&output.clone()); | 285 | self.niri.queue_redraw(&output.clone()); |
| 286 | } | 286 | } |
| 287 | + return; | ||
| 287 | } | 288 | } |
| 288 | 289 | ||
| 289 | // This might be a layer-shell surface. | 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 | // This might be a cursor surface. | 295 | // This might be a cursor surface. |
| 293 | - if matches!(&self.niri.cursor_manager.cursor_image(), CursorImageStatus::Surface(s) if s == surface) | 296 | + if matches!( |
| 294 | - { | 297 | + &self.niri.cursor_manager.cursor_image(), |
| 298 | + CursorImageStatus::Surface(s) if s == &root_surface | ||
| 299 | + ) { | ||
| 295 | // FIXME: granular redraws for cursors. | 300 | // FIXME: granular redraws for cursors. |
| 296 | self.niri.queue_redraw_all(); | 301 | self.niri.queue_redraw_all(); |
| 302 | + return; | ||
| 297 | } | 303 | } |
| 298 | 304 | ||
| 299 | // This might be a DnD icon surface. | 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 | // FIXME: granular redraws for cursors. | 307 | // FIXME: granular redraws for cursors. |
| 302 | self.niri.queue_redraw_all(); | 308 | self.niri.queue_redraw_all(); |
| 309 | + return; | ||
| 303 | } | 310 | } |
| 304 | 311 | ||
| 305 | // This might be a lock surface. | 312 | // This might be a lock surface. |
| @@ -308,7 +315,7 @@ impl CompositorHandler for State { | |||
| 308 | if let Some(lock_surface) = &state.lock_surface { | 315 | if let Some(lock_surface) = &state.lock_surface { |
| 309 | if lock_surface.wl_surface() == &root_surface { | 316 | if lock_surface.wl_surface() == &root_surface { |
| 310 | self.niri.queue_redraw(&output.clone()); | 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 | use smithay::output::Output; | 3 | use smithay::output::Output; |
| 4 | use smithay::reexports::wayland_server::protocol::wl_output::WlOutput; | 4 | use smithay::reexports::wayland_server::protocol::wl_output::WlOutput; |
| 5 | use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; | 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 | use smithay::wayland::shell::wlr_layer::{ | 7 | use smithay::wayland::shell::wlr_layer::{ |
| 8 | Layer, LayerSurface as WlrLayerSurface, LayerSurfaceData, WlrLayerShellHandler, | 8 | Layer, LayerSurface as WlrLayerSurface, LayerSurfaceData, WlrLayerShellHandler, |
| 9 | WlrLayerShellState, | 9 | WlrLayerShellState, |
| @@ -68,52 +68,65 @@ impl WlrLayerShellHandler for State { | |||
| 68 | delegate_layer_shell!(State); | 68 | delegate_layer_shell!(State); |
| 69 | 69 | ||
| 70 | impl State { | 70 | impl State { |
| 71 | - pub fn layer_shell_handle_commit(&mut self, surface: &WlSurface) { | 71 | + pub fn layer_shell_handle_commit(&mut self, surface: &WlSurface) -> bool { |
| 72 | - let Some(output) = self | 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 | .niri | 78 | .niri |
| 74 | .layout | 79 | .layout |
| 75 | .outputs() | 80 | .outputs() |
| 76 | .find(|o| { | 81 | .find(|o| { |
| 77 | let map = layer_map_for_output(o); | 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 | .is_some() | 84 | .is_some() |
| 80 | }) | 85 | }) |
| 81 | - .cloned() | 86 | + .cloned(); |
| 82 | - else { | 87 | + let Some(output) = output else { |
| 83 | - return; | 88 | + return false; |
| 84 | }; | 89 | }; |
| 85 | 90 | ||
| 86 | - let initial_configure_sent = with_states(surface, |states| { | 91 | + if surface == &root_surface { |
| 87 | - states | 92 | + let initial_configure_sent = with_states(surface, |states| { |
| 88 | - .data_map | 93 | + states |
| 89 | - .get::<LayerSurfaceData>() | 94 | + .data_map |
| 90 | - .unwrap() | 95 | + .get::<LayerSurfaceData>() |
| 91 | - .lock() | 96 | + .unwrap() |
| 92 | - .unwrap() | 97 | + .lock() |
| 93 | - .initial_configure_sent | 98 | + .unwrap() |
| 94 | - }); | 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 | 104 | + // arrange the layers before sending the initial configure |
| 99 | - // to respect any size the client may have sent | 105 | + // to respect any size the client may have sent |
| 100 | - map.arrange(); | 106 | + map.arrange(); |
| 101 | - // send the initial configure if relevant | 107 | + // send the initial configure if relevant |
| 102 | - if !initial_configure_sent { | 108 | + if !initial_configure_sent { |
| 103 | - let layer = map | 109 | + let layer = map |
| 104 | - .layer_for_surface(surface, WindowSurfaceType::TOPLEVEL) | 110 | + .layer_for_surface(surface, WindowSurfaceType::TOPLEVEL) |
| 105 | - .unwrap(); | 111 | + .unwrap(); |
| 106 | 112 | ||
| 107 | - let scale = output.current_scale(); | 113 | + let scale = output.current_scale(); |
| 108 | - let transform = output.current_transform(); | 114 | + let transform = output.current_transform(); |
| 109 | - with_states(surface, |data| { | 115 | + with_states(surface, |data| { |
| 110 | - send_scale_transform(surface, data, scale, transform); | 116 | + send_scale_transform(surface, data, scale, transform); |
| 111 | - }); | 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 | } |