forge
Explore
Log in

Don't you dare go Hollow

Possibly fix some unsync subsurfaces not redrawing output

Browse files at this commit

70fa38fadfe3ad5305ac450d801b425f4262a7d4Ivan MolodetskikhParent: 3514cd2
src/handlers/compositor.rsmodified+12 -5
@@ -284,22 +284,29 @@ impl CompositorHandler for State {
284284 if let Some(output) = self.output_for_popup(&popup) {
285285 self.niri.queue_redraw(&output.clone());
286286 }
287+ return;
287288 }
288289
289290 // 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+ }
291294
292295 // 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+ ) {
295300 // FIXME: granular redraws for cursors.
296301 self.niri.queue_redraw_all();
302+ return;
297303 }
298304
299305 // 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) {
301307 // FIXME: granular redraws for cursors.
302308 self.niri.queue_redraw_all();
309+ return;
303310 }
304311
305312 // This might be a lock surface.
@@ -308,7 +315,7 @@ impl CompositorHandler for State {
308315 if let Some(lock_surface) = &state.lock_surface {
309316 if lock_surface.wl_surface() == &root_surface {
310317 self.niri.queue_redraw(&output.clone());
311- break;
318+ return;
312319 }
313320 }
314321 }
src/handlers/layer_shell.rsmodified+46 -33
@@ -3,7 +3,7 @@ use smithay::desktop::{layer_map_for_output, LayerSurface, PopupKind, WindowSurf
33 use smithay::output::Output;
44 use smithay::reexports::wayland_server::protocol::wl_output::WlOutput;
55 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};
77 use smithay::wayland::shell::wlr_layer::{
88 Layer, LayerSurface as WlrLayerSurface, LayerSurfaceData, WlrLayerShellHandler,
99 WlrLayerShellState,
@@ -68,52 +68,65 @@ impl WlrLayerShellHandler for State {
6868 delegate_layer_shell!(State);
6969
7070 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
7378 .niri
7479 .layout
7580 .outputs()
7681 .find(|o| {
7782 let map = layer_map_for_output(o);
78- map.layer_for_surface(surface, WindowSurfaceType::TOPLEVEL)
83+ map.layer_for_surface(&root_surface, WindowSurfaceType::TOPLEVEL)
7984 .is_some()
8085 })
81- .cloned()
82- else {
83- return;
86+ .cloned();
87+ let Some(output) = output else {
88+ return false;
8489 };
8590
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+ });
95101
96- let mut map = layer_map_for_output(&output);
102+ let mut map = layer_map_for_output(&output);
97103
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();
106112
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);
112122
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);
114128 }
115- drop(map);
116129
117- self.niri.output_resized(&output);
130+ true
118131 }
119132 }