#[allow(unused_imports)]
use crate::cookie::Cookie;
#[allow(unused_imports)]
use crate::cookie::FixedCookie;
#[allow(unused_imports)]
use crate::cookie::VoidCookie;
#[allow(unused_imports)]
use crate::util::FixedLengthSerialize;
#[allow(unused_imports)]
use crate::util::VariableLengthSerialize;
pub fn query_version<IO, XS>(
io: &mut IO,
xcb_state: &mut XS,
forget: bool,
) -> crate::error::Result<FixedCookie<crate::proto::xf86dri::QueryVersionReply, 16>>
where
IO: crate::con::SocketIo,
XS: crate::con::XcbState,
{
let major_opcode = xcb_state
.major_opcode(crate::proto::xf86dri::EXTENSION_NAME)
.ok_or(crate::error::Error::MissingExtension(
crate::proto::xf86dri::EXTENSION_NAME,
))?;
io.use_write_buffer(|buf| {
let buf = buf.get_mut(..4).ok_or(crate::error::Error::Serialize)?;
buf[0] = major_opcode;
buf[1] = 0;
buf[2..4].copy_from_slice(&(1u16).to_ne_bytes());
Ok::<usize, crate::error::Error>(4)
})?;
let seq = if forget {
xcb_state.next_seq()
} else {
xcb_state.keep_and_return_next_seq()
};
Ok(FixedCookie::new(seq))
}
pub fn query_direct_rendering_capable<IO, XS>(
io: &mut IO,
xcb_state: &mut XS,
screen: u32,
forget: bool,
) -> crate::error::Result<FixedCookie<crate::proto::xf86dri::QueryDirectRenderingCapableReply, 9>>
where
IO: crate::con::SocketIo,
XS: crate::con::XcbState,
{
let major_opcode = xcb_state
.major_opcode(crate::proto::xf86dri::EXTENSION_NAME)
.ok_or(crate::error::Error::MissingExtension(
crate::proto::xf86dri::EXTENSION_NAME,
))?;
let length: [u8; 2] = (2u16).to_ne_bytes();
let screen_bytes = screen.serialize_fixed();
io.use_write_buffer(|buf| {
buf.get_mut(..8)
.ok_or(crate::error::Error::Serialize)?
.copy_from_slice(&[
major_opcode,
1,
length[0],
length[1],
screen_bytes[0],
screen_bytes[1],
screen_bytes[2],
screen_bytes[3],
]);
Ok::<usize, crate::error::Error>(8)
})?;
let seq = if forget {
xcb_state.next_seq()
} else {
xcb_state.keep_and_return_next_seq()
};
Ok(FixedCookie::new(seq))
}
pub fn open_connection<IO, XS>(
io: &mut IO,
xcb_state: &mut XS,
screen: u32,
forget: bool,
) -> crate::error::Result<Cookie<crate::proto::xf86dri::OpenConnectionReply>>
where
IO: crate::con::SocketIo,
XS: crate::con::XcbState,
{
let major_opcode = xcb_state
.major_opcode(crate::proto::xf86dri::EXTENSION_NAME)
.ok_or(crate::error::Error::MissingExtension(
crate::proto::xf86dri::EXTENSION_NAME,
))?;
let length: [u8; 2] = (2u16).to_ne_bytes();
let screen_bytes = screen.serialize_fixed();
io.use_write_buffer(|buf| {
buf.get_mut(..8)
.ok_or(crate::error::Error::Serialize)?
.copy_from_slice(&[
major_opcode,
2,
length[0],
length[1],
screen_bytes[0],
screen_bytes[1],
screen_bytes[2],
screen_bytes[3],
]);
Ok::<usize, crate::error::Error>(8)
})?;
let seq = if forget {
xcb_state.next_seq()
} else {
xcb_state.keep_and_return_next_seq()
};
Ok(Cookie::new(seq))
}
pub fn close_connection<IO, XS>(
io: &mut IO,
xcb_state: &mut XS,
screen: u32,
forget: bool,
) -> crate::error::Result<VoidCookie>
where
IO: crate::con::SocketIo,
XS: crate::con::XcbState,
{
let major_opcode = xcb_state
.major_opcode(crate::proto::xf86dri::EXTENSION_NAME)
.ok_or(crate::error::Error::MissingExtension(
crate::proto::xf86dri::EXTENSION_NAME,
))?;
let length: [u8; 2] = (2u16).to_ne_bytes();
let screen_bytes = screen.serialize_fixed();
io.use_write_buffer(|buf| {
buf.get_mut(..8)
.ok_or(crate::error::Error::Serialize)?
.copy_from_slice(&[
major_opcode,
3,
length[0],
length[1],
screen_bytes[0],
screen_bytes[1],
screen_bytes[2],
screen_bytes[3],
]);
Ok::<usize, crate::error::Error>(8)
})?;
let seq = if forget {
xcb_state.next_seq()
} else {
xcb_state.keep_and_return_next_seq()
};
Ok(VoidCookie::new(seq))
}
pub fn get_client_driver_name<IO, XS>(
io: &mut IO,
xcb_state: &mut XS,
screen: u32,
forget: bool,
) -> crate::error::Result<Cookie<crate::proto::xf86dri::GetClientDriverNameReply>>
where
IO: crate::con::SocketIo,
XS: crate::con::XcbState,
{
let major_opcode = xcb_state
.major_opcode(crate::proto::xf86dri::EXTENSION_NAME)
.ok_or(crate::error::Error::MissingExtension(
crate::proto::xf86dri::EXTENSION_NAME,
))?;
let length: [u8; 2] = (2u16).to_ne_bytes();
let screen_bytes = screen.serialize_fixed();
io.use_write_buffer(|buf| {
buf.get_mut(..8)
.ok_or(crate::error::Error::Serialize)?
.copy_from_slice(&[
major_opcode,
4,
length[0],
length[1],
screen_bytes[0],
screen_bytes[1],
screen_bytes[2],
screen_bytes[3],
]);
Ok::<usize, crate::error::Error>(8)
})?;
let seq = if forget {
xcb_state.next_seq()
} else {
xcb_state.keep_and_return_next_seq()
};
Ok(Cookie::new(seq))
}
pub fn create_context<IO, XS>(
io: &mut IO,
xcb_state: &mut XS,
screen: u32,
visual: u32,
context: u32,
forget: bool,
) -> crate::error::Result<FixedCookie<crate::proto::xf86dri::CreateContextReply, 12>>
where
IO: crate::con::SocketIo,
XS: crate::con::XcbState,
{
let major_opcode = xcb_state
.major_opcode(crate::proto::xf86dri::EXTENSION_NAME)
.ok_or(crate::error::Error::MissingExtension(
crate::proto::xf86dri::EXTENSION_NAME,
))?;
let length: [u8; 2] = (4u16).to_ne_bytes();
let screen_bytes = screen.serialize_fixed();
let visual_bytes = visual.serialize_fixed();
let context_bytes = context.serialize_fixed();
io.use_write_buffer(|buf| {
buf.get_mut(..16)
.ok_or(crate::error::Error::Serialize)?
.copy_from_slice(&[
major_opcode,
5,
length[0],
length[1],
screen_bytes[0],
screen_bytes[1],
screen_bytes[2],
screen_bytes[3],
visual_bytes[0],
visual_bytes[1],
visual_bytes[2],
visual_bytes[3],
context_bytes[0],
context_bytes[1],
context_bytes[2],
context_bytes[3],
]);
Ok::<usize, crate::error::Error>(16)
})?;
let seq = if forget {
xcb_state.next_seq()
} else {
xcb_state.keep_and_return_next_seq()
};
Ok(FixedCookie::new(seq))
}
pub fn destroy_context<IO, XS>(
io: &mut IO,
xcb_state: &mut XS,
screen: u32,
context: u32,
forget: bool,
) -> crate::error::Result<VoidCookie>
where
IO: crate::con::SocketIo,
XS: crate::con::XcbState,
{
let major_opcode = xcb_state
.major_opcode(crate::proto::xf86dri::EXTENSION_NAME)
.ok_or(crate::error::Error::MissingExtension(
crate::proto::xf86dri::EXTENSION_NAME,
))?;
let length: [u8; 2] = (3u16).to_ne_bytes();
let screen_bytes = screen.serialize_fixed();
let context_bytes = context.serialize_fixed();
io.use_write_buffer(|buf| {
buf.get_mut(..12)
.ok_or(crate::error::Error::Serialize)?
.copy_from_slice(&[
major_opcode,
6,
length[0],
length[1],
screen_bytes[0],
screen_bytes[1],
screen_bytes[2],
screen_bytes[3],
context_bytes[0],
context_bytes[1],
context_bytes[2],
context_bytes[3],
]);
Ok::<usize, crate::error::Error>(12)
})?;
let seq = if forget {
xcb_state.next_seq()
} else {
xcb_state.keep_and_return_next_seq()
};
Ok(VoidCookie::new(seq))
}
pub fn create_drawable<IO, XS>(
io: &mut IO,
xcb_state: &mut XS,
screen: u32,
drawable: u32,
forget: bool,
) -> crate::error::Result<FixedCookie<crate::proto::xf86dri::CreateDrawableReply, 12>>
where
IO: crate::con::SocketIo,
XS: crate::con::XcbState,
{
let major_opcode = xcb_state
.major_opcode(crate::proto::xf86dri::EXTENSION_NAME)
.ok_or(crate::error::Error::MissingExtension(
crate::proto::xf86dri::EXTENSION_NAME,
))?;
let length: [u8; 2] = (3u16).to_ne_bytes();
let screen_bytes = screen.serialize_fixed();
let drawable_bytes = drawable.serialize_fixed();
io.use_write_buffer(|buf| {
buf.get_mut(..12)
.ok_or(crate::error::Error::Serialize)?
.copy_from_slice(&[
major_opcode,
7,
length[0],
length[1],
screen_bytes[0],
screen_bytes[1],
screen_bytes[2],
screen_bytes[3],
drawable_bytes[0],
drawable_bytes[1],
drawable_bytes[2],
drawable_bytes[3],
]);
Ok::<usize, crate::error::Error>(12)
})?;
let seq = if forget {
xcb_state.next_seq()
} else {
xcb_state.keep_and_return_next_seq()
};
Ok(FixedCookie::new(seq))
}
pub fn destroy_drawable<IO, XS>(
io: &mut IO,
xcb_state: &mut XS,
screen: u32,
drawable: u32,
forget: bool,
) -> crate::error::Result<VoidCookie>
where
IO: crate::con::SocketIo,
XS: crate::con::XcbState,
{
let major_opcode = xcb_state
.major_opcode(crate::proto::xf86dri::EXTENSION_NAME)
.ok_or(crate::error::Error::MissingExtension(
crate::proto::xf86dri::EXTENSION_NAME,
))?;
let length: [u8; 2] = (3u16).to_ne_bytes();
let screen_bytes = screen.serialize_fixed();
let drawable_bytes = drawable.serialize_fixed();
io.use_write_buffer(|buf| {
buf.get_mut(..12)
.ok_or(crate::error::Error::Serialize)?
.copy_from_slice(&[
major_opcode,
8,
length[0],
length[1],
screen_bytes[0],
screen_bytes[1],
screen_bytes[2],
screen_bytes[3],
drawable_bytes[0],
drawable_bytes[1],
drawable_bytes[2],
drawable_bytes[3],
]);
Ok::<usize, crate::error::Error>(12)
})?;
let seq = if forget {
xcb_state.next_seq()
} else {
xcb_state.keep_and_return_next_seq()
};
Ok(VoidCookie::new(seq))
}
pub fn get_drawable_info<IO, XS>(
io: &mut IO,
xcb_state: &mut XS,
screen: u32,
drawable: u32,
forget: bool,
) -> crate::error::Result<Cookie<crate::proto::xf86dri::GetDrawableInfoReply>>
where
IO: crate::con::SocketIo,
XS: crate::con::XcbState,
{
let major_opcode = xcb_state
.major_opcode(crate::proto::xf86dri::EXTENSION_NAME)
.ok_or(crate::error::Error::MissingExtension(
crate::proto::xf86dri::EXTENSION_NAME,
))?;
let length: [u8; 2] = (3u16).to_ne_bytes();
let screen_bytes = screen.serialize_fixed();
let drawable_bytes = drawable.serialize_fixed();
io.use_write_buffer(|buf| {
buf.get_mut(..12)
.ok_or(crate::error::Error::Serialize)?
.copy_from_slice(&[
major_opcode,
9,
length[0],
length[1],
screen_bytes[0],
screen_bytes[1],
screen_bytes[2],
screen_bytes[3],
drawable_bytes[0],
drawable_bytes[1],
drawable_bytes[2],
drawable_bytes[3],
]);
Ok::<usize, crate::error::Error>(12)
})?;
let seq = if forget {
xcb_state.next_seq()
} else {
xcb_state.keep_and_return_next_seq()
};
Ok(Cookie::new(seq))
}
pub fn get_device_info<IO, XS>(
io: &mut IO,
xcb_state: &mut XS,
screen: u32,
forget: bool,
) -> crate::error::Result<Cookie<crate::proto::xf86dri::GetDeviceInfoReply>>
where
IO: crate::con::SocketIo,
XS: crate::con::XcbState,
{
let major_opcode = xcb_state
.major_opcode(crate::proto::xf86dri::EXTENSION_NAME)
.ok_or(crate::error::Error::MissingExtension(
crate::proto::xf86dri::EXTENSION_NAME,
))?;
let length: [u8; 2] = (2u16).to_ne_bytes();
let screen_bytes = screen.serialize_fixed();
io.use_write_buffer(|buf| {
buf.get_mut(..8)
.ok_or(crate::error::Error::Serialize)?
.copy_from_slice(&[
major_opcode,
10,
length[0],
length[1],
screen_bytes[0],
screen_bytes[1],
screen_bytes[2],
screen_bytes[3],
]);
Ok::<usize, crate::error::Error>(8)
})?;
let seq = if forget {
xcb_state.next_seq()
} else {
xcb_state.keep_and_return_next_seq()
};
Ok(Cookie::new(seq))
}
pub fn auth_connection<IO, XS>(
io: &mut IO,
xcb_state: &mut XS,
screen: u32,
magic: u32,
forget: bool,
) -> crate::error::Result<FixedCookie<crate::proto::xf86dri::AuthConnectionReply, 12>>
where
IO: crate::con::SocketIo,
XS: crate::con::XcbState,
{
let major_opcode = xcb_state
.major_opcode(crate::proto::xf86dri::EXTENSION_NAME)
.ok_or(crate::error::Error::MissingExtension(
crate::proto::xf86dri::EXTENSION_NAME,
))?;
let length: [u8; 2] = (3u16).to_ne_bytes();
let screen_bytes = screen.serialize_fixed();
let magic_bytes = magic.serialize_fixed();
io.use_write_buffer(|buf| {
buf.get_mut(..12)
.ok_or(crate::error::Error::Serialize)?
.copy_from_slice(&[
major_opcode,
11,
length[0],
length[1],
screen_bytes[0],
screen_bytes[1],
screen_bytes[2],
screen_bytes[3],
magic_bytes[0],
magic_bytes[1],
magic_bytes[2],
magic_bytes[3],
]);
Ok::<usize, crate::error::Error>(12)
})?;
let seq = if forget {
xcb_state.next_seq()
} else {
xcb_state.keep_and_return_next_seq()
};
Ok(FixedCookie::new(seq))
}