use smithay::{ desktop::{layer_map_for_output, LayerSurface}, output::Output, utils::SERIAL_COUNTER, wayland::shell::wlr_layer::{KeyboardInteractivity, Layer, WlrLayerShellHandler}, }; use wayland_server::protocol::wl_output::WlOutput; use crate::State; impl WlrLayerShellHandler for State { fn shell_state(&mut self) -> &mut smithay::wayland::shell::wlr_layer::WlrLayerShellState { &mut self.wlr_layer_shell_state } fn new_layer_surface( &mut self, surface: smithay::wayland::shell::wlr_layer::LayerSurface, output: Option, layer: smithay::wayland::shell::wlr_layer::Layer, namespace: String, ) { let output = output .as_ref() .and_then(Output::from_resource) .unwrap_or_else(|| self.space.outputs().next().unwrap().clone()); let mut map = layer_map_for_output(&output); let layer_surface = LayerSurface::new(surface.clone(), namespace); map.map_layer(&layer_surface).unwrap(); surface.send_configure(); let state = layer_surface.cached_state(); if layer_surface.can_receive_keyboard_focus() { let keyboard = self.seat.get_keyboard().unwrap(); keyboard.set_focus( self, Some(surface.wl_surface().clone()), SERIAL_COUNTER.next_serial(), ); } } fn layer_destroyed(&mut self, surface: smithay::wayland::shell::wlr_layer::LayerSurface) { if let Some((mut map, layer)) = self.space.outputs().find_map(|o| { let map = layer_map_for_output(o); let layer = map .layers() .find(|&layer| layer.layer_surface() == &surface) .cloned(); layer.map(|layer| (map, layer)) }) { map.unmap_layer(&layer); } } }