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 = "SELinux";
pub const MAJOR_VERSION: u32 = 1;
pub const MINOR_VERSION: u32 = 0;
pub const VERSION_STRING: &str = "1.0";
pub(crate) static mut FFI_EXT: xcb_extension_t = xcb_extension_t {
name: "SELinux\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 SELinux 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::SeLinux,
major_opcode: reply.major_opcode(),
first_event: reply.first_event(),
first_error: reply.first_error(),
};
std::mem::forget(reply);
Some(res)
}
}
pub struct ListItem {
data: [u8],
}
#[allow(unused_parens)]
impl ListItem {
pub(crate) unsafe fn from_data<D: AsRef<[u8]> + ?Sized>(data: &D) -> &ListItem {
debug_assert_eq!(data.as_ref().len(), <&ListItem as base::WiredIn>::compute_wire_len(data.as_ref().as_ptr(), ()));
&*(data.as_ref() as *const [u8] as *const ListItem)
}
fn wire_ptr(&self) -> *const u8 { self.data.as_ptr() }
pub fn name(&self) -> xproto::Atom {
unsafe {
let offset = 0usize;
let ptr = self.wire_ptr().add(offset) as *const xproto::Atom;
base::value_from_ptr(ptr)
}
}
fn object_context_len(&self) -> u32 {
unsafe {
let offset = 4usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
fn data_context_len(&self) -> u32 {
unsafe {
let offset = 8usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn object_context(&self) -> &Lat1Str {
unsafe {
let offset = 12usize;
let len = (self.object_context_len() as usize) as _;
let ptr = self.wire_ptr().add(offset);
let bytes = std::slice::from_raw_parts(ptr, len);
Lat1Str::from_bytes(bytes)
}
}
pub fn data_context(&self) -> &Lat1Str {
unsafe {
let offset = ((12usize + (self.object_context_len() as usize)) + base::align_pad((12usize + (self.object_context_len() as usize)), 4));
let len = (self.data_context_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::WiredOut for ListItem {
fn wire_len(&self) -> usize { self.data.len() }
fn serialize(&self, wire_buf: &mut [u8]) -> usize {
(&mut wire_buf[..self.data.len()]).copy_from_slice(&self.data);
self.data.len()
}
}
impl base::WiredIn for &ListItem {
type Params = ();
unsafe fn compute_wire_len(ptr: *const u8, _params: ()) -> usize {
let mut sz = 0;
sz += 4usize;
let object_context_len = *(ptr.add(sz) as *const u32);
sz += 4usize;
let data_context_len = *(ptr.add(sz) as *const u32);
sz += 4usize;
sz += (object_context_len as usize);
sz += base::align_pad(sz, 4);
sz += (data_context_len as usize);
sz += base::align_pad(sz, 4);
sz
}
unsafe fn unserialize(ptr: *const u8, params: (), offset: &mut usize) -> Self {
let sz = Self::compute_wire_len(ptr, params);
*offset += sz;
let data = std::slice::from_raw_parts(ptr, sz);
ListItem::from_data(data)
}
}
#[derive(Clone)]
pub struct ListItemBuf {
data: Vec<u8>,
}
impl ListItemBuf {
pub(crate) unsafe fn from_data(data: Vec<u8>) -> ListItemBuf {
debug_assert_eq!(<&ListItem>::compute_wire_len(data.as_ptr(), ()), data.len());
ListItemBuf { data }
}
#[allow(unused_assignments, unused_unsafe)]
pub fn new(
name: xproto::Atom,
object_context: &[u8],
data_context: &[u8],
) -> ListItemBuf {
unsafe {
let mut wire_sz = 0usize;
wire_sz += 4; wire_sz += 4; wire_sz += 4; wire_sz += object_context.len();
wire_sz += base::align_pad(wire_sz, 4);
wire_sz += data_context.len();
wire_sz += base::align_pad(wire_sz, 4);
let mut wire_buf = vec![0u8; wire_sz];
let mut wire_off = 0usize;
wire_off += name.serialize(&mut wire_buf[wire_off .. ]);
wire_off += (object_context.len() as u32).serialize(&mut wire_buf[wire_off .. ]);
wire_off += (data_context.len() as u32).serialize(&mut wire_buf[wire_off .. ]);
wire_buf[wire_off .. wire_off + object_context.len()].copy_from_slice(object_context);
wire_off += object_context.len();
wire_off += base::align_pad(wire_off, 4);
wire_buf[wire_off .. wire_off + data_context.len()].copy_from_slice(data_context);
wire_off += data_context.len();
wire_off += base::align_pad(wire_off, 4);
ListItemBuf { data: wire_buf }
}
}
}
impl base::WiredIn for ListItemBuf {
type Params = ();
unsafe fn compute_wire_len(ptr: *const u8, params: ()) -> usize {
<&ListItem>::compute_wire_len(ptr, params)
}
unsafe fn unserialize(ptr: *const u8, params: (), offset: &mut usize) -> Self {
let sz = Self::compute_wire_len(ptr, params);
*offset += sz;
let data = std::slice::from_raw_parts(ptr, sz);
ListItemBuf::from_data(data.to_vec())
}
}
impl std::ops::Deref for ListItemBuf {
type Target = ListItem;
fn deref(&self) -> &Self::Target {
unsafe { ListItem::from_data(&self.data) }
}
}
impl std::borrow::Borrow<ListItem> for ListItemBuf {
fn borrow(&self) -> &ListItem {
unsafe { ListItem::from_data(&self.data) }
}
}
impl std::borrow::ToOwned for ListItem {
type Owned = ListItemBuf;
fn to_owned(&self) -> Self::Owned {
ListItemBuf {
data: self.data.to_vec()
}
}
}
impl std::fmt::Debug for ListItem {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("ListItem")
.field("name", &self.name())
.field("object_context_len", &self.object_context_len())
.field("data_context_len", &self.data_context_len())
.field("object_context", &self.object_context())
.field("align_pad", &4)
.field("data_context", &self.data_context())
.field("align_pad", &4)
.finish()
}
}
impl std::fmt::Debug for ListItemBuf {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("ListItemBuf")
.field("name", &self.name())
.field("object_context_len", &self.object_context_len())
.field("data_context_len", &self.data_context_len())
.field("object_context", &self.object_context())
.field("align_pad", &4)
.field("data_context", &self.data_context())
.field("align_pad", &4)
.finish()
}
}
#[derive(Clone)]
pub struct ListItemIterator<'a> {
pub(crate) params: (),
pub(crate) rem: usize,
pub(crate) ptr: *const u8,
pub(crate) phantom: std::marker::PhantomData<&'a ListItem>,
}
impl<'a> Iterator for ListItemIterator<'a> {
type Item = &'a ListItem;
fn next(&mut self) -> std::option::Option<Self::Item> {
if self.rem == 0 {
None
} else { unsafe {
self.rem -= 1;
let mut offset = 0;
let res = <&ListItem>::unserialize(self.ptr, self.params, &mut offset);
self.ptr = self.ptr.add(offset);
Some(res)
}}
}
}
impl<'a> std::fmt::Debug for ListItemIterator<'a> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_list().entries(self.clone()).finish()
}
}
pub(crate) fn request_name(opcode: u16) -> std::option::Option<&'static str> {
match opcode {
0 => Some("xselinux::QueryVersion"),
1 => Some("xselinux::SetDeviceCreateContext"),
2 => Some("xselinux::GetDeviceCreateContext"),
3 => Some("xselinux::SetDeviceContext"),
4 => Some("xselinux::GetDeviceContext"),
5 => Some("xselinux::SetWindowCreateContext"),
6 => Some("xselinux::GetWindowCreateContext"),
7 => Some("xselinux::GetWindowContext"),
8 => Some("xselinux::SetPropertyCreateContext"),
9 => Some("xselinux::GetPropertyCreateContext"),
10 => Some("xselinux::SetPropertyUseContext"),
11 => Some("xselinux::GetPropertyUseContext"),
12 => Some("xselinux::GetPropertyContext"),
13 => Some("xselinux::GetPropertyDataContext"),
14 => Some("xselinux::ListProperties"),
15 => Some("xselinux::SetSelectionCreateContext"),
16 => Some("xselinux::GetSelectionCreateContext"),
17 => Some("xselinux::SetSelectionUseContext"),
18 => Some("xselinux::GetSelectionUseContext"),
19 => Some("xselinux::GetSelectionContext"),
20 => Some("xselinux::GetSelectionDataContext"),
21 => Some("xselinux::ListSelections"),
22 => Some("xselinux::GetClientContext"),
_ => 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 server_major(&self) -> u16 {
unsafe {
let offset = 8usize;
let ptr = self.wire_ptr().add(offset) as *const u16;
base::value_from_ptr(ptr)
}
}
pub fn server_minor(&self) -> u16 {
unsafe {
let offset = 10usize;
let ptr = self.wire_ptr().add(offset) as *const u16;
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("server_major", &self.server_major())
.field("server_minor", &self.server_minor())
.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 {
pub client_major: u8,
pub client_minor: u8,
}
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; 6];
self.client_major.serialize(&mut buf0[4 .. ]);
self.client_minor.serialize(&mut buf0[5 .. ]);
sections[2].iov_base = buf0.as_mut_ptr() as *mut _;
sections[2].iov_len = 6;
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;
}
#[derive(Clone, Debug)]
pub struct SetDeviceCreateContext<'a> {
pub context: &'a [u8],
}
unsafe impl<'a> base::RawRequest for SetDeviceCreateContext<'a> {
fn raw_request(&self, c: &base::Connection, checked: bool) -> u64 { unsafe {
let mut protocol_request = xcb_protocol_request_t {
count: 4,
ext: (&mut FFI_EXT) as *mut _,
opcode: 1,
isvoid: 1,
};
let mut sections: [iovec; 6] = [iovec {
iov_base: std::ptr::null_mut(),
iov_len: 0,
}; 6];
let buf0: &mut [u8] = &mut [0; 8];
(self.context.len() as u32).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);
sections[4].iov_base = self.context.as_ptr() as *mut _;
sections[4].iov_len = self.context.len();
sections[5].iov_len = base::align_pad(sections[4].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<'a> base::Request for SetDeviceCreateContext<'a> {
type Cookie = base::VoidCookie;
const IS_VOID: bool = true;
}
impl<'a> base::RequestWithoutReply for SetDeviceCreateContext<'a> {
}
pub struct GetDeviceCreateContextReply {
raw: *const u8,
}
impl GetDeviceCreateContextReply {
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;
let context_len = *(ptr.add(sz) as *const u32);
sz += 4usize;
sz += 20usize;
sz += (context_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)
}
}
fn context_len(&self) -> u32 {
unsafe {
let offset = 8usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn context(&self) -> &Lat1Str {
unsafe {
let offset = 32usize;
let len = (self.context_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 GetDeviceCreateContextReply {
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 GetDeviceCreateContextReply {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("GetDeviceCreateContextReply")
.field("response_type", &self.response_type())
.field("pad", &1)
.field("sequence", &self.sequence())
.field("length", &self.length())
.field("context_len", &self.context_len())
.field("pad", &20)
.field("context", &self.context())
.finish()
}
}
impl Drop for GetDeviceCreateContextReply {
fn drop(&mut self) {
unsafe { libc::free(self.raw as *mut _); }
}
}
unsafe impl std::marker::Send for GetDeviceCreateContextReply {}
unsafe impl std::marker::Sync for GetDeviceCreateContextReply {}
#[derive(Debug)]
pub struct GetDeviceCreateContextCookie {
seq: u64,
}
#[derive(Debug)]
pub struct GetDeviceCreateContextCookieUnchecked {
seq: u64,
}
impl base::Cookie for GetDeviceCreateContextCookie {
unsafe fn from_sequence(seq: u64) -> Self {
GetDeviceCreateContextCookie { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieChecked for GetDeviceCreateContextCookie {
}
unsafe impl base::CookieWithReplyChecked for GetDeviceCreateContextCookie {
type Reply = GetDeviceCreateContextReply;
}
impl base::Cookie for GetDeviceCreateContextCookieUnchecked {
unsafe fn from_sequence(seq: u64) -> Self {
GetDeviceCreateContextCookieUnchecked { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieWithReplyUnchecked for GetDeviceCreateContextCookieUnchecked {
type Reply = GetDeviceCreateContextReply;
}
#[derive(Clone, Debug)]
pub struct GetDeviceCreateContext {
}
unsafe impl base::RawRequest for GetDeviceCreateContext {
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; 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 GetDeviceCreateContext {
type Cookie = GetDeviceCreateContextCookie;
const IS_VOID: bool = false;
}
impl base::RequestWithReply for GetDeviceCreateContext {
type Reply = GetDeviceCreateContextReply;
type Cookie = GetDeviceCreateContextCookie;
type CookieUnchecked = GetDeviceCreateContextCookieUnchecked;
}
#[derive(Clone, Debug)]
pub struct SetDeviceContext<'a> {
pub device: u32,
pub context: &'a [u8],
}
unsafe impl<'a> base::RawRequest for SetDeviceContext<'a> {
fn raw_request(&self, c: &base::Connection, checked: bool) -> u64 { unsafe {
let mut protocol_request = xcb_protocol_request_t {
count: 4,
ext: (&mut FFI_EXT) as *mut _,
opcode: 3,
isvoid: 1,
};
let mut sections: [iovec; 6] = [iovec {
iov_base: std::ptr::null_mut(),
iov_len: 0,
}; 6];
let buf0: &mut [u8] = &mut [0; 12];
self.device.serialize(&mut buf0[4 .. ]);
(self.context.len() as u32).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);
sections[4].iov_base = self.context.as_ptr() as *mut _;
sections[4].iov_len = self.context.len();
sections[5].iov_len = base::align_pad(sections[4].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<'a> base::Request for SetDeviceContext<'a> {
type Cookie = base::VoidCookie;
const IS_VOID: bool = true;
}
impl<'a> base::RequestWithoutReply for SetDeviceContext<'a> {
}
pub struct GetDeviceContextReply {
raw: *const u8,
}
impl GetDeviceContextReply {
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;
let context_len = *(ptr.add(sz) as *const u32);
sz += 4usize;
sz += 20usize;
sz += (context_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)
}
}
fn context_len(&self) -> u32 {
unsafe {
let offset = 8usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn context(&self) -> &Lat1Str {
unsafe {
let offset = 32usize;
let len = (self.context_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 GetDeviceContextReply {
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 GetDeviceContextReply {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("GetDeviceContextReply")
.field("response_type", &self.response_type())
.field("pad", &1)
.field("sequence", &self.sequence())
.field("length", &self.length())
.field("context_len", &self.context_len())
.field("pad", &20)
.field("context", &self.context())
.finish()
}
}
impl Drop for GetDeviceContextReply {
fn drop(&mut self) {
unsafe { libc::free(self.raw as *mut _); }
}
}
unsafe impl std::marker::Send for GetDeviceContextReply {}
unsafe impl std::marker::Sync for GetDeviceContextReply {}
#[derive(Debug)]
pub struct GetDeviceContextCookie {
seq: u64,
}
#[derive(Debug)]
pub struct GetDeviceContextCookieUnchecked {
seq: u64,
}
impl base::Cookie for GetDeviceContextCookie {
unsafe fn from_sequence(seq: u64) -> Self {
GetDeviceContextCookie { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieChecked for GetDeviceContextCookie {
}
unsafe impl base::CookieWithReplyChecked for GetDeviceContextCookie {
type Reply = GetDeviceContextReply;
}
impl base::Cookie for GetDeviceContextCookieUnchecked {
unsafe fn from_sequence(seq: u64) -> Self {
GetDeviceContextCookieUnchecked { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieWithReplyUnchecked for GetDeviceContextCookieUnchecked {
type Reply = GetDeviceContextReply;
}
#[derive(Clone, Debug)]
pub struct GetDeviceContext {
pub device: u32,
}
unsafe impl base::RawRequest for GetDeviceContext {
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.device.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 GetDeviceContext {
type Cookie = GetDeviceContextCookie;
const IS_VOID: bool = false;
}
impl base::RequestWithReply for GetDeviceContext {
type Reply = GetDeviceContextReply;
type Cookie = GetDeviceContextCookie;
type CookieUnchecked = GetDeviceContextCookieUnchecked;
}
#[derive(Clone, Debug)]
pub struct SetWindowCreateContext<'a> {
pub context: &'a [u8],
}
unsafe impl<'a> base::RawRequest for SetWindowCreateContext<'a> {
fn raw_request(&self, c: &base::Connection, checked: bool) -> u64 { unsafe {
let mut protocol_request = xcb_protocol_request_t {
count: 4,
ext: (&mut FFI_EXT) as *mut _,
opcode: 5,
isvoid: 1,
};
let mut sections: [iovec; 6] = [iovec {
iov_base: std::ptr::null_mut(),
iov_len: 0,
}; 6];
let buf0: &mut [u8] = &mut [0; 8];
(self.context.len() as u32).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);
sections[4].iov_base = self.context.as_ptr() as *mut _;
sections[4].iov_len = self.context.len();
sections[5].iov_len = base::align_pad(sections[4].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<'a> base::Request for SetWindowCreateContext<'a> {
type Cookie = base::VoidCookie;
const IS_VOID: bool = true;
}
impl<'a> base::RequestWithoutReply for SetWindowCreateContext<'a> {
}
pub struct GetWindowCreateContextReply {
raw: *const u8,
}
impl GetWindowCreateContextReply {
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;
let context_len = *(ptr.add(sz) as *const u32);
sz += 4usize;
sz += 20usize;
sz += (context_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)
}
}
fn context_len(&self) -> u32 {
unsafe {
let offset = 8usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn context(&self) -> &Lat1Str {
unsafe {
let offset = 32usize;
let len = (self.context_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 GetWindowCreateContextReply {
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 GetWindowCreateContextReply {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("GetWindowCreateContextReply")
.field("response_type", &self.response_type())
.field("pad", &1)
.field("sequence", &self.sequence())
.field("length", &self.length())
.field("context_len", &self.context_len())
.field("pad", &20)
.field("context", &self.context())
.finish()
}
}
impl Drop for GetWindowCreateContextReply {
fn drop(&mut self) {
unsafe { libc::free(self.raw as *mut _); }
}
}
unsafe impl std::marker::Send for GetWindowCreateContextReply {}
unsafe impl std::marker::Sync for GetWindowCreateContextReply {}
#[derive(Debug)]
pub struct GetWindowCreateContextCookie {
seq: u64,
}
#[derive(Debug)]
pub struct GetWindowCreateContextCookieUnchecked {
seq: u64,
}
impl base::Cookie for GetWindowCreateContextCookie {
unsafe fn from_sequence(seq: u64) -> Self {
GetWindowCreateContextCookie { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieChecked for GetWindowCreateContextCookie {
}
unsafe impl base::CookieWithReplyChecked for GetWindowCreateContextCookie {
type Reply = GetWindowCreateContextReply;
}
impl base::Cookie for GetWindowCreateContextCookieUnchecked {
unsafe fn from_sequence(seq: u64) -> Self {
GetWindowCreateContextCookieUnchecked { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieWithReplyUnchecked for GetWindowCreateContextCookieUnchecked {
type Reply = GetWindowCreateContextReply;
}
#[derive(Clone, Debug)]
pub struct GetWindowCreateContext {
}
unsafe impl base::RawRequest for GetWindowCreateContext {
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: 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 GetWindowCreateContext {
type Cookie = GetWindowCreateContextCookie;
const IS_VOID: bool = false;
}
impl base::RequestWithReply for GetWindowCreateContext {
type Reply = GetWindowCreateContextReply;
type Cookie = GetWindowCreateContextCookie;
type CookieUnchecked = GetWindowCreateContextCookieUnchecked;
}
pub struct GetWindowContextReply {
raw: *const u8,
}
impl GetWindowContextReply {
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;
let context_len = *(ptr.add(sz) as *const u32);
sz += 4usize;
sz += 20usize;
sz += (context_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)
}
}
fn context_len(&self) -> u32 {
unsafe {
let offset = 8usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn context(&self) -> &Lat1Str {
unsafe {
let offset = 32usize;
let len = (self.context_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 GetWindowContextReply {
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 GetWindowContextReply {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("GetWindowContextReply")
.field("response_type", &self.response_type())
.field("pad", &1)
.field("sequence", &self.sequence())
.field("length", &self.length())
.field("context_len", &self.context_len())
.field("pad", &20)
.field("context", &self.context())
.finish()
}
}
impl Drop for GetWindowContextReply {
fn drop(&mut self) {
unsafe { libc::free(self.raw as *mut _); }
}
}
unsafe impl std::marker::Send for GetWindowContextReply {}
unsafe impl std::marker::Sync for GetWindowContextReply {}
#[derive(Debug)]
pub struct GetWindowContextCookie {
seq: u64,
}
#[derive(Debug)]
pub struct GetWindowContextCookieUnchecked {
seq: u64,
}
impl base::Cookie for GetWindowContextCookie {
unsafe fn from_sequence(seq: u64) -> Self {
GetWindowContextCookie { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieChecked for GetWindowContextCookie {
}
unsafe impl base::CookieWithReplyChecked for GetWindowContextCookie {
type Reply = GetWindowContextReply;
}
impl base::Cookie for GetWindowContextCookieUnchecked {
unsafe fn from_sequence(seq: u64) -> Self {
GetWindowContextCookieUnchecked { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieWithReplyUnchecked for GetWindowContextCookieUnchecked {
type Reply = GetWindowContextReply;
}
#[derive(Clone, Debug)]
pub struct GetWindowContext {
pub window: xproto::Window,
}
unsafe impl base::RawRequest for GetWindowContext {
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; 8];
self.window.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 GetWindowContext {
type Cookie = GetWindowContextCookie;
const IS_VOID: bool = false;
}
impl base::RequestWithReply for GetWindowContext {
type Reply = GetWindowContextReply;
type Cookie = GetWindowContextCookie;
type CookieUnchecked = GetWindowContextCookieUnchecked;
}
#[derive(Clone, Debug)]
pub struct SetPropertyCreateContext<'a> {
pub context: &'a [u8],
}
unsafe impl<'a> base::RawRequest for SetPropertyCreateContext<'a> {
fn raw_request(&self, c: &base::Connection, checked: bool) -> u64 { unsafe {
let mut protocol_request = xcb_protocol_request_t {
count: 4,
ext: (&mut FFI_EXT) as *mut _,
opcode: 8,
isvoid: 1,
};
let mut sections: [iovec; 6] = [iovec {
iov_base: std::ptr::null_mut(),
iov_len: 0,
}; 6];
let buf0: &mut [u8] = &mut [0; 8];
(self.context.len() as u32).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);
sections[4].iov_base = self.context.as_ptr() as *mut _;
sections[4].iov_len = self.context.len();
sections[5].iov_len = base::align_pad(sections[4].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<'a> base::Request for SetPropertyCreateContext<'a> {
type Cookie = base::VoidCookie;
const IS_VOID: bool = true;
}
impl<'a> base::RequestWithoutReply for SetPropertyCreateContext<'a> {
}
pub struct GetPropertyCreateContextReply {
raw: *const u8,
}
impl GetPropertyCreateContextReply {
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;
let context_len = *(ptr.add(sz) as *const u32);
sz += 4usize;
sz += 20usize;
sz += (context_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)
}
}
fn context_len(&self) -> u32 {
unsafe {
let offset = 8usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn context(&self) -> &Lat1Str {
unsafe {
let offset = 32usize;
let len = (self.context_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 GetPropertyCreateContextReply {
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 GetPropertyCreateContextReply {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("GetPropertyCreateContextReply")
.field("response_type", &self.response_type())
.field("pad", &1)
.field("sequence", &self.sequence())
.field("length", &self.length())
.field("context_len", &self.context_len())
.field("pad", &20)
.field("context", &self.context())
.finish()
}
}
impl Drop for GetPropertyCreateContextReply {
fn drop(&mut self) {
unsafe { libc::free(self.raw as *mut _); }
}
}
unsafe impl std::marker::Send for GetPropertyCreateContextReply {}
unsafe impl std::marker::Sync for GetPropertyCreateContextReply {}
#[derive(Debug)]
pub struct GetPropertyCreateContextCookie {
seq: u64,
}
#[derive(Debug)]
pub struct GetPropertyCreateContextCookieUnchecked {
seq: u64,
}
impl base::Cookie for GetPropertyCreateContextCookie {
unsafe fn from_sequence(seq: u64) -> Self {
GetPropertyCreateContextCookie { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieChecked for GetPropertyCreateContextCookie {
}
unsafe impl base::CookieWithReplyChecked for GetPropertyCreateContextCookie {
type Reply = GetPropertyCreateContextReply;
}
impl base::Cookie for GetPropertyCreateContextCookieUnchecked {
unsafe fn from_sequence(seq: u64) -> Self {
GetPropertyCreateContextCookieUnchecked { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieWithReplyUnchecked for GetPropertyCreateContextCookieUnchecked {
type Reply = GetPropertyCreateContextReply;
}
#[derive(Clone, Debug)]
pub struct GetPropertyCreateContext {
}
unsafe impl base::RawRequest for GetPropertyCreateContext {
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; 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 GetPropertyCreateContext {
type Cookie = GetPropertyCreateContextCookie;
const IS_VOID: bool = false;
}
impl base::RequestWithReply for GetPropertyCreateContext {
type Reply = GetPropertyCreateContextReply;
type Cookie = GetPropertyCreateContextCookie;
type CookieUnchecked = GetPropertyCreateContextCookieUnchecked;
}
#[derive(Clone, Debug)]
pub struct SetPropertyUseContext<'a> {
pub context: &'a [u8],
}
unsafe impl<'a> base::RawRequest for SetPropertyUseContext<'a> {
fn raw_request(&self, c: &base::Connection, checked: bool) -> u64 { unsafe {
let mut protocol_request = xcb_protocol_request_t {
count: 4,
ext: (&mut FFI_EXT) as *mut _,
opcode: 10,
isvoid: 1,
};
let mut sections: [iovec; 6] = [iovec {
iov_base: std::ptr::null_mut(),
iov_len: 0,
}; 6];
let buf0: &mut [u8] = &mut [0; 8];
(self.context.len() as u32).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);
sections[4].iov_base = self.context.as_ptr() as *mut _;
sections[4].iov_len = self.context.len();
sections[5].iov_len = base::align_pad(sections[4].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<'a> base::Request for SetPropertyUseContext<'a> {
type Cookie = base::VoidCookie;
const IS_VOID: bool = true;
}
impl<'a> base::RequestWithoutReply for SetPropertyUseContext<'a> {
}
pub struct GetPropertyUseContextReply {
raw: *const u8,
}
impl GetPropertyUseContextReply {
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;
let context_len = *(ptr.add(sz) as *const u32);
sz += 4usize;
sz += 20usize;
sz += (context_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)
}
}
fn context_len(&self) -> u32 {
unsafe {
let offset = 8usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn context(&self) -> &Lat1Str {
unsafe {
let offset = 32usize;
let len = (self.context_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 GetPropertyUseContextReply {
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 GetPropertyUseContextReply {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("GetPropertyUseContextReply")
.field("response_type", &self.response_type())
.field("pad", &1)
.field("sequence", &self.sequence())
.field("length", &self.length())
.field("context_len", &self.context_len())
.field("pad", &20)
.field("context", &self.context())
.finish()
}
}
impl Drop for GetPropertyUseContextReply {
fn drop(&mut self) {
unsafe { libc::free(self.raw as *mut _); }
}
}
unsafe impl std::marker::Send for GetPropertyUseContextReply {}
unsafe impl std::marker::Sync for GetPropertyUseContextReply {}
#[derive(Debug)]
pub struct GetPropertyUseContextCookie {
seq: u64,
}
#[derive(Debug)]
pub struct GetPropertyUseContextCookieUnchecked {
seq: u64,
}
impl base::Cookie for GetPropertyUseContextCookie {
unsafe fn from_sequence(seq: u64) -> Self {
GetPropertyUseContextCookie { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieChecked for GetPropertyUseContextCookie {
}
unsafe impl base::CookieWithReplyChecked for GetPropertyUseContextCookie {
type Reply = GetPropertyUseContextReply;
}
impl base::Cookie for GetPropertyUseContextCookieUnchecked {
unsafe fn from_sequence(seq: u64) -> Self {
GetPropertyUseContextCookieUnchecked { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieWithReplyUnchecked for GetPropertyUseContextCookieUnchecked {
type Reply = GetPropertyUseContextReply;
}
#[derive(Clone, Debug)]
pub struct GetPropertyUseContext {
}
unsafe impl base::RawRequest for GetPropertyUseContext {
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; 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 GetPropertyUseContext {
type Cookie = GetPropertyUseContextCookie;
const IS_VOID: bool = false;
}
impl base::RequestWithReply for GetPropertyUseContext {
type Reply = GetPropertyUseContextReply;
type Cookie = GetPropertyUseContextCookie;
type CookieUnchecked = GetPropertyUseContextCookieUnchecked;
}
pub struct GetPropertyContextReply {
raw: *const u8,
}
impl GetPropertyContextReply {
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;
let context_len = *(ptr.add(sz) as *const u32);
sz += 4usize;
sz += 20usize;
sz += (context_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)
}
}
fn context_len(&self) -> u32 {
unsafe {
let offset = 8usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn context(&self) -> &Lat1Str {
unsafe {
let offset = 32usize;
let len = (self.context_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 GetPropertyContextReply {
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 GetPropertyContextReply {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("GetPropertyContextReply")
.field("response_type", &self.response_type())
.field("pad", &1)
.field("sequence", &self.sequence())
.field("length", &self.length())
.field("context_len", &self.context_len())
.field("pad", &20)
.field("context", &self.context())
.finish()
}
}
impl Drop for GetPropertyContextReply {
fn drop(&mut self) {
unsafe { libc::free(self.raw as *mut _); }
}
}
unsafe impl std::marker::Send for GetPropertyContextReply {}
unsafe impl std::marker::Sync for GetPropertyContextReply {}
#[derive(Debug)]
pub struct GetPropertyContextCookie {
seq: u64,
}
#[derive(Debug)]
pub struct GetPropertyContextCookieUnchecked {
seq: u64,
}
impl base::Cookie for GetPropertyContextCookie {
unsafe fn from_sequence(seq: u64) -> Self {
GetPropertyContextCookie { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieChecked for GetPropertyContextCookie {
}
unsafe impl base::CookieWithReplyChecked for GetPropertyContextCookie {
type Reply = GetPropertyContextReply;
}
impl base::Cookie for GetPropertyContextCookieUnchecked {
unsafe fn from_sequence(seq: u64) -> Self {
GetPropertyContextCookieUnchecked { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieWithReplyUnchecked for GetPropertyContextCookieUnchecked {
type Reply = GetPropertyContextReply;
}
#[derive(Clone, Debug)]
pub struct GetPropertyContext {
pub window: xproto::Window,
pub property: xproto::Atom,
}
unsafe impl base::RawRequest for GetPropertyContext {
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: 12,
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.window.serialize(&mut buf0[4 .. ]);
self.property.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 GetPropertyContext {
type Cookie = GetPropertyContextCookie;
const IS_VOID: bool = false;
}
impl base::RequestWithReply for GetPropertyContext {
type Reply = GetPropertyContextReply;
type Cookie = GetPropertyContextCookie;
type CookieUnchecked = GetPropertyContextCookieUnchecked;
}
pub struct GetPropertyDataContextReply {
raw: *const u8,
}
impl GetPropertyDataContextReply {
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;
let context_len = *(ptr.add(sz) as *const u32);
sz += 4usize;
sz += 20usize;
sz += (context_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)
}
}
fn context_len(&self) -> u32 {
unsafe {
let offset = 8usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn context(&self) -> &Lat1Str {
unsafe {
let offset = 32usize;
let len = (self.context_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 GetPropertyDataContextReply {
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 GetPropertyDataContextReply {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("GetPropertyDataContextReply")
.field("response_type", &self.response_type())
.field("pad", &1)
.field("sequence", &self.sequence())
.field("length", &self.length())
.field("context_len", &self.context_len())
.field("pad", &20)
.field("context", &self.context())
.finish()
}
}
impl Drop for GetPropertyDataContextReply {
fn drop(&mut self) {
unsafe { libc::free(self.raw as *mut _); }
}
}
unsafe impl std::marker::Send for GetPropertyDataContextReply {}
unsafe impl std::marker::Sync for GetPropertyDataContextReply {}
#[derive(Debug)]
pub struct GetPropertyDataContextCookie {
seq: u64,
}
#[derive(Debug)]
pub struct GetPropertyDataContextCookieUnchecked {
seq: u64,
}
impl base::Cookie for GetPropertyDataContextCookie {
unsafe fn from_sequence(seq: u64) -> Self {
GetPropertyDataContextCookie { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieChecked for GetPropertyDataContextCookie {
}
unsafe impl base::CookieWithReplyChecked for GetPropertyDataContextCookie {
type Reply = GetPropertyDataContextReply;
}
impl base::Cookie for GetPropertyDataContextCookieUnchecked {
unsafe fn from_sequence(seq: u64) -> Self {
GetPropertyDataContextCookieUnchecked { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieWithReplyUnchecked for GetPropertyDataContextCookieUnchecked {
type Reply = GetPropertyDataContextReply;
}
#[derive(Clone, Debug)]
pub struct GetPropertyDataContext {
pub window: xproto::Window,
pub property: xproto::Atom,
}
unsafe impl base::RawRequest for GetPropertyDataContext {
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: 13,
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.window.serialize(&mut buf0[4 .. ]);
self.property.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 GetPropertyDataContext {
type Cookie = GetPropertyDataContextCookie;
const IS_VOID: bool = false;
}
impl base::RequestWithReply for GetPropertyDataContext {
type Reply = GetPropertyDataContextReply;
type Cookie = GetPropertyDataContextCookie;
type CookieUnchecked = GetPropertyDataContextCookieUnchecked;
}
pub struct ListPropertiesReply {
raw: *const u8,
}
impl ListPropertiesReply {
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;
let properties_len = *(ptr.add(sz) as *const u32);
sz += 4usize;
sz += 20usize;
for _ in 0 .. (properties_len as usize) {
sz += <&ListItem>::compute_wire_len(ptr.add(sz), ());
}
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)
}
}
fn properties_len(&self) -> u32 {
unsafe {
let offset = 8usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn properties(&self) -> ListItemIterator {
unsafe {
let offset = 32usize;
ListItemIterator {
params: (),
rem: (self.properties_len() as usize),
ptr: self.wire_ptr().add(offset),
phantom: std::marker::PhantomData,
}
}
}
}
impl base::Reply for ListPropertiesReply {
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 ListPropertiesReply {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("ListPropertiesReply")
.field("response_type", &self.response_type())
.field("pad", &1)
.field("sequence", &self.sequence())
.field("length", &self.length())
.field("properties_len", &self.properties_len())
.field("pad", &20)
.field("properties", &self.properties())
.finish()
}
}
impl Drop for ListPropertiesReply {
fn drop(&mut self) {
unsafe { libc::free(self.raw as *mut _); }
}
}
unsafe impl std::marker::Send for ListPropertiesReply {}
unsafe impl std::marker::Sync for ListPropertiesReply {}
#[derive(Debug)]
pub struct ListPropertiesCookie {
seq: u64,
}
#[derive(Debug)]
pub struct ListPropertiesCookieUnchecked {
seq: u64,
}
impl base::Cookie for ListPropertiesCookie {
unsafe fn from_sequence(seq: u64) -> Self {
ListPropertiesCookie { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieChecked for ListPropertiesCookie {
}
unsafe impl base::CookieWithReplyChecked for ListPropertiesCookie {
type Reply = ListPropertiesReply;
}
impl base::Cookie for ListPropertiesCookieUnchecked {
unsafe fn from_sequence(seq: u64) -> Self {
ListPropertiesCookieUnchecked { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieWithReplyUnchecked for ListPropertiesCookieUnchecked {
type Reply = ListPropertiesReply;
}
#[derive(Clone, Debug)]
pub struct ListProperties {
pub window: xproto::Window,
}
unsafe impl base::RawRequest for ListProperties {
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: 14,
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.window.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 ListProperties {
type Cookie = ListPropertiesCookie;
const IS_VOID: bool = false;
}
impl base::RequestWithReply for ListProperties {
type Reply = ListPropertiesReply;
type Cookie = ListPropertiesCookie;
type CookieUnchecked = ListPropertiesCookieUnchecked;
}
#[derive(Clone, Debug)]
pub struct SetSelectionCreateContext<'a> {
pub context: &'a [u8],
}
unsafe impl<'a> base::RawRequest for SetSelectionCreateContext<'a> {
fn raw_request(&self, c: &base::Connection, checked: bool) -> u64 { unsafe {
let mut protocol_request = xcb_protocol_request_t {
count: 4,
ext: (&mut FFI_EXT) as *mut _,
opcode: 15,
isvoid: 1,
};
let mut sections: [iovec; 6] = [iovec {
iov_base: std::ptr::null_mut(),
iov_len: 0,
}; 6];
let buf0: &mut [u8] = &mut [0; 8];
(self.context.len() as u32).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);
sections[4].iov_base = self.context.as_ptr() as *mut _;
sections[4].iov_len = self.context.len();
sections[5].iov_len = base::align_pad(sections[4].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<'a> base::Request for SetSelectionCreateContext<'a> {
type Cookie = base::VoidCookie;
const IS_VOID: bool = true;
}
impl<'a> base::RequestWithoutReply for SetSelectionCreateContext<'a> {
}
pub struct GetSelectionCreateContextReply {
raw: *const u8,
}
impl GetSelectionCreateContextReply {
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;
let context_len = *(ptr.add(sz) as *const u32);
sz += 4usize;
sz += 20usize;
sz += (context_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)
}
}
fn context_len(&self) -> u32 {
unsafe {
let offset = 8usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn context(&self) -> &Lat1Str {
unsafe {
let offset = 32usize;
let len = (self.context_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 GetSelectionCreateContextReply {
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 GetSelectionCreateContextReply {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("GetSelectionCreateContextReply")
.field("response_type", &self.response_type())
.field("pad", &1)
.field("sequence", &self.sequence())
.field("length", &self.length())
.field("context_len", &self.context_len())
.field("pad", &20)
.field("context", &self.context())
.finish()
}
}
impl Drop for GetSelectionCreateContextReply {
fn drop(&mut self) {
unsafe { libc::free(self.raw as *mut _); }
}
}
unsafe impl std::marker::Send for GetSelectionCreateContextReply {}
unsafe impl std::marker::Sync for GetSelectionCreateContextReply {}
#[derive(Debug)]
pub struct GetSelectionCreateContextCookie {
seq: u64,
}
#[derive(Debug)]
pub struct GetSelectionCreateContextCookieUnchecked {
seq: u64,
}
impl base::Cookie for GetSelectionCreateContextCookie {
unsafe fn from_sequence(seq: u64) -> Self {
GetSelectionCreateContextCookie { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieChecked for GetSelectionCreateContextCookie {
}
unsafe impl base::CookieWithReplyChecked for GetSelectionCreateContextCookie {
type Reply = GetSelectionCreateContextReply;
}
impl base::Cookie for GetSelectionCreateContextCookieUnchecked {
unsafe fn from_sequence(seq: u64) -> Self {
GetSelectionCreateContextCookieUnchecked { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieWithReplyUnchecked for GetSelectionCreateContextCookieUnchecked {
type Reply = GetSelectionCreateContextReply;
}
#[derive(Clone, Debug)]
pub struct GetSelectionCreateContext {
}
unsafe impl base::RawRequest for GetSelectionCreateContext {
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: 16,
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 GetSelectionCreateContext {
type Cookie = GetSelectionCreateContextCookie;
const IS_VOID: bool = false;
}
impl base::RequestWithReply for GetSelectionCreateContext {
type Reply = GetSelectionCreateContextReply;
type Cookie = GetSelectionCreateContextCookie;
type CookieUnchecked = GetSelectionCreateContextCookieUnchecked;
}
#[derive(Clone, Debug)]
pub struct SetSelectionUseContext<'a> {
pub context: &'a [u8],
}
unsafe impl<'a> base::RawRequest for SetSelectionUseContext<'a> {
fn raw_request(&self, c: &base::Connection, checked: bool) -> u64 { unsafe {
let mut protocol_request = xcb_protocol_request_t {
count: 4,
ext: (&mut FFI_EXT) as *mut _,
opcode: 17,
isvoid: 1,
};
let mut sections: [iovec; 6] = [iovec {
iov_base: std::ptr::null_mut(),
iov_len: 0,
}; 6];
let buf0: &mut [u8] = &mut [0; 8];
(self.context.len() as u32).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);
sections[4].iov_base = self.context.as_ptr() as *mut _;
sections[4].iov_len = self.context.len();
sections[5].iov_len = base::align_pad(sections[4].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<'a> base::Request for SetSelectionUseContext<'a> {
type Cookie = base::VoidCookie;
const IS_VOID: bool = true;
}
impl<'a> base::RequestWithoutReply for SetSelectionUseContext<'a> {
}
pub struct GetSelectionUseContextReply {
raw: *const u8,
}
impl GetSelectionUseContextReply {
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;
let context_len = *(ptr.add(sz) as *const u32);
sz += 4usize;
sz += 20usize;
sz += (context_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)
}
}
fn context_len(&self) -> u32 {
unsafe {
let offset = 8usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn context(&self) -> &Lat1Str {
unsafe {
let offset = 32usize;
let len = (self.context_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 GetSelectionUseContextReply {
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 GetSelectionUseContextReply {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("GetSelectionUseContextReply")
.field("response_type", &self.response_type())
.field("pad", &1)
.field("sequence", &self.sequence())
.field("length", &self.length())
.field("context_len", &self.context_len())
.field("pad", &20)
.field("context", &self.context())
.finish()
}
}
impl Drop for GetSelectionUseContextReply {
fn drop(&mut self) {
unsafe { libc::free(self.raw as *mut _); }
}
}
unsafe impl std::marker::Send for GetSelectionUseContextReply {}
unsafe impl std::marker::Sync for GetSelectionUseContextReply {}
#[derive(Debug)]
pub struct GetSelectionUseContextCookie {
seq: u64,
}
#[derive(Debug)]
pub struct GetSelectionUseContextCookieUnchecked {
seq: u64,
}
impl base::Cookie for GetSelectionUseContextCookie {
unsafe fn from_sequence(seq: u64) -> Self {
GetSelectionUseContextCookie { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieChecked for GetSelectionUseContextCookie {
}
unsafe impl base::CookieWithReplyChecked for GetSelectionUseContextCookie {
type Reply = GetSelectionUseContextReply;
}
impl base::Cookie for GetSelectionUseContextCookieUnchecked {
unsafe fn from_sequence(seq: u64) -> Self {
GetSelectionUseContextCookieUnchecked { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieWithReplyUnchecked for GetSelectionUseContextCookieUnchecked {
type Reply = GetSelectionUseContextReply;
}
#[derive(Clone, Debug)]
pub struct GetSelectionUseContext {
}
unsafe impl base::RawRequest for GetSelectionUseContext {
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: 18,
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 GetSelectionUseContext {
type Cookie = GetSelectionUseContextCookie;
const IS_VOID: bool = false;
}
impl base::RequestWithReply for GetSelectionUseContext {
type Reply = GetSelectionUseContextReply;
type Cookie = GetSelectionUseContextCookie;
type CookieUnchecked = GetSelectionUseContextCookieUnchecked;
}
pub struct GetSelectionContextReply {
raw: *const u8,
}
impl GetSelectionContextReply {
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;
let context_len = *(ptr.add(sz) as *const u32);
sz += 4usize;
sz += 20usize;
sz += (context_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)
}
}
fn context_len(&self) -> u32 {
unsafe {
let offset = 8usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn context(&self) -> &Lat1Str {
unsafe {
let offset = 32usize;
let len = (self.context_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 GetSelectionContextReply {
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 GetSelectionContextReply {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("GetSelectionContextReply")
.field("response_type", &self.response_type())
.field("pad", &1)
.field("sequence", &self.sequence())
.field("length", &self.length())
.field("context_len", &self.context_len())
.field("pad", &20)
.field("context", &self.context())
.finish()
}
}
impl Drop for GetSelectionContextReply {
fn drop(&mut self) {
unsafe { libc::free(self.raw as *mut _); }
}
}
unsafe impl std::marker::Send for GetSelectionContextReply {}
unsafe impl std::marker::Sync for GetSelectionContextReply {}
#[derive(Debug)]
pub struct GetSelectionContextCookie {
seq: u64,
}
#[derive(Debug)]
pub struct GetSelectionContextCookieUnchecked {
seq: u64,
}
impl base::Cookie for GetSelectionContextCookie {
unsafe fn from_sequence(seq: u64) -> Self {
GetSelectionContextCookie { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieChecked for GetSelectionContextCookie {
}
unsafe impl base::CookieWithReplyChecked for GetSelectionContextCookie {
type Reply = GetSelectionContextReply;
}
impl base::Cookie for GetSelectionContextCookieUnchecked {
unsafe fn from_sequence(seq: u64) -> Self {
GetSelectionContextCookieUnchecked { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieWithReplyUnchecked for GetSelectionContextCookieUnchecked {
type Reply = GetSelectionContextReply;
}
#[derive(Clone, Debug)]
pub struct GetSelectionContext {
pub selection: xproto::Atom,
}
unsafe impl base::RawRequest for GetSelectionContext {
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: 19,
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.selection.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 GetSelectionContext {
type Cookie = GetSelectionContextCookie;
const IS_VOID: bool = false;
}
impl base::RequestWithReply for GetSelectionContext {
type Reply = GetSelectionContextReply;
type Cookie = GetSelectionContextCookie;
type CookieUnchecked = GetSelectionContextCookieUnchecked;
}
pub struct GetSelectionDataContextReply {
raw: *const u8,
}
impl GetSelectionDataContextReply {
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;
let context_len = *(ptr.add(sz) as *const u32);
sz += 4usize;
sz += 20usize;
sz += (context_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)
}
}
fn context_len(&self) -> u32 {
unsafe {
let offset = 8usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn context(&self) -> &Lat1Str {
unsafe {
let offset = 32usize;
let len = (self.context_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 GetSelectionDataContextReply {
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 GetSelectionDataContextReply {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("GetSelectionDataContextReply")
.field("response_type", &self.response_type())
.field("pad", &1)
.field("sequence", &self.sequence())
.field("length", &self.length())
.field("context_len", &self.context_len())
.field("pad", &20)
.field("context", &self.context())
.finish()
}
}
impl Drop for GetSelectionDataContextReply {
fn drop(&mut self) {
unsafe { libc::free(self.raw as *mut _); }
}
}
unsafe impl std::marker::Send for GetSelectionDataContextReply {}
unsafe impl std::marker::Sync for GetSelectionDataContextReply {}
#[derive(Debug)]
pub struct GetSelectionDataContextCookie {
seq: u64,
}
#[derive(Debug)]
pub struct GetSelectionDataContextCookieUnchecked {
seq: u64,
}
impl base::Cookie for GetSelectionDataContextCookie {
unsafe fn from_sequence(seq: u64) -> Self {
GetSelectionDataContextCookie { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieChecked for GetSelectionDataContextCookie {
}
unsafe impl base::CookieWithReplyChecked for GetSelectionDataContextCookie {
type Reply = GetSelectionDataContextReply;
}
impl base::Cookie for GetSelectionDataContextCookieUnchecked {
unsafe fn from_sequence(seq: u64) -> Self {
GetSelectionDataContextCookieUnchecked { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieWithReplyUnchecked for GetSelectionDataContextCookieUnchecked {
type Reply = GetSelectionDataContextReply;
}
#[derive(Clone, Debug)]
pub struct GetSelectionDataContext {
pub selection: xproto::Atom,
}
unsafe impl base::RawRequest for GetSelectionDataContext {
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: 20,
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.selection.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 GetSelectionDataContext {
type Cookie = GetSelectionDataContextCookie;
const IS_VOID: bool = false;
}
impl base::RequestWithReply for GetSelectionDataContext {
type Reply = GetSelectionDataContextReply;
type Cookie = GetSelectionDataContextCookie;
type CookieUnchecked = GetSelectionDataContextCookieUnchecked;
}
pub struct ListSelectionsReply {
raw: *const u8,
}
impl ListSelectionsReply {
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;
let selections_len = *(ptr.add(sz) as *const u32);
sz += 4usize;
sz += 20usize;
for _ in 0 .. (selections_len as usize) {
sz += <&ListItem>::compute_wire_len(ptr.add(sz), ());
}
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)
}
}
fn selections_len(&self) -> u32 {
unsafe {
let offset = 8usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn selections(&self) -> ListItemIterator {
unsafe {
let offset = 32usize;
ListItemIterator {
params: (),
rem: (self.selections_len() as usize),
ptr: self.wire_ptr().add(offset),
phantom: std::marker::PhantomData,
}
}
}
}
impl base::Reply for ListSelectionsReply {
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 ListSelectionsReply {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("ListSelectionsReply")
.field("response_type", &self.response_type())
.field("pad", &1)
.field("sequence", &self.sequence())
.field("length", &self.length())
.field("selections_len", &self.selections_len())
.field("pad", &20)
.field("selections", &self.selections())
.finish()
}
}
impl Drop for ListSelectionsReply {
fn drop(&mut self) {
unsafe { libc::free(self.raw as *mut _); }
}
}
unsafe impl std::marker::Send for ListSelectionsReply {}
unsafe impl std::marker::Sync for ListSelectionsReply {}
#[derive(Debug)]
pub struct ListSelectionsCookie {
seq: u64,
}
#[derive(Debug)]
pub struct ListSelectionsCookieUnchecked {
seq: u64,
}
impl base::Cookie for ListSelectionsCookie {
unsafe fn from_sequence(seq: u64) -> Self {
ListSelectionsCookie { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieChecked for ListSelectionsCookie {
}
unsafe impl base::CookieWithReplyChecked for ListSelectionsCookie {
type Reply = ListSelectionsReply;
}
impl base::Cookie for ListSelectionsCookieUnchecked {
unsafe fn from_sequence(seq: u64) -> Self {
ListSelectionsCookieUnchecked { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieWithReplyUnchecked for ListSelectionsCookieUnchecked {
type Reply = ListSelectionsReply;
}
#[derive(Clone, Debug)]
pub struct ListSelections {
}
unsafe impl base::RawRequest for ListSelections {
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: 21,
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 ListSelections {
type Cookie = ListSelectionsCookie;
const IS_VOID: bool = false;
}
impl base::RequestWithReply for ListSelections {
type Reply = ListSelectionsReply;
type Cookie = ListSelectionsCookie;
type CookieUnchecked = ListSelectionsCookieUnchecked;
}
pub struct GetClientContextReply {
raw: *const u8,
}
impl GetClientContextReply {
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;
let context_len = *(ptr.add(sz) as *const u32);
sz += 4usize;
sz += 20usize;
sz += (context_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)
}
}
fn context_len(&self) -> u32 {
unsafe {
let offset = 8usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn context(&self) -> &Lat1Str {
unsafe {
let offset = 32usize;
let len = (self.context_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 GetClientContextReply {
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 GetClientContextReply {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("GetClientContextReply")
.field("response_type", &self.response_type())
.field("pad", &1)
.field("sequence", &self.sequence())
.field("length", &self.length())
.field("context_len", &self.context_len())
.field("pad", &20)
.field("context", &self.context())
.finish()
}
}
impl Drop for GetClientContextReply {
fn drop(&mut self) {
unsafe { libc::free(self.raw as *mut _); }
}
}
unsafe impl std::marker::Send for GetClientContextReply {}
unsafe impl std::marker::Sync for GetClientContextReply {}
#[derive(Debug)]
pub struct GetClientContextCookie {
seq: u64,
}
#[derive(Debug)]
pub struct GetClientContextCookieUnchecked {
seq: u64,
}
impl base::Cookie for GetClientContextCookie {
unsafe fn from_sequence(seq: u64) -> Self {
GetClientContextCookie { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieChecked for GetClientContextCookie {
}
unsafe impl base::CookieWithReplyChecked for GetClientContextCookie {
type Reply = GetClientContextReply;
}
impl base::Cookie for GetClientContextCookieUnchecked {
unsafe fn from_sequence(seq: u64) -> Self {
GetClientContextCookieUnchecked { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieWithReplyUnchecked for GetClientContextCookieUnchecked {
type Reply = GetClientContextReply;
}
#[derive(Clone, Debug)]
pub struct GetClientContext {
pub resource: u32,
}
unsafe impl base::RawRequest for GetClientContext {
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: 22,
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.resource.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 GetClientContext {
type Cookie = GetClientContextCookie;
const IS_VOID: bool = false;
}
impl base::RequestWithReply for GetClientContext {
type Reply = GetClientContextReply;
type Cookie = GetClientContextCookie;
type CookieUnchecked = GetClientContextCookieUnchecked;
}