euv-core 0.48.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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
use super::*;

/// Cached `libX11.so.6` function pointer table resolved once per process.
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct LinuxX11Syms {
    /// Handle returned by `dlopen("libX11.so.6")`.
    pub(crate) lib: usize,
    /// `XOpenDisplay` symbol address.
    pub(crate) open_display: usize,
    /// `XDefaultScreen` symbol address.
    pub(crate) default_screen: usize,
    /// `XRootWindow` symbol address.
    pub(crate) root_window: usize,
    /// `XCreateSimpleWindow` symbol address.
    pub(crate) create_simple_window: usize,
    /// `XStoreName` symbol address.
    pub(crate) store_name: usize,
    /// `XMapWindow` symbol address.
    pub(crate) map_window: usize,
    /// `XResizeWindow` symbol address.
    pub(crate) resize_window: usize,
    /// `XDestroyWindow` symbol address.
    pub(crate) destroy_window: usize,
    /// `XFlush` symbol address.
    pub(crate) flush: usize,
    /// `XDefaultGC` symbol address.
    pub(crate) default_gc: usize,
    /// `XDefaultVisual` symbol address.
    pub(crate) default_visual: usize,
    /// `XDefaultDepth` symbol address.
    pub(crate) default_depth: usize,
    /// `XCreateImage` symbol address.
    pub(crate) create_image: usize,
    /// `XPutImage` symbol address.
    pub(crate) put_image: usize,
    /// `XFree` symbol address.
    pub(crate) free: usize,
    /// `XSelectInput` symbol address.
    pub(crate) select_input: usize,
    /// `XInternAtom` symbol address.
    pub(crate) intern_atom: usize,
    /// `XSetWMProtocols` symbol address.
    pub(crate) set_wm_protocols: usize,
    /// `XPending` symbol address.
    pub(crate) pending: usize,
    /// `XNextEvent` symbol address.
    pub(crate) next_event: usize,
    /// `XLookupString` symbol address.
    pub(crate) lookup_string: usize,
    /// `XResourceManagerString` symbol address.
    pub(crate) resource_manager_string: usize,
}

/// Cached `libXrandr.so.2` function pointer table resolved once per process.
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct LinuxXRandrSyms {
    /// `XRRGetScreenInfo` symbol address.
    pub(crate) get_screen_info: usize,
    /// `XRRConfigCurrentRate` symbol address.
    pub(crate) config_current_rate: usize,
    /// `XRRFreeScreenConfigInfo` symbol address.
    pub(crate) free_screen_config_info: usize,
}

/// Cached `libXext.so.6` MIT-SHM function pointer table resolved once per process.
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct LinuxXShmSyms {
    /// `XShmQueryExtension` symbol address.
    pub(crate) query_extension: usize,
    /// `XShmCreateImage` symbol address.
    pub(crate) create_image: usize,
    /// `XShmAttach` symbol address.
    pub(crate) attach: usize,
    /// `XShmDetach` symbol address.
    pub(crate) detach: usize,
    /// `XShmPutImage` symbol address.
    pub(crate) put_image: usize,
}

/// Cached `libwayland-client.so.0` + Vulkan WSI symbol table resolved once per process.
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct LinuxWaylandSyms {
    /// Handle returned by `dlopen("libwayland-client.so.0")`.
    pub(crate) lib: usize,
    /// `wl_display_connect` symbol address.
    pub(crate) display_connect: usize,
    /// `wl_display_disconnect` symbol address.
    pub(crate) display_disconnect: usize,
    /// `wl_display_dispatch_pending` symbol address.
    pub(crate) display_dispatch_pending: usize,
    /// `wl_display_dispatch` symbol address.
    pub(crate) display_dispatch: usize,
    /// `wl_display_flush` symbol address.
    pub(crate) display_flush: usize,
    /// `wl_display_roundtrip` symbol address.
    pub(crate) display_roundtrip: usize,
    /// `wl_display_get_error` symbol address.
    pub(crate) display_get_error: usize,
    /// `wl_proxy_marshal_flags` symbol address.
    pub(crate) proxy_marshal_flags: usize,
    /// `wl_proxy_add_listener` symbol address.
    pub(crate) proxy_add_listener: usize,
    /// `wl_proxy_destroy` symbol address.
    pub(crate) proxy_destroy: usize,
    /// `wl_proxy_get_version` symbol address.
    pub(crate) proxy_get_version: usize,
    /// Exported `wl_registry_interface` pointer address.
    pub(crate) registry_interface: usize,
    /// Exported `wl_compositor_interface` pointer address.
    pub(crate) compositor_interface: usize,
    /// Exported `wl_surface_interface` pointer address.
    pub(crate) surface_interface: usize,
    /// Exported `wl_shm_interface` pointer address.
    pub(crate) shm_interface: usize,
    /// Exported `wl_shm_pool_interface` pointer address.
    pub(crate) shm_pool_interface: usize,
    /// Exported `wl_buffer_interface` pointer address.
    pub(crate) buffer_interface: usize,
    /// True when `vkCreateWaylandSurfaceKHR` is available in `libvulkan.so.1`.
    pub(crate) vulkan_wsi_available: bool,
    /// True when `vkCreateXlibSurfaceKHR` is available in `libvulkan.so.1`.
    pub(crate) xlib_vulkan_wsi_available: bool,
}

/// Raw `wl_registry_listener` ABI table registered during Wayland global discovery.
#[repr(C)]
#[derive(Clone, Copy)]
pub(crate) struct WlRegistryListener {
    /// Callback invoked for each advertised Wayland global `(data, registry, name, interface, version)`.
    pub(crate) global: unsafe extern "C" fn(*mut c_void, *mut c_void, u32, *const c_char, u32),
    /// Callback invoked when a Wayland global is removed `(data, registry, name)`.
    pub(crate) global_remove: unsafe extern "C" fn(*mut c_void, *mut c_void, u32),
}

/// Raw `wl_buffer_listener` ABI table tracking compositor buffer release notifications.
#[repr(C)]
#[derive(Clone, Copy)]
pub(crate) struct WlBufferListener {
    /// Callback invoked when the compositor finishes reading a `wl_buffer` (`(data, buffer)`).
    pub(crate) release: unsafe extern "C" fn(*mut c_void, *mut c_void),
}

/// Mutable state populated by `WL_REGISTRY_LISTENER` during initial `wl_display_roundtrip`.
#[repr(C)]
#[derive(Clone, Copy, Debug, Default)]
pub(crate) struct WlRegistryBindState {
    /// Bound `wl_compositor*` proxy handle.
    pub(crate) compositor: usize,
    /// Negotiated `wl_compositor` protocol version.
    pub(crate) compositor_version: u32,
    /// Bound `wl_shm*` proxy handle.
    pub(crate) shm: usize,
}

/// Descriptor carrying POSIX shared-memory FD, geometry, format, and release flag pointer for `WaylandShmCommitOps`.
#[derive(Clone, Copy, Data, Debug, Default, Eq, New, PartialEq)]
pub struct WaylandShmBufferDescriptor {
    /// Open shared-memory file descriptor (`memfd_create` or `/dev/shm`).
    #[get(type(copy))]
    pub(crate) fd: i32,
    /// Total mapped buffer byte size.
    #[get(type(copy))]
    pub(crate) size: i32,
    /// Physical buffer width in pixels.
    #[get(type(copy))]
    pub(crate) width: i32,
    /// Physical buffer height in pixels.
    #[get(type(copy))]
    pub(crate) height: i32,
    /// Row stride in bytes (`width * 4`).
    #[get(type(copy))]
    pub(crate) stride: i32,
    /// Wayland shm pixel format (`WL_SHM_FORMAT_ARGB8888` or `WL_SHM_FORMAT_XRGB8888`).
    #[get(type(copy))]
    pub(crate) format: u32,
    /// Raw pointer to the slot's release `AtomicBool` userdata registered on `wl_buffer.release`.
    #[get(type(copy))]
    pub(crate) release_flag_ptr: usize,
}

/// Single double-buffered Wayland `wl_shm` memory mapping and protocol buffer slot.
#[derive(Debug)]
pub struct WaylandShmBufferSlot {
    /// Open POSIX shared-memory file descriptor (`-1` when unallocated).
    pub(crate) fd: i32,
    /// Base pointer returned by `mmap(..., MAP_SHARED, fd, 0)` (`0` when unmapped).
    pub(crate) mapped_ptr: usize,
    /// Mapped byte capacity of this shared-memory region.
    pub(crate) mapped_len: usize,
    /// Current allocated buffer width in physical pixels.
    pub(crate) width: u32,
    /// Current allocated buffer height in physical pixels.
    pub(crate) height: u32,
    /// Row stride in bytes (`width * 4`).
    pub(crate) stride: u32,
    /// Bound Wayland shm pixel format (`WL_SHM_FORMAT_ARGB8888` or `WL_SHM_FORMAT_XRGB8888`).
    pub(crate) format: u32,
    /// Associated `wl_shm_pool*` proxy handle (`0` when detached).
    pub(crate) wl_pool: usize,
    /// Associated `wl_buffer*` proxy handle (`0` when detached).
    pub(crate) wl_buffer: usize,
    /// Atomic busy flag cleared asynchronously by `wl_buffer.release` (`true` while held by compositor).
    pub(crate) busy: Box<AtomicBool>,
    /// True once this slot has received a complete full-frame pixel copy for its current dimensions.
    pub(crate) has_full_copy: bool,
}

/// Double-buffered Wayland `wl_shm` software swapchain owning two POSIX shm mappings and dirty-rect tracking.
#[derive(Debug)]
pub struct WaylandShmSwapchain {
    /// Two ping-pong shared-memory slots enabling tear-free double-buffered Wayland commits.
    pub(crate) slots: [WaylandShmBufferSlot; WL_SHM_SLOT_COUNT],
    /// Wayland shm pixel format (`WL_SHM_FORMAT_XRGB8888` or `WL_SHM_FORMAT_ARGB8888`).
    pub(crate) pixel_format: u32,
    /// Dirty rectangles from the immediately preceding submitted frame so double-buffered back slots stay coherent.
    pub(crate) previous_dirty_rects: Vec<(u32, u32, u32, u32)>,
    /// Index (`0` or `1`) of the most recently committed buffer slot.
    pub(crate) last_committed_slot: u8,
    /// Cumulative count of successfully committed Wayland shm frames.
    pub(crate) submitted_frames: u64,
    /// Cumulative count of unchanged frames skipped without commit.
    pub(crate) skipped_unchanged_frames: u64,
    /// Cumulative count of failed presentation attempts.
    pub(crate) failed_frames: u64,
}

/// Native `libwayland-client.so.0` transport invoking `wl_shm_pool`, `wl_buffer`, `wl_surface`, and `wl_display_flush`.
#[derive(Clone, Copy, Data, Debug, Default, Eq, New, PartialEq)]
pub struct NativeWaylandShmTransport {
    /// Live `wl_display*` connection pointer.
    #[get(type(copy))]
    pub(crate) display: usize,
    /// Live `wl_surface*` proxy pointer.
    #[get(type(copy))]
    pub(crate) surface: usize,
    /// Live `wl_shm*` global proxy pointer.
    #[get(type(copy))]
    pub(crate) wl_shm: usize,
    /// Negotiated `wl_surface` interface version (`>= 4` uses `damage_buffer`, `< 4` uses `damage`).
    #[get(type(copy))]
    pub(crate) surface_version: u32,
}

/// Explicit per-frame Linux presentation telemetry separating direct GPU vs Wayland shm vs X11 software blits.
#[derive(Clone, Copy, Data, Debug, Default, Eq, PartialEq)]
pub struct LinuxPresentTelemetry {
    /// Active presentation transport (`GpuDirect`, `WaylandShmSoftware`, or `X11Software`).
    #[get(type(copy))]
    pub(crate) mode: LinuxPresentationMode,
    /// Explicit frame outcome (`Submitted`, `SkippedUnchanged`, or `Failed`).
    #[get(type(copy))]
    pub(crate) outcome: LinuxPresentOutcome,
    /// True whenever a CPU software framebuffer mirror is active (`false` for `GpuDirect`).
    #[get(type(copy))]
    pub(crate) cpu_mirror_active: bool,
    /// Exact pixel bytes copied into Wayland shm or uploaded via X11 `XPutImage` (`0` for `GpuDirect` or skip).
    #[get(type(copy))]
    pub(crate) upload_bytes: u64,
    /// Number of dirty rectangles damaged or uploaded during this frame.
    #[get(type(copy))]
    pub(crate) dirty_rect_count: u32,
    /// Double-buffered Wayland shm slot index (`0` or `1`) committed on this frame.
    #[get(type(copy))]
    pub(crate) committed_buffer_slot: u8,
    /// Cumulative submitted frames recorded on this window.
    #[get(type(copy))]
    pub(crate) submitted_frames: u64,
    /// Cumulative unchanged frames skipped on this window.
    #[get(type(copy))]
    pub(crate) skipped_unchanged_frames: u64,
    /// Cumulative failed frames recorded on this window.
    #[get(type(copy))]
    pub(crate) failed_frames: u64,
}

/// 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,
    /// True when X11 MIT-SHM (`XShmQueryExtension`) is supported on this display.
    #[get(type(copy))]
    pub(crate) mit_shm_available: bool,
    /// True when Wayland Vulkan WSI (`VK_KHR_wayland_surface`) is available.
    #[get(type(copy))]
    pub(crate) wayland_vulkan_wsi: bool,
    /// True when X11 Vulkan WSI (`VK_KHR_xlib_surface`) is available.
    #[get(type(copy))]
    pub(crate) xlib_vulkan_wsi: bool,
    /// Bound Wayland `wl_compositor*` proxy pointer (`0` on X11 or unavailable).
    #[get(type(copy))]
    pub(crate) wl_compositor: usize,
    /// Bound Wayland `wl_shm*` proxy pointer (`0` on X11 or unavailable).
    #[get(type(copy))]
    pub(crate) wl_shm: usize,
    /// Negotiated Wayland `wl_surface` interface version (`0` on X11).
    #[get(type(copy))]
    pub(crate) wl_surface_version: u32,
}

/// 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,
    /// Whether `XMapWindow` has been issued after Frame 1 presentation (eliminates unmapped flash).
    #[get(type(copy))]
    pub(crate) revealed: bool,
    /// Whether X11 MIT-SHM shared-memory image transport is supported by the X server.
    #[get(type(copy))]
    pub(crate) mit_shm_available: bool,
    /// Whether Wayland Vulkan WSI (`VK_KHR_wayland_surface`) is ready on this display.
    #[get(type(copy))]
    pub(crate) wayland_vulkan_wsi: bool,
    /// Whether X11 Vulkan WSI (`VK_KHR_xlib_surface`) is ready on this display.
    #[get(type(copy))]
    pub(crate) xlib_vulkan_wsi: bool,
    /// Bound Wayland `wl_compositor*` proxy pointer (`0` on X11).
    #[get(type(copy))]
    pub(crate) wl_compositor: usize,
    /// Bound Wayland `wl_shm*` proxy pointer (`0` on X11).
    #[get(type(copy))]
    pub(crate) wl_shm: usize,
    /// Negotiated Wayland `wl_surface` interface version (`>= 4` supports `damage_buffer`).
    #[get(type(copy))]
    pub(crate) wl_surface_version: u32,
    /// Reported `wl_output.mode` refresh rate in millihertz (e.g. `240000` for `240Hz`, `0` if unset).
    #[get(type(copy))]
    pub(crate) wayland_output_refresh_milli_hz: u32,
    /// Latest `wp_presentation` feedback timestamp in nanoseconds (`0` before first presentation).
    #[get(type(copy))]
    pub(crate) wayland_presentation_time_ns: u64,
    /// Whether a `wl_surface::frame` callback is currently armed awaiting compositor VSync.
    #[get(type(copy))]
    pub(crate) wayland_frame_callback_pending: bool,
    /// Active Linux presentation mode (`GpuDirect`, `WaylandShmSoftware`, or `X11Software`).
    #[get(type(copy))]
    pub(crate) presentation_mode: LinuxPresentationMode,
    /// Explicit CPU-mirror telemetry flag (`true` on Wayland shm / X11 software; `false` on direct GPU).
    #[get(type(copy))]
    pub(crate) cpu_mirror_active: bool,
    /// Most recent per-frame Linux presentation telemetry snapshot.
    #[get(type(copy))]
    pub(crate) last_telemetry: LinuxPresentTelemetry,
    /// Double-buffered Wayland `wl_shm` software swapchain attached to this window when Wayland is active.
    #[get(skip)]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) wayland_shm: Option<Arc<Mutex<WaylandShmSwapchain>>>,
}

/// 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>,
    /// Whether the Linux X11/Wayland frame pump is paused for background freeze.
    #[get(pub(crate), type(copy))]
    #[set(pub(crate))]
    pub(crate) pump_paused: bool,
}