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
+27
View File
@@ -0,0 +1,27 @@
use winit::event_loop::ActiveEventLoop;
use winit::platform::wayland::ActiveEventLoopExtWayland;
use winit::platform::wayland::WindowAttributesWayland;
use winit::platform::x11::WindowAttributesX11;
use winit::window::{Window, WindowAttributes};
use crate::consts::{APP_ID, APP_NAME};
use super::NativeWindow;
pub(super) struct NativeWindowImpl {}
impl NativeWindow for NativeWindowImpl {
fn configure(attributes: WindowAttributes, event_loop: &dyn ActiveEventLoop) -> WindowAttributes {
if event_loop.is_wayland() {
let wayland_attributes = WindowAttributesWayland::default().with_name(APP_ID, "").with_prefer_csd(true);
attributes.with_platform_attributes(Box::new(wayland_attributes))
} else {
let x11_attributes = WindowAttributesX11::default().with_name(APP_ID, APP_NAME);
attributes.with_platform_attributes(Box::new(x11_attributes))
}
}
fn new(_window: &dyn Window) -> Self {
NativeWindowImpl {}
}
}