[WIP] Have EventsLoopProxy::wakeup return a Result. Begin linux impl.

X11 and Wayland implementations are now half implemented, however both
still do not correctly break from the inner blocking event dispatch
functions when `wakeup` is called, which they should do.
This commit is contained in:
mitchmindtree 2017-05-25 23:19:13 +10:00
parent c8e791b402
commit f6587aed39
7 changed files with 149 additions and 34 deletions

View file

@ -3,9 +3,7 @@
use std::collections::VecDeque;
use std::sync::Arc;
use CreationError;
use CursorState;
use MouseCursor;
use {CreationError, CursorState, EventsLoopClosed, MouseCursor};
use libc;
use self::x11::XConnection;
@ -309,6 +307,11 @@ pub enum EventsLoop {
X(x11::EventsLoop)
}
pub enum EventsLoopProxy {
X(x11::EventsLoopProxy),
Wayland(wayland::EventsLoopProxy),
}
impl EventsLoop {
pub fn new() -> EventsLoop {
match *UNIX_BACKEND {
@ -326,6 +329,13 @@ impl EventsLoop {
}
}
pub fn create_proxy(&self) -> EventsLoopProxy {
match *self {
EventsLoop::Wayland(ref evlp) => EventsLoopProxy::Wayland(evlp.create_proxy()),
EventsLoop::X(ref evlp) => EventsLoopProxy::X(evlp.create_proxy()),
}
}
pub fn interrupt(&self) {
match *self {
EventsLoop::Wayland(ref evlp) => evlp.interrupt(),
@ -351,3 +361,12 @@ impl EventsLoop {
}
}
}
impl EventsLoopProxy {
pub fn wakeup(&self) -> Result<(), EventsLoopClosed> {
match *self {
EventsLoopProxy::Wayland(ref proxy) => proxy.wakeup(),
EventsLoopProxy::X(ref proxy) => proxy.wakeup(),
}
}
}