1
0
Fork 0

Cleanup GUID string and add more conditional compilation

This commit is contained in:
Mirko Covizzi 2020-05-26 09:39:13 +02:00
parent 2294fdb28d
commit e5c37cc0de
2 changed files with 12 additions and 4 deletions

View file

@ -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);
}

View file

@ -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,