Upgrade mio to 0.7 (#1875)

* Upgrade `mio` to 0.7
Replaced `mio-extras` with `mio-misc`.

* Possible improvement

* Remove leftover

* Wrong rebase

* Fix typo
This commit is contained in:
daxpedda 2021-03-09 17:50:15 +01:00 committed by GitHub
parent ffe2143d14
commit 889258f538
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 32 deletions

View file

@ -15,6 +15,7 @@
- On Windows, fixed `WindowEvent::ThemeChanged` not properly firing and fixed `Window::theme` returning the wrong theme. - 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. - On Web, added support for `DeviceEvent::MouseMotion` to listen for relative mouse movements.
- Added `Window::drag_window`. Implemented on Windows, macOS, X11 and Wayland. - Added `Window::drag_window`. Implemented on Windows, macOS, X11 and Wayland.
- On X11, bump `mio` to 0.7.
# 0.24.0 (2020-12-09) # 0.24.0 (2020-12-09)

View file

@ -20,7 +20,7 @@ targets = ["i686-pc-windows-msvc", "x86_64-pc-windows-msvc", "i686-unknown-linux
default = ["x11", "wayland"] default = ["x11", "wayland"]
web-sys = ["web_sys", "wasm-bindgen", "instant/wasm-bindgen"] web-sys = ["web_sys", "wasm-bindgen", "instant/wasm-bindgen"]
stdweb = ["std_web", "instant/stdweb"] 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"] wayland = ["wayland-client", "sctk"]
[dependencies] [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] [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 } wayland-client = { version = "0.28", features = [ "dlopen"] , optional = true }
sctk = { package = "smithay-client-toolkit", version = "0.12.3", optional = true } sctk = { package = "smithay-client-toolkit", version = "0.12.3", optional = true }
mio = { version = "0.6", optional = true } mio = { version = "0.7", features = ["os-ext"], optional = true }
mio-extras = { version = "2.0", optional = true } mio-misc = { version = "1.0", optional = true }
x11-dl = { version = "2.18.5", optional = true } x11-dl = { version = "2.18.5", optional = true }
percent-encoding = { version = "2.0", optional = true } percent-encoding = { version = "2.0", optional = true }
parking_lot = { version = "0.11.0", optional = true } parking_lot = { version = "0.11.0", optional = true }

View file

@ -32,15 +32,20 @@ use std::{
ptr, ptr,
rc::Rc, rc::Rc,
slice, slice,
sync::mpsc::Receiver,
sync::{mpsc, Arc, Weak}, sync::{mpsc, Arc, Weak},
time::{Duration, Instant}, time::{Duration, Instant},
}; };
use libc::{self, setlocale, LC_CTYPE}; 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::{ use self::{
dnd::{Dnd, DndState}, dnd::{Dnd, DndState},
@ -57,8 +62,7 @@ use crate::{
}; };
const X_TOKEN: Token = Token(0); const X_TOKEN: Token = Token(0);
const USER_TOKEN: Token = Token(1); const USER_REDRAW_TOKEN: Token = Token(1);
const REDRAW_TOKEN: Token = Token(2);
pub struct EventLoopWindowTarget<T> { pub struct EventLoopWindowTarget<T> {
xconn: Arc<XConnection>, xconn: Arc<XConnection>,
@ -180,33 +184,16 @@ impl<T: 'static> EventLoop<T> {
mod_keymap.reset_from_x_connection(&xconn); mod_keymap.reset_from_x_connection(&xconn);
let poll = Poll::new().unwrap(); 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(); poll.registry()
let (redraw_sender, redraw_channel) = channel(); .register(&mut SourceFd(&xconn.x11_fd), X_TOKEN, Interest::READABLE)
.unwrap();
poll.register( let (user_sender, user_channel) = channel(queue.clone(), NotificationId::gen_next());
&EventedFd(&xconn.x11_fd),
X_TOKEN,
Ready::readable(),
PollOpt::level(),
)
.unwrap();
poll.register( let (redraw_sender, redraw_channel) = channel(queue, NotificationId::gen_next());
&user_channel,
USER_TOKEN,
Ready::readable(),
PollOpt::level(),
)
.unwrap();
poll.register(
&redraw_channel,
REDRAW_TOKEN,
Ready::readable(),
PollOpt::level(),
)
.unwrap();
let target = Rc::new(RootELW { let target = Rc::new(RootELW {
p: super::EventLoopWindowTarget::X(EventLoopWindowTarget { p: super::EventLoopWindowTarget::X(EventLoopWindowTarget {

View file

@ -10,7 +10,7 @@ use std::{
}; };
use libc; use libc;
use mio_extras::channel::Sender; use mio_misc::channel::Sender;
use parking_lot::Mutex; use parking_lot::Mutex;
use crate::{ use crate::{