mirror of
https://github.com/rust-windowing/winit.git
synced 2026-09-01 14:20:05 -04:00
Added is_closed to osx window
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
use Event;
|
use Event;
|
||||||
|
use std::sync::atomics::AtomicBool;
|
||||||
|
|
||||||
#[cfg(feature = "window")]
|
#[cfg(feature = "window")]
|
||||||
use WindowBuilder;
|
use WindowBuilder;
|
||||||
@@ -14,8 +15,10 @@ use core_foundation::string::CFString;
|
|||||||
use core_foundation::bundle::{CFBundleGetBundleWithIdentifier, CFBundleGetFunctionPointerForName};
|
use core_foundation::bundle::{CFBundleGetBundleWithIdentifier, CFBundleGetFunctionPointerForName};
|
||||||
|
|
||||||
pub struct Window {
|
pub struct Window {
|
||||||
|
window: id,
|
||||||
view: id,
|
view: id,
|
||||||
context: id,
|
context: id,
|
||||||
|
is_closed: AtomicBool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct HeadlessContext(Window);
|
pub struct HeadlessContext(Window);
|
||||||
@@ -87,8 +90,10 @@ impl Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let window = Window {
|
let window = Window {
|
||||||
|
window: window,
|
||||||
view: view,
|
view: view,
|
||||||
context: context,
|
context: context,
|
||||||
|
is_closed: AtomicBool::new(false),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(window)
|
Ok(window)
|
||||||
@@ -172,8 +177,8 @@ impl Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_closed(&self) -> bool {
|
pub fn is_closed(&self) -> bool {
|
||||||
// TODO: remove fake implementation
|
use std::sync::atomics::Relaxed;
|
||||||
false
|
self.is_closed.load(Relaxed)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_title(&self, _title: &str) {
|
pub fn set_title(&self, _title: &str) {
|
||||||
@@ -212,6 +217,7 @@ impl Window {
|
|||||||
NSDefaultRunLoopMode,
|
NSDefaultRunLoopMode,
|
||||||
true);
|
true);
|
||||||
if event == nil { break; }
|
if event == nil { break; }
|
||||||
|
NSApp().sendEvent_(event);
|
||||||
|
|
||||||
match event.get_type() {
|
match event.get_type() {
|
||||||
NSLeftMouseDown => { events.push(MouseInput(Pressed, LeftMouseButton)); },
|
NSLeftMouseDown => { events.push(MouseInput(Pressed, LeftMouseButton)); },
|
||||||
@@ -244,6 +250,7 @@ impl Window {
|
|||||||
NSDate::distantFuture(nil),
|
NSDate::distantFuture(nil),
|
||||||
NSDefaultRunLoopMode,
|
NSDefaultRunLoopMode,
|
||||||
false);
|
false);
|
||||||
|
NSApp().sendEvent_(event);
|
||||||
|
|
||||||
self.poll_events()
|
self.poll_events()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user