Struct x11rb::xcb_ffi::XCBConnection
source · pub struct XCBConnection {
conn: XcbConnectionWrapper,
setup: Setup,
ext_mgr: Mutex<ExtensionManager>,
errors: PendingErrors,
maximum_sequence_received: AtomicU64,
}
Expand description
A connection to an X11 server.
This type wraps *mut xcb_connection_t
that is provided by libxcb. It provides a rust
interface to this C library.
Fields§
§conn: XcbConnectionWrapper
§setup: Setup
§ext_mgr: Mutex<ExtensionManager>
§errors: PendingErrors
§maximum_sequence_received: AtomicU64
Implementations§
source§impl XCBConnection
impl XCBConnection
unsafe fn connection_error_from_connection( c: *mut xcb_connection_t, ) -> ConnectionError
fn connection_error_from_c_error(error: c_int) -> ConnectionError
fn connect_error_from_c_error(error: c_int) -> ConnectError
sourcepub fn connect(
dpy_name: Option<&CStr>,
) -> Result<(XCBConnection, usize), ConnectError>
pub fn connect( dpy_name: Option<&CStr>, ) -> Result<(XCBConnection, usize), ConnectError>
Establish a new connection to an X11 server.
If a dpy_name
is provided, it describes the display that should be connected to, for
example 127.0.0.1:1
. If no value is provided, the $DISPLAY
environment variable is
used.
sourcepub unsafe fn from_raw_xcb_connection(
ptr: *mut c_void,
should_drop: bool,
) -> Result<XCBConnection, ConnectError>
pub unsafe fn from_raw_xcb_connection( ptr: *mut c_void, should_drop: bool, ) -> Result<XCBConnection, ConnectError>
Create a connection wrapper for a raw libxcb xcb_connection_t
.
xcb_disconnect
is called on drop only if should_drop
is true
.
If this function returns an Err()
and should_drop
was true, then
xcb_disconnect
was already called.
§Safety
If should_drop
is false
, the connection must live longer than the returned
XCBConnection
. If should_drop
is true
, the returned XCBConnection
will
take the ownership of the connection.
unsafe fn parse_setup(setup: *const xcb_setup_t) -> Result<Setup, ParseError>
fn send_request( &self, bufs: &[IoSlice<'_>], fds: Vec<RawFdContainer>, has_reply: bool, reply_has_fds: bool, ) -> Result<SequenceNumber, ConnectionError>
sourcepub fn has_error(&self) -> Option<ConnectionError>
pub fn has_error(&self) -> Option<ConnectionError>
Check if the underlying XCB connection is in an error state.
sourcepub fn get_raw_xcb_connection(&self) -> *mut c_void
pub fn get_raw_xcb_connection(&self) -> *mut c_void
Get access to the raw libxcb xcb_connection_t
.
The returned pointer is valid for as long as the original object was not dropped. No ownerhsip is transferred.
sourcefn poll_for_reply(&self, sequence: SequenceNumber) -> Result<Option<CSlice>, ()>
fn poll_for_reply(&self, sequence: SequenceNumber) -> Result<Option<CSlice>, ()>
Check if a reply to the given request already received.
Return Err(()) when the reply was not yet received. Returns Ok(None) when there can be no reply. Returns Ok(buffer) with the reply if there is one (this buffer can be an error or a reply).
unsafe fn wrap_reply( &self, reply: *const u8, sequence: SequenceNumber, ) -> CSlice
unsafe fn wrap_error( &self, error: *const u8, sequence: SequenceNumber, ) -> CSlice
unsafe fn wrap_event( &self, event: *mut u8, ) -> Result<RawEventAndSeqNumber, ParseError>
sourcefn reconstruct_full_sequence(&self, seqno: u32) -> SequenceNumber
fn reconstruct_full_sequence(&self, seqno: u32) -> SequenceNumber
Reconstruct a full sequence number based on a partial value.
The assumption for the algorithm here is that the given sequence number was received recently. Thus, the maximum sequence number that was received so far is used to fill in the missing bytes for the result.