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 = "MIT-SCREEN-SAVER";
pub const MAJOR_VERSION: u32 = 1;
pub const MINOR_VERSION: u32 = 1;
pub const VERSION_STRING: &str = "1.1";
pub(crate) static mut FFI_EXT: xcb_extension_t = xcb_extension_t {
name: "MIT-SCREEN-SAVER\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(), std::ptr::addr_of_mut!(FFI_EXT));
}
}
pub fn get_extension_data(conn: &base::Connection) -> std::option::Option<ext::ExtensionData> {
unsafe {
let reply = xcb_get_extension_data(conn.get_raw_conn(), std::ptr::addr_of_mut!(FFI_EXT));
assert!(!reply.is_null(), "Could not fetch ScreenSaver 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::ScreenSaver,
major_opcode: reply.major_opcode(),
first_event: reply.first_event(),
first_error: reply.first_error(),
};
std::mem::forget(reply);
Some(res)
}
}
pub struct NotifyEvent {
raw: *mut xcb_generic_event_t,
}
impl base::Raw<xcb_generic_event_t> for NotifyEvent {
unsafe fn from_raw(raw: *mut xcb_generic_event_t) -> Self { NotifyEvent { raw } }
fn as_raw(&self) -> *mut xcb_generic_event_t {
self.raw
}
}
impl base::BaseEvent for NotifyEvent {
const EXTENSION: std::option::Option<ext::Extension> = Some(ext::Extension::ScreenSaver);
const NUMBER: u32 = 0;
}
impl NotifyEvent {
pub fn new(event_base: u8,
state: State,
time: xproto::Timestamp,
root: xproto::Window,
window: xproto::Window,
kind: Kind,
forced: bool,
) -> NotifyEvent {
unsafe {
let ptr = libc::malloc(32) as *mut u8;
let wire_buf = std::slice::from_raw_parts_mut(ptr, 32);
let mut wire_off = 0usize;
let response_type = event_base;
let sequence = 0u16;
wire_off += response_type.serialize(&mut wire_buf[wire_off ..]);
wire_off += (std::mem::transmute::<_, u32>(state) as u8).serialize(&mut wire_buf[wire_off ..]);
wire_off += sequence.serialize(&mut wire_buf[wire_off ..]);
wire_off += time.serialize(&mut wire_buf[wire_off ..]);
wire_off += root.serialize(&mut wire_buf[wire_off ..]);
wire_off += window.serialize(&mut wire_buf[wire_off ..]);
wire_off += (std::mem::transmute::<_, u32>(kind) as u8).serialize(&mut wire_buf[wire_off ..]);
let forced: u8 = if forced { 1 } else { 0 };
forced.serialize(&mut wire_buf[wire_off ..]);
NotifyEvent::from_raw(ptr as *mut xcb_generic_event_t)
}
}
fn wire_ptr(&self) -> *const u8 { self.raw as *const u8 }
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 state(&self) -> State {
unsafe {
let offset = 1usize;
let ptr = self.wire_ptr().add(offset) as *const u8;
let val = base::value_from_ptr(ptr) as u32;
std::mem::transmute::<u32, State>(val)
}
}
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 time(&self) -> xproto::Timestamp {
unsafe {
let offset = 4usize;
let ptr = self.wire_ptr().add(offset) as *const xproto::Timestamp;
base::value_from_ptr(ptr)
}
}
pub fn root(&self) -> xproto::Window {
unsafe {
let offset = 8usize;
let ptr = self.wire_ptr().add(offset) as *const xproto::Window;
base::value_from_ptr(ptr)
}
}
pub fn window(&self) -> xproto::Window {
unsafe {
let offset = 12usize;
let ptr = self.wire_ptr().add(offset) as *const xproto::Window;
base::value_from_ptr(ptr)
}
}
pub fn kind(&self) -> Kind {
unsafe {
let offset = 16usize;
let ptr = self.wire_ptr().add(offset) as *const u8;
let val = base::value_from_ptr(ptr) as u32;
std::mem::transmute::<u32, Kind>(val)
}
}
pub fn forced(&self) -> bool {
let val = unsafe { *(self.wire_ptr().add(17usize)) };
val != 0
}
}
impl std::fmt::Debug for NotifyEvent {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("NotifyEvent")
.field("response_type", &self.response_type())
.field("state", &self.state())
.field("sequence", &self.sequence())
.field("time", &self.time())
.field("root", &self.root())
.field("window", &self.window())
.field("kind", &self.kind())
.field("forced", &self.forced())
.field("pad", &14)
.finish()
}
}
impl base::WiredOut for NotifyEvent {
fn wire_len(&self) -> usize {
32usize
}
fn serialize(&self, wire_buf: &mut[u8]) -> usize {
debug_assert!(wire_buf.len() >= self.wire_len());
let raw_slice = unsafe { std::slice::from_raw_parts(self.raw as *const u8, self.wire_len()) };
wire_buf[0 .. self.wire_len()].copy_from_slice(raw_slice);
self.wire_len()
}
}
impl base::WiredIn for NotifyEvent {
type Params = ();
unsafe fn compute_wire_len(_ptr: *const u8, _params: ()) -> usize {
32
}
unsafe fn unserialize(ptr: *const u8, _params: (), offset: &mut usize) -> Self {
let sz = Self::compute_wire_len(ptr, ());
*offset += sz;
let raw = libc::malloc(sz) as *mut xcb_generic_event_t;
std::ptr::copy(ptr as *const xcb_generic_event_t, raw, sz);
NotifyEvent { raw }
}
}
impl Drop for NotifyEvent {
fn drop(&mut self) {
unsafe { libc::free(self.raw as *mut _); }
}
}
unsafe impl Send for NotifyEvent {}
unsafe impl Sync for NotifyEvent {}
#[derive(Debug)]
pub enum Event {
Notify(NotifyEvent),
}
impl Event {
pub fn as_raw(&self) -> *mut xcb_generic_event_t {
match self {
Self::Notify(e) => e.as_raw(),
}
}
}
impl base::ResolveWireEvent for Event {
unsafe fn resolve_wire_event(first_event: u8, raw: *mut xcb_generic_event_t) -> std::option::Option<Self> {
debug_assert!(!raw.is_null());
let response_type = (*raw).response_type & 0x7F;
debug_assert!(response_type != 0, "This is not an event but an error!");
debug_assert!(response_type != XCB_GE_GENERIC, "This is a GE_GENERIC event!");
match response_type - first_event {
0 => std::option::Option::Some(Event::Notify(NotifyEvent::from_raw(raw))),
_ => std::option::Option::None,
}
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
#[repr(u32)]
pub enum Kind {
Blanked = 0,
Internal = 1,
External = 2,
}
bitflags! {
pub struct EventFlags: u32 {
const NOTIFY_MASK = 0x00000001;
const CYCLE_MASK = 0x00000002;
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
#[repr(u32)]
pub enum State {
Off = 0,
On = 1,
Cycle = 2,
Disabled = 3,
}
pub(crate) fn request_name(opcode: u16) -> std::option::Option<&'static str> {
match opcode {
0 => Some("screensaver::QueryVersion"),
1 => Some("screensaver::QueryInfo"),
2 => Some("screensaver::SelectInput"),
3 => Some("screensaver::SetAttributes"),
4 => Some("screensaver::UnsetAttributes"),
5 => Some("screensaver::Suspend"),
_ => 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_version(&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_version(&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
}
unsafe fn as_raw(&self) -> *const u8 {
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_version", &self.server_major_version())
.field("server_minor_version", &self.server_minor_version())
.field("pad", &20)
.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_version: u8,
pub client_minor_version: 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: std::ptr::addr_of_mut!(FFI_EXT),
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; 8];
self.client_major_version.serialize(&mut buf0[4 .. ]);
self.client_minor_version.serialize(&mut buf0[5 .. ]);
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 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 QueryInfoReply {
raw: *const u8,
}
impl QueryInfoReply {
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 state(&self) -> u8 {
unsafe {
let offset = 1usize;
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 saver_window(&self) -> xproto::Window {
unsafe {
let offset = 8usize;
let ptr = self.wire_ptr().add(offset) as *const xproto::Window;
base::value_from_ptr(ptr)
}
}
pub fn ms_until_server(&self) -> u32 {
unsafe {
let offset = 12usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn ms_since_user_input(&self) -> u32 {
unsafe {
let offset = 16usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn event_mask(&self) -> u32 {
unsafe {
let offset = 20usize;
let ptr = self.wire_ptr().add(offset) as *const u32;
base::value_from_ptr(ptr)
}
}
pub fn kind(&self) -> Kind {
unsafe {
let offset = 24usize;
let ptr = self.wire_ptr().add(offset) as *const u8;
let val = base::value_from_ptr(ptr) as u32;
std::mem::transmute::<u32, Kind>(val)
}
}
}
impl base::Reply for QueryInfoReply {
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
}
unsafe fn as_raw(&self) -> *const u8 {
self.raw
}
}
impl std::fmt::Debug for QueryInfoReply {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("QueryInfoReply")
.field("response_type", &self.response_type())
.field("state", &self.state())
.field("sequence", &self.sequence())
.field("length", &self.length())
.field("saver_window", &self.saver_window())
.field("ms_until_server", &self.ms_until_server())
.field("ms_since_user_input", &self.ms_since_user_input())
.field("event_mask", &self.event_mask())
.field("kind", &self.kind())
.field("pad", &7)
.finish()
}
}
impl Drop for QueryInfoReply {
fn drop(&mut self) {
unsafe { libc::free(self.raw as *mut _); }
}
}
unsafe impl std::marker::Send for QueryInfoReply {}
unsafe impl std::marker::Sync for QueryInfoReply {}
#[derive(Debug)]
pub struct QueryInfoCookie {
seq: u64,
}
#[derive(Debug)]
pub struct QueryInfoCookieUnchecked {
seq: u64,
}
impl base::Cookie for QueryInfoCookie {
unsafe fn from_sequence(seq: u64) -> Self {
QueryInfoCookie { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieChecked for QueryInfoCookie {
}
unsafe impl base::CookieWithReplyChecked for QueryInfoCookie {
type Reply = QueryInfoReply;
}
impl base::Cookie for QueryInfoCookieUnchecked {
unsafe fn from_sequence(seq: u64) -> Self {
QueryInfoCookieUnchecked { seq }
}
fn sequence(&self) -> u64 {
self.seq
}
}
unsafe impl base::CookieWithReplyUnchecked for QueryInfoCookieUnchecked {
type Reply = QueryInfoReply;
}
#[derive(Clone, Debug)]
pub struct QueryInfo {
pub drawable: xproto::Drawable,
}
unsafe impl base::RawRequest for QueryInfo {
fn raw_request(&self, c: &base::Connection, checked: bool) -> u64 { unsafe {
let mut protocol_request = xcb_protocol_request_t {
count: 2,
ext: std::ptr::addr_of_mut!(FFI_EXT),
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.drawable.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 QueryInfo {
type Cookie = QueryInfoCookie;
const IS_VOID: bool = false;
}
impl base::RequestWithReply for QueryInfo {
type Reply = QueryInfoReply;
type Cookie = QueryInfoCookie;
type CookieUnchecked = QueryInfoCookieUnchecked;
}
#[derive(Clone, Debug)]
pub struct SelectInput {
pub drawable: xproto::Drawable,
pub event_mask: EventFlags,
}
unsafe impl base::RawRequest for SelectInput {
fn raw_request(&self, c: &base::Connection, checked: bool) -> u64 { unsafe {
let mut protocol_request = xcb_protocol_request_t {
count: 2,
ext: std::ptr::addr_of_mut!(FFI_EXT),
opcode: 2,
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.drawable.serialize(&mut buf0[4 .. ]);
self.event_mask.bits().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 SelectInput {
type Cookie = base::VoidCookie;
const IS_VOID: bool = true;
}
impl base::RequestWithoutReply for SelectInput {
}
#[derive(Clone, Debug)]
pub struct SetAttributes<'a> {
pub drawable: xproto::Drawable,
pub x: i16,
pub y: i16,
pub width: u16,
pub height: u16,
pub border_width: u16,
pub class: xproto::WindowClass,
pub depth: u8,
pub visual: xproto::Visualid,
pub value_list: &'a [xproto::Cw],
}
unsafe impl<'a> base::RawRequest for SetAttributes<'a> {
fn raw_request(&self, c: &base::Connection, checked: bool) -> u64 { unsafe {
assert!(xproto::Cw::is_sorted_distinct(self.value_list), "SetAttributes::value_list must be sorted!");
let mut protocol_request = xcb_protocol_request_t {
count: 4,
ext: std::ptr::addr_of_mut!(FFI_EXT),
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; 28];
self.drawable.serialize(&mut buf0[4 .. ]);
self.x.serialize(&mut buf0[8 .. ]);
self.y.serialize(&mut buf0[10 .. ]);
self.width.serialize(&mut buf0[12 .. ]);
self.height.serialize(&mut buf0[14 .. ]);
self.border_width.serialize(&mut buf0[16 .. ]);
(std::mem::transmute::<_, u32>(self.class) as u8).serialize(&mut buf0[18 .. ]);
self.depth.serialize(&mut buf0[19 .. ]);
self.visual.serialize(&mut buf0[20 .. ]);
(xproto::Cw::get_mask(self.value_list).bits() as u32).serialize(&mut buf0[24 .. ]);
sections[2].iov_base = buf0.as_mut_ptr() as *mut _;
sections[2].iov_len = 28;
sections[3].iov_len = base::align_pad(sections[2].iov_len, 4);
let len1 = self.value_list.wire_len();
let mut buf1 = vec![0u8; len1];
self.value_list.serialize(&mut buf1);
sections[4].iov_base = buf1.as_ptr() as *mut _;
sections[4].iov_len = buf1.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 SetAttributes<'a> {
type Cookie = base::VoidCookie;
const IS_VOID: bool = true;
}
impl<'a> base::RequestWithoutReply for SetAttributes<'a> {
}
#[derive(Clone, Debug)]
pub struct UnsetAttributes {
pub drawable: xproto::Drawable,
}
unsafe impl base::RawRequest for UnsetAttributes {
fn raw_request(&self, c: &base::Connection, checked: bool) -> u64 { unsafe {
let mut protocol_request = xcb_protocol_request_t {
count: 2,
ext: std::ptr::addr_of_mut!(FFI_EXT),
opcode: 4,
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.drawable.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 UnsetAttributes {
type Cookie = base::VoidCookie;
const IS_VOID: bool = true;
}
impl base::RequestWithoutReply for UnsetAttributes {
}
#[derive(Clone, Debug)]
pub struct Suspend {
pub suspend: u32,
}
unsafe impl base::RawRequest for Suspend {
fn raw_request(&self, c: &base::Connection, checked: bool) -> u64 { unsafe {
let mut protocol_request = xcb_protocol_request_t {
count: 2,
ext: std::ptr::addr_of_mut!(FFI_EXT),
opcode: 5,
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.suspend.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 Suspend {
type Cookie = base::VoidCookie;
const IS_VOID: bool = true;
}
impl base::RequestWithoutReply for Suspend {
}