use bitflags::bitflags;
use sctk::shell::wlr_layer;
use crate::dpi::LogicalSize;
#[non_exhaustive]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub enum Layer {
Background,
Bottom,
#[default]
Top,
Overlay,
}
bitflags! {
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub struct Anchor: u32 {
const TOP = 1;
const BOTTOM = 2;
const LEFT = 4;
const RIGHT = 8;
}
}
#[non_exhaustive]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub enum KeyboardInteractivity {
#[default]
None,
OnDemand,
Exclusive,
}
#[derive(Clone, Debug)]
pub struct LayerSurfaceAttributes {
pub layer: Layer,
pub namespace: String,
pub anchor: Anchor,
pub size: LogicalSize<u32>,
pub exclusive_zone: i32,
pub margin: (i32, i32, i32, i32),
pub keyboard_interactivity: KeyboardInteractivity,
}
impl Default for LayerSurfaceAttributes {
fn default() -> Self {
Self {
layer: Layer::default(),
namespace: String::from("winit"),
anchor: Anchor::empty(),
size: LogicalSize::new(0, 0),
exclusive_zone: 0,
margin: (0, 0, 0, 0),
keyboard_interactivity: KeyboardInteractivity::default(),
}
}
}
impl From<Layer> for wlr_layer::Layer {
fn from(layer: Layer) -> Self {
match layer {
Layer::Background => Self::Background,
Layer::Bottom => Self::Bottom,
Layer::Top => Self::Top,
Layer::Overlay => Self::Overlay,
}
}
}
impl From<Anchor> for wlr_layer::Anchor {
fn from(anchor: Anchor) -> Self {
Self::from_bits_truncate(anchor.bits())
}
}
impl From<KeyboardInteractivity> for wlr_layer::KeyboardInteractivity {
fn from(keyboard: KeyboardInteractivity) -> Self {
match keyboard {
KeyboardInteractivity::None => Self::None,
KeyboardInteractivity::OnDemand => Self::OnDemand,
KeyboardInteractivity::Exclusive => Self::Exclusive,
}
}
}