1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-26 23:04:49 +03:00

impl Evented for XCB Connection

This commit is contained in:
Wez Furlong 2018-03-04 09:48:37 -08:00
parent 88473e5a09
commit d571d555f1
2 changed files with 32 additions and 7 deletions

View File

@ -8,7 +8,7 @@ use sigchld;
use std::cell::RefCell;
use std::collections::HashMap;
use std::io;
use std::os::unix::io::{AsRawFd, RawFd};
use std::os::unix::io::RawFd;
use std::rc::Rc;
use std::sync::mpsc::TryRecvError;
use std::time::{Duration, Instant};
@ -78,12 +78,7 @@ impl GuiEventLoop {
let conn = Rc::new(Connection::new()?);
poll.register(
&EventedFd(&conn.conn().as_raw_fd()),
Token(TOK_XCB),
Ready::readable(),
PollOpt::level(),
)?;
poll.register(&*conn, Token(TOK_XCB), Ready::readable(), PollOpt::level())?;
let (fut_tx, fut_rx) = channel();
poll.register(

View File

@ -2,10 +2,14 @@ use egli;
use gl;
use glium;
use glium::backend::Backend;
use mio::{Evented, Poll, PollOpt, Ready, Token};
use mio::unix::EventedFd;
use std::cell::RefCell;
use std::io;
use std::mem;
use std::ops::Deref;
use std::os;
use std::os::unix::io::AsRawFd;
use std::ptr;
use std::rc::Rc;
use std::result;
@ -45,6 +49,32 @@ impl Deref for Connection {
}
}
impl Evented for Connection {
fn register(
&self,
poll: &Poll,
token: Token,
interest: Ready,
opts: PollOpt,
) -> io::Result<()> {
EventedFd(&self.conn.as_raw_fd()).register(poll, token, interest, opts)
}
fn reregister(
&self,
poll: &Poll,
token: Token,
interest: Ready,
opts: PollOpt,
) -> io::Result<()> {
EventedFd(&self.conn.as_raw_fd()).reregister(poll, token, interest, opts)
}
fn deregister(&self, poll: &Poll) -> io::Result<()> {
EventedFd(&self.conn.as_raw_fd()).deregister(poll)
}
}
#[link(name = "X11-xcb")]
extern "C" {
fn XGetXCBConnection(display: *mut x11::xlib::Display) -> *mut xcb::ffi::xcb_connection_t;