mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-02-24 00:37:43 +11:00
Change the RegisterClass code.
Prevents an issue when creating multiple contexts.
This commit is contained in:
parent
d93cea808d
commit
c1ecc06baf
1 changed files with 26 additions and 23 deletions
|
@ -31,6 +31,7 @@ pub fn new_window(dimensions: Option<(uint, uint)>, title: &str,
|
||||||
// This is the only safe method. Using `nosend` wouldn't work for non-native runtime.
|
// This is the only safe method. Using `nosend` wouldn't work for non-native runtime.
|
||||||
TaskBuilder::new().native().spawn(proc() {
|
TaskBuilder::new().native().spawn(proc() {
|
||||||
// registering the window class
|
// registering the window class
|
||||||
|
let class_name = {
|
||||||
let class_name: Vec<u16> = "Window Class".utf16_units().collect::<Vec<u16>>()
|
let class_name: Vec<u16> = "Window Class".utf16_units().collect::<Vec<u16>>()
|
||||||
.append_one(0);
|
.append_one(0);
|
||||||
|
|
||||||
|
@ -49,12 +50,14 @@ pub fn new_window(dimensions: Option<(uint, uint)>, title: &str,
|
||||||
hIconSm: ptr::mut_null(),
|
hIconSm: ptr::mut_null(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if unsafe { ffi::RegisterClassExW(&class) } == 0 {
|
// We ignore errors because registering the same window class twice would trigger
|
||||||
use std::os;
|
// an error, and because errors here are detected during CreateWindowEx anyway.
|
||||||
tx.send(Err(format!("RegisterClassEx function failed: {}",
|
// Also since there is no weird element in the struct, there is no reason for this
|
||||||
os::error_string(os::errno() as uint))));
|
// call to fail.
|
||||||
return;
|
unsafe { ffi::RegisterClassExW(&class) };
|
||||||
}
|
|
||||||
|
class_name
|
||||||
|
};
|
||||||
|
|
||||||
// building a RECT object with coordinates
|
// building a RECT object with coordinates
|
||||||
let mut rect = ffi::RECT {
|
let mut rect = ffi::RECT {
|
||||||
|
|
Loading…
Add table
Reference in a new issue