use bitflags::bitflags;
use thiserror::Error;
use wayland_protocols_wlr::layer_shell::v1::client::{zwlr_layer_shell_v1, zwlr_layer_surface_v1};
use crate::Pixels;
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
pub enum Layer {
Background,
Bottom,
Top,
#[default]
Overlay,
}
impl From<Layer> for zwlr_layer_shell_v1::Layer {
fn from(layer: Layer) -> Self {
match layer {
Layer::Background => Self::Background,
Layer::Bottom => Self::Bottom,
Layer::Top => Self::Top,
Layer::Overlay => Self::Overlay,
}
}
}
bitflags! {
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
pub struct Anchor: u32 {
const TOP = 1;
const BOTTOM = 2;
const LEFT = 4;
const RIGHT = 8;
}
}
impl From<Anchor> for zwlr_layer_surface_v1::Anchor {
fn from(anchor: Anchor) -> Self {
Self::from_bits_truncate(anchor.bits())
}
}
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
pub enum KeyboardInteractivity {
None,
Exclusive,
#[default]
OnDemand,
}
impl From<KeyboardInteractivity> for zwlr_layer_surface_v1::KeyboardInteractivity {
fn from(value: KeyboardInteractivity) -> Self {
match value {
KeyboardInteractivity::None => Self::None,
KeyboardInteractivity::Exclusive => Self::Exclusive,
KeyboardInteractivity::OnDemand => Self::OnDemand,
}
}
}
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct LayerShellOptions {
pub namespace: String,
pub layer: Layer,
pub anchor: Anchor,
pub exclusive_zone: Option<Pixels>,
pub exclusive_edge: Option<Anchor>,
pub margin: Option<(Pixels, Pixels, Pixels, Pixels)>,
pub keyboard_interactivity: KeyboardInteractivity,
}
#[derive(Debug, Error)]
#[error("Compositor doesn't support zwlr_layer_shell_v1")]
pub struct LayerShellNotSupportedError;