Skip to content

Commit

Permalink
Make sure x11rb doesn't appear in public interface
Browse files Browse the repository at this point in the history
  • Loading branch information
notgull committed Jan 5, 2023
1 parent f1078b4 commit a6d9f45
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions src/platform_impl/linux/x11/xdisplay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ use std::{
mem::ManuallyDrop,
os::raw::c_int,
ptr::{self, NonNull},
sync::{Arc, Mutex},
sync::Mutex,
};

use x11rb::errors::{ConnectError, ReplyError};
use x11rb::resource_manager;
use x11rb::xcb_ffi::XCBConnection;
use x11rb::{connection::Connection, protocol::xproto};
Expand Down Expand Up @@ -112,15 +111,16 @@ impl XConnection {
}

// Create the x11rb wrapper.
unsafe { XCBConnection::from_raw_xcb_connection(raw_conn, false)? }
unsafe { XCBConnection::from_raw_xcb_connection(raw_conn, false) }
.expect("Failed to create x11rb connection")
};

// Begin loading the atoms.
let atom_cookie = Atoms::request(&connection).expect("Failed to load atoms");

// Load the resource manager database.
let database = resource_manager::new_from_default(&connection)
.map_err(|err| XNotSupported::DatabaseError(err.into()))?;
.expect("Failed to load resource manager database");

// Finish loading the atoms.
let atoms = atom_cookie.reply().expect("Failed to load atoms");
Expand Down Expand Up @@ -215,12 +215,6 @@ pub enum XNotSupported {
/// Failed to load one or several shared libraries.
LibraryOpenError(ffi::OpenError),

/// Failed to open the `libxcb` wrapper.
XcbOpenError(Arc<x11rb::errors::ConnectError>),

/// Failed to open the X11 database.
DatabaseError(Arc<ReplyError>),

/// Connecting to the X server with `XOpenDisplay` failed.
XOpenDisplayFailed, // TODO: add better message
}
Expand All @@ -232,19 +226,10 @@ impl From<ffi::OpenError> for XNotSupported {
}
}

impl From<ConnectError> for XNotSupported {
#[inline]
fn from(err: ConnectError) -> XNotSupported {
XNotSupported::XcbOpenError(err.into())
}
}

impl XNotSupported {
fn description(&self) -> &'static str {
match self {
XNotSupported::LibraryOpenError(_) => "Failed to load one of xlib's shared libraries",
XNotSupported::XcbOpenError(_) => "Failed to open the libxcb wrapper",
XNotSupported::DatabaseError(_) => "Failed to open the X11 database",
XNotSupported::XOpenDisplayFailed => "Failed to open connection to X server",
}
}
Expand Down

0 comments on commit a6d9f45

Please sign in to comment.