aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-09-10 09:52:31 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2024-09-10 09:52:31 +0300
commit70fa38fadfe3ad5305ac450d801b425f4262a7d4 (patch)
tree5d7434fb8a3470bce9384b05fb0ad084a95f6dd9 /src
parent3514cd2e368fe1883e1ed284e701ea9c18af438d (diff)
downloadniri-70fa38fadfe3ad5305ac450d801b425f4262a7d4.tar.gz
niri-70fa38fadfe3ad5305ac450d801b425f4262a7d4.tar.bz2
niri-70fa38fadfe3ad5305ac450d801b425f4262a7d4.zip
Possibly fix some unsync subsurfaces not redrawing output
Diffstat (limited to 'src')
-rw-r--r--src/handlers/compositor.rs17
-rw-r--r--src/handlers/layer_shell.rs79
2 files changed, 58 insertions, 38 deletions
diff --git a/src/handlers/compositor.rs b/src/handlers/compositor.rs
index 2244da19..57be5ad3 100644
--- a/src/handlers/compositor.rs
+++ b/src/handlers/compositor.rs
@@ -284,22 +284,29 @@ impl CompositorHandler for State {
if let Some(output) = self.output_for_popup(&popup) {
self.niri.queue_redraw(&output.clone());
}
+ return;
}
// This might be a layer-shell surface.
- self.layer_shell_handle_commit(surface);
+ if self.layer_shell_handle_commit(surface) {
+ return;
+ }
// This might be a cursor surface.
- if matches!(&self.niri.cursor_manager.cursor_image(), CursorImageStatus::Surface(s) if s == surface)
- {
+ if matches!(
+ &self.niri.cursor_manager.cursor_image(),
+ CursorImageStatus::Surface(s) if s == &root_surface
+ ) {
// FIXME: granular redraws for cursors.
self.niri.queue_redraw_all();
+ return;
}
// This might be a DnD icon surface.
- if self.niri.dnd_icon.as_ref() == Some(surface) {
+ if self.niri.dnd_icon.as_ref() == Some(&root_surface) {
// FIXME: granular redraws for cursors.
self.niri.queue_redraw_all();
+ return;
}
// This might be a lock surface.
@@ -308,7 +315,7 @@ impl CompositorHandler for State {
if let Some(lock_surface) = &state.lock_surface {
if lock_surface.wl_surface() == &root_surface {
self.niri.queue_redraw(&output.clone());
- break;
+ return;
}
}
}
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
}
}