layer_shell: Handle configures better

This commit is contained in:
Victoria Brekenfeld 2022-07-05 20:43:30 +02:00
parent 39de286d51
commit c3c0a25a80

View file

@ -4,7 +4,7 @@ use crate::{state::BackendData, utils::prelude::*};
use smithay::{ use smithay::{
backend::renderer::utils::on_commit_buffer_handler, backend::renderer::utils::on_commit_buffer_handler,
delegate_compositor, delegate_compositor,
desktop::{Kind, LayerSurface, PopupKind, WindowSurfaceType}, desktop::{Kind, LayerSurface, PopupKind, WindowSurfaceType, layer_map_for_output},
reexports::wayland_server::{protocol::wl_surface::WlSurface, DisplayHandle}, reexports::wayland_server::{protocol::wl_surface::WlSurface, DisplayHandle},
wayland::{ wayland::{
compositor::{with_states, CompositorHandler, CompositorState}, 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 // send the initial configure if relevant
let initial_configure_sent = with_states(surface.wl_surface(), |states| { let initial_configure_sent = with_states(surface.wl_surface(), |states| {
states states
@ -89,8 +89,9 @@ impl State {
.initial_configure_sent .initial_configure_sent
}); });
if !initial_configure_sent { if !initial_configure_sent {
// TODO: we should be able to compute the initial dimensions // compute initial dimensions by mapping
surface.layer_surface().send_configure(); self.common.shell.map_layer(&surface, dh);
// this will also send a configure
} }
initial_configure_sent initial_configure_sent
} }
@ -131,9 +132,7 @@ impl CompositorHandler for State {
.find(|(layer_surface, _, _)| layer_surface.wl_surface() == surface) .find(|(layer_surface, _, _)| layer_surface.wl_surface() == surface)
.cloned() .cloned()
{ {
if self.layer_surface_ensure_inital_configure(&layer_surface) { if !self.layer_surface_ensure_inital_configure(&layer_surface, dh) {
self.common.shell.map_layer(&layer_surface, dh);
} else {
return; 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); on_commit_buffer_handler(surface);
self.early_import_surface(dh, surface); self.early_import_surface(dh, surface);
self.common.shell.popups.commit(surface); self.common.shell.popups.commit(surface);