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::{ crate::{
client::{CAP_LAYER_SHELL, Client, ClientCaps, ClientError}, client::{CAP_LAYER_SHELL, Client, ClientCaps, ClientError},
globals::{Global, GlobalName}, 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, leaks::Tracker,
object::{Object, Version}, object::{Object, Version},
wire::{ZwlrLayerShellV1Id, zwlr_layer_shell_v1::*}, 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> { fn get_layer_surface(&self, req: GetLayerSurface, slf: &Rc<Self>) -> Result<(), Self::Error> {
let surface = self.client.lookup(req.surface)?; let surface = self.client.lookup(req.surface)?;
let output = 'get_output: { let output = if req.output.is_some() {
if req.output.is_some() { Some(self.client.lookup(req.output)?.global.clone())
self.client.lookup(req.output)?.global.clone() } else {
} else { 'get_output: {
for seat in self.client.state.seat_queue.rev_iter() { for seat in self.client.state.seat_queue.rev_iter() {
let output = seat.get_fallback_output(); let output = seat.get_fallback_output();
if !output.is_dummy { 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(); let outputs = self.client.state.root.outputs.lock();
if let Some(output) = outputs.values().next() { 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 { if req.layer > OVERLAY {
return Err(ZwlrLayerShellV1Error::UnknownLayer(req.layer)); return Err(ZwlrLayerShellV1Error::UnknownLayer(req.layer));
} }
let output = output.unwrap_or_else(|| Rc::new(OutputGlobalOpt::default()));
let surface = Rc::new(ZwlrLayerSurfaceV1::new( let surface = Rc::new(ZwlrLayerSurfaceV1::new(
req.id, req.id,
slf, slf,
@ -86,6 +90,9 @@ impl ZwlrLayerShellV1RequestHandler for ZwlrLayerShellV1 {
track!(self.client, surface); track!(self.client, surface);
self.client.add_client_obj(&surface)?; self.client.add_client_obj(&surface)?;
surface.install()?; surface.install()?;
if output.node().is_none() {
surface.send_closed();
}
Ok(()) Ok(())
} }
@ -128,8 +135,6 @@ pub enum ZwlrLayerShellV1Error {
ClientError(Box<ClientError>), ClientError(Box<ClientError>),
#[error("Unknown layer {0}")] #[error("Unknown layer {0}")]
UnknownLayer(u32), UnknownLayer(u32),
#[error("There are no outputs")]
NoOutputs,
#[error(transparent)] #[error(transparent)]
ZwlrLayerSurfaceV1Error(Box<ZwlrLayerSurfaceV1Error>), ZwlrLayerSurfaceV1Error(Box<ZwlrLayerSurfaceV1Error>),
} }