1
0
Fork 0
forked from wry/wry

zwlr_layer_shell: send_close() if not outputs are available so clients can properly clean up surface

This commit is contained in:
kossLAN 2026-04-04 23:28:39 -04:00
parent 15757b248f
commit 1edc497dde
No known key found for this signature in database

View file

@ -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<Self>) -> 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<ClientError>),
#[error("Unknown layer {0}")]
UnknownLayer(u32),
#[error("There are no outputs")]
NoOutputs,
#[error(transparent)]
ZwlrLayerSurfaceV1Error(Box<ZwlrLayerSurfaceV1Error>),
}