diff options
author | Glenn Watson <gw@intuitionlibrary.com> | 2014-12-17 14:49:11 +1000 |
---|---|---|
committer | Glenn Watson <gw@intuitionlibrary.com> | 2014-12-17 14:50:05 +1000 |
commit | 9dc5689eef87cace5e6ac6b5438928a1c99688c4 (patch) | |
tree | 224ec970788ed9d1f6830381946421a05d9c8741 /src/lib.rs | |
parent | 19d120b8b19d85e9cea5c3e8851b8809d072b8bd (diff) | |
download | glutin-9dc5689eef87cace5e6ac6b5438928a1c99688c4.tar.gz glutin-9dc5689eef87cace5e6ac6b5438928a1c99688c4.zip |
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.
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -473,6 +473,15 @@ impl Window { pub fn get_api(&self) -> Api { self.window.get_api() } + + /// Create a window proxy for this window, that can be freely + /// passed to different threads. + #[inline] + pub fn create_window_proxy(&self) -> WindowProxy { + WindowProxy { + proxy: self.window.create_window_proxy() + } + } } #[cfg(feature = "window")] @@ -482,6 +491,28 @@ impl gl_common::GlFunctionsSource for Window { } } +/// Represents a thread safe subset of operations that can be called +/// on a window. This structure can be safely cloned and sent between +/// threads. +/// +#[cfg(feature = "window")] +#[deriving(Clone)] +pub struct WindowProxy { + proxy: winimpl::WindowProxy, +} + +#[cfg(feature = "window")] +impl WindowProxy { + + /// Triggers a blocked event loop to wake up. This is + /// typically called when another thread wants to wake + /// up the blocked rendering thread to cause a refresh. + #[inline] + pub fn wakeup_event_loop(&self) { + self.proxy.wakeup_event_loop(); + } +} + /// Represents a headless OpenGL context. #[cfg(feature = "headless")] pub struct HeadlessContext { |