diff options
author | Pierre Krieger <pierre.krieger1708@gmail.com> | 2015-06-16 13:48:08 +0200 |
---|---|---|
committer | Pierre Krieger <pierre.krieger1708@gmail.com> | 2015-06-16 14:03:58 +0200 |
commit | 39128dd7e11ffa05eb06933cb6e3ce0e750e8806 (patch) | |
tree | db182dc6912706438a39525bed7aa4e3150d4571 /src | |
parent | eb73c2514eefae08a5f1850ce7ee7178b903c4cf (diff) | |
download | glutin-39128dd7e11ffa05eb06933cb6e3ce0e750e8806.tar.gz glutin-39128dd7e11ffa05eb06933cb6e3ce0e750e8806.zip |
Remove the is_closed function
Diffstat (limited to 'src')
-rw-r--r-- | src/api/caca/mod.rs | 4 | ||||
-rw-r--r-- | src/api/cocoa/mod.rs | 8 | ||||
-rw-r--r-- | src/api/emscripten/mod.rs | 5 | ||||
-rw-r--r-- | src/api/wayland/mod.rs | 5 | ||||
-rw-r--r-- | src/api/win32/init.rs | 1 | ||||
-rw-r--r-- | src/api/win32/mod.rs | 33 | ||||
-rw-r--r-- | src/api/x11/window.rs | 8 | ||||
-rw-r--r-- | src/platform/linux/api_dispatch.rs | 7 | ||||
-rw-r--r-- | src/window.rs | 6 |
9 files changed, 4 insertions, 73 deletions
diff --git a/src/api/caca/mod.rs b/src/api/caca/mod.rs index 06a6931..953ce7d 100644 --- a/src/api/caca/mod.rs +++ b/src/api/caca/mod.rs @@ -129,10 +129,6 @@ impl Window { }) } - pub fn is_closed(&self) -> bool { - false - } - pub fn set_title(&self, title: &str) { } diff --git a/src/api/cocoa/mod.rs b/src/api/cocoa/mod.rs index ba5710d..de24c2b 100644 --- a/src/api/cocoa/mod.rs +++ b/src/api/cocoa/mod.rs @@ -59,7 +59,6 @@ static mut win_pressed: bool = false; static mut alt_pressed: bool = false; struct DelegateState { - is_closed: bool, context: IdRef, view: IdRef, window: IdRef, @@ -83,8 +82,6 @@ impl WindowDelegate { unsafe { let state: *mut libc::c_void = *this.get_ivar("glutinState"); let state = state as *mut DelegateState; - (*state).is_closed = true; - (*state).pending_events.lock().unwrap().push_back(Closed); } YES @@ -366,7 +363,6 @@ impl Window { } let ds = DelegateState { - is_closed: false, context: context.clone(), view: view.clone(), window: window.clone(), @@ -588,10 +584,6 @@ impl Window { } } - pub fn is_closed(&self) -> bool { - self.delegate.state.is_closed - } - pub fn set_title(&self, title: &str) { unsafe { let title = IdRef::new(NSString::alloc(nil).init_str(title)); diff --git a/src/api/emscripten/mod.rs b/src/api/emscripten/mod.rs index 48b31a9..9d4bb56 100644 --- a/src/api/emscripten/mod.rs +++ b/src/api/emscripten/mod.rs @@ -108,11 +108,6 @@ impl Window { }) } - pub fn is_closed(&self) -> bool { - use std::ptr; - unsafe { ffi::emscripten_is_webgl_context_lost(ptr::null()) != 0 } - } - pub fn set_title(&self, _title: &str) { } diff --git a/src/api/wayland/mod.rs b/src/api/wayland/mod.rs index b9bfa18..95996ca 100644 --- a/src/api/wayland/mod.rs +++ b/src/api/wayland/mod.rs @@ -184,11 +184,6 @@ impl Window { }) } - pub fn is_closed(&self) -> bool { - // TODO - false - } - pub fn set_title(&self, title: &str) { let ctitle = CString::new(title).unwrap(); self.shell_surface.set_title(&ctitle); diff --git a/src/api/win32/init.rs b/src/api/win32/init.rs index f46c395..7cb5433 100644 --- a/src/api/win32/init.rs +++ b/src/api/win32/init.rs @@ -257,7 +257,6 @@ unsafe fn init(title: Vec<u16>, builder: BuilderAttribs<'static>, window: real_window, context: context, events_receiver: events_receiver, - is_closed: AtomicBool::new(false), cursor_state: cursor_state, }) } diff --git a/src/api/win32/mod.rs b/src/api/win32/mod.rs index af339c5..5b0339a 100644 --- a/src/api/win32/mod.rs +++ b/src/api/win32/mod.rs @@ -47,9 +47,6 @@ pub struct Window { /// Receiver for the events dispatched by the window callback. events_receiver: Receiver<Event>, - /// True if a `Closed` event has been received. - is_closed: AtomicBool, - /// The current cursor state. cursor_state: Arc<Mutex<CursorState>>, } @@ -98,12 +95,6 @@ impl Window { } /// See the docs in the crate root file. - pub fn is_closed(&self) -> bool { - use std::sync::atomic::Ordering::Relaxed; - self.is_closed.load(Relaxed) - } - - /// See the docs in the crate root file. /// /// Calls SetWindowText on the HWND. pub fn set_title(&self, text: &str) { @@ -366,17 +357,7 @@ impl<'a> Iterator for PollEventsIterator<'a> { type Item = Event; fn next(&mut self) -> Option<Event> { - use events::Event::Closed; - - match self.window.events_receiver.try_recv() { - Ok(Closed) => { - use std::sync::atomic::Ordering::Relaxed; - self.window.is_closed.store(true, Relaxed); - Some(Closed) - }, - Ok(ev) => Some(ev), - Err(_) => None - } + self.window.events_receiver.try_recv().ok() } } @@ -388,17 +369,7 @@ impl<'a> Iterator for WaitEventsIterator<'a> { type Item = Event; fn next(&mut self) -> Option<Event> { - use events::Event::Closed; - - match self.window.events_receiver.recv() { - Ok(Closed) => { - use std::sync::atomic::Ordering::Relaxed; - self.window.is_closed.store(true, Relaxed); - Some(Closed) - }, - Ok(ev) => Some(ev), - Err(_) => None - } + self.window.events_receiver.recv().ok() } } diff --git a/src/api/x11/window.rs b/src/api/x11/window.rs index ba0fe52..41b74f5 100644 --- a/src/api/x11/window.rs +++ b/src/api/x11/window.rs @@ -263,9 +263,10 @@ impl<'a> Iterator for WaitEventsIterator<'a> { type Item = Event; fn next(&mut self) -> Option<Event> { + use std::sync::atomic::Ordering::Relaxed; use std::mem; - while !self.window.is_closed() { + while !self.window.is_closed.load(Relaxed) { if let Some(ev) = self.window.pending_events.lock().unwrap().pop_front() { return Some(ev); } @@ -596,11 +597,6 @@ impl Window { Ok(window) } - pub fn is_closed(&self) -> bool { - use std::sync::atomic::Ordering::Relaxed; - self.is_closed.load(Relaxed) - } - pub fn set_title(&self, title: &str) { with_c_str(title, |title| unsafe { (self.x.display.xlib.XStoreName)(self.x.display.display, self.x.window, title); diff --git a/src/platform/linux/api_dispatch.rs b/src/platform/linux/api_dispatch.rs index d04a1fb..795b89f 100644 --- a/src/platform/linux/api_dispatch.rs +++ b/src/platform/linux/api_dispatch.rs @@ -154,13 +154,6 @@ impl Window { } } - pub fn is_closed(&self) -> bool { - match self { - &Window::X(ref w) => w.is_closed(), - &Window::Wayland(ref w) => w.is_closed() - } - } - pub fn set_title(&self, title: &str) { match self { &Window::X(ref w) => w.set_title(title), diff --git a/src/window.rs b/src/window.rs index 578c237..b42a16f 100644 --- a/src/window.rs +++ b/src/window.rs @@ -224,12 +224,6 @@ impl Window { builder.build() } - /// Returns true if the window has previously been closed by the user. - #[inline] - pub fn is_closed(&self) -> bool { - self.window.is_closed() - } - /// Modifies the title of the window. /// /// This is a no-op if the window has already been closed. |