From 9dc5689eef87cace5e6ac6b5438928a1c99688c4 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Wed, 17 Dec 2014 14:49:11 +1000 Subject: Introduce a WindowProxy for accessing a subset of functionality from other threads. This currently provides a way for other threads to wakeup a blocked event loop on X11. Other platforms have stub functions that need to be implemented. This is similar to the functionality of glfwPostEmptyEvent. --- src/osx/mod.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/osx') diff --git a/src/osx/mod.rs b/src/osx/mod.rs index c69486a..3f9da82 100644 --- a/src/osx/mod.rs +++ b/src/osx/mod.rs @@ -74,6 +74,16 @@ impl Window { } } +#[cfg(feature = "window")] +#[deriving(Clone)] +pub struct WindowProxy; + +impl WindowProxy { + pub fn wakeup_event_loop(&self) { + // TODO + } +} + extern fn window_should_close(this: id, _: id) -> id { unsafe { let mut stored_value = ptr::null_mut(); @@ -278,6 +288,10 @@ impl Window { unimplemented!() } + pub fn create_window_proxy(&self) -> WindowProxy { + WindowProxy + } + pub fn poll_events(&self) -> Vec { let mut events = Vec::new(); -- cgit v1.2.3 From 2c150143d8da8bded7d9441ef08f67eab51db7c4 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Thu, 18 Dec 2014 14:22:58 +1000 Subject: Add mac implementation of wakeup_event_loop. --- src/osx/mod.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/osx') diff --git a/src/osx/mod.rs b/src/osx/mod.rs index 3f9da82..22ae432 100644 --- a/src/osx/mod.rs +++ b/src/osx/mod.rs @@ -80,7 +80,23 @@ pub struct WindowProxy; impl WindowProxy { pub fn wakeup_event_loop(&self) { - // TODO + unsafe { + let pool = NSAutoreleasePool::new(nil); + let event = + NSEvent::otherEventWithType_location_modifierFlags_timestamp_windowNumber_context_subtype_data1_data2( + nil, + NSApplicationDefined, + NSPoint::new(0.0, 0.0), + 0, + 0.0, + 0, + ptr::null_mut(), + 0, + 0, + 0); + NSApp().postEvent_atStart_(event, true); + pool.drain(); + } } } -- cgit v1.2.3