30 lines
951 B
Rust
30 lines
951 B
Rust
|
|
use smithay::{
|
||
|
|
desktop::{layer_map_for_output, LayerSurface},
|
||
|
|
output::Output,
|
||
|
|
wayland::shell::wlr_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<WlOutput>,
|
||
|
|
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);
|
||
|
|
map.map_layer(&LayerSurface::new(surface, namespace))
|
||
|
|
.unwrap();
|
||
|
|
}
|
||
|
|
}
|