euv-core 0.39.1

Core cross-platform runtime for euv featuring arena-based fine-grained reactivity, deterministic layout, flat scene graph, multi-mode rendering, and direct OS platform adapters.
Documentation
use super::*;

/// Raw 192-byte X11 `XEvent` union storage aligned for 64-bit Linux LP64 ABI.
#[repr(C)]
#[derive(Clone, Copy)]
pub(crate) struct X11EventRaw {
    /// Raw union payload words.
    pub(crate) pad: [isize; 24],
}

/// X11 `XKeyEvent` / `XButtonEvent` ABI layout on LP64 Linux.
#[repr(C)]
#[derive(Clone, Copy)]
pub(crate) struct X11KeyOrButtonEvent {
    /// Event discriminant (`KeyPress`, `KeyRelease`, `ButtonPress`, `ButtonRelease`).
    pub(crate) event_type: i32,
    /// X server serial number.
    pub(crate) serial: usize,
    /// Non-zero when generated by `SendEvent`.
    pub(crate) send_event: i32,
    /// Connection `Display*`.
    pub(crate) display: *mut c_void,
    /// Target `Window` XID.
    pub(crate) window: u64,
    /// Root window XID.
    pub(crate) root: u64,
    /// Subwindow XID.
    pub(crate) subwindow: u64,
    /// Event timestamp in milliseconds.
    pub(crate) time: u64,
    /// Pointer X coordinate relative to window.
    pub(crate) x: i32,
    /// Pointer Y coordinate relative to window.
    pub(crate) y: i32,
    /// Pointer X relative to root window.
    pub(crate) x_root: i32,
    /// Pointer Y relative to root window.
    pub(crate) y_root: i32,
    /// Modifier key / button mask.
    pub(crate) state: u32,
    /// Hardware keycode or mouse button number.
    pub(crate) detail: u32,
    /// Same-screen flag.
    pub(crate) same_screen: i32,
}

/// X11 `XMotionEvent` ABI layout on LP64 Linux.
#[repr(C)]
#[derive(Clone, Copy)]
pub(crate) struct X11MotionEvent {
    /// Event discriminant (`MotionNotify`).
    pub(crate) event_type: i32,
    /// X server serial number.
    pub(crate) serial: usize,
    /// Send-event flag.
    pub(crate) send_event: i32,
    /// Connection `Display*`.
    pub(crate) display: *mut c_void,
    /// Target `Window` XID.
    pub(crate) window: u64,
    /// Root window XID.
    pub(crate) root: u64,
    /// Subwindow XID.
    pub(crate) subwindow: u64,
    /// Timestamp in milliseconds.
    pub(crate) time: u64,
    /// Pointer X coordinate relative to window.
    pub(crate) x: i32,
    /// Pointer Y coordinate relative to window.
    pub(crate) y: i32,
    /// Pointer X relative to root window.
    pub(crate) x_root: i32,
    /// Pointer Y relative to root window.
    pub(crate) y_root: i32,
    /// Active modifier mask.
    pub(crate) state: u32,
    /// Motion hint byte.
    pub(crate) is_hint: c_char,
    /// Same-screen flag.
    pub(crate) same_screen: i32,
}

/// X11 `XConfigureEvent` ABI layout on LP64 Linux.
#[repr(C)]
#[derive(Clone, Copy)]
pub(crate) struct X11ConfigureEvent {
    /// Event discriminant (`ConfigureNotify`).
    pub(crate) event_type: i32,
    /// X server serial number.
    pub(crate) serial: usize,
    /// Send-event flag.
    pub(crate) send_event: i32,
    /// Connection `Display*`.
    pub(crate) display: *mut c_void,
    /// Event-delivery window XID.
    pub(crate) event_window: u64,
    /// Reconfigured target window XID.
    pub(crate) window: u64,
    /// New window X position.
    pub(crate) x: i32,
    /// New window Y position.
    pub(crate) y: i32,
    /// New window client width in physical pixels.
    pub(crate) width: i32,
    /// New window client height in physical pixels.
    pub(crate) height: i32,
}

/// X11 `XClientMessageEvent` ABI layout on LP64 Linux.
#[repr(C)]
#[derive(Clone, Copy)]
pub(crate) struct X11ClientMessageEvent {
    /// Event discriminant (`ClientMessage`).
    pub(crate) event_type: i32,
    /// X server serial number.
    pub(crate) serial: usize,
    /// Send-event flag.
    pub(crate) send_event: i32,
    /// Connection `Display*`.
    pub(crate) display: *mut c_void,
    /// Target `Window` XID.
    pub(crate) window: u64,
    /// Message type atom (`WM_PROTOCOLS`).
    pub(crate) message_type: u64,
    /// Data format (`8`, `16`, or `32`).
    pub(crate) format: i32,
    /// 32-bit protocol data payload (`l[0]` holds `WM_DELETE_WINDOW`).
    pub(crate) data: [u64; 5],
}

/// Bundle returned when opening a native Linux X11 or Wayland window.
#[derive(Clone, Copy, Data, Debug)]
pub(crate) struct LinuxNativeWindowHandle {
    /// Dynamically loaded `libX11` or `libwayland-client` handle.
    #[get(type(copy))]
    pub(crate) lib: usize,
    /// True when backed by Wayland; false when backed by X11.
    #[get(type(copy))]
    pub(crate) is_wayland: bool,
    /// Raw `Display*` or `wl_display*`.
    #[get(type(copy))]
    pub(crate) display: usize,
    /// Native X11 `Window` XID or Wayland surface pointer.
    #[get(type(copy))]
    pub(crate) window: u64,
    /// Cached X11 `GC` handle for `XPutImage`.
    #[get(type(copy))]
    pub(crate) gc: usize,
    /// Cached X11 `Visual*` pointer for `XCreateImage`.
    #[get(type(copy))]
    pub(crate) visual: usize,
    /// X11 default visual color depth (e.g., `24` or `32`).
    #[get(type(copy))]
    pub(crate) depth: u32,
    /// Interned `WM_DELETE_WINDOW` atom for graceful window closing.
    #[get(type(copy))]
    pub(crate) wm_delete_atom: u64,
    /// Probed display DPI scale factor (`1.0..=4.0`).
    #[get(type(copy))]
    pub(crate) scale_factor: f32,
}

/// Native Linux X11 / Wayland window record.
#[derive(Clone, Data, Debug)]
pub struct LinuxWindowRecord {
    /// Window configuration.
    pub(crate) config: WindowConfig,
    /// Live window state.
    #[get(type(copy))]
    pub(crate) state: WindowState,
    /// True when backed by Wayland; false when backed by X11 Xlib.
    #[get(type(copy))]
    pub(crate) is_wayland: bool,
    /// Raw display handle (`Display*` or `wl_display*`).
    #[get(type(copy))]
    pub(crate) display: usize,
    /// Raw window or surface identifier (`Window` or `wl_surface*`).
    #[get(type(copy))]
    pub(crate) window: u64,
    /// Cached X11 `GC` handle used by `XPutImage`.
    #[get(type(copy))]
    pub(crate) gc: usize,
    /// Cached X11 `Visual*` pointer used by `XCreateImage`.
    #[get(type(copy))]
    pub(crate) visual: usize,
    /// X11 visual depth in bits (`24` or `32`).
    #[get(type(copy))]
    pub(crate) depth: u32,
    /// Interned `WM_DELETE_WINDOW` protocol atom.
    #[get(type(copy))]
    pub(crate) wm_delete_atom: u64,
}

/// Direct Linux X11 / Wayland (`dlopen`-loaded) + Vulkan platform backend.
#[derive(Clone, Data, Debug)]
pub struct LinuxPlatform {
    /// Monotonic window handle generator.
    #[get(pub(crate), type(copy))]
    #[get_mut(pub(crate))]
    #[set(pub(crate))]
    pub(crate) next_id: u64,
    /// Dynamically loaded `libX11` handle if present.
    #[get(pub(crate), type(copy))]
    #[get_mut(pub(crate))]
    #[set(pub(crate))]
    pub(crate) x11_lib: usize,
    /// Active native Linux windows.
    pub(crate) windows: HashMap<WindowId, LinuxWindowRecord>,
    /// Queued window and input events.
    pub(crate) pending_events: Vec<WindowEvent>,
    /// Clipboard text cache.
    #[get(skip)]
    pub(crate) clipboard_cache: Option<String>,
}