use core::{fmt::Debug, num::NonZeroUsize};
use bincode::{Decode, Encode};
use crate::{cursor::Cursor, size::PercentLength};
#[derive(Debug, Encode, Decode, Clone)]
pub enum Request {
SetPosition(SetPosition),
SetAnchor(SetAnchor),
SetMargin(SetMargin),
ListenInput(ListenInput),
BlockInput(BlockInput),
SetBlockingCursor(SetBlockingCursor),
UpdateSharedHandle(UpdateSharedHandle),
}
#[derive(Debug, Default, Encode, Decode, Clone, PartialEq)]
pub struct SetPosition {
pub x: PercentLength,
pub y: PercentLength,
}
#[derive(Debug, Default, Encode, Decode, Clone, PartialEq)]
pub struct SetAnchor {
pub x: PercentLength,
pub y: PercentLength,
}
#[derive(Debug, Default, Encode, Decode, Clone, PartialEq)]
pub struct SetMargin {
pub top: PercentLength,
pub right: PercentLength,
pub bottom: PercentLength,
pub left: PercentLength,
}
impl SetMargin {
pub const fn xy(x: PercentLength, y: PercentLength) -> Self {
Self {
top: y,
right: x,
bottom: y,
left: x,
}
}
}
#[derive(Debug, Default, Encode, Decode, Clone, PartialEq, Eq)]
pub struct GetSize {
pub hwnd: u32,
}
#[derive(Debug, Default, Encode, Decode, Clone, PartialEq, Eq)]
pub struct ListenInput {
pub hwnd: u32,
pub cursor: bool,
pub keyboard: bool,
}
#[derive(Debug, Default, Encode, Decode, Clone, PartialEq, Eq)]
pub struct BlockInput {
pub hwnd: u32,
pub block: bool,
}
#[derive(Debug, Default, Encode, Decode, Clone, PartialEq, Eq)]
pub struct SetBlockingCursor {
pub hwnd: u32,
pub cursor: Option<Cursor>,
}
#[derive(Debug, Encode, Decode, Clone, PartialEq, Eq)]
pub struct UpdateSharedHandle {
pub handle: Option<NonZeroUsize>,
}