diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e5000e7..cdd48cce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - On Windows, fixed `WindowEvent::ThemeChanged` not properly firing and fixed `Window::theme` returning the wrong theme. - On Web, added support for `DeviceEvent::MouseMotion` to listen for relative mouse movements. - Added `Window::drag_window`. Implemented on Windows, macOS, X11 and Wayland. +- On X11, bump `mio` to 0.7. # 0.24.0 (2020-12-09) diff --git a/Cargo.toml b/Cargo.toml index 68e85a1c..1af7d4d2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ targets = ["i686-pc-windows-msvc", "x86_64-pc-windows-msvc", "i686-unknown-linux default = ["x11", "wayland"] web-sys = ["web_sys", "wasm-bindgen", "instant/wasm-bindgen"] stdweb = ["std_web", "instant/stdweb"] -x11 = ["x11-dl", "mio", "mio-extras", "percent-encoding", "parking_lot"] +x11 = ["x11-dl", "mio", "mio-misc", "percent-encoding", "parking_lot"] wayland = ["wayland-client", "sctk"] [dependencies] @@ -87,8 +87,8 @@ features = [ [target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd", target_os = "netbsd"))'.dependencies] wayland-client = { version = "0.28", features = [ "dlopen"] , optional = true } sctk = { package = "smithay-client-toolkit", version = "0.12.3", optional = true } -mio = { version = "0.6", optional = true } -mio-extras = { version = "2.0", optional = true } +mio = { version = "0.7", features = ["os-ext"], optional = true } +mio-misc = { version = "1.0", optional = true } x11-dl = { version = "2.18.5", optional = true } percent-encoding = { version = "2.0", optional = true } parking_lot = { version = "0.11.0", optional = true } diff --git a/src/platform_impl/linux/x11/mod.rs b/src/platform_impl/linux/x11/mod.rs index d06936c5..11b5d9ec 100644 --- a/src/platform_impl/linux/x11/mod.rs +++ b/src/platform_impl/linux/x11/mod.rs @@ -32,15 +32,20 @@ use std::{ ptr, rc::Rc, slice, + sync::mpsc::Receiver, sync::{mpsc, Arc, Weak}, time::{Duration, Instant}, }; use libc::{self, setlocale, LC_CTYPE}; -use mio::{unix::EventedFd, Events, Poll, PollOpt, Ready, Token}; +use mio::{unix::SourceFd, Events, Interest, Poll, Token, Waker}; -use mio_extras::channel::{channel, Receiver, SendError, Sender}; +use mio_misc::{ + channel::{channel, SendError, Sender}, + queue::NotificationQueue, + NotificationId, +}; use self::{ dnd::{Dnd, DndState}, @@ -57,8 +62,7 @@ use crate::{ }; const X_TOKEN: Token = Token(0); -const USER_TOKEN: Token = Token(1); -const REDRAW_TOKEN: Token = Token(2); +const USER_REDRAW_TOKEN: Token = Token(1); pub struct EventLoopWindowTarget { xconn: Arc, @@ -180,33 +184,16 @@ impl EventLoop { mod_keymap.reset_from_x_connection(&xconn); let poll = Poll::new().unwrap(); + let waker = Arc::new(Waker::new(poll.registry(), USER_REDRAW_TOKEN).unwrap()); + let queue = Arc::new(NotificationQueue::new(waker)); - let (user_sender, user_channel) = channel(); - let (redraw_sender, redraw_channel) = channel(); + poll.registry() + .register(&mut SourceFd(&xconn.x11_fd), X_TOKEN, Interest::READABLE) + .unwrap(); - poll.register( - &EventedFd(&xconn.x11_fd), - X_TOKEN, - Ready::readable(), - PollOpt::level(), - ) - .unwrap(); + let (user_sender, user_channel) = channel(queue.clone(), NotificationId::gen_next()); - poll.register( - &user_channel, - USER_TOKEN, - Ready::readable(), - PollOpt::level(), - ) - .unwrap(); - - poll.register( - &redraw_channel, - REDRAW_TOKEN, - Ready::readable(), - PollOpt::level(), - ) - .unwrap(); + let (redraw_sender, redraw_channel) = channel(queue, NotificationId::gen_next()); let target = Rc::new(RootELW { p: super::EventLoopWindowTarget::X(EventLoopWindowTarget { diff --git a/src/platform_impl/linux/x11/window.rs b/src/platform_impl/linux/x11/window.rs index b4ca7c40..3f720f0b 100644 --- a/src/platform_impl/linux/x11/window.rs +++ b/src/platform_impl/linux/x11/window.rs @@ -10,7 +10,7 @@ use std::{ }; use libc; -use mio_extras::channel::Sender; +use mio_misc::channel::Sender; use parking_lot::Mutex; use crate::{