Cleanup GUID string and add more conditional compilation
This commit is contained in:
parent
2294fdb28d
commit
e5c37cc0de
11
src/lib.rs
11
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;
|
mod win;
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
pub use win::*;
|
pub use win::*;
|
||||||
|
|
||||||
use std::ffi::c_void;
|
use std::ffi::c_void;
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
mod x11;
|
mod x11;
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
mod macos;
|
mod macos;
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
pub use macos::Window;
|
pub use macos::Window;
|
||||||
|
|
||||||
pub enum Parent {
|
pub enum Parent {
|
||||||
|
@ -25,5 +33,6 @@ pub struct WindowOpenOptions<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run(options: WindowOpenOptions) {
|
pub fn run(options: WindowOpenOptions) {
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
x11::run(options);
|
x11::run(options);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ pub fn create_window(w: WindowOpenOptions) {
|
||||||
let mut guid: GUID = MaybeUninit::uninit().assume_init();
|
let mut guid: GUID = MaybeUninit::uninit().assume_init();
|
||||||
CoCreateGuid(&mut guid);
|
CoCreateGuid(&mut guid);
|
||||||
let class_name = format!(
|
let class_name = format!(
|
||||||
"Baseview-{}-{}-{}-{}{}{}{}{}{}{}{}\0",
|
"Baseview-{:0X}-{:0X}-{:0X}-{:0X}{:0X}-{:0X}{:0X}{:0X}{:0X}{:0X}{:0X}\0",
|
||||||
guid.Data1,
|
guid.Data1,
|
||||||
guid.Data2,
|
guid.Data2,
|
||||||
guid.Data3,
|
guid.Data3,
|
||||||
|
@ -86,8 +86,7 @@ pub fn create_window(w: WindowOpenOptions) {
|
||||||
let _hwnd = CreateWindowExA(
|
let _hwnd = CreateWindowExA(
|
||||||
0,
|
0,
|
||||||
class_name.as_ptr() as *const i8,
|
class_name.as_ptr() as *const i8,
|
||||||
// todo: change title based on options struct
|
(w.title.to_owned() + "\0").as_ptr() as *const i8,
|
||||||
"Baseview\0".as_ptr() as *const i8,
|
|
||||||
// todo: fine for now, will have to change with a parent
|
// todo: fine for now, will have to change with a parent
|
||||||
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
|
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
|
||||||
CW_USEDEFAULT,
|
CW_USEDEFAULT,
|
||||||
|
|
Loading…
Reference in a new issue