From 1edc497dde91864ff44921067906d3bf7648065d Mon Sep 17 00:00:00 2001 From: kossLAN Date: Sat, 4 Apr 2026 23:28:39 -0400 Subject: [PATCH] zwlr_layer_shell: send_close() if not outputs are available so clients can properly clean up surface --- src/ifs/zwlr_layer_shell_v1.rs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/ifs/zwlr_layer_shell_v1.rs b/src/ifs/zwlr_layer_shell_v1.rs index 2d060860..6394fcbe 100644 --- a/src/ifs/zwlr_layer_shell_v1.rs +++ b/src/ifs/zwlr_layer_shell_v1.rs @@ -2,7 +2,10 @@ use { crate::{ client::{CAP_LAYER_SHELL, Client, ClientCaps, ClientError}, globals::{Global, GlobalName}, - ifs::wl_surface::zwlr_layer_surface_v1::{ZwlrLayerSurfaceV1, ZwlrLayerSurfaceV1Error}, + ifs::{ + wl_output::OutputGlobalOpt, + wl_surface::zwlr_layer_surface_v1::{ZwlrLayerSurfaceV1, ZwlrLayerSurfaceV1Error}, + }, leaks::Tracker, object::{Object, Version}, wire::{ZwlrLayerShellV1Id, zwlr_layer_shell_v1::*}, @@ -55,26 +58,27 @@ impl ZwlrLayerShellV1RequestHandler for ZwlrLayerShellV1 { fn get_layer_surface(&self, req: GetLayerSurface, slf: &Rc) -> Result<(), Self::Error> { let surface = self.client.lookup(req.surface)?; - let output = 'get_output: { - if req.output.is_some() { - self.client.lookup(req.output)?.global.clone() - } else { + let output = if req.output.is_some() { + Some(self.client.lookup(req.output)?.global.clone()) + } else { + 'get_output: { for seat in self.client.state.seat_queue.rev_iter() { let output = seat.get_fallback_output(); if !output.is_dummy { - break 'get_output output.global.opt.clone(); + break 'get_output Some(output.global.opt.clone()); } } let outputs = self.client.state.root.outputs.lock(); if let Some(output) = outputs.values().next() { - break 'get_output output.global.opt.clone(); + break 'get_output Some(output.global.opt.clone()); } - return Err(ZwlrLayerShellV1Error::NoOutputs); + None } }; if req.layer > OVERLAY { return Err(ZwlrLayerShellV1Error::UnknownLayer(req.layer)); } + let output = output.unwrap_or_else(|| Rc::new(OutputGlobalOpt::default())); let surface = Rc::new(ZwlrLayerSurfaceV1::new( req.id, slf, @@ -86,6 +90,9 @@ impl ZwlrLayerShellV1RequestHandler for ZwlrLayerShellV1 { track!(self.client, surface); self.client.add_client_obj(&surface)?; surface.install()?; + if output.node().is_none() { + surface.send_closed(); + } Ok(()) } @@ -128,8 +135,6 @@ pub enum ZwlrLayerShellV1Error { ClientError(Box), #[error("Unknown layer {0}")] UnknownLayer(u32), - #[error("There are no outputs")] - NoOutputs, #[error(transparent)] ZwlrLayerSurfaceV1Error(Box), }