feat: expose native window handles

This commit is contained in:
2026-06-23 22:50:32 +04:00
parent dc7e72961a
commit a0a4089e4b
7 changed files with 42 additions and 2 deletions
Generated
+4
View File
@@ -642,12 +642,16 @@ version = "0.1.0"
[[package]]
name = "fparkan-platform"
version = "0.1.0"
dependencies = [
"raw-window-handle",
]
[[package]]
name = "fparkan-platform-winit"
version = "0.1.0"
dependencies = [
"fparkan-platform",
"raw-window-handle",
"winit",
]
@@ -7,6 +7,7 @@ repository.workspace = true
[dependencies]
fparkan-platform = { path = "../../crates/fparkan-platform" }
raw-window-handle = "0.6"
winit = "0.30"
[lints]
+17 -2
View File
@@ -21,9 +21,10 @@
//! Minimal `winit`-backed platform adapter shim.
use fparkan_platform::{
EventSource, MonotonicClock, MonotonicInstant, PhysicalSize, PlatformError, PlatformEvent,
RenderRequest, WindowHandle, WindowPort,
EventSource, MonotonicClock, MonotonicInstant, NativeWindowHandles, PhysicalSize,
PlatformError, PlatformEvent, RenderRequest, WindowHandle, WindowPort,
};
use raw_window_handle::{HasDisplayHandle, HasWindowHandle};
use std::collections::VecDeque;
use std::sync::atomic::{AtomicU64, Ordering};
use std::time::{SystemTime, UNIX_EPOCH};
@@ -153,6 +154,7 @@ pub struct WinitWindow {
focused: bool,
minimized: bool,
occluded: bool,
native_handles: Option<NativeWindowHandles>,
}
impl WinitWindow {
@@ -171,6 +173,7 @@ impl WinitWindow {
focused: true,
minimized: false,
occluded: false,
native_handles: native_handles(window),
}
}
@@ -187,6 +190,7 @@ impl WinitWindow {
focused: true,
minimized: false,
occluded: false,
native_handles: None,
}
}
@@ -224,6 +228,16 @@ impl WindowPort for WinitWindow {
fn handle(&self) -> WindowHandle {
self.handle
}
fn native_handles(&self) -> Option<NativeWindowHandles> {
self.native_handles
}
}
fn native_handles(window: &Window) -> Option<NativeWindowHandles> {
let display = window.display_handle().ok()?.as_raw();
let window = window.window_handle().ok()?.as_raw();
Some(NativeWindowHandles { display, window })
}
#[cfg(test)]
@@ -259,6 +273,7 @@ mod tests {
height: 360
}
);
assert!(window.native_handles().is_none());
}
#[test]
+1
View File
@@ -6,6 +6,7 @@ license.workspace = true
repository.workspace = true
[dependencies]
raw-window-handle = "0.6"
[lints]
workspace = true
+15
View File
@@ -20,6 +20,8 @@
)]
//! Platform ports for clocks, event sources and window descriptors.
use raw_window_handle::{RawDisplayHandle, RawWindowHandle};
/// Monotonic instant measured in milliseconds since process start.
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub struct MonotonicInstant(pub u64);
@@ -143,6 +145,15 @@ pub struct WindowHandle {
pub id: u64,
}
/// Native raw window/display handles for render surface creation.
#[derive(Clone, Copy, Debug)]
pub struct NativeWindowHandles {
/// Raw display handle.
pub display: RawDisplayHandle,
/// Raw window handle.
pub window: RawWindowHandle,
}
/// Window presentation and lifecycle port.
///
/// Presentation is not owned by the window abstraction. Render adapters
@@ -160,6 +171,10 @@ pub trait WindowPort {
fn is_occluded(&self) -> bool;
/// Opaque window identity.
fn handle(&self) -> WindowHandle;
/// Raw native handles for render surface creation, when backed by a native window.
fn native_handles(&self) -> Option<NativeWindowHandles> {
None
}
}
/// Render backend request contract.
+2
View File
@@ -21,6 +21,8 @@ S0-CORPUS-005 covered cargo test -p fparkan-corpus --offline fingerprint_changes
S0-CORPUS-006 covered cargo test -p fparkan-corpus --offline atomic_report_write
S0-CLI-001 covered cargo test -p fparkan-cli --offline stable_exit_codes_are_mapped
S0-CLI-002 covered cargo test -p fparkan-cli --offline accepts_json_format_option archive_json_has_schema_version
S0-PLAT-001 covered cargo test -p fparkan-platform-winit --offline window_port_reports_default_request_profile
S0-PLAT-002 covered cargo clippy -p fparkan-platform -p fparkan-platform-winit --all-targets --all-features --locked -- -D warnings
S0-VK-001 covered cargo test -p fparkan-render-vulkan --offline backend_tracks_render_request_and_presents
S0-VK-002 covered cargo test -p fparkan-render-vulkan --offline device_scoring_is_deterministic_and_prefers_discrete_unified_queue
S0-VK-003 covered cargo test -p fparkan-render-vulkan --offline portability_subset_is_reported_and_enabled_when_exposed
1 # Acceptance coverage manifest.
21 S0-CORPUS-006
22 S0-CLI-001
23 S0-CLI-002
24 S0-PLAT-001
25 S0-PLAT-002
26 S0-VK-001
27 S0-VK-002
28 S0-VK-003
+2
View File
@@ -21,6 +21,8 @@
`S0-CORPUS-006`
`S0-CLI-001`
`S0-CLI-002`
`S0-PLAT-001`
`S0-PLAT-002`
`S0-VK-001`
`S0-VK-002`
`S0-VK-003`