From c3c0a25a80e6512cee5b9328d757cddf5bd399ee Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Tue, 5 Jul 2022 20:43:30 +0200 Subject: [PATCH] layer_shell: Handle configures better --- src/wayland/handlers/compositor.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/wayland/handlers/compositor.rs b/src/wayland/handlers/compositor.rs index 70b72011..1e432250 100644 --- a/src/wayland/handlers/compositor.rs +++ b/src/wayland/handlers/compositor.rs @@ -4,7 +4,7 @@ use crate::{state::BackendData, utils::prelude::*}; use smithay::{ backend::renderer::utils::on_commit_buffer_handler, delegate_compositor, - desktop::{Kind, LayerSurface, PopupKind, WindowSurfaceType}, + desktop::{Kind, LayerSurface, PopupKind, WindowSurfaceType, layer_map_for_output}, reexports::wayland_server::{protocol::wl_surface::WlSurface, DisplayHandle}, wayland::{ compositor::{with_states, CompositorHandler, CompositorState}, @@ -77,7 +77,7 @@ impl State { } } - fn layer_surface_ensure_inital_configure(&mut self, surface: &LayerSurface) -> bool { + fn layer_surface_ensure_inital_configure(&mut self, surface: &LayerSurface, dh: &DisplayHandle) -> bool { // send the initial configure if relevant let initial_configure_sent = with_states(surface.wl_surface(), |states| { states @@ -89,8 +89,9 @@ impl State { .initial_configure_sent }); if !initial_configure_sent { - // TODO: we should be able to compute the initial dimensions - surface.layer_surface().send_configure(); + // compute initial dimensions by mapping + self.common.shell.map_layer(&surface, dh); + // this will also send a configure } initial_configure_sent } @@ -131,9 +132,7 @@ impl CompositorHandler for State { .find(|(layer_surface, _, _)| layer_surface.wl_surface() == surface) .cloned() { - if self.layer_surface_ensure_inital_configure(&layer_surface) { - self.common.shell.map_layer(&layer_surface, dh); - } else { + if !self.layer_surface_ensure_inital_configure(&layer_surface, dh) { return; } }; @@ -168,6 +167,13 @@ impl CompositorHandler for State { } } + if let Some(output) = self.common.shell.outputs().find(|o| { + let map = layer_map_for_output(o); + map.layer_for_surface(surface, WindowSurfaceType::ALL).is_some() + }) { + layer_map_for_output(output).arrange(dh); + } + on_commit_buffer_handler(surface); self.early_import_surface(dh, surface); self.common.shell.popups.commit(surface);