From e5c37cc0de9e0696675e5b126948419c4b75f64a Mon Sep 17 00:00:00 2001 From: Mirko Covizzi Date: Tue, 26 May 2020 09:39:13 +0200 Subject: [PATCH] Cleanup GUID string and add more conditional compilation --- src/lib.rs | 11 ++++++++++- src/win/window.rs | 5 ++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index aacc02a..d3df97f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,12 +1,20 @@ +// todo: will deal with conditional compilation/visibility later, +// todo: we still have to choose how to organize the code +// todo: for now I need this to be able to check and compile +// todo: We should consider doing it as winit does it +#[cfg(target_os = "windows")] mod win; - +#[cfg(target_os = "windows")] pub use win::*; use std::ffi::c_void; +#[cfg(target_os = "linux")] mod x11; +#[cfg(target_os = "macos")] mod macos; +#[cfg(target_os = "macos")] pub use macos::Window; pub enum Parent { @@ -25,5 +33,6 @@ pub struct WindowOpenOptions<'a> { } pub fn run(options: WindowOpenOptions) { + #[cfg(target_os = "linux")] x11::run(options); } diff --git a/src/win/window.rs b/src/win/window.rs index 4684907..158325f 100644 --- a/src/win/window.rs +++ b/src/win/window.rs @@ -53,7 +53,7 @@ pub fn create_window(w: WindowOpenOptions) { let mut guid: GUID = MaybeUninit::uninit().assume_init(); CoCreateGuid(&mut guid); let class_name = format!( - "Baseview-{}-{}-{}-{}{}{}{}{}{}{}{}\0", + "Baseview-{:0X}-{:0X}-{:0X}-{:0X}{:0X}-{:0X}{:0X}{:0X}{:0X}{:0X}{:0X}\0", guid.Data1, guid.Data2, guid.Data3, @@ -86,8 +86,7 @@ pub fn create_window(w: WindowOpenOptions) { let _hwnd = CreateWindowExA( 0, class_name.as_ptr() as *const i8, - // todo: change title based on options struct - "Baseview\0".as_ptr() as *const i8, + (w.title.to_owned() + "\0").as_ptr() as *const i8, // todo: fine for now, will have to change with a parent WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT,