diff options
author | Pierre Krieger <pierre.krieger1708@gmail.com> | 2014-08-07 17:54:04 +0200 |
---|---|---|
committer | Pierre Krieger <pierre.krieger1708@gmail.com> | 2014-08-07 17:54:04 +0200 |
commit | 76ebf39bcdec733bd11950ea8478c665878460a6 (patch) | |
tree | d758748fbbcb78dd9a36d347ff2f1b9b2799eb2a /src/win32 | |
parent | 5d997b618f1a16efb107028960b20e41a6b1bcce (diff) | |
parent | d2bd19bc21889e78c18bf64a570677e6330bbad0 (diff) | |
download | glutin-76ebf39bcdec733bd11950ea8478c665878460a6.tar.gz glutin-76ebf39bcdec733bd11950ea8478c665878460a6.zip |
Merge branch 'master' of https://github.com/tomaka/gl-init-rs
Diffstat (limited to 'src/win32')
-rw-r--r-- | src/win32/mod.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/win32/mod.rs b/src/win32/mod.rs index 891c783..f29bf89 100644 --- a/src/win32/mod.rs +++ b/src/win32/mod.rs @@ -133,6 +133,7 @@ impl Window { } } + // if one of the received events is `Closed`, setting `is_closed` to true if events.iter().find(|e| match e { &&::Closed => true, _ => false }).is_some() { use std::sync::atomics::Relaxed; self.is_closed.store(true, Relaxed); @@ -146,10 +147,21 @@ impl Window { pub fn wait_events(&self) -> Vec<Event> { match self.events_receiver.recv_opt() { Ok(ev) => { + // if the received event is `Closed`, setting `is_closed` to true + match ev { + ::Closed => { + use std::sync::atomics::Relaxed; + self.is_closed.store(true, Relaxed); + }, + _ => () + }; + + // looing for other possible events in the queue let mut result = self.poll_events(); result.insert(0, ev); result }, + Err(_) => { use std::sync::atomics::Relaxed; self.is_closed.store(true, Relaxed); @@ -187,6 +199,9 @@ impl Window { #[unsafe_destructor] impl Drop for Window { fn drop(&mut self) { + use std::ptr; + unsafe { ffi::wglMakeCurrent(ptr::mut_null(), ptr::mut_null()); } + unsafe { ffi::wglDeleteContext(self.context); } unsafe { ffi::DestroyWindow(self.window); } } } |