diff options
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 { |