diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-09-10 09:52:31 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-09-10 09:52:31 +0300 |
| commit | 70fa38fadfe3ad5305ac450d801b425f4262a7d4 (patch) | |
| tree | 5d7434fb8a3470bce9384b05fb0ad084a95f6dd9 /src/handlers/layer_shell.rs | |
| parent | 3514cd2e368fe1883e1ed284e701ea9c18af438d (diff) | |
| download | niri-70fa38fadfe3ad5305ac450d801b425f4262a7d4.tar.gz niri-70fa38fadfe3ad5305ac450d801b425f4262a7d4.tar.bz2 niri-70fa38fadfe3ad5305ac450d801b425f4262a7d4.zip | |
Possibly fix some unsync subsurfaces not redrawing output
Diffstat (limited to 'src/handlers/layer_shell.rs')
| -rw-r--r-- | src/handlers/layer_shell.rs | 79 |
1 files changed, 46 insertions, 33 deletions
diff --git a/src/handlers/layer_shell.rs b/src/handlers/layer_shell.rs index ae4ffe66..f1138ea1 100644 --- a/src/handlers/layer_shell.rs +++ b/src/handlers/layer_shell.rs @@ -3,7 +3,7 @@ use smithay::desktop::{layer_map_for_output, LayerSurface, PopupKind, WindowSurf use smithay::output::Output; use smithay::reexports::wayland_server::protocol::wl_output::WlOutput; use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; -use smithay::wayland::compositor::with_states; +use smithay::wayland::compositor::{get_parent, with_states}; use smithay::wayland::shell::wlr_layer::{ Layer, LayerSurface as WlrLayerSurface, LayerSurfaceData, WlrLayerShellHandler, WlrLayerShellState, @@ -68,52 +68,65 @@ impl WlrLayerShellHandler for State { delegate_layer_shell!(State); impl State { - pub fn layer_shell_handle_commit(&mut self, surface: &WlSurface) { - let Some(output) = self + pub fn layer_shell_handle_commit(&mut self, surface: &WlSurface) -> bool { + let mut root_surface = surface.clone(); + while let Some(parent) = get_parent(&root_surface) { + root_surface = parent; + } + + let output = self .niri .layout .outputs() .find(|o| { let map = layer_map_for_output(o); - map.layer_for_surface(surface, WindowSurfaceType::TOPLEVEL) + map.layer_for_surface(&root_surface, WindowSurfaceType::TOPLEVEL) .is_some() }) - .cloned() - else { - return; + .cloned(); + let Some(output) = output else { + return false; }; - let initial_configure_sent = with_states(surface, |states| { - states - .data_map - .get::<LayerSurfaceData>() - .unwrap() - .lock() - .unwrap() - .initial_configure_sent - }); + if surface == &root_surface { + let initial_configure_sent = with_states(surface, |states| { + states + .data_map + .get::<LayerSurfaceData>() + .unwrap() + .lock() + .unwrap() + .initial_configure_sent + }); - let mut map = layer_map_for_output(&output); + let mut map = layer_map_for_output(&output); - // arrange the layers before sending the initial configure - // to respect any size the client may have sent - map.arrange(); - // send the initial configure if relevant - if !initial_configure_sent { - let layer = map - .layer_for_surface(surface, WindowSurfaceType::TOPLEVEL) - .unwrap(); + // arrange the layers before sending the initial configure + // to respect any size the client may have sent + map.arrange(); + // send the initial configure if relevant + if !initial_configure_sent { + let layer = map + .layer_for_surface(surface, WindowSurfaceType::TOPLEVEL) + .unwrap(); - let scale = output.current_scale(); - let transform = output.current_transform(); - with_states(surface, |data| { - send_scale_transform(surface, data, scale, transform); - }); + let scale = output.current_scale(); + let transform = output.current_transform(); + with_states(surface, |data| { + send_scale_transform(surface, data, scale, transform); + }); + + layer.layer_surface().send_configure(); + } + drop(map); - layer.layer_surface().send_configure(); + // This will call queue_redraw() inside. + self.niri.output_resized(&output); + } else { + // This is an unsync layer-shell subsurface. + self.niri.queue_redraw(&output); } - drop(map); - self.niri.output_resized(&output); + true } } |
