mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-01 17:08:12 +08:00
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:
@@ -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;
|
||||
Reference in New Issue
Block a user