cosmic-comp/src/wayland/handlers/layer_shell.rs

57 lines
1.6 KiB
Rust
Raw Normal View History

// SPDX-License-Identifier: GPL-3.0-only
2022-07-04 16:00:29 +02:00
use crate::utils::prelude::*;
use smithay::{
2022-07-04 16:00:29 +02:00
delegate_layer_shell,
2022-07-07 19:45:55 +02:00
desktop::{LayerSurface, PopupKind},
output::Output,
2022-08-31 13:01:23 +02:00
reexports::wayland_server::protocol::wl_output::WlOutput,
wayland::shell::{
wlr_layer::{
Layer, LayerSurface as WlrLayerSurface, WlrLayerShellHandler, WlrLayerShellState,
},
xdg::PopupSurface,
},
};
impl WlrLayerShellHandler for State {
fn shell_state(&mut self) -> &mut WlrLayerShellState {
&mut self.common.shell.layer_shell_state
}
fn new_layer_surface(
2022-07-04 16:00:29 +02:00
&mut self,
surface: WlrLayerSurface,
wl_output: Option<WlOutput>,
_layer: Layer,
namespace: String,
) {
super::mark_dirty_on_drop(&self.common, surface.wl_surface());
2022-09-28 12:01:29 +02:00
let seat = self.common.last_active_seat().clone();
let output = wl_output
.as_ref()
.and_then(Output::from_resource)
2022-09-28 12:01:29 +02:00
.unwrap_or_else(|| seat.active_output());
self.common.shell.pending_layers.push((
LayerSurface::new(surface, namespace),
output,
seat,
));
}
2022-07-07 19:45:55 +02:00
2022-08-31 13:01:23 +02:00
fn new_popup(&mut self, _parent: WlrLayerSurface, popup: PopupSurface) {
2022-07-07 19:45:55 +02:00
let positioner = popup.with_pending_state(|state| state.positioner);
self.common.shell.unconstrain_popup(&popup, &positioner);
if popup.send_configure().is_ok() {
self.common
.shell
.popups
.track_popup(PopupKind::from(popup))
.unwrap();
}
}
}
delegate_layer_shell!(State);