use crate::base::{self, BaseError, BaseEvent, GeEvent, Raw, Reply, WiredIn, WiredOut, Xid};
use crate::ext;
use crate::ffi::base::*;
use crate::ffi::ext::*;
use crate::lat1_str::{Lat1Str, Lat1String, Lat1StrF};
use crate::xproto;
use crate::xproto::PropEl;
use bitflags::bitflags;
use libc::{self, iovec};
use std::convert::TryInto;
use std::hash::{Hash, Hasher};
use std::os::unix::io::RawFd;
pub const XNAME: &str = "XFree86-DRI";
pub const MAJOR_VERSION: u32 = 4;
pub const MINOR_VERSION: u32 = 1;
pub const VERSION_STRING: &str = "4.1";
pub(crate) static mut FFI_EXT: xcb_extension_t = xcb_extension_t {
name: "XFree86-DRI\0".as_ptr() as *const _,
global_id: 0,
};
pub fn prefetch_extension_data(conn: &base::Connection) {
unsafe {
xcb_prefetch_extension_data(conn.get_raw_conn(), &mut FFI_EXT as *mut _);
}
}
pub fn get_extension_data(conn: &base::Connection) -> std::option::Option<ext::ExtensionData> {
unsafe {
let reply = xcb_get_extension_data(conn.get_raw_conn(), &mut FFI_EXT as *mut _);
assert!(!reply.is_null(), "Could not fetch XF86Dri extension data");
let reply = xproto::QueryExtensionReply::from_raw(reply);
if !reply.present() {
std::mem::forget(reply);
return None;
}
let res = ext::ExtensionData{
ext: ext::Extension::Xf86Dri,
major_opcode: reply.major_opcode(),
first_event: reply.first_event(),
first_error: reply.first_error(),
};
std::mem::forget(reply);
Some(res)
}
}
#[derive(Copy, Clone, Debug)]
#[repr(C)]
pub struct DrmClipRect {
pub x1: i16,
pub y1: i16,
pub x2: i16,
pub x3: i16,
}
#[test]
fn test_sizeof_drm_clip_rect() {
assert_eq!(std::mem::size_of::<DrmClipRect>(), 8);
}
impl base::WiredOut for DrmClipRect {
fn wire_len(&self) -> usize { 8 }
fn serialize(&self, wire_buf: &mut [u8]) -> usize {
let me = unsafe {
std::slice::from_raw_parts(self as *const DrmClipRect as _, 8)
};
(&mut wire_buf[..me.len()]).copy_from_slice(me);
8
}
}
impl base::WiredIn for DrmClipRect {
type Params = ();
unsafe fn compute_wire_len(_ptr: *const u8, _params: ()) -> usize { 8 }
unsafe fn unserialize(ptr: *const u8, _params: (), offset: &mut usize) -> Self {
*offset += 8;
*(ptr as *const DrmClipRect)
}
}
pub(crate) fn request_name(opcode: u16) -> std::option::Option<&'static str> {
match opcode {
0 => Some("xf86dri::QueryVersion"),
1 => Some("xf86dri::QueryDirectRenderingCapable"),
2 => Some("xf86dri::OpenConnection"),
3 => Some("xf86dri::CloseConnection"),
4 => Some("xf86dri::GetClientDriverName"),
5 => Some("xf86dri::CreateContext"),
6 => Some("xf86dri::DestroyContext"),
7 => Some("xf86dri::CreateDrawable"),
8 => Some("xf86dri::DestroyDrawable"),
9 => Some("xf86dri::GetDrawableInfo"),
10 => Some("xf86dri::GetDeviceInfo"),
11 => Some("xf86dri::AuthConnection"),
_ => None,
}
}
pub struct QueryVersionReply {
raw: *const u8,
}
impl QueryVersionReply {
fn wire_ptr(&self) -> *const u8 {
self.raw
}
fn wire_len(&self) -> usize {
(32 + self.length() * 4) as _
}
pub fn response_type(&self) -> u8 {
unsafe {
let offset = 0usize;
let ptr = self.wire_ptr().add(offset) as *const u8;
base::value_from_ptr(ptr)
}
}
pub fn sequence(&self) -> u16 {
unsafe {
let offset = 2usize;
let ptr = self.wire_ptr().add(offset) as *const u16;
base::value_from_ptr(ptr)
}
}
pub fn length(&self) -> u32 {
unsafe {
let offset = 4usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn dri_major_version(&self) -> u16 {
unsafe {
let offset = 8usize;
let ptr = self.wire_ptr().add(offset) as *const u16;
base::value_from_ptr(ptr)
}
}
pub fn dri_minor_version(&self) -> u16 {
unsafe {
let offset = 10usize;
let ptr = self.wire_ptr().add(offset) as *const u16;
base::value_from_ptr(ptr)
}
}
pub fn dri_minor_patch(&self) -> u32 {
unsafe {
let offset = 12usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
}
impl base::Reply for QueryVersionReply {
unsafe fn from_raw(raw: *const u8) -> Self {
Self { raw }
}
unsafe fn into_raw(self) -> *const u8 {
let raw = self.raw;
std::mem::forget(self);
raw
}
}
impl std::fmt::Debug for QueryVersionReply {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("QueryVersionReply")
.field("response_type", &self.response_type())
.field("pad", &1)
.field("sequence", &self.sequence())
.field("length", &self.length())
.field("dri_major_version", &self.dri_major_version())
.field("dri_minor_version", &self.dri_minor_version())
.field("dri_minor_patch", &self.dri_minor_patch())
.finish()
}
}
impl Drop for QueryVersionReply {
fn drop(&mut self) {
unsafe { libc::free(self.raw as *mut _); }
}
}
unsafe impl std::marker::Send for QueryVersionReply {}
unsafe impl std::marker::Sync for QueryVersionReply {}
#[derive(Debug)]
pub struct QueryVersionCookie {
seq: u64,
}
#[derive(Debug)]
pub struct QueryVersionCookieUnchecked {
seq: u64,
}
impl base::Cookie for QueryVersionCookie {
unsafe fn from_sequence(seq: u64) -> Self {
QueryVersionCookie { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieChecked for QueryVersionCookie {
}
unsafe impl base::CookieWithReplyChecked for QueryVersionCookie {
type Reply = QueryVersionReply;
}
impl base::Cookie for QueryVersionCookieUnchecked {
unsafe fn from_sequence(seq: u64) -> Self {
QueryVersionCookieUnchecked { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieWithReplyUnchecked for QueryVersionCookieUnchecked {
type Reply = QueryVersionReply;
}
#[derive(Clone, Debug)]
pub struct QueryVersion {
}
unsafe impl base::RawRequest for QueryVersion {
fn raw_request(&self, c: &base::Connection, checked: bool) -> u64 { unsafe {
let mut protocol_request = xcb_protocol_request_t {
count: 2,
ext: (&mut FFI_EXT) as *mut _,
opcode: 0,
isvoid: 0,
};
let mut sections: [iovec; 4] = [iovec {
iov_base: std::ptr::null_mut(),
iov_len: 0,
}; 4];
let buf0: &mut [u8] = &mut [0; 4];
sections[2].iov_base = buf0.as_mut_ptr() as *mut _;
sections[2].iov_len = 4;
sections[3].iov_len = base::align_pad(sections[2].iov_len, 4);
let flags = if checked { base::RequestFlags::CHECKED } else { base::RequestFlags::NONE };
xcb_send_request64(
c.get_raw_conn(),
flags.bits() as _,
sections.as_mut_ptr().add(2),
&mut protocol_request as *mut _,
)
}
}}
impl base::Request for QueryVersion {
type Cookie = QueryVersionCookie;
const IS_VOID: bool = false;
}
impl base::RequestWithReply for QueryVersion {
type Reply = QueryVersionReply;
type Cookie = QueryVersionCookie;
type CookieUnchecked = QueryVersionCookieUnchecked;
}
pub struct QueryDirectRenderingCapableReply {
raw: *const u8,
}
impl QueryDirectRenderingCapableReply {
fn wire_ptr(&self) -> *const u8 {
self.raw
}
fn wire_len(&self) -> usize {
(32 + self.length() * 4) as _
}
pub fn response_type(&self) -> u8 {
unsafe {
let offset = 0usize;
let ptr = self.wire_ptr().add(offset) as *const u8;
base::value_from_ptr(ptr)
}
}
pub fn sequence(&self) -> u16 {
unsafe {
let offset = 2usize;
let ptr = self.wire_ptr().add(offset) as *const u16;
base::value_from_ptr(ptr)
}
}
pub fn length(&self) -> u32 {
unsafe {
let offset = 4usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn is_capable(&self) -> bool {
let val = unsafe { *(self.wire_ptr().add(8usize)) };
val != 0
}
}
impl base::Reply for QueryDirectRenderingCapableReply {
unsafe fn from_raw(raw: *const u8) -> Self {
Self { raw }
}
unsafe fn into_raw(self) -> *const u8 {
let raw = self.raw;
std::mem::forget(self);
raw
}
}
impl std::fmt::Debug for QueryDirectRenderingCapableReply {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("QueryDirectRenderingCapableReply")
.field("response_type", &self.response_type())
.field("pad", &1)
.field("sequence", &self.sequence())
.field("length", &self.length())
.field("is_capable", &self.is_capable())
.finish()
}
}
impl Drop for QueryDirectRenderingCapableReply {
fn drop(&mut self) {
unsafe { libc::free(self.raw as *mut _); }
}
}
unsafe impl std::marker::Send for QueryDirectRenderingCapableReply {}
unsafe impl std::marker::Sync for QueryDirectRenderingCapableReply {}
#[derive(Debug)]
pub struct QueryDirectRenderingCapableCookie {
seq: u64,
}
#[derive(Debug)]
pub struct QueryDirectRenderingCapableCookieUnchecked {
seq: u64,
}
impl base::Cookie for QueryDirectRenderingCapableCookie {
unsafe fn from_sequence(seq: u64) -> Self {
QueryDirectRenderingCapableCookie { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieChecked for QueryDirectRenderingCapableCookie {
}
unsafe impl base::CookieWithReplyChecked for QueryDirectRenderingCapableCookie {
type Reply = QueryDirectRenderingCapableReply;
}
impl base::Cookie for QueryDirectRenderingCapableCookieUnchecked {
unsafe fn from_sequence(seq: u64) -> Self {
QueryDirectRenderingCapableCookieUnchecked { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieWithReplyUnchecked for QueryDirectRenderingCapableCookieUnchecked {
type Reply = QueryDirectRenderingCapableReply;
}
#[derive(Clone, Debug)]
pub struct QueryDirectRenderingCapable {
pub screen: u32,
}
unsafe impl base::RawRequest for QueryDirectRenderingCapable {
fn raw_request(&self, c: &base::Connection, checked: bool) -> u64 { unsafe {
let mut protocol_request = xcb_protocol_request_t {
count: 2,
ext: (&mut FFI_EXT) as *mut _,
opcode: 1,
isvoid: 0,
};
let mut sections: [iovec; 4] = [iovec {
iov_base: std::ptr::null_mut(),
iov_len: 0,
}; 4];
let buf0: &mut [u8] = &mut [0; 8];
self.screen.serialize(&mut buf0[4 .. ]);
sections[2].iov_base = buf0.as_mut_ptr() as *mut _;
sections[2].iov_len = 8;
sections[3].iov_len = base::align_pad(sections[2].iov_len, 4);
let flags = if checked { base::RequestFlags::CHECKED } else { base::RequestFlags::NONE };
xcb_send_request64(
c.get_raw_conn(),
flags.bits() as _,
sections.as_mut_ptr().add(2),
&mut protocol_request as *mut _,
)
}
}}
impl base::Request for QueryDirectRenderingCapable {
type Cookie = QueryDirectRenderingCapableCookie;
const IS_VOID: bool = false;
}
impl base::RequestWithReply for QueryDirectRenderingCapable {
type Reply = QueryDirectRenderingCapableReply;
type Cookie = QueryDirectRenderingCapableCookie;
type CookieUnchecked = QueryDirectRenderingCapableCookieUnchecked;
}
pub struct OpenConnectionReply {
raw: *const u8,
}
impl OpenConnectionReply {
fn wire_ptr(&self) -> *const u8 {
self.raw
}
fn wire_len(&self) -> usize {
(32 + self.length() * 4) as _
}
unsafe fn compute_len(ptr: *const u8, _params: ()) -> usize {
let mut sz = 0;
sz += 1usize;
sz += 1usize;
sz += 2usize;
sz += 4usize;
sz += 4usize;
sz += 4usize;
let bus_id_len = *(ptr.add(sz) as *const u32);
sz += 4usize;
sz += 12usize;
sz += (bus_id_len as usize);
sz
}
pub fn response_type(&self) -> u8 {
unsafe {
let offset = 0usize;
let ptr = self.wire_ptr().add(offset) as *const u8;
base::value_from_ptr(ptr)
}
}
pub fn sequence(&self) -> u16 {
unsafe {
let offset = 2usize;
let ptr = self.wire_ptr().add(offset) as *const u16;
base::value_from_ptr(ptr)
}
}
pub fn length(&self) -> u32 {
unsafe {
let offset = 4usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn sarea_handle_low(&self) -> u32 {
unsafe {
let offset = 8usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn sarea_handle_high(&self) -> u32 {
unsafe {
let offset = 12usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
fn bus_id_len(&self) -> u32 {
unsafe {
let offset = 16usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn bus_id(&self) -> &Lat1Str {
unsafe {
let offset = 32usize;
let len = (self.bus_id_len() as usize) as _;
let ptr = self.wire_ptr().add(offset);
let bytes = std::slice::from_raw_parts(ptr, len);
Lat1Str::from_bytes(bytes)
}
}
}
impl base::Reply for OpenConnectionReply {
unsafe fn from_raw(raw: *const u8) -> Self {
Self { raw }
}
unsafe fn into_raw(self) -> *const u8 {
let raw = self.raw;
std::mem::forget(self);
raw
}
}
impl std::fmt::Debug for OpenConnectionReply {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("OpenConnectionReply")
.field("response_type", &self.response_type())
.field("pad", &1)
.field("sequence", &self.sequence())
.field("length", &self.length())
.field("sarea_handle_low", &self.sarea_handle_low())
.field("sarea_handle_high", &self.sarea_handle_high())
.field("bus_id_len", &self.bus_id_len())
.field("pad", &12)
.field("bus_id", &self.bus_id())
.finish()
}
}
impl Drop for OpenConnectionReply {
fn drop(&mut self) {
unsafe { libc::free(self.raw as *mut _); }
}
}
unsafe impl std::marker::Send for OpenConnectionReply {}
unsafe impl std::marker::Sync for OpenConnectionReply {}
#[derive(Debug)]
pub struct OpenConnectionCookie {
seq: u64,
}
#[derive(Debug)]
pub struct OpenConnectionCookieUnchecked {
seq: u64,
}
impl base::Cookie for OpenConnectionCookie {
unsafe fn from_sequence(seq: u64) -> Self {
OpenConnectionCookie { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieChecked for OpenConnectionCookie {
}
unsafe impl base::CookieWithReplyChecked for OpenConnectionCookie {
type Reply = OpenConnectionReply;
}
impl base::Cookie for OpenConnectionCookieUnchecked {
unsafe fn from_sequence(seq: u64) -> Self {
OpenConnectionCookieUnchecked { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieWithReplyUnchecked for OpenConnectionCookieUnchecked {
type Reply = OpenConnectionReply;
}
#[derive(Clone, Debug)]
pub struct OpenConnection {
pub screen: u32,
}
unsafe impl base::RawRequest for OpenConnection {
fn raw_request(&self, c: &base::Connection, checked: bool) -> u64 { unsafe {
let mut protocol_request = xcb_protocol_request_t {
count: 2,
ext: (&mut FFI_EXT) as *mut _,
opcode: 2,
isvoid: 0,
};
let mut sections: [iovec; 4] = [iovec {
iov_base: std::ptr::null_mut(),
iov_len: 0,
}; 4];
let buf0: &mut [u8] = &mut [0; 8];
self.screen.serialize(&mut buf0[4 .. ]);
sections[2].iov_base = buf0.as_mut_ptr() as *mut _;
sections[2].iov_len = 8;
sections[3].iov_len = base::align_pad(sections[2].iov_len, 4);
let flags = if checked { base::RequestFlags::CHECKED } else { base::RequestFlags::NONE };
xcb_send_request64(
c.get_raw_conn(),
flags.bits() as _,
sections.as_mut_ptr().add(2),
&mut protocol_request as *mut _,
)
}
}}
impl base::Request for OpenConnection {
type Cookie = OpenConnectionCookie;
const IS_VOID: bool = false;
}
impl base::RequestWithReply for OpenConnection {
type Reply = OpenConnectionReply;
type Cookie = OpenConnectionCookie;
type CookieUnchecked = OpenConnectionCookieUnchecked;
}
#[derive(Clone, Debug)]
pub struct CloseConnection {
pub screen: u32,
}
unsafe impl base::RawRequest for CloseConnection {
fn raw_request(&self, c: &base::Connection, checked: bool) -> u64 { unsafe {
let mut protocol_request = xcb_protocol_request_t {
count: 2,
ext: (&mut FFI_EXT) as *mut _,
opcode: 3,
isvoid: 1,
};
let mut sections: [iovec; 4] = [iovec {
iov_base: std::ptr::null_mut(),
iov_len: 0,
}; 4];
let buf0: &mut [u8] = &mut [0; 8];
self.screen.serialize(&mut buf0[4 .. ]);
sections[2].iov_base = buf0.as_mut_ptr() as *mut _;
sections[2].iov_len = 8;
sections[3].iov_len = base::align_pad(sections[2].iov_len, 4);
let flags = if checked { base::RequestFlags::CHECKED } else { base::RequestFlags::NONE };
xcb_send_request64(
c.get_raw_conn(),
flags.bits() as _,
sections.as_mut_ptr().add(2),
&mut protocol_request as *mut _,
)
}
}}
impl base::Request for CloseConnection {
type Cookie = base::VoidCookie;
const IS_VOID: bool = true;
}
impl base::RequestWithoutReply for CloseConnection {
}
pub struct GetClientDriverNameReply {
raw: *const u8,
}
impl GetClientDriverNameReply {
fn wire_ptr(&self) -> *const u8 {
self.raw
}
fn wire_len(&self) -> usize {
(32 + self.length() * 4) as _
}
unsafe fn compute_len(ptr: *const u8, _params: ()) -> usize {
let mut sz = 0;
sz += 1usize;
sz += 1usize;
sz += 2usize;
sz += 4usize;
sz += 4usize;
sz += 4usize;
sz += 4usize;
let client_driver_name_len = *(ptr.add(sz) as *const u32);
sz += 4usize;
sz += 8usize;
sz += (client_driver_name_len as usize);
sz
}
pub fn response_type(&self) -> u8 {
unsafe {
let offset = 0usize;
let ptr = self.wire_ptr().add(offset) as *const u8;
base::value_from_ptr(ptr)
}
}
pub fn sequence(&self) -> u16 {
unsafe {
let offset = 2usize;
let ptr = self.wire_ptr().add(offset) as *const u16;
base::value_from_ptr(ptr)
}
}
pub fn length(&self) -> u32 {
unsafe {
let offset = 4usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn client_driver_major_version(&self) -> u32 {
unsafe {
let offset = 8usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn client_driver_minor_version(&self) -> u32 {
unsafe {
let offset = 12usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn client_driver_patch_version(&self) -> u32 {
unsafe {
let offset = 16usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
fn client_driver_name_len(&self) -> u32 {
unsafe {
let offset = 20usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn client_driver_name(&self) -> &Lat1Str {
unsafe {
let offset = 32usize;
let len = (self.client_driver_name_len() as usize) as _;
let ptr = self.wire_ptr().add(offset);
let bytes = std::slice::from_raw_parts(ptr, len);
Lat1Str::from_bytes(bytes)
}
}
}
impl base::Reply for GetClientDriverNameReply {
unsafe fn from_raw(raw: *const u8) -> Self {
Self { raw }
}
unsafe fn into_raw(self) -> *const u8 {
let raw = self.raw;
std::mem::forget(self);
raw
}
}
impl std::fmt::Debug for GetClientDriverNameReply {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("GetClientDriverNameReply")
.field("response_type", &self.response_type())
.field("pad", &1)
.field("sequence", &self.sequence())
.field("length", &self.length())
.field("client_driver_major_version", &self.client_driver_major_version())
.field("client_driver_minor_version", &self.client_driver_minor_version())
.field("client_driver_patch_version", &self.client_driver_patch_version())
.field("client_driver_name_len", &self.client_driver_name_len())
.field("pad", &8)
.field("client_driver_name", &self.client_driver_name())
.finish()
}
}
impl Drop for GetClientDriverNameReply {
fn drop(&mut self) {
unsafe { libc::free(self.raw as *mut _); }
}
}
unsafe impl std::marker::Send for GetClientDriverNameReply {}
unsafe impl std::marker::Sync for GetClientDriverNameReply {}
#[derive(Debug)]
pub struct GetClientDriverNameCookie {
seq: u64,
}
#[derive(Debug)]
pub struct GetClientDriverNameCookieUnchecked {
seq: u64,
}
impl base::Cookie for GetClientDriverNameCookie {
unsafe fn from_sequence(seq: u64) -> Self {
GetClientDriverNameCookie { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieChecked for GetClientDriverNameCookie {
}
unsafe impl base::CookieWithReplyChecked for GetClientDriverNameCookie {
type Reply = GetClientDriverNameReply;
}
impl base::Cookie for GetClientDriverNameCookieUnchecked {
unsafe fn from_sequence(seq: u64) -> Self {
GetClientDriverNameCookieUnchecked { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieWithReplyUnchecked for GetClientDriverNameCookieUnchecked {
type Reply = GetClientDriverNameReply;
}
#[derive(Clone, Debug)]
pub struct GetClientDriverName {
pub screen: u32,
}
unsafe impl base::RawRequest for GetClientDriverName {
fn raw_request(&self, c: &base::Connection, checked: bool) -> u64 { unsafe {
let mut protocol_request = xcb_protocol_request_t {
count: 2,
ext: (&mut FFI_EXT) as *mut _,
opcode: 4,
isvoid: 0,
};
let mut sections: [iovec; 4] = [iovec {
iov_base: std::ptr::null_mut(),
iov_len: 0,
}; 4];
let buf0: &mut [u8] = &mut [0; 8];
self.screen.serialize(&mut buf0[4 .. ]);
sections[2].iov_base = buf0.as_mut_ptr() as *mut _;
sections[2].iov_len = 8;
sections[3].iov_len = base::align_pad(sections[2].iov_len, 4);
let flags = if checked { base::RequestFlags::CHECKED } else { base::RequestFlags::NONE };
xcb_send_request64(
c.get_raw_conn(),
flags.bits() as _,
sections.as_mut_ptr().add(2),
&mut protocol_request as *mut _,
)
}
}}
impl base::Request for GetClientDriverName {
type Cookie = GetClientDriverNameCookie;
const IS_VOID: bool = false;
}
impl base::RequestWithReply for GetClientDriverName {
type Reply = GetClientDriverNameReply;
type Cookie = GetClientDriverNameCookie;
type CookieUnchecked = GetClientDriverNameCookieUnchecked;
}
pub struct CreateContextReply {
raw: *const u8,
}
impl CreateContextReply {
fn wire_ptr(&self) -> *const u8 {
self.raw
}
fn wire_len(&self) -> usize {
(32 + self.length() * 4) as _
}
pub fn response_type(&self) -> u8 {
unsafe {
let offset = 0usize;
let ptr = self.wire_ptr().add(offset) as *const u8;
base::value_from_ptr(ptr)
}
}
pub fn sequence(&self) -> u16 {
unsafe {
let offset = 2usize;
let ptr = self.wire_ptr().add(offset) as *const u16;
base::value_from_ptr(ptr)
}
}
pub fn length(&self) -> u32 {
unsafe {
let offset = 4usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn hw_context(&self) -> u32 {
unsafe {
let offset = 8usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
}
impl base::Reply for CreateContextReply {
unsafe fn from_raw(raw: *const u8) -> Self {
Self { raw }
}
unsafe fn into_raw(self) -> *const u8 {
let raw = self.raw;
std::mem::forget(self);
raw
}
}
impl std::fmt::Debug for CreateContextReply {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("CreateContextReply")
.field("response_type", &self.response_type())
.field("pad", &1)
.field("sequence", &self.sequence())
.field("length", &self.length())
.field("hw_context", &self.hw_context())
.finish()
}
}
impl Drop for CreateContextReply {
fn drop(&mut self) {
unsafe { libc::free(self.raw as *mut _); }
}
}
unsafe impl std::marker::Send for CreateContextReply {}
unsafe impl std::marker::Sync for CreateContextReply {}
#[derive(Debug)]
pub struct CreateContextCookie {
seq: u64,
}
#[derive(Debug)]
pub struct CreateContextCookieUnchecked {
seq: u64,
}
impl base::Cookie for CreateContextCookie {
unsafe fn from_sequence(seq: u64) -> Self {
CreateContextCookie { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieChecked for CreateContextCookie {
}
unsafe impl base::CookieWithReplyChecked for CreateContextCookie {
type Reply = CreateContextReply;
}
impl base::Cookie for CreateContextCookieUnchecked {
unsafe fn from_sequence(seq: u64) -> Self {
CreateContextCookieUnchecked { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieWithReplyUnchecked for CreateContextCookieUnchecked {
type Reply = CreateContextReply;
}
#[derive(Clone, Debug)]
pub struct CreateContext {
pub screen: u32,
pub visual: u32,
pub context: u32,
}
unsafe impl base::RawRequest for CreateContext {
fn raw_request(&self, c: &base::Connection, checked: bool) -> u64 { unsafe {
let mut protocol_request = xcb_protocol_request_t {
count: 2,
ext: (&mut FFI_EXT) as *mut _,
opcode: 5,
isvoid: 0,
};
let mut sections: [iovec; 4] = [iovec {
iov_base: std::ptr::null_mut(),
iov_len: 0,
}; 4];
let buf0: &mut [u8] = &mut [0; 16];
self.screen.serialize(&mut buf0[4 .. ]);
self.visual.serialize(&mut buf0[8 .. ]);
self.context.serialize(&mut buf0[12 .. ]);
sections[2].iov_base = buf0.as_mut_ptr() as *mut _;
sections[2].iov_len = 16;
sections[3].iov_len = base::align_pad(sections[2].iov_len, 4);
let flags = if checked { base::RequestFlags::CHECKED } else { base::RequestFlags::NONE };
xcb_send_request64(
c.get_raw_conn(),
flags.bits() as _,
sections.as_mut_ptr().add(2),
&mut protocol_request as *mut _,
)
}
}}
impl base::Request for CreateContext {
type Cookie = CreateContextCookie;
const IS_VOID: bool = false;
}
impl base::RequestWithReply for CreateContext {
type Reply = CreateContextReply;
type Cookie = CreateContextCookie;
type CookieUnchecked = CreateContextCookieUnchecked;
}
#[derive(Clone, Debug)]
pub struct DestroyContext {
pub screen: u32,
pub context: u32,
}
unsafe impl base::RawRequest for DestroyContext {
fn raw_request(&self, c: &base::Connection, checked: bool) -> u64 { unsafe {
let mut protocol_request = xcb_protocol_request_t {
count: 2,
ext: (&mut FFI_EXT) as *mut _,
opcode: 6,
isvoid: 1,
};
let mut sections: [iovec; 4] = [iovec {
iov_base: std::ptr::null_mut(),
iov_len: 0,
}; 4];
let buf0: &mut [u8] = &mut [0; 12];
self.screen.serialize(&mut buf0[4 .. ]);
self.context.serialize(&mut buf0[8 .. ]);
sections[2].iov_base = buf0.as_mut_ptr() as *mut _;
sections[2].iov_len = 12;
sections[3].iov_len = base::align_pad(sections[2].iov_len, 4);
let flags = if checked { base::RequestFlags::CHECKED } else { base::RequestFlags::NONE };
xcb_send_request64(
c.get_raw_conn(),
flags.bits() as _,
sections.as_mut_ptr().add(2),
&mut protocol_request as *mut _,
)
}
}}
impl base::Request for DestroyContext {
type Cookie = base::VoidCookie;
const IS_VOID: bool = true;
}
impl base::RequestWithoutReply for DestroyContext {
}
pub struct CreateDrawableReply {
raw: *const u8,
}
impl CreateDrawableReply {
fn wire_ptr(&self) -> *const u8 {
self.raw
}
fn wire_len(&self) -> usize {
(32 + self.length() * 4) as _
}
pub fn response_type(&self) -> u8 {
unsafe {
let offset = 0usize;
let ptr = self.wire_ptr().add(offset) as *const u8;
base::value_from_ptr(ptr)
}
}
pub fn sequence(&self) -> u16 {
unsafe {
let offset = 2usize;
let ptr = self.wire_ptr().add(offset) as *const u16;
base::value_from_ptr(ptr)
}
}
pub fn length(&self) -> u32 {
unsafe {
let offset = 4usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn hw_drawable_handle(&self) -> u32 {
unsafe {
let offset = 8usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
}
impl base::Reply for CreateDrawableReply {
unsafe fn from_raw(raw: *const u8) -> Self {
Self { raw }
}
unsafe fn into_raw(self) -> *const u8 {
let raw = self.raw;
std::mem::forget(self);
raw
}
}
impl std::fmt::Debug for CreateDrawableReply {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("CreateDrawableReply")
.field("response_type", &self.response_type())
.field("pad", &1)
.field("sequence", &self.sequence())
.field("length", &self.length())
.field("hw_drawable_handle", &self.hw_drawable_handle())
.finish()
}
}
impl Drop for CreateDrawableReply {
fn drop(&mut self) {
unsafe { libc::free(self.raw as *mut _); }
}
}
unsafe impl std::marker::Send for CreateDrawableReply {}
unsafe impl std::marker::Sync for CreateDrawableReply {}
#[derive(Debug)]
pub struct CreateDrawableCookie {
seq: u64,
}
#[derive(Debug)]
pub struct CreateDrawableCookieUnchecked {
seq: u64,
}
impl base::Cookie for CreateDrawableCookie {
unsafe fn from_sequence(seq: u64) -> Self {
CreateDrawableCookie { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieChecked for CreateDrawableCookie {
}
unsafe impl base::CookieWithReplyChecked for CreateDrawableCookie {
type Reply = CreateDrawableReply;
}
impl base::Cookie for CreateDrawableCookieUnchecked {
unsafe fn from_sequence(seq: u64) -> Self {
CreateDrawableCookieUnchecked { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieWithReplyUnchecked for CreateDrawableCookieUnchecked {
type Reply = CreateDrawableReply;
}
#[derive(Clone, Debug)]
pub struct CreateDrawable {
pub screen: u32,
pub drawable: u32,
}
unsafe impl base::RawRequest for CreateDrawable {
fn raw_request(&self, c: &base::Connection, checked: bool) -> u64 { unsafe {
let mut protocol_request = xcb_protocol_request_t {
count: 2,
ext: (&mut FFI_EXT) as *mut _,
opcode: 7,
isvoid: 0,
};
let mut sections: [iovec; 4] = [iovec {
iov_base: std::ptr::null_mut(),
iov_len: 0,
}; 4];
let buf0: &mut [u8] = &mut [0; 12];
self.screen.serialize(&mut buf0[4 .. ]);
self.drawable.serialize(&mut buf0[8 .. ]);
sections[2].iov_base = buf0.as_mut_ptr() as *mut _;
sections[2].iov_len = 12;
sections[3].iov_len = base::align_pad(sections[2].iov_len, 4);
let flags = if checked { base::RequestFlags::CHECKED } else { base::RequestFlags::NONE };
xcb_send_request64(
c.get_raw_conn(),
flags.bits() as _,
sections.as_mut_ptr().add(2),
&mut protocol_request as *mut _,
)
}
}}
impl base::Request for CreateDrawable {
type Cookie = CreateDrawableCookie;
const IS_VOID: bool = false;
}
impl base::RequestWithReply for CreateDrawable {
type Reply = CreateDrawableReply;
type Cookie = CreateDrawableCookie;
type CookieUnchecked = CreateDrawableCookieUnchecked;
}
#[derive(Clone, Debug)]
pub struct DestroyDrawable {
pub screen: u32,
pub drawable: u32,
}
unsafe impl base::RawRequest for DestroyDrawable {
fn raw_request(&self, c: &base::Connection, checked: bool) -> u64 { unsafe {
let mut protocol_request = xcb_protocol_request_t {
count: 2,
ext: (&mut FFI_EXT) as *mut _,
opcode: 8,
isvoid: 1,
};
let mut sections: [iovec; 4] = [iovec {
iov_base: std::ptr::null_mut(),
iov_len: 0,
}; 4];
let buf0: &mut [u8] = &mut [0; 12];
self.screen.serialize(&mut buf0[4 .. ]);
self.drawable.serialize(&mut buf0[8 .. ]);
sections[2].iov_base = buf0.as_mut_ptr() as *mut _;
sections[2].iov_len = 12;
sections[3].iov_len = base::align_pad(sections[2].iov_len, 4);
let flags = if checked { base::RequestFlags::CHECKED } else { base::RequestFlags::NONE };
xcb_send_request64(
c.get_raw_conn(),
flags.bits() as _,
sections.as_mut_ptr().add(2),
&mut protocol_request as *mut _,
)
}
}}
impl base::Request for DestroyDrawable {
type Cookie = base::VoidCookie;
const IS_VOID: bool = true;
}
impl base::RequestWithoutReply for DestroyDrawable {
}
pub struct GetDrawableInfoReply {
raw: *const u8,
}
impl GetDrawableInfoReply {
fn wire_ptr(&self) -> *const u8 {
self.raw
}
fn wire_len(&self) -> usize {
(32 + self.length() * 4) as _
}
unsafe fn compute_len(ptr: *const u8, _params: ()) -> usize {
let mut sz = 0;
sz += 1usize;
sz += 1usize;
sz += 2usize;
sz += 4usize;
sz += 4usize;
sz += 4usize;
sz += 2usize;
sz += 2usize;
sz += 2usize;
sz += 2usize;
let num_clip_rects = *(ptr.add(sz) as *const u32);
sz += 4usize;
sz += 2usize;
sz += 2usize;
let num_back_clip_rects = *(ptr.add(sz) as *const u32);
sz += 4usize;
sz += ((num_clip_rects as usize) * 8usize);
sz += ((num_back_clip_rects as usize) * 8usize);
sz
}
pub fn response_type(&self) -> u8 {
unsafe {
let offset = 0usize;
let ptr = self.wire_ptr().add(offset) as *const u8;
base::value_from_ptr(ptr)
}
}
pub fn sequence(&self) -> u16 {
unsafe {
let offset = 2usize;
let ptr = self.wire_ptr().add(offset) as *const u16;
base::value_from_ptr(ptr)
}
}
pub fn length(&self) -> u32 {
unsafe {
let offset = 4usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn drawable_table_index(&self) -> u32 {
unsafe {
let offset = 8usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn drawable_table_stamp(&self) -> u32 {
unsafe {
let offset = 12usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn drawable_origin_x(&self) -> i16 {
unsafe {
let offset = 16usize;
let ptr = self.wire_ptr().add(offset) as *const i16;
base::value_from_ptr(ptr)
}
}
pub fn drawable_origin_y(&self) -> i16 {
unsafe {
let offset = 18usize;
let ptr = self.wire_ptr().add(offset) as *const i16;
base::value_from_ptr(ptr)
}
}
pub fn drawable_size_w(&self) -> i16 {
unsafe {
let offset = 20usize;
let ptr = self.wire_ptr().add(offset) as *const i16;
base::value_from_ptr(ptr)
}
}
pub fn drawable_size_h(&self) -> i16 {
unsafe {
let offset = 22usize;
let ptr = self.wire_ptr().add(offset) as *const i16;
base::value_from_ptr(ptr)
}
}
fn num_clip_rects(&self) -> u32 {
unsafe {
let offset = 24usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn back_x(&self) -> i16 {
unsafe {
let offset = 28usize;
let ptr = self.wire_ptr().add(offset) as *const i16;
base::value_from_ptr(ptr)
}
}
pub fn back_y(&self) -> i16 {
unsafe {
let offset = 30usize;
let ptr = self.wire_ptr().add(offset) as *const i16;
base::value_from_ptr(ptr)
}
}
fn num_back_clip_rects(&self) -> u32 {
unsafe {
let offset = 32usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn clip_rects(&self) -> &[DrmClipRect] {
unsafe {
let offset = 36usize;
let len = (self.num_clip_rects() as usize) as _;
let ptr = self.wire_ptr().add(offset) as *const DrmClipRect;
std::slice::from_raw_parts(ptr, len)
}
}
pub fn back_clip_rects(&self) -> &[DrmClipRect] {
unsafe {
let offset = (36usize + ((self.num_clip_rects() as usize) * 8usize));
let len = (self.num_back_clip_rects() as usize) as _;
let ptr = self.wire_ptr().add(offset) as *const DrmClipRect;
std::slice::from_raw_parts(ptr, len)
}
}
}
impl base::Reply for GetDrawableInfoReply {
unsafe fn from_raw(raw: *const u8) -> Self {
Self { raw }
}
unsafe fn into_raw(self) -> *const u8 {
let raw = self.raw;
std::mem::forget(self);
raw
}
}
impl std::fmt::Debug for GetDrawableInfoReply {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("GetDrawableInfoReply")
.field("response_type", &self.response_type())
.field("pad", &1)
.field("sequence", &self.sequence())
.field("length", &self.length())
.field("drawable_table_index", &self.drawable_table_index())
.field("drawable_table_stamp", &self.drawable_table_stamp())
.field("drawable_origin_x", &self.drawable_origin_x())
.field("drawable_origin_y", &self.drawable_origin_y())
.field("drawable_size_w", &self.drawable_size_w())
.field("drawable_size_h", &self.drawable_size_h())
.field("num_clip_rects", &self.num_clip_rects())
.field("back_x", &self.back_x())
.field("back_y", &self.back_y())
.field("num_back_clip_rects", &self.num_back_clip_rects())
.field("clip_rects", &self.clip_rects())
.field("back_clip_rects", &self.back_clip_rects())
.finish()
}
}
impl Drop for GetDrawableInfoReply {
fn drop(&mut self) {
unsafe { libc::free(self.raw as *mut _); }
}
}
unsafe impl std::marker::Send for GetDrawableInfoReply {}
unsafe impl std::marker::Sync for GetDrawableInfoReply {}
#[derive(Debug)]
pub struct GetDrawableInfoCookie {
seq: u64,
}
#[derive(Debug)]
pub struct GetDrawableInfoCookieUnchecked {
seq: u64,
}
impl base::Cookie for GetDrawableInfoCookie {
unsafe fn from_sequence(seq: u64) -> Self {
GetDrawableInfoCookie { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieChecked for GetDrawableInfoCookie {
}
unsafe impl base::CookieWithReplyChecked for GetDrawableInfoCookie {
type Reply = GetDrawableInfoReply;
}
impl base::Cookie for GetDrawableInfoCookieUnchecked {
unsafe fn from_sequence(seq: u64) -> Self {
GetDrawableInfoCookieUnchecked { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieWithReplyUnchecked for GetDrawableInfoCookieUnchecked {
type Reply = GetDrawableInfoReply;
}
#[derive(Clone, Debug)]
pub struct GetDrawableInfo {
pub screen: u32,
pub drawable: u32,
}
unsafe impl base::RawRequest for GetDrawableInfo {
fn raw_request(&self, c: &base::Connection, checked: bool) -> u64 { unsafe {
let mut protocol_request = xcb_protocol_request_t {
count: 2,
ext: (&mut FFI_EXT) as *mut _,
opcode: 9,
isvoid: 0,
};
let mut sections: [iovec; 4] = [iovec {
iov_base: std::ptr::null_mut(),
iov_len: 0,
}; 4];
let buf0: &mut [u8] = &mut [0; 12];
self.screen.serialize(&mut buf0[4 .. ]);
self.drawable.serialize(&mut buf0[8 .. ]);
sections[2].iov_base = buf0.as_mut_ptr() as *mut _;
sections[2].iov_len = 12;
sections[3].iov_len = base::align_pad(sections[2].iov_len, 4);
let flags = if checked { base::RequestFlags::CHECKED } else { base::RequestFlags::NONE };
xcb_send_request64(
c.get_raw_conn(),
flags.bits() as _,
sections.as_mut_ptr().add(2),
&mut protocol_request as *mut _,
)
}
}}
impl base::Request for GetDrawableInfo {
type Cookie = GetDrawableInfoCookie;
const IS_VOID: bool = false;
}
impl base::RequestWithReply for GetDrawableInfo {
type Reply = GetDrawableInfoReply;
type Cookie = GetDrawableInfoCookie;
type CookieUnchecked = GetDrawableInfoCookieUnchecked;
}
pub struct GetDeviceInfoReply {
raw: *const u8,
}
impl GetDeviceInfoReply {
fn wire_ptr(&self) -> *const u8 {
self.raw
}
fn wire_len(&self) -> usize {
(32 + self.length() * 4) as _
}
unsafe fn compute_len(ptr: *const u8, _params: ()) -> usize {
let mut sz = 0;
sz += 1usize;
sz += 1usize;
sz += 2usize;
sz += 4usize;
sz += 4usize;
sz += 4usize;
sz += 4usize;
sz += 4usize;
sz += 4usize;
let device_private_size = *(ptr.add(sz) as *const u32);
sz += 4usize;
sz += ((device_private_size as usize) * 4usize);
sz
}
pub fn response_type(&self) -> u8 {
unsafe {
let offset = 0usize;
let ptr = self.wire_ptr().add(offset) as *const u8;
base::value_from_ptr(ptr)
}
}
pub fn sequence(&self) -> u16 {
unsafe {
let offset = 2usize;
let ptr = self.wire_ptr().add(offset) as *const u16;
base::value_from_ptr(ptr)
}
}
pub fn length(&self) -> u32 {
unsafe {
let offset = 4usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn framebuffer_handle_low(&self) -> u32 {
unsafe {
let offset = 8usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn framebuffer_handle_high(&self) -> u32 {
unsafe {
let offset = 12usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn framebuffer_origin_offset(&self) -> u32 {
unsafe {
let offset = 16usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn framebuffer_size(&self) -> u32 {
unsafe {
let offset = 20usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn framebuffer_stride(&self) -> u32 {
unsafe {
let offset = 24usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
fn device_private_size(&self) -> u32 {
unsafe {
let offset = 28usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn device_private(&self) -> &[u32] {
unsafe {
let offset = 32usize;
let len = (self.device_private_size() as usize);
let ptr = self.wire_ptr().add(offset) as *const u32;
std::slice::from_raw_parts(ptr, len)
}
}
}
impl base::Reply for GetDeviceInfoReply {
unsafe fn from_raw(raw: *const u8) -> Self {
Self { raw }
}
unsafe fn into_raw(self) -> *const u8 {
let raw = self.raw;
std::mem::forget(self);
raw
}
}
impl std::fmt::Debug for GetDeviceInfoReply {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("GetDeviceInfoReply")
.field("response_type", &self.response_type())
.field("pad", &1)
.field("sequence", &self.sequence())
.field("length", &self.length())
.field("framebuffer_handle_low", &self.framebuffer_handle_low())
.field("framebuffer_handle_high", &self.framebuffer_handle_high())
.field("framebuffer_origin_offset", &self.framebuffer_origin_offset())
.field("framebuffer_size", &self.framebuffer_size())
.field("framebuffer_stride", &self.framebuffer_stride())
.field("device_private_size", &self.device_private_size())
.field("device_private", &self.device_private())
.finish()
}
}
impl Drop for GetDeviceInfoReply {
fn drop(&mut self) {
unsafe { libc::free(self.raw as *mut _); }
}
}
unsafe impl std::marker::Send for GetDeviceInfoReply {}
unsafe impl std::marker::Sync for GetDeviceInfoReply {}
#[derive(Debug)]
pub struct GetDeviceInfoCookie {
seq: u64,
}
#[derive(Debug)]
pub struct GetDeviceInfoCookieUnchecked {
seq: u64,
}
impl base::Cookie for GetDeviceInfoCookie {
unsafe fn from_sequence(seq: u64) -> Self {
GetDeviceInfoCookie { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieChecked for GetDeviceInfoCookie {
}
unsafe impl base::CookieWithReplyChecked for GetDeviceInfoCookie {
type Reply = GetDeviceInfoReply;
}
impl base::Cookie for GetDeviceInfoCookieUnchecked {
unsafe fn from_sequence(seq: u64) -> Self {
GetDeviceInfoCookieUnchecked { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieWithReplyUnchecked for GetDeviceInfoCookieUnchecked {
type Reply = GetDeviceInfoReply;
}
#[derive(Clone, Debug)]
pub struct GetDeviceInfo {
pub screen: u32,
}
unsafe impl base::RawRequest for GetDeviceInfo {
fn raw_request(&self, c: &base::Connection, checked: bool) -> u64 { unsafe {
let mut protocol_request = xcb_protocol_request_t {
count: 2,
ext: (&mut FFI_EXT) as *mut _,
opcode: 10,
isvoid: 0,
};
let mut sections: [iovec; 4] = [iovec {
iov_base: std::ptr::null_mut(),
iov_len: 0,
}; 4];
let buf0: &mut [u8] = &mut [0; 8];
self.screen.serialize(&mut buf0[4 .. ]);
sections[2].iov_base = buf0.as_mut_ptr() as *mut _;
sections[2].iov_len = 8;
sections[3].iov_len = base::align_pad(sections[2].iov_len, 4);
let flags = if checked { base::RequestFlags::CHECKED } else { base::RequestFlags::NONE };
xcb_send_request64(
c.get_raw_conn(),
flags.bits() as _,
sections.as_mut_ptr().add(2),
&mut protocol_request as *mut _,
)
}
}}
impl base::Request for GetDeviceInfo {
type Cookie = GetDeviceInfoCookie;
const IS_VOID: bool = false;
}
impl base::RequestWithReply for GetDeviceInfo {
type Reply = GetDeviceInfoReply;
type Cookie = GetDeviceInfoCookie;
type CookieUnchecked = GetDeviceInfoCookieUnchecked;
}
pub struct AuthConnectionReply {
raw: *const u8,
}
impl AuthConnectionReply {
fn wire_ptr(&self) -> *const u8 {
self.raw
}
fn wire_len(&self) -> usize {
(32 + self.length() * 4) as _
}
pub fn response_type(&self) -> u8 {
unsafe {
let offset = 0usize;
let ptr = self.wire_ptr().add(offset) as *const u8;
base::value_from_ptr(ptr)
}
}
pub fn sequence(&self) -> u16 {
unsafe {
let offset = 2usize;
let ptr = self.wire_ptr().add(offset) as *const u16;
base::value_from_ptr(ptr)
}
}
pub fn length(&self) -> u32 {
unsafe {
let offset = 4usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn authenticated(&self) -> u32 {
unsafe {
let offset = 8usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
}
impl base::Reply for AuthConnectionReply {
unsafe fn from_raw(raw: *const u8) -> Self {
Self { raw }
}
unsafe fn into_raw(self) -> *const u8 {
let raw = self.raw;
std::mem::forget(self);
raw
}
}
impl std::fmt::Debug for AuthConnectionReply {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("AuthConnectionReply")
.field("response_type", &self.response_type())
.field("pad", &1)
.field("sequence", &self.sequence())
.field("length", &self.length())
.field("authenticated", &self.authenticated())
.finish()
}
}
impl Drop for AuthConnectionReply {
fn drop(&mut self) {
unsafe { libc::free(self.raw as *mut _); }
}
}
unsafe impl std::marker::Send for AuthConnectionReply {}
unsafe impl std::marker::Sync for AuthConnectionReply {}
#[derive(Debug)]
pub struct AuthConnectionCookie {
seq: u64,
}
#[derive(Debug)]
pub struct AuthConnectionCookieUnchecked {
seq: u64,
}
impl base::Cookie for AuthConnectionCookie {
unsafe fn from_sequence(seq: u64) -> Self {
AuthConnectionCookie { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieChecked for AuthConnectionCookie {
}
unsafe impl base::CookieWithReplyChecked for AuthConnectionCookie {
type Reply = AuthConnectionReply;
}
impl base::Cookie for AuthConnectionCookieUnchecked {
unsafe fn from_sequence(seq: u64) -> Self {
AuthConnectionCookieUnchecked { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieWithReplyUnchecked for AuthConnectionCookieUnchecked {
type Reply = AuthConnectionReply;
}
#[derive(Clone, Debug)]
pub struct AuthConnection {
pub screen: u32,
pub magic: u32,
}
unsafe impl base::RawRequest for AuthConnection {
fn raw_request(&self, c: &base::Connection, checked: bool) -> u64 { unsafe {
let mut protocol_request = xcb_protocol_request_t {
count: 2,
ext: (&mut FFI_EXT) as *mut _,
opcode: 11,
isvoid: 0,
};
let mut sections: [iovec; 4] = [iovec {
iov_base: std::ptr::null_mut(),
iov_len: 0,
}; 4];
let buf0: &mut [u8] = &mut [0; 12];
self.screen.serialize(&mut buf0[4 .. ]);
self.magic.serialize(&mut buf0[8 .. ]);
sections[2].iov_base = buf0.as_mut_ptr() as *mut _;
sections[2].iov_len = 12;
sections[3].iov_len = base::align_pad(sections[2].iov_len, 4);
let flags = if checked { base::RequestFlags::CHECKED } else { base::RequestFlags::NONE };
xcb_send_request64(
c.get_raw_conn(),
flags.bits() as _,
sections.as_mut_ptr().add(2),
&mut protocol_request as *mut _,
)
}
}}
impl base::Request for AuthConnection {
type Cookie = AuthConnectionCookie;
const IS_VOID: bool = false;
}
impl base::RequestWithReply for AuthConnection {
type Reply = AuthConnectionReply;
type Cookie = AuthConnectionCookie;
type CookieUnchecked = AuthConnectionCookieUnchecked;
}