use crate::reexport::{Anchor, Layer, WlRegion};
use iced_core::window::Id as IcedId;
use layershellev::{NewInputPanelSettings, NewLayerShellSettings, NewXdgWindowSettings};
use std::sync::Arc;
#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
pub struct IcedXdgWindowSettings {
pub size: Option<(u32, u32)>,
}
impl From<IcedXdgWindowSettings> for NewXdgWindowSettings {
fn from(val: IcedXdgWindowSettings) -> Self {
NewXdgWindowSettings {
title: None,
size: val.size,
}
}
}
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub struct IcedNewPopupSettings {
pub size: (u32, u32),
pub position: (i32, i32),
}
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum MenuDirection {
Up,
Down,
}
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub struct IcedNewMenuSettings {
pub size: (u32, u32),
pub direction: MenuDirection,
}
type Callback = Arc<dyn Fn(&WlRegion) + Send + Sync>;
#[derive(Clone)]
pub struct ActionCallback(pub Callback);
impl std::fmt::Debug for ActionCallback {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "callback function")
}
}
impl ActionCallback {
pub fn new<F>(callback: F) -> Self
where
F: Fn(&WlRegion) + Send + Sync + 'static,
{
ActionCallback(Arc::new(callback))
}
}
#[derive(Debug, Clone)]
pub enum LayerShellCustomAction {
AnchorChange(Anchor),
LayerChange(Layer),
AnchorSizeChange(Anchor, (u32, u32)),
MarginChange((i32, i32, i32, i32)),
SizeChange((u32, u32)),
ExclusiveZoneChange(i32),
KeyboardInteractivityChange(layershellev::reexport::KeyboardInteractivity),
VirtualKeyboardPressed {
key: u32,
},
NewLayerShell {
settings: NewLayerShellSettings,
id: IcedId,
},
SetInputRegion(ActionCallback),
NewPopUp {
settings: IcedNewPopupSettings,
id: IcedId,
},
NewBaseWindow {
settings: IcedXdgWindowSettings,
id: IcedId,
},
NewMenu {
settings: IcedNewMenuSettings,
id: IcedId,
},
NewInputPanel {
settings: NewInputPanelSettings,
id: IcedId,
},
RemoveWindow,
ForgetLastOutput,
}
#[derive(Debug, Clone)]
pub struct LayerShellCustomActionWithId(pub Option<IcedId>, pub LayerShellCustomAction);
impl LayerShellCustomActionWithId {
pub fn new(id: Option<IcedId>, action: LayerShellCustomAction) -> Self {
Self(id, action)
}
}