Skip to content

Commit

Permalink
port to xcb 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
rtbo authored and quininer committed Mar 19, 2022
1 parent 919ec0b commit b060caa
Show file tree
Hide file tree
Showing 4 changed files with 264 additions and 216 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ license = "MIT"
travis-ci = { repository = "quininer/x11-clipboard" }

[dependencies]
xcb = { version = "0.10.1", features = [ "thread", "xfixes" ] }
xcb = { version = "1.1.1", features = [ "xfixes" ] }
33 changes: 19 additions & 14 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
use xcb::{Atom, ReplyError};
use xcb::base::{ ConnError, GenericError };
use xcb::{ ConnError, ProtocolError };
use xcb::x;
use std::fmt;
use std::sync::mpsc::SendError;
use std::error::Error as StdError;

#[must_use]
#[derive(Debug)]
pub enum Error {
Set(SendError<Atom>),
Set(SendError<x::Atom>),
XcbConn(ConnError),
XcbGeneric(GenericError),
XcbReply(ReplyError),
XcbProtocol(ProtocolError),
Lock,
Timeout,
Owner,
UnexpectedType(Atom),
UnexpectedType(x::Atom),

#[doc(hidden)]
__Unknown
Expand All @@ -26,12 +25,11 @@ impl fmt::Display for Error {
match self {
Set(e) => write!(f, "XCB - couldn't set atom: {:?}", e),
XcbConn(e) => write!(f, "XCB connection error: {:?}", e),
XcbGeneric(e) => write!(f, "XCB generic error: {:?}", e),
XcbReply(e) => write!(f, "XCB reply error: {:?}", e),
XcbProtocol(e) => write!(f, "XCB protocol error: {:?}", e),
Lock => write!(f, "XCB: Lock is poisoned"),
Timeout => write!(f, "Selection timed out"),
Owner => write!(f, "Failed to set new owner of XCB selection"),
UnexpectedType(target) => write!(f, "Unexpected Reply type: {}", target),
UnexpectedType(target) => write!(f, "Unexpected Reply type: {:?}", target),
__Unknown => unreachable!()
}
}
Expand All @@ -43,8 +41,7 @@ impl StdError for Error {
match self {
Set(e) => Some(e),
XcbConn(e) => Some(e),
XcbGeneric(e) => Some(e),
XcbReply(e) => Some(e),
XcbProtocol(e) => Some(e),
Lock | Timeout | Owner | UnexpectedType(_) => None,
__Unknown => unreachable!()
}
Expand All @@ -61,7 +58,15 @@ macro_rules! define_from {
}
}

define_from!(Set from SendError<Atom>);
define_from!(Set from SendError<x::Atom>);
define_from!(XcbConn from ConnError);
define_from!(XcbGeneric from GenericError);
define_from!(XcbReply from ReplyError);
define_from!(XcbProtocol from ProtocolError);

impl From<xcb::Error> for Error {
fn from(err: xcb::Error) -> Error {
match err {
xcb::Error::Connection(err) => Error::XcbConn(err),
xcb::Error::Protocol(err) => Error::XcbProtocol(err),
}
}
}
Loading

0 comments on commit b060caa

Please sign in to comment.