Desktop: Add window abstraction layer (#3302)

* add bundle for mac os and windows

* Fix bundle name

This name gets used as the display name of the app on mac os, shorter name looks better and is more consistent.

* preserve std out by running bin directly

* bundle placeholder on linux

* fix linux

* window abstraction

* fix linux

* fix windows

* fix fmt

* remove windows file that was left

* use self
This commit is contained in:
Timon
2025-10-23 11:33:32 +00:00
committed by GitHub
parent 7fbe440e73
commit c4f6a2c9c1
9 changed files with 190 additions and 121 deletions
+32
View File
@@ -0,0 +1,32 @@
use winit::event_loop::ActiveEventLoop;
use winit::window::{Window, WindowAttributes};
use super::NativeWindow;
pub(super) struct NativeWindowImpl {
native_handle: native_handle::NativeWindowHandle,
}
impl NativeWindow for NativeWindowImpl {
fn configure(attributes: WindowAttributes, _event_loop: &dyn ActiveEventLoop) -> WindowAttributes {
if let Ok(win_icon) = winit::platform::windows::WinIcon::from_resource(1, None) {
let icon = winit::icon::Icon(std::sync::Arc::new(win_icon));
attributes.with_window_icon(Some(icon))
} else {
attributes
}
}
fn new(window: &dyn Window) -> Self {
let native_handle = native_handle::NativeWindowHandle::new(window);
NativeWindowImpl { native_handle }
}
}
impl Drop for NativeWindowImpl {
fn drop(&mut self) {
self.native_handle.destroy();
}
}
mod native_handle;