Skip to content

Commit

Permalink
Merge pull request #924 from psychon/update-xcb-proto
Browse files Browse the repository at this point in the history
Update vendored xcb-proto to 1.17.0
  • Loading branch information
mergify[bot] authored Apr 17, 2024
2 parents 2b3a646 + c0d8103 commit be76619
Show file tree
Hide file tree
Showing 71 changed files with 611 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PROTO=xcb-proto-1.15.2-13-gb016df1
PROTO=xcb-proto-1.17.0
PROTO_OUT=x11rb-protocol/src/protocol
X11RB_OUT=x11rb/src/protocol
ASYNC_OUT=x11rb-async/src/protocol
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ Licensed under either of

at your option.

The subdirectory xcb-proto-1.15.2-gb016df1 contains a vendored copy of the
The subdirectory xcb-proto-1.17.0 contains a vendored copy of the
package of the same name. It is covered by the MIT license. See
[xcb-proto-1.15.2-gb016df1/COPYING](xcb-proto-1.15.2/COPYING) for details.
[xcb-proto-1.17.0/COPYING](xcb-proto-1.17.0/COPYING) for details.

## Contribution

Expand Down
12 changes: 6 additions & 6 deletions x11rb-async/src/protocol/composite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ where
assert_eq!(slices.len(), bytes.len());
conn.send_request_with_reply(&slices, fds).await
}
/// Redirect the heirarchy starting at window to off-screen storage..
/// Redirect the hierarchy starting at "window" to off-screen storage..
///
/// The hierarchy starting at 'window' is directed to off-screen
/// storage. When all clients enabling redirection terminate,
Expand All @@ -71,7 +71,7 @@ where
///
/// # Fields
///
/// * `window` - The root of the heirarchy to redirect to off-screen storage.
/// * `window` - The root of the hierarchy to redirect to off-screen storage.
/// * `update` - Whether contents are automatically mirrored to the parent window. If one client
/// already specifies an update type of Manual, any attempt by another to specify a
/// mode of Manual so will result in an Access error.
Expand All @@ -97,7 +97,7 @@ where
///
/// # Fields
///
/// * `window` - The root of the heirarchy to redirect to off-screen storage.
/// * `window` - The root of the hierarchy to redirect to off-screen storage.
/// * `update` - Whether contents are automatically mirrored to the parent window. If one client
/// already specifies an update type of Manual, any attempt by another to specify a
/// mode of Manual so will result in an Access error.
Expand Down Expand Up @@ -227,7 +227,7 @@ pub trait ConnectionExt: RequestConnection {
{
Box::pin(query_version(self, client_major_version, client_minor_version))
}
/// Redirect the heirarchy starting at window to off-screen storage..
/// Redirect the hierarchy starting at "window" to off-screen storage..
///
/// The hierarchy starting at 'window' is directed to off-screen
/// storage. When all clients enabling redirection terminate,
Expand All @@ -238,7 +238,7 @@ pub trait ConnectionExt: RequestConnection {
///
/// # Fields
///
/// * `window` - The root of the heirarchy to redirect to off-screen storage.
/// * `window` - The root of the hierarchy to redirect to off-screen storage.
/// * `update` - Whether contents are automatically mirrored to the parent window. If one client
/// already specifies an update type of Manual, any attempt by another to specify a
/// mode of Manual so will result in an Access error.
Expand All @@ -255,7 +255,7 @@ pub trait ConnectionExt: RequestConnection {
///
/// # Fields
///
/// * `window` - The root of the heirarchy to redirect to off-screen storage.
/// * `window` - The root of the hierarchy to redirect to off-screen storage.
/// * `update` - Whether contents are automatically mirrored to the parent window. If one client
/// already specifies an update type of Manual, any attempt by another to specify a
/// mode of Manual so will result in an Access error.
Expand Down
38 changes: 38 additions & 0 deletions x11rb-async/src/protocol/dri3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,34 @@ where
assert_eq!(slices.len(), bytes.len());
conn.send_request_without_reply(&slices, fds).await
}
pub async fn import_syncobj<Conn, A>(conn: &Conn, syncobj: Syncobj, drawable: xproto::Drawable, syncobj_fd: A) -> Result<VoidCookie<'_, Conn>, ConnectionError>
where
Conn: RequestConnection + ?Sized,
A: Into<RawFdContainer> + Send,
{
let syncobj_fd: RawFdContainer = syncobj_fd.into();
let request0 = ImportSyncobjRequest {
syncobj,
drawable,
syncobj_fd,
};
let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
let slices = [IoSlice::new(&bytes[0])];
assert_eq!(slices.len(), bytes.len());
conn.send_request_without_reply(&slices, fds).await
}
pub async fn free_syncobj<Conn>(conn: &Conn, syncobj: Syncobj) -> Result<VoidCookie<'_, Conn>, ConnectionError>
where
Conn: RequestConnection + ?Sized,
{
let request0 = FreeSyncobjRequest {
syncobj,
};
let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
let slices = [IoSlice::new(&bytes[0])];
assert_eq!(slices.len(), bytes.len());
conn.send_request_without_reply(&slices, fds).await
}
/// Extension trait defining the requests of this extension.
pub trait ConnectionExt: RequestConnection {
fn dri3_query_version(&self, major_version: u32, minor_version: u32) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, QueryVersionReply>, ConnectionError>> + Send + '_>>
Expand Down Expand Up @@ -239,6 +267,16 @@ pub trait ConnectionExt: RequestConnection {
{
Box::pin(set_drm_device_in_use(self, window, drm_major, drm_minor))
}
fn dri3_import_syncobj<A>(&self, syncobj: Syncobj, drawable: xproto::Drawable, syncobj_fd: A) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
where
A: Into<RawFdContainer> + Send + 'static,
{
Box::pin(import_syncobj(self, syncobj, drawable, syncobj_fd))
}
fn dri3_free_syncobj(&self, syncobj: Syncobj) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
{
Box::pin(free_syncobj(self, syncobj))
}
}

impl<C: RequestConnection + ?Sized> ConnectionExt for C {}
37 changes: 37 additions & 0 deletions x11rb-async/src/protocol/present.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ use crate::errors::ReplyOrIdError;
use std::future::Future;
use std::pin::Pin;
#[allow(unused_imports)]
use super::dri3;
#[allow(unused_imports)]
use super::randr;
#[allow(unused_imports)]
use super::sync;
Expand Down Expand Up @@ -123,6 +125,34 @@ where
assert_eq!(slices.len(), bytes.len());
conn.send_request_with_reply(&slices, fds).await
}
pub async fn pixmap_synced<'c, 'input, Conn>(conn: &'c Conn, window: xproto::Window, pixmap: xproto::Pixmap, serial: u32, valid: xfixes::Region, update: xfixes::Region, x_off: i16, y_off: i16, target_crtc: randr::Crtc, acquire_syncobj: dri3::Syncobj, release_syncobj: dri3::Syncobj, acquire_point: u64, release_point: u64, options: u32, target_msc: u64, divisor: u64, remainder: u64, notifies: &'input [Notify]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
where
Conn: RequestConnection + ?Sized,
{
let request0 = PixmapSyncedRequest {
window,
pixmap,
serial,
valid,
update,
x_off,
y_off,
target_crtc,
acquire_syncobj,
release_syncobj,
acquire_point,
release_point,
options,
target_msc,
divisor,
remainder,
notifies: Cow::Borrowed(notifies),
};
let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
assert_eq!(slices.len(), bytes.len());
conn.send_request_without_reply(&slices, fds).await
}
/// Extension trait defining the requests of this extension.
pub trait ConnectionExt: RequestConnection {
fn present_query_version(&self, major_version: u32, minor_version: u32) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, QueryVersionReply>, ConnectionError>> + Send + '_>>
Expand All @@ -148,6 +178,13 @@ pub trait ConnectionExt: RequestConnection {
{
Box::pin(query_capabilities(self, target))
}
fn present_pixmap_synced<'c, 'input, 'future>(&'c self, window: xproto::Window, pixmap: xproto::Pixmap, serial: u32, valid: xfixes::Region, update: xfixes::Region, x_off: i16, y_off: i16, target_crtc: randr::Crtc, acquire_syncobj: dri3::Syncobj, release_syncobj: dri3::Syncobj, acquire_point: u64, release_point: u64, options: u32, target_msc: u64, divisor: u64, remainder: u64, notifies: &'input [Notify]) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'c, Self>, ConnectionError>> + Send + 'future>>
where
'c: 'future,
'input: 'future,
{
Box::pin(pixmap_synced(self, window, pixmap, serial, valid, update, x_off, y_off, target_crtc, acquire_syncobj, release_syncobj, acquire_point, release_point, options, target_msc, divisor, remainder, notifies))
}
}

impl<C: RequestConnection + ?Sized> ConnectionExt for C {}
8 changes: 4 additions & 4 deletions x11rb-async/src/protocol/shm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ where
/// * `dst_y` - The Y coordinate on the destination drawable to copy to.
/// * `depth` - The depth to use.
/// * `format` - The format of the image being drawn. If it is XYBitmap, depth must be 1, or a
/// BadMatch error results. The foreground pixel in the GC determines the source
/// "BadMatch" error results. The foreground pixel in the GC determines the source
/// for the one bits in the image, and the background pixel determines the source
/// for the zero bits. For XYPixmap and ZPixmap, the depth must match the depth of
/// the drawable, or a BadMatch error results.
/// the drawable, or a "BadMatch" error results.
/// * `send_event` - True if the server should send an XCB_SHM_COMPLETION event when the blit
/// completes.
/// * `offset` - The offset that the source image starts at.
Expand Down Expand Up @@ -338,10 +338,10 @@ pub trait ConnectionExt: RequestConnection {
/// * `dst_y` - The Y coordinate on the destination drawable to copy to.
/// * `depth` - The depth to use.
/// * `format` - The format of the image being drawn. If it is XYBitmap, depth must be 1, or a
/// BadMatch error results. The foreground pixel in the GC determines the source
/// "BadMatch" error results. The foreground pixel in the GC determines the source
/// for the one bits in the image, and the background pixel determines the source
/// for the zero bits. For XYPixmap and ZPixmap, the depth must match the depth of
/// the drawable, or a BadMatch error results.
/// the drawable, or a "BadMatch" error results.
/// * `send_event` - True if the server should send an XCB_SHM_COMPLETION event when the blit
/// completes.
/// * `offset` - The offset that the source image starts at.
Expand Down
6 changes: 3 additions & 3 deletions x11rb-protocol/src/protocol/composite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ impl Serialize for QueryVersionReply {

/// Opcode for the RedirectWindow request
pub const REDIRECT_WINDOW_REQUEST: u8 = 1;
/// Redirect the heirarchy starting at window to off-screen storage..
/// Redirect the hierarchy starting at "window" to off-screen storage..
///
/// The hierarchy starting at 'window' is directed to off-screen
/// storage. When all clients enabling redirection terminate,
Expand All @@ -279,7 +279,7 @@ pub const REDIRECT_WINDOW_REQUEST: u8 = 1;
///
/// # Fields
///
/// * `window` - The root of the heirarchy to redirect to off-screen storage.
/// * `window` - The root of the hierarchy to redirect to off-screen storage.
/// * `update` - Whether contents are automatically mirrored to the parent window. If one client
/// already specifies an update type of Manual, any attempt by another to specify a
/// mode of Manual so will result in an Access error.
Expand Down Expand Up @@ -358,7 +358,7 @@ pub const REDIRECT_SUBWINDOWS_REQUEST: u8 = 2;
///
/// # Fields
///
/// * `window` - The root of the heirarchy to redirect to off-screen storage.
/// * `window` - The root of the hierarchy to redirect to off-screen storage.
/// * `update` - Whether contents are automatically mirrored to the parent window. If one client
/// already specifies an update type of Manual, any attempt by another to specify a
/// mode of Manual so will result in an Access error.
Expand Down
126 changes: 125 additions & 1 deletion x11rb-protocol/src/protocol/dri3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ pub const X11_EXTENSION_NAME: &str = "DRI3";
/// by this build of x11rb. For most things, it does not make sense to use this
/// information. If you need to send a `QueryVersion`, it is recommended to instead
/// send the maximum version of the extension that you need.
pub const X11_XML_VERSION: (u32, u32) = (1, 3);
pub const X11_XML_VERSION: (u32, u32) = (1, 4);

pub type Syncobj = u32;

/// Opcode for the QueryVersion request
pub const QUERY_VERSION_REQUEST: u8 = 0;
Expand Down Expand Up @@ -1348,3 +1350,125 @@ impl Request for SetDRMDeviceInUseRequest {
impl crate::x11_utils::VoidRequest for SetDRMDeviceInUseRequest {
}

/// Opcode for the ImportSyncobj request
pub const IMPORT_SYNCOBJ_REQUEST: u8 = 10;
#[cfg_attr(feature = "extra-traits", derive(Debug))]
pub struct ImportSyncobjRequest {
pub syncobj: Syncobj,
pub drawable: xproto::Drawable,
pub syncobj_fd: RawFdContainer,
}
impl_debug_if_no_extra_traits!(ImportSyncobjRequest, "ImportSyncobjRequest");
impl ImportSyncobjRequest {
/// Serialize this request into bytes for the provided connection
pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
let length_so_far = 0;
let syncobj_bytes = self.syncobj.serialize();
let drawable_bytes = self.drawable.serialize();
let mut request0 = vec![
major_opcode,
IMPORT_SYNCOBJ_REQUEST,
0,
0,
syncobj_bytes[0],
syncobj_bytes[1],
syncobj_bytes[2],
syncobj_bytes[3],
drawable_bytes[0],
drawable_bytes[1],
drawable_bytes[2],
drawable_bytes[3],
];
let length_so_far = length_so_far + request0.len();
assert_eq!(length_so_far % 4, 0);
let length = u16::try_from(length_so_far / 4).unwrap_or(0);
request0[2..4].copy_from_slice(&length.to_ne_bytes());
([request0.into()], vec![self.syncobj_fd])
}
/// Parse this request given its header, its body, and any fds that go along with it
#[cfg(feature = "request-parsing")]
pub fn try_parse_request_fd(header: RequestHeader, value: &[u8], fds: &mut Vec<RawFdContainer>) -> Result<Self, ParseError> {
if header.minor_opcode != IMPORT_SYNCOBJ_REQUEST {
return Err(ParseError::InvalidValue);
}
let (syncobj, remaining) = Syncobj::try_parse(value)?;
let (drawable, remaining) = xproto::Drawable::try_parse(remaining)?;
if fds.is_empty() { return Err(ParseError::MissingFileDescriptors) }
let syncobj_fd = fds.remove(0);
let _ = remaining;
Ok(ImportSyncobjRequest {
syncobj,
drawable,
syncobj_fd,
})
}
}
impl Request for ImportSyncobjRequest {
const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);

fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
let (bufs, fds) = self.serialize(major_opcode);
// Flatten the buffers into a single vector
let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
(buf, fds)
}
}
impl crate::x11_utils::VoidRequest for ImportSyncobjRequest {
}

/// Opcode for the FreeSyncobj request
pub const FREE_SYNCOBJ_REQUEST: u8 = 11;
#[derive(Clone, Copy, Default)]
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct FreeSyncobjRequest {
pub syncobj: Syncobj,
}
impl_debug_if_no_extra_traits!(FreeSyncobjRequest, "FreeSyncobjRequest");
impl FreeSyncobjRequest {
/// Serialize this request into bytes for the provided connection
pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
let length_so_far = 0;
let syncobj_bytes = self.syncobj.serialize();
let mut request0 = vec![
major_opcode,
FREE_SYNCOBJ_REQUEST,
0,
0,
syncobj_bytes[0],
syncobj_bytes[1],
syncobj_bytes[2],
syncobj_bytes[3],
];
let length_so_far = length_so_far + request0.len();
assert_eq!(length_so_far % 4, 0);
let length = u16::try_from(length_so_far / 4).unwrap_or(0);
request0[2..4].copy_from_slice(&length.to_ne_bytes());
([request0.into()], vec![])
}
/// Parse this request given its header, its body, and any fds that go along with it
#[cfg(feature = "request-parsing")]
pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
if header.minor_opcode != FREE_SYNCOBJ_REQUEST {
return Err(ParseError::InvalidValue);
}
let (syncobj, remaining) = Syncobj::try_parse(value)?;
let _ = remaining;
Ok(FreeSyncobjRequest {
syncobj,
})
}
}
impl Request for FreeSyncobjRequest {
const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);

fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
let (bufs, fds) = self.serialize(major_opcode);
// Flatten the buffers into a single vector
let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
(buf, fds)
}
}
impl crate::x11_utils::VoidRequest for FreeSyncobjRequest {
}

Loading

0 comments on commit be76619

Please sign in to comment.