From 2a08f125b753cbf298051b0b3a05525462fc39cf Mon Sep 17 00:00:00 2001 From: Syudagye Date: Tue, 24 Jan 2023 14:48:34 +0100 Subject: [PATCH 1/3] Moved attributes after doc comments --- src/common.rs | 2 +- src/connection.rs | 6 +- src/message.rs | 8 +- src/x11/error.rs | 224 ++++++++++++++++----------------- src/x11/event.rs | 306 +++++++++++++++++++++++----------------------- 5 files changed, 273 insertions(+), 273 deletions(-) diff --git a/src/common.rs b/src/common.rs index 92156c49..e19d8e3c 100644 --- a/src/common.rs +++ b/src/common.rs @@ -104,10 +104,10 @@ pub enum WindowGravity { // The `derive_xrb!` attribute here is used to write the discriminants as `u16`. derive_xrb! { - #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug, X11Size, Readable, Writable)] /// A [window]'s class; whether it has a visual output form. /// /// [window]: Window + #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug, X11Size, Readable, Writable)] pub enum WindowClass: u16 { /// A [window] that both receives input and has a visual output (i.e. what /// one would normally consider a window to be). diff --git a/src/connection.rs b/src/connection.rs index 1abb16b9..6063a7fa 100644 --- a/src/connection.rs +++ b/src/connection.rs @@ -88,8 +88,8 @@ impl ConnectionResponse { } derive_xrb! { - #[derive(Debug, X11Size, Readable, Writable)] /// There was a failure in attempting the connection. + #[derive(Debug, X11Size, Readable, Writable)] pub struct ConnectionFailure { #[allow(clippy::cast_possible_truncation)] let reason_len: u8 = reason => reason.len() as u8, @@ -112,8 +112,8 @@ derive_xrb! { [_; ..], } - #[derive(Debug, X11Size, Readable, Writable)] /// The connection was successfully established. + #[derive(Debug, X11Size, Readable, Writable)] pub struct ConnectionSuccess { _, /// The major version of the X11 protocol used by the X server. @@ -165,8 +165,8 @@ derive_xrb! { pub roots: Vec, } - #[derive(Debug, X11Size, Readable, Writable)] /// The connection was refused because authentication was unsuccessful. + #[derive(Debug, X11Size, Readable, Writable)] pub struct ConnectionAuthenticationError { [_; 5], diff --git a/src/message.rs b/src/message.rs index 888948ac..abf8a951 100644 --- a/src/message.rs +++ b/src/message.rs @@ -7,8 +7,8 @@ use crate::x11::error; use xrbk::{Readable, Writable, X11Size}; -#[doc(notable_trait)] /// A message sent from an X client to the X server. +#[doc(notable_trait)] pub trait Request: X11Size + Writable { /// The type representing the [other possible errors][other-errors] /// generated by this `Request`. @@ -209,9 +209,9 @@ pub enum RequestError { Other(OtherErrors), } -#[doc(notable_trait)] /// A message sent from the X server to an X client in response to a /// [`Request`]. +#[doc(notable_trait)] pub trait Reply: X11Size + Readable { /// The [request] that generates this `Reply`. /// @@ -319,7 +319,6 @@ pub trait Reply: X11Size + Readable { fn sequence(&self) -> u16; } -#[doc(notable_trait)] /// A message sent from the X server to an X client. /// /// `Event`s differ from [replies] in that they are not a direct response to a @@ -327,6 +326,7 @@ pub trait Reply: X11Size + Readable { /// /// [replies]: Reply /// [request]: Request +#[doc(notable_trait)] pub trait Event: X11Size + Readable + Writable { /// The code uniquely identifying this `Event` (among other `Event`s). /// @@ -342,11 +342,11 @@ pub trait Event: X11Size + Readable + Writable { fn sequence(&self) -> Option; } -#[doc(notable_trait)] /// An error sent from the X server to an X client in response to a failed /// [request]. /// /// [request]: Request +#[doc(notable_trait)] pub trait Error: X11Size + Readable { /// The code uniquely identifying this `Error` (among other `Error`s). /// diff --git a/src/x11/error.rs b/src/x11/error.rs index 77eec6c1..3afd230b 100644 --- a/src/x11/error.rs +++ b/src/x11/error.rs @@ -18,8 +18,6 @@ use xrbk_macro::derive_xrb; extern crate self as xrb; derive_xrb! { - #[derive(Debug, Derivative, Writable, Readable, X11Size)] - #[derivative(Hash, PartialEq, Eq)] /// An [error] generated when the [major opcode] and [minor opcode] /// combination provided in a [request] does not specify a valid [request]. /// @@ -27,16 +25,17 @@ derive_xrb! { /// [request]: crate::message::Request /// [major opcode]: crate::message::Request::MAJOR_OPCODE /// [minor opcode]: crate::message::Request::MINOR_OPCODE + #[derive(Debug, Derivative, Writable, Readable, X11Size)] + #[derivative(Hash, PartialEq, Eq)] pub struct Request: Error(1) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The sequence number identifying the [request] that was /// sent. /// /// [request]: crate::message::Request + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, - #[minor_opcode] /// The [minor opcode] meant to refer to the type of [request] that was /// sent. /// @@ -47,9 +46,9 @@ derive_xrb! { /// /// [request]: crate::message::Request /// [minor opcode]: crate::message::Request::MINOR_OPCODE + #[minor_opcode] pub invalid_minor_opcode: u16, - #[major_opcode] /// The [major opcode] meant to refer to the type of [request] that was /// sent. /// @@ -60,12 +59,11 @@ derive_xrb! { /// /// [request]: crate::message::Request /// [major opcode]: crate::message::Request::MAJOR_OPCODE + #[major_opcode] pub invalid_major_opcode: u8, [_; ..], } - #[derive(Debug, Derivative, Writable, Readable, X11Size)] - #[derivative(Hash, PartialEq, Eq)] /// An [error] generated when a numerical value contained in the [request] /// falls outside of the range of accepted values. /// @@ -74,16 +72,17 @@ derive_xrb! { /// /// [request]: crate::message::Request /// [error]: Error + #[derive(Debug, Derivative, Writable, Readable, X11Size)] + #[derivative(Hash, PartialEq, Eq)] pub struct Value: Error(2) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The sequence number identifying the [request] that was /// sent. /// /// [request]: crate::message::Request + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, - #[error_data] /// The numerical value which fell outside of the accepted ranges. /// /// This is represented as four bytes instead of a `u32` value because @@ -91,30 +90,29 @@ derive_xrb! { /// `u32` value. Encoding it as such if it wasn't meant to be could /// cause issues with byte-swapping, where the bytes of a value would /// be swapped to translate it to a `u32` value on the target platform. + #[error_data] pub invalid_value: [u8; 4], - #[minor_opcode] /// The [minor opcode] referring to the type of [request] that was sent. /// /// See [`Request::MINOR_OPCODE`][minor opcode] for more information. /// /// [request]: crate::message::Request /// [minor opcode]: crate::message::Request::MINOR_OPCODE + #[minor_opcode] pub minor_opcode: u16, - #[major_opcode] /// The [major opcode] referring to the type of [request] that was sent. /// /// See [`Request::MAJOR_OPCODE`][major opcode] for more information. /// /// [request]: crate::message::Request /// [major opcode]: crate::message::Request::MAJOR_OPCODE + #[major_opcode] pub major_opcode: u8, [_; ..], } - #[derive(Debug, Derivative, Writable, Readable, X11Size)] - #[derivative(Hash, PartialEq, Eq)] /// An [error] generated when the [`Window`] ID used in the [request] does /// not refer to a defined [window]. /// @@ -122,16 +120,17 @@ derive_xrb! { /// [`Window`]: crate::Window /// [window]: crate::Window /// [request]: crate::message::Request + #[derive(Debug, Derivative, Writable, Readable, X11Size)] + #[derivative(Hash, PartialEq, Eq)] pub struct Window: Error(3) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The sequence number identifying the [request] that was /// sent. /// /// [request]: crate::message::Request + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, - #[error_data] /// The invalid [`Window`] ID. /// /// This is of type `u32`, not [`Window`], because it does not refer to @@ -139,30 +138,29 @@ derive_xrb! { /// /// [`Window`]: crate::Window /// [window]: crate::Window + #[error_data] pub invalid_window_id: u32, - #[minor_opcode] /// The [minor opcode] referring to the type of [request] that was sent. /// /// See [`Request::MINOR_OPCODE`][minor opcode] for more information. /// /// [request]: crate::message::Request /// [minor opcode]: crate::message::Request::MINOR_OPCODE + #[minor_opcode] pub minor_opcode: u16, - #[major_opcode] /// The [major opcode] referring to the type of [request] that was sent. /// /// See [`Request::MAJOR_OPCODE`][major opcode] for more information. /// /// [request]: crate::message::Request /// [major opcode]: crate::message::Request::MAJOR_OPCODE + #[major_opcode] pub major_opcode: u8, [_; ..], } - #[derive(Debug, Derivative, Writable, Readable, X11Size)] - #[derivative(Hash, PartialEq, Eq)] /// An [error] generated when the [`Pixmap`] ID used in the [request] does /// not refer to a defined [pixmap]. /// @@ -170,16 +168,17 @@ derive_xrb! { /// [`Pixmap`]: crate::Pixmap /// [pixmap]: crate::Pixmap /// [request]: crate::message::Request + #[derive(Debug, Derivative, Writable, Readable, X11Size)] + #[derivative(Hash, PartialEq, Eq)] pub struct Pixmap: Error(4) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The sequence number identifying the [request] that was /// sent. /// /// [request]: crate::message::Request + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, - #[error_data] /// The invalid [`Pixmap`] ID. /// /// This is of type `u32`, not [`Pixmap`], because it does not refer to @@ -187,30 +186,29 @@ derive_xrb! { /// /// [`Pixmap`]: crate::Pixmap /// [pixmap]: crate::Pixmap + #[error_data] pub invalid_pixmap_id: u32, - #[minor_opcode] /// The [minor opcode] referring to the type of [request] that was sent. /// /// See [`Request::MINOR_OPCODE`][minor opcode] for more information. /// /// [request]: crate::message::Request /// [minor opcode]: crate::message::Request::MINOR_OPCODE + #[minor_opcode] pub minor_opcode: u16, - #[major_opcode] /// The [major opcode] referring to the type of [request] that was sent. /// /// See [`Request::MAJOR_OPCODE`][major opcode] for more information. /// /// [request]: crate::message::Request /// [major opcode]: crate::message::Request::MAJOR_OPCODE + #[major_opcode] pub major_opcode: u8, [_; ..], } - #[derive(Debug, Derivative, Writable, Readable, X11Size)] - #[derivative(Hash, PartialEq, Eq)] /// An [error] generated when the [`Atom`] ID used in the [request] does /// not refer to a defined [atom]. /// @@ -218,16 +216,17 @@ derive_xrb! { /// [`Atom`]: crate::Atom /// [atom]: crate::Atom /// [request]: crate::message::Request + #[derive(Debug, Derivative, Writable, Readable, X11Size)] + #[derivative(Hash, PartialEq, Eq)] pub struct Atom: Error(5) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The sequence number identifying the [request] that was /// sent. /// /// [request]: crate::message::Request + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, - #[error_data] /// The invalid [`Atom`] ID. /// /// This is of type `u32`, not [`Atom`], because it does not refer to @@ -235,30 +234,29 @@ derive_xrb! { /// /// [`Atom`]: crate::Atom /// [atom]: crate::Atom + #[error_data] pub invalid_atom_id: u32, - #[minor_opcode] /// The [minor opcode] referring to the type of [request] that was sent. /// /// See [`Request::MINOR_OPCODE`][minor opcode] for more information. /// /// [request]: crate::message::Request /// [minor opcode]: crate::message::Request::MINOR_OPCODE + #[minor_opcode] pub minor_opcode: u16, - #[major_opcode] /// The [major opcode] referring to the type of [request] that was sent. /// /// See [`Request::MAJOR_OPCODE`][major opcode] for more information. /// /// [request]: crate::message::Request /// [major opcode]: crate::message::Request::MAJOR_OPCODE + #[major_opcode] pub major_opcode: u8, [_; ..], } - #[derive(Debug, Derivative, Writable, Readable, X11Size)] - #[derivative(Hash, PartialEq, Eq)] /// An [error] generated when the [`CursorAppearance`] ID used in the /// [request] does not refer to a defined [cursor appearance]. /// @@ -266,16 +264,17 @@ derive_xrb! { /// [`CursorAppearance`]: crate::CursorAppearance /// [cursor appearance]: crate::CursorAppearance /// [request]: crate::message::Request + #[derive(Debug, Derivative, Writable, Readable, X11Size)] + #[derivative(Hash, PartialEq, Eq)] pub struct CursorAppearance: Error(6) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The sequence number identifying the [request] that was /// sent. /// /// [request]: crate::message::Request + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, - #[error_data] /// The invalid [`CursorAppearance`] ID. /// /// This is of type `u32`, not [`CursorAppearance`], because it does @@ -284,30 +283,29 @@ derive_xrb! { /// /// [`CursorAppearance`]: crate::CursorAppearance /// [cursor appearance]: crate::CursorAppearance + #[error_data] pub invalid_cursor_appearance_id: u32, - #[minor_opcode] /// The [minor opcode] referring to the type of [request] that was sent. /// /// See [`Request::MINOR_OPCODE`][minor opcode] for more information. /// /// [request]: crate::message::Request /// [minor opcode]: crate::message::Request::MINOR_OPCODE + #[minor_opcode] pub minor_opcode: u16, - #[major_opcode] /// The [major opcode] referring to the type of [request] that was sent. /// /// See [`Request::MAJOR_OPCODE`][major opcode] for more information. /// /// [request]: crate::message::Request /// [major opcode]: crate::message::Request::MAJOR_OPCODE + #[major_opcode] pub major_opcode: u8, [_; ..], } - #[derive(Debug, Derivative, Writable, Readable, X11Size)] - #[derivative(Hash, PartialEq, Eq)] /// An [error] generated when the [`Font`] ID used in the [request] does /// not refer to a defined [font]. /// @@ -315,16 +313,17 @@ derive_xrb! { /// [`Font`]: crate::Font /// [font]: crate::Font /// [request]: crate::message::Request + #[derive(Debug, Derivative, Writable, Readable, X11Size)] + #[derivative(Hash, PartialEq, Eq)] pub struct Font: Error(7) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The sequence number identifying the [request] that was /// sent. /// /// [request]: crate::message::Request + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, - #[error_data] /// The invalid [`Font`] ID. /// /// This is of type `u32`, not [`Font`], because it does not refer to @@ -332,30 +331,29 @@ derive_xrb! { /// /// [`Font`]: crate::Font /// [font]: crate::Font + #[error_data] pub invalid_font_id: u32, - #[minor_opcode] /// The [minor opcode] referring to the type of [request] that was sent. /// /// See [`Request::MINOR_OPCODE`][minor opcode] for more information. /// /// [request]: crate::message::Request /// [minor opcode]: crate::message::Request::MINOR_OPCODE + #[minor_opcode] pub minor_opcode: u16, - #[major_opcode] /// The [major opcode] referring to the type of [request] that was sent. /// /// See [`Request::MAJOR_OPCODE`][major opcode] for more information. /// /// [request]: crate::message::Request /// [major opcode]: crate::message::Request::MAJOR_OPCODE + #[major_opcode] pub major_opcode: u8, [_; ..], } - #[derive(Debug, Derivative, Writable, Readable, X11Size)] - #[derivative(Hash, PartialEq, Eq)] /// An [error] generated when there is a mismatch of some kind. /// /// This [error] is generated for a number of reasons: @@ -372,37 +370,37 @@ derive_xrb! { /// [drawable]: crate::Drawable /// [request]: crate::message::Request /// [graphics context]: crate::GraphicsContext + #[derive(Debug, Derivative, Writable, Readable, X11Size)] + #[derivative(Hash, PartialEq, Eq)] pub struct Match: Error(8) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The sequence number identifying the [request] that was /// sent. /// /// [request]: crate::message::Request + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, - #[minor_opcode] /// The [minor opcode] referring to the type of [request] that was sent. /// /// See [`Request::MINOR_OPCODE`][minor opcode] for more information. /// /// [request]: crate::message::Request /// [minor opcode]: crate::message::Request::MINOR_OPCODE + #[minor_opcode] pub minor_opcode: u16, - #[major_opcode] /// The [major opcode] referring to the type of [request] that was sent. /// /// See [`Request::MAJOR_OPCODE`][major opcode] for more information. /// /// [request]: crate::message::Request /// [major opcode]: crate::message::Request::MAJOR_OPCODE + #[major_opcode] pub major_opcode: u8, [_; ..], } - #[derive(Debug, Derivative, Writable, Readable, X11Size)] - #[derivative(Hash, PartialEq, Eq)] /// An [error] generated when the [`Drawable`] ID used in the [request] /// does not refer to a defined [window] or [pixmap]. /// @@ -411,16 +409,17 @@ derive_xrb! { /// [window]: crate::Window /// [pixmap]: crate::Pixmap /// [request]: crate::message::Request + #[derive(Debug, Derivative, Writable, Readable, X11Size)] + #[derivative(Hash, PartialEq, Eq)] pub struct Drawable: Error(9) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The sequence number identifying the [request] that was /// sent. /// /// [request]: crate::message::Request + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, - #[error_data] /// The invalid [`Drawable`] ID. /// /// This is of type `u32`, not [`Drawable`], because it does not refer to @@ -429,30 +428,29 @@ derive_xrb! { /// [`Drawable`]: crate::Drawable /// [window]: crate::Window /// [pixmap]: crate::Pixmap + #[error_data] pub invalid_drawable_id: u32, - #[minor_opcode] /// The [minor opcode] referring to the type of [request] that was sent. /// /// See [`Request::MINOR_OPCODE`][minor opcode] for more information. /// /// [request]: crate::message::Request /// [minor opcode]: crate::message::Request::MINOR_OPCODE + #[minor_opcode] pub minor_opcode: u16, - #[major_opcode] /// The [major opcode] referring to the type of [request] that was sent. /// /// See [`Request::MAJOR_OPCODE`][major opcode] for more information. /// /// [request]: crate::message::Request /// [major opcode]: crate::message::Request::MAJOR_OPCODE + #[major_opcode] pub major_opcode: u8, [_; ..], } - #[derive(Debug, Derivative, Writable, Readable, X11Size)] - #[derivative(Hash, PartialEq, Eq)] /// An [error] generated when access is not allowed for what the [request] is /// trying to do. /// @@ -477,72 +475,72 @@ derive_xrb! { /// [select to receive]: crate::mask::EventMask /// [button]: crate::Button /// [colormap]: crate::Colormap + #[derive(Debug, Derivative, Writable, Readable, X11Size)] + #[derivative(Hash, PartialEq, Eq)] pub struct Access: Error(10) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The sequence number identifying the [request] that was /// sent. /// /// [request]: crate::message::Request + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, - #[minor_opcode] /// The [minor opcode] referring to the type of [request] that was sent. /// /// See [`Request::MINOR_OPCODE`][minor opcode] for more information. /// /// [request]: crate::message::Request /// [minor opcode]: crate::message::Request::MINOR_OPCODE + #[minor_opcode] pub minor_opcode: u16, - #[major_opcode] /// The [major opcode] referring to the type of [request] that was sent. /// /// See [`Request::MAJOR_OPCODE`][major opcode] for more information. /// /// [request]: crate::message::Request /// [major opcode]: crate::message::Request::MAJOR_OPCODE + #[major_opcode] pub major_opcode: u8, [_; ..], } - #[derive(Debug, Derivative, Writable, Readable, X11Size)] - #[derivative(Hash, PartialEq, Eq)] /// An [error] generated when the X server failed to allocate the requested /// resource. /// /// [error]: Error + #[derive(Debug, Derivative, Writable, Readable, X11Size)] + #[derivative(Hash, PartialEq, Eq)] pub struct Alloc: Error(11) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The sequence number identifying the [request] that was /// sent. /// /// [request]: crate::message::Request + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, - #[minor_opcode] /// The [minor opcode] referring to the type of [request] that was sent. /// /// See [`Request::MINOR_OPCODE`][minor opcode] for more information. /// /// [request]: crate::message::Request /// [minor opcode]: crate::message::Request::MINOR_OPCODE + #[minor_opcode] pub minor_opcode: u16, - #[major_opcode] /// The [major opcode] referring to the type of [request] that was sent. /// /// See [`Request::MAJOR_OPCODE`][major opcode] for more information. /// /// [request]: crate::message::Request /// [major opcode]: crate::message::Request::MAJOR_OPCODE + #[major_opcode] pub major_opcode: u8, [_; ..], } - #[derive(Debug, Derivative, Writable, Readable, X11Size)] - #[derivative(Hash, PartialEq, Eq)] /// An [error] generated when the [`Colormap`] ID used in the [request] /// does not refer to a defined [colormap]. /// @@ -550,16 +548,17 @@ derive_xrb! { /// [`Colormap`]: crate::Colormap /// [colormap]: crate::Colormap /// [request]: crate::message::Request + #[derive(Debug, Derivative, Writable, Readable, X11Size)] + #[derivative(Hash, PartialEq, Eq)] pub struct Colormap: Error(12) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The sequence number identifying the [request] that was /// sent. /// /// [request]: crate::message::Request + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, - #[error_data] /// The invalid [`Colormap`] ID. /// /// This is of type `u32`, not [`Colormap`], because it does not refer to @@ -567,30 +566,29 @@ derive_xrb! { /// /// [`Colormap`]: crate::Colormap /// [colormap]: crate::Colormap + #[error_data] pub invalid_colormap_id: u32, - #[minor_opcode] /// The [minor opcode] referring to the type of [request] that was sent. /// /// See [`Request::MINOR_OPCODE`][minor opcode] for more information. /// /// [request]: crate::message::Request /// [minor opcode]: crate::message::Request::MINOR_OPCODE + #[minor_opcode] pub minor_opcode: u16, - #[major_opcode] /// The [major opcode] referring to the type of [request] that was sent. /// /// See [`Request::MAJOR_OPCODE`][major opcode] for more information. /// /// [request]: crate::message::Request /// [major opcode]: crate::message::Request::MAJOR_OPCODE + #[major_opcode] pub major_opcode: u8, [_; ..], } - #[derive(Debug, Derivative, Writable, Readable, X11Size)] - #[derivative(Hash, PartialEq, Eq)] /// An [error] generated when the [`GraphicsContext`] ID used in the [request] /// does not refer to a defined [graphics context]. /// @@ -598,16 +596,17 @@ derive_xrb! { /// [`GraphicsContext`]: crate::GraphicsContext /// [graphics context]: crate::GraphicsContext /// [request]: crate::message::Request + #[derive(Debug, Derivative, Writable, Readable, X11Size)] + #[derivative(Hash, PartialEq, Eq)] pub struct GraphicsContext: Error(13) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The sequence number identifying the [request] that was /// sent. /// /// [request]: crate::message::Request + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, - #[error_data] /// The invalid [`GraphicsContext`] ID. /// /// This is of type `u32`, not [`GraphicsContext`], because it does not refer to @@ -615,107 +614,106 @@ derive_xrb! { /// /// [`GraphicsContext`]: crate::GraphicsContext /// [graphics context]: crate::GraphicsContext + #[error_data] pub invalid_graphics_context_id: u32, - #[minor_opcode] /// The [minor opcode] referring to the type of [request] that was sent. /// /// See [`Request::MINOR_OPCODE`][minor opcode] for more information. /// /// [request]: crate::message::Request /// [minor opcode]: crate::message::Request::MINOR_OPCODE + #[minor_opcode] pub minor_opcode: u16, - #[major_opcode] /// The [major opcode] referring to the type of [request] that was sent. /// /// See [`Request::MAJOR_OPCODE`][major opcode] for more information. /// /// [request]: crate::message::Request /// [major opcode]: crate::message::Request::MAJOR_OPCODE + #[major_opcode] pub major_opcode: u8, [_; ..], } - #[derive(Debug, Derivative, Writable, Readable, X11Size)] - #[derivative(Hash, PartialEq, Eq)] /// An [error] generated when a chosen resource ID is not in the range of /// resource IDs assigned to the client, or the ID is already in use. /// /// [error]: Error + #[derive(Debug, Derivative, Writable, Readable, X11Size)] + #[derivative(Hash, PartialEq, Eq)] pub struct ResourceIdChoice: Error(14) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The sequence number identifying the [request] that was /// sent. /// /// [request]: crate::message::Request + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, - #[error_data] /// The resource ID that was either not assigned to the client or was /// already in use. + #[error_data] pub unavailable_resource_id: u32, - #[minor_opcode] /// The [minor opcode] referring to the type of [request] that was sent. /// /// See [`Request::MINOR_OPCODE`][minor opcode] for more information. /// /// [request]: crate::message::Request /// [minor opcode]: crate::message::Request::MINOR_OPCODE + #[minor_opcode] pub minor_opcode: u16, - #[major_opcode] /// The [major opcode] referring to the type of [request] that was sent. /// /// See [`Request::MAJOR_OPCODE`][major opcode] for more information. /// /// [request]: crate::message::Request /// [major opcode]: crate::message::Request::MAJOR_OPCODE + #[major_opcode] pub major_opcode: u8, [_; ..], } - #[derive(Debug, Derivative, Writable, Readable, X11Size)] - #[derivative(Hash, PartialEq, Eq)] /// An [error] generated when the [request] specifies the name of a [font] /// or color which does not exist. /// /// [error]: Error /// [request]: crate::message::Request /// [font]: crate::Font + #[derive(Debug, Derivative, Writable, Readable, X11Size)] + #[derivative(Hash, PartialEq, Eq)] pub struct Name: Error(15) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The sequence number identifying the [request] that was /// sent. /// /// [request]: crate::message::Request + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, - #[minor_opcode] /// The [minor opcode] referring to the type of [request] that was sent. /// /// See [`Request::MINOR_OPCODE`][minor opcode] for more information. /// /// [request]: crate::message::Request /// [minor opcode]: crate::message::Request::MINOR_OPCODE + #[minor_opcode] pub minor_opcode: u16, - #[major_opcode] /// The [major opcode] referring to the type of [request] that was sent. /// /// See [`Request::MAJOR_OPCODE`][major opcode] for more information. /// /// [request]: crate::message::Request /// [major opcode]: crate::message::Request::MAJOR_OPCODE + #[major_opcode] pub major_opcode: u8, [_; ..], } - #[derive(Debug, Derivative, Writable, Readable, X11Size)] - #[derivative(Hash, PartialEq, Eq)] /// An [error] generated when a [request] is not of the correct length. /// /// The length may be too short or too long to hold the fields defined for @@ -724,67 +722,69 @@ derive_xrb! { /// /// [error]: Error /// [request]: crate::message::Request + #[derive(Debug, Derivative, Writable, Readable, X11Size)] + #[derivative(Hash, PartialEq, Eq)] pub struct Length: Error(16) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The sequence number identifying the [request] that was /// sent. /// /// [request]: crate::message::Request + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, - #[minor_opcode] /// The [minor opcode] referring to the type of [request] that was sent. /// /// See [`Request::MINOR_OPCODE`][minor opcode] for more information. /// /// [request]: crate::message::Request /// [minor opcode]: crate::message::Request::MINOR_OPCODE + #[minor_opcode] pub minor_opcode: u16, - #[major_opcode] /// The [major opcode] referring to the type of [request] that was sent. /// /// See [`Request::MAJOR_OPCODE`][major opcode] for more information. /// /// [request]: crate::message::Request /// [major opcode]: crate::message::Request::MAJOR_OPCODE + #[major_opcode] pub major_opcode: u8, [_; ..], } - #[derive(Debug, Derivative, Writable, Readable, X11Size)] - #[derivative(Hash, PartialEq, Eq)] /// An [error] generated when the X server does not implement some aspect /// of the [request]. /// /// [error]: Error /// [request]: crate::message::Request + #[derive(Debug, Derivative, Writable, Readable, X11Size)] + #[derivative(Hash, PartialEq, Eq)] pub struct Implementation: Error(17) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The sequence number identifying the [request] that was /// sent. /// /// [request]: crate::message::Request + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, - #[minor_opcode] /// The [minor opcode] referring to the type of [request] that was sent. /// /// See [`Request::MINOR_OPCODE`][minor opcode] for more information. /// /// [request]: crate::message::Request /// [minor opcode]: crate::message::Request::MINOR_OPCODE + #[minor_opcode] pub minor_opcode: u16, - #[major_opcode] /// The [major opcode] referring to the type of [request] that was sent. /// /// See [`Request::MAJOR_OPCODE`][major opcode] for more information. /// /// [request]: crate::message::Request /// [major opcode]: crate::message::Request::MAJOR_OPCODE + #[major_opcode] pub major_opcode: u8, [_; ..], } diff --git a/src/x11/event.rs b/src/x11/event.rs index cb65e5cd..2155c9a3 100644 --- a/src/x11/event.rs +++ b/src/x11/event.rs @@ -35,8 +35,6 @@ use xrbk_macro::{derive_xrb, ConstantX11Size, Readable, Writable, X11Size}; extern crate self as xrb; derive_xrb! { - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated when a key is pressed. /// /// This [event] is generated for all keys: that includes modifier keys. @@ -48,19 +46,21 @@ derive_xrb! { /// [event]: crate::message::Event /// [window]: Window /// [`KEY_PRESS`]: crate::EventMask::KEY_PRESS + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct KeyPress: Event(2) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [request]: crate::message::Request /// [event]: crate::message::Event + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, - #[metabyte] /// The keycode of the key that was pressed. + #[metabyte] pub keycode: Keycode, /// The time at which this [event] was generated. @@ -117,8 +117,6 @@ derive_xrb! { _, } - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated when a key is released. /// /// This [event] is generated for all keys: that includes modifier keys. @@ -129,19 +127,21 @@ derive_xrb! { /// /// [event]: crate::message::Event /// [`KEY_RELEASE`]: crate::EventMask::KEY_RELEASE + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct KeyRelease: Event(3) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [request]: crate::message::Request /// [event]: crate::message::Event + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, - #[metabyte] /// The keycode of the key which was released. + #[metabyte] pub keycode: Keycode, /// The time at which this [event] was generated. @@ -202,8 +202,6 @@ derive_xrb! { _, } - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated when a [mouse button] is pressed. /// /// # Recipients @@ -213,19 +211,21 @@ derive_xrb! { /// [event]: crate::message::Event /// [mouse button]: Button /// [`BUTTON_PRESS`]: crate::EventMask::BUTTON_PRESS + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct ButtonPress: Event(4) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [request]: crate::message::Request /// [event]: crate::message::Event + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, - #[metabyte] /// The mouse button which was pressed. + #[metabyte] pub button: Button, /// The time at which this [event] was generated. @@ -284,8 +284,6 @@ derive_xrb! { _, } - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated when a [mouse button] is released. /// /// # Recipients @@ -295,19 +293,21 @@ derive_xrb! { /// [event]: crate::message::Event /// [mouse button]: Button /// [`BUTTON_RELEASE`]: crate::EventMask::BUTTON_RELEASE + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct ButtonRelease: Event(5) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [request]: crate::message::Request /// [event]: crate::message::Event + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, - #[metabyte] /// The mouse button which was released. + #[metabyte] pub button: Button, /// The time at which this [event] was generated. @@ -366,12 +366,12 @@ derive_xrb! { } } -#[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, X11Size, Readable, Writable)] /// The type of [`Motion` event] sent. /// /// This is used in the [`Motion` event]. /// /// [`Motion` event]: Motion +#[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, X11Size, Readable, Writable)] pub enum MotionNotificationType { /// The [`Motion` event] was not one generated for a client selecting /// [`MOTION_HINT`]. @@ -399,8 +399,6 @@ pub enum MotionNotificationType { } derive_xrb! { - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated when the cursor moves within a [window]. /// /// `Motion` events are only generated when the cursor motion begins and ends @@ -440,19 +438,21 @@ derive_xrb! { /// /// [event]: crate::message::Event /// [window]: Window + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct Motion: Event(6) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [request]: crate::message::Request /// [event]: crate::message::Event + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, - #[metabyte] /// The type of `Motion` event sent. + #[metabyte] pub notification_type: MotionNotificationType, /// The time at which this event was generated. @@ -510,7 +510,6 @@ derive_xrb! { } } -#[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, X11Size, Readable, Writable)] /// Detail that describes how a [window] receiving a [`LeaveWindow`] or /// [`EnterWindow`] event relates to the [event] which took place. /// @@ -559,6 +558,7 @@ derive_xrb! { /// /// [event]: crate::message::Event /// [window]: Window +#[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, X11Size, Readable, Writable)] pub enum EnterLeaveDetail { /// Used for [`LeaveWindow` events] when the cursor leaves a [window] and /// enters an ancestor of that [window], and for [`EnterWindow` events] @@ -612,8 +612,8 @@ pub enum EnterLeaveDetail { } bitflags! { - #[derive(Default, X11Size, Readable, ConstantX11Size, Writable)] /// A bitmask used in the [`EnterWindow`] and [`LeaveWindow`] events. + #[derive(Default, X11Size, Readable, ConstantX11Size, Writable)] pub struct EnterLeaveMask: u8 { /// Whether the `event_window` is the focused [window] or a descendant /// of the focused [window]. @@ -628,8 +628,6 @@ bitflags! { } derive_xrb! { - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated when the cursor enters a [window]. /// /// This [event] is triggered both when the cursor moves to be in a different @@ -645,23 +643,25 @@ derive_xrb! { /// [event]: crate::message::Event /// [window]: Window /// [`ENTER_WINDOW`]: crate::EventMask::ENTER_WINDOW + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct EnterWindow: Event(7) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [request]: crate::message::Request /// [event]: crate::message::Event + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, - #[metabyte] /// Detail about how the [event] was generated. /// /// See [`EnterLeaveDetail`] for more information. /// /// [event]: crate::message::Event + #[metabyte] pub detail: EnterLeaveDetail, /// The time at which this [event] was generated. @@ -719,8 +719,6 @@ derive_xrb! { pub mask: EnterLeaveMask, } - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated when the cursor leaves a [window]. /// /// This event is triggered both when the cursor moves to be in a different @@ -736,23 +734,25 @@ derive_xrb! { /// [event]: crate::message::Event /// [window]: Window /// [`LEAVE_WINDOW`]: crate::EventMask::LEAVE_WINDOW + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct LeaveWindow: Event(8) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [request]: crate::message::Request /// [event]: crate::message::Event + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, - #[metabyte] /// Detail about how the [event] was generated. /// /// See [`EnterLeaveDetail`] for more information. /// /// [event]: crate::message::Event + #[metabyte] pub detail: EnterLeaveDetail, /// The time at which this [event] was generated. @@ -819,7 +819,6 @@ derive_xrb! { } } -#[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, X11Size, Readable, Writable)] /// Detail describing how a [window] that receives a [`Focus`] or [`Unfocus`] /// event relates to the [event] that occurred. /// @@ -940,6 +939,7 @@ derive_xrb! { /// /// [event]: crate::message::Event /// [window]: Window +#[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, X11Size, Readable, Writable)] pub enum FocusDetail { /// Used for [`Unfocus` events] for the [window] which has been unfocused if /// the newly focused [window] is an ancestor of that [window], and for @@ -986,9 +986,9 @@ pub enum FocusDetail { None, } -#[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, X11Size, Readable, Writable)] /// Detail about how an [`Unfocus`] or [`Focus`] event was generated in relation /// to grabs. +#[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, X11Size, Readable, Writable)] pub enum FocusGrabMode { /// Used for [`Unfocus`] and [`Focus`] events generated when the keyboard is /// not grabbed. @@ -1007,8 +1007,6 @@ pub enum FocusGrabMode { } derive_xrb! { - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated when a [window] is focused. /// /// `Focus` events generated when the keyboard is not grabbed have @@ -1025,23 +1023,25 @@ derive_xrb! { /// [event]: crate::message::Event /// [window]: Window /// [`FOCUS_CHANGE`]: crate::EventMask::FOCUS_CHANGE + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct Focus: Event(9) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [request]: crate::message::Request /// [event]: crate::message::Event + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, - #[metabyte] /// Detail about how the [event] was generated. /// /// See [`FocusDetail`] for more information. /// /// [event]: crate::message::Event + #[metabyte] pub detail: FocusDetail, /// The window which was focused. @@ -1066,8 +1066,6 @@ derive_xrb! { [_; ..], } - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated when a [window] is unfocused. /// /// `Unfocus` events generated when the keyboard is not grabbed have @@ -1084,23 +1082,25 @@ derive_xrb! { /// [event]: crate::message::Event /// [window]: Window /// [`FOCUS_CHANGE`]: crate::EventMask::FOCUS_CHANGE + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct Unfocus: Event(10) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [request]: crate::message::Request /// [event]: crate::message::Event + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, - #[metabyte] /// Detail about how the [event] was generated. /// /// See [`FocusDetail`] for more information. /// /// [event]: crate::message::Event + #[metabyte] pub detail: FocusDetail, /// The window which was unfocused. @@ -1125,7 +1125,6 @@ derive_xrb! { [_; ..], } - #[derive(Debug, Hash, X11Size, Readable, Writable)] /// An [event] describing the current state of the keyboard. /// /// # Recipients @@ -1135,6 +1134,7 @@ derive_xrb! { /// [event]: crate::message::Event /// [window]: Window /// [`KEYS_STATE`]: crate::EventMask::KEYS_STATE + #[derive(Debug, Hash, X11Size, Readable, Writable)] pub struct KeysState: Event(11) { /// A bit vector representing the current keyboard state. /// @@ -1147,8 +1147,6 @@ derive_xrb! { pub keys: [u8; 31], } - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated when a rectangular area of a [window] needs to be /// rendered. /// @@ -1178,15 +1176,17 @@ derive_xrb! { /// [`WindowClass::InputOnly`]: crate::WindowClass::InputOnly /// /// [`EXPOSURE`]: crate::EventMask::EXPOSURE + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct Expose: Event(12) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [event]: crate::message::Event /// [request]: crate::message::Request + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, /// The window which this `Expose` event applies to. @@ -1202,8 +1202,6 @@ derive_xrb! { [_; ..], } - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated when using graphics operations when a region of a /// source [`Drawable`] is obscured. /// @@ -1217,15 +1215,17 @@ derive_xrb! { /// [event]: crate::message::Event /// [`GraphicsContext`]: crate::GraphicsContext /// [`graphics_exposure`]: crate::set::GraphicsOptions::graphics_exposure + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct GraphicsExposure: Event(13) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [event]: crate::message::Event /// [request]: crate::message::Request + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, /// The [`Drawable`] this `GraphicsExposure` event applies to. @@ -1259,8 +1259,6 @@ derive_xrb! { [_; ..], } - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated when a graphics request which might generate /// [`GraphicsExposure` events] doesn't generate any. /// @@ -1272,15 +1270,17 @@ derive_xrb! { /// [`GraphicsExposure` events]: GraphicsExposure /// [`GraphicsContext`]: crate::GraphicsContext /// [`graphics_exposure`]: crate::set::GraphicsOptions::graphics_exposure + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct NoExposure: Event(14) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [request]: crate::message::Request /// [event]: crate::message::Event + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, /// The [`Drawable`] this `NoExposure` event applies to. @@ -1307,13 +1307,13 @@ derive_xrb! { } } -#[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, X11Size, Readable, Writable)] /// The state of a [window]'s visibility. /// /// This is used in the [`Visibility` event]. /// /// [window]: Window /// [`Visibility` event]: Visibility +#[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, X11Size, Readable, Writable)] pub enum VisibilityState { /// There is nothing obscuring the `window`. /// @@ -1344,8 +1344,6 @@ pub enum VisibilityState { } derive_xrb! { - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated when changes to a [window]'s visibility occur. /// /// The [window]'s visibility is calculated ignoring all of its subwindows. @@ -1376,15 +1374,17 @@ derive_xrb! { /// [`FullyObscured`]: VisibilityState::FullyObscured /// /// [`VISIBILITY_CHANGE`]: crate::EventMask::VISIBILITY_CHANGE + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct Visibility: Event(15) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [request]: crate::message::Request /// [event]: crate::message::Event + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, /// The window this `Visibility` event applies to. @@ -1394,8 +1394,6 @@ derive_xrb! { [_; ..], } - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated when a [window] is created. /// /// # Recipients @@ -1405,15 +1403,17 @@ derive_xrb! { /// [event]: crate::message::Event /// [window]: Window /// [`SUBSTRUCTURE_NOTIFY`]: crate::EventMask::SUBSTRUCTURE_NOTIFY + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct Create: Event(16) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [request]: crate::message::Request /// [event]: crate::message::Event + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, /// The parent of the `window` that was created. @@ -1449,8 +1449,6 @@ derive_xrb! { [_; ..], } - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated when a [window] is destroyed. /// /// # Recipients @@ -1462,15 +1460,17 @@ derive_xrb! { /// [window]: Window /// [`STRUCTURE_NOTIFY`]: crate::EventMask::STRUCTURE_NOTIFY /// [`SUBSTRUCTURE_NOTIFY`]: crate::EventMask::SUBSTRUCTURE_NOTIFY + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct Destroy: Event(17) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [request]: crate::message::Request /// [event]: crate::message::Event + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, /// The window on which this `Destroy` event was generated. @@ -1487,8 +1487,6 @@ derive_xrb! { [_; ..], } - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated when a [window] is unmapped. /// /// Unmapping a [window] is the X term for hiding it. This is commonly used to @@ -1502,15 +1500,17 @@ derive_xrb! { /// [window]: Window /// [`STRUCTURE_NOTIFY`]: crate::EventMask::STRUCTURE_NOTIFY /// [`SUBSTRUCTURE_NOTIFY`]: crate::EventMask::SUBSTRUCTURE_NOTIFY + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct Unmap: Event(18) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [request]: crate::message::Request /// [event]: crate::message::Event + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, /// The window on which this `Unmap` event was generated. @@ -1535,8 +1535,6 @@ derive_xrb! { [_; ..], } - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated when a [window] is mapped. /// /// Mapping a [window] is the X term for showing it. It is the reverse of @@ -1550,15 +1548,17 @@ derive_xrb! { /// [window]: Window /// [`STRUCTURE_NOTIFY`]: crate::EventMask::STRUCTURE_NOTIFY /// [`SUBSTRUCTURE_NOTIFY`]: crate::EventMask::SUBSTRUCTURE_NOTIFY + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct Map: Event(19) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [request]: crate::message::Request /// [event]: crate::message::Event + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, /// The window on which this `Map` event was generated. @@ -1588,8 +1588,6 @@ derive_xrb! { [_; ..], } - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated when an unmapped [window] with an /// [`override_redirect` attribute] of `false` sends a [`MapWindow` request]. /// @@ -1605,15 +1603,17 @@ derive_xrb! { /// [`MapWindow` request]: super::request::MapWindow /// /// [`SUBSTRUCTURE_REDIRECT`]: crate::EventMask::SUBSTRUCTURE_REDIRECT + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct MapRequest: Event(20) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [request]: crate::message::Request /// [event]: crate::message::Event + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, /// The `window`'s parent. @@ -1625,8 +1625,6 @@ derive_xrb! { [_; ..], } - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated when a [window] is reparented. /// /// Reparenting a [window] means to remove it from its current position in @@ -1641,15 +1639,17 @@ derive_xrb! { /// [window]: Window /// [`SUBSTRUCTURE_NOTIFY`]: crate::EventMask::SUBSTRUCTURE_NOTIFY /// [`STRUCTURE_NOTIFY`]: crate::EventMask::STRUCTURE_NOTIFY + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct Reparent: Event(21) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [request]: crate::message::Request /// [event]: crate::message::Event + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, /// The window on which this `Reparent` event was generated. @@ -1685,8 +1685,6 @@ derive_xrb! { [_; ..], } - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated when a [`ConfigureWindow` request] changes the state /// of a [window]. /// @@ -1699,15 +1697,17 @@ derive_xrb! { /// [window]: Window /// [`STRUCTURE_NOTIFY`]: crate::EventMask::STRUCTURE_NOTIFY /// [`SUBSTRUCTURE_NOTIFY`]: crate::EventMask::SUBSTRUCTURE_NOTIFY + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct Configure: Event(22) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [request]: crate::message::Request /// [event]: crate::message::Event + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, /// The window on which this `Configure` event was generated. @@ -1758,8 +1758,6 @@ derive_xrb! { [_; ..], } - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated when a [window] sends a [`ConfigureWindow` request]. /// /// This [event] is generated when a client other than the one selecting @@ -1781,15 +1779,17 @@ derive_xrb! { /// [`ConfigureWindow` request]: super::request::ConfigureWindow /// /// [`SUBSTRUCTURE_REDIRECT`]: crate::EventMask::SUBSTRUCTURE_REDIRECT + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct ConfigureWindowRequest: Event(23) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [request]: crate::message::Request /// [event]: crate::message::Event + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, #[metabyte] @@ -1833,8 +1833,6 @@ derive_xrb! { [_; ..], } - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated when a [window] is moved because its parent is /// resized. /// @@ -1846,15 +1844,17 @@ derive_xrb! { /// [window]: Window /// [`STRUCTURE_NOTIFY`]: crate::EventMask::STRUCTURE_NOTIFY /// [`SUBSTRUCTURE_NOTIFY`]: crate::EventMask::SUBSTRUCTURE_NOTIFY + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct Gravity: Event(24) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [request]: crate::message::Request /// [event]: crate::message::Event + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, /// The window which this `Gravity` event was generated on. @@ -1875,8 +1875,6 @@ derive_xrb! { [_; ..], } - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated when a [window] on which a client is selecting /// [`RESIZE_REDIRECT`] has a [`ConfigureWindow` request] sent by another /// client attempt to change the [window]'s size. @@ -1889,15 +1887,17 @@ derive_xrb! { /// [window]: Window /// [`RESIZE_REDIRECT`]: crate::EventMask::RESIZE_REDIRECT /// [`ConfigureWindow` request]: super::request::ConfigureWindow + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct ResizeRequest: Event(25) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [request]: crate::message::Request /// [event]: crate::message::Event + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, /// The window which the [`ConfigureWindow` request] attempted to @@ -1920,7 +1920,6 @@ derive_xrb! { } } -#[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, X11Size, Readable, Writable)] /// The new placement of a [window] restacked in a [`CirculateWindow` request]. /// /// This is used in [`Circulate` events]. @@ -1928,6 +1927,7 @@ derive_xrb! { /// [window]: Window /// [`CirculateWindow` request]: super::request::CirculateWindow /// [`Circulate` events]: Circulate +#[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, X11Size, Readable, Writable)] pub enum Placement { /// The `window` is now above all its siblings in the stack. Top, @@ -1936,8 +1936,6 @@ pub enum Placement { } derive_xrb! { - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated when a [window] is restacked due to a /// [`CirculateWindow` request]. /// @@ -1951,15 +1949,17 @@ derive_xrb! { /// /// [`STRUCTURE_NOTIFY`]: crate::EventMask::STRUCTURE_NOTIFY /// [`SUBSTRUCTURE_NOTIFY`]: crate::EventMask::SUBSTRUCTURE_NOTIFY + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct Circulate: Event(26) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [request]: crate::message::Request /// [event]: crate::message::Event + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, /// The window which this `Circulate` event was generated on. @@ -1981,8 +1981,6 @@ derive_xrb! { [_; ..], } - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated when a [`CirculateWindow` request] is sent for a /// [window] and that [window] actually needs to be restacked. /// @@ -1994,15 +1992,17 @@ derive_xrb! { /// [window]: Window /// [`SUBSTRUCTURE_REDIRECT`]: crate::EventMask::SUBSTRUCTURE_REDIRECT /// [`CirculateWindow` request]: super::request::CirculateWindow + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct CirculateRequest: Event(27) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [request]: crate::message::Request /// [event]: crate::message::Event + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, /// The parent of the `window` the [`CirculateWindow` request] applies @@ -2027,13 +2027,13 @@ derive_xrb! { } } -#[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, X11Size, Readable, Writable)] /// Whether a `property` was [`Modified`] or [`Deleted`] in a [`Property` /// event]. /// /// [`Property` event]: Property /// [`Modified`]: PropertyChange::Modified /// [`Deleted`]: PropertyChange::Deleted +#[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, X11Size, Readable, Writable)] pub enum PropertyChange { /// The `property` was added or its value was changed. Modified, @@ -2042,8 +2042,6 @@ pub enum PropertyChange { } derive_xrb! { - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated when a [window] property is added, modified, or /// removed. /// @@ -2054,15 +2052,17 @@ derive_xrb! { /// [event]: crate::message::Event /// [window]: Window /// [`PROPERTY_CHANGE`]: crate::EventMask::PROPERTY_CHANGE + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct Property: Event(28) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [request]: crate::message::Request /// [event]: crate::message::Event + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, /// The window on which the `property` was changed. @@ -2080,8 +2080,6 @@ derive_xrb! { [_; ..], } - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated when a new selection owner is defined for a /// selection. /// @@ -2093,15 +2091,17 @@ derive_xrb! { /// /// [event]: crate::message::Event /// [`SetSelectionOwner` request]: super::request::SetSelectionOwner + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct SelectionClear: Event(29) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [request]: crate::message::Request /// [event]: crate::message::Event + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, /// The time at which the new `selection` owner was defined. @@ -2113,8 +2113,6 @@ derive_xrb! { [_; ..], } - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated when a [`ConvertSelection` request] is sent. /// /// The owner should convert the selection based on the specified target @@ -2131,15 +2129,17 @@ derive_xrb! { /// [`ConvertSelection` request]: super::request::ConvertSelection /// [`Selection` event]: Selection /// [`SendEvent` request]: super::request::SendEvent + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct ConvertSelectionRequest: Event(30) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [request]: crate::message::Request /// [event]: crate::message::Event + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, /// The time at which the [`ConvertSelection` request] was sent. @@ -2163,8 +2163,6 @@ derive_xrb! { [_; ..], } - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// A reply to the [`ConvertSelection` request]. /// /// If the selection has no owner, this is generated by the X server. If the @@ -2178,15 +2176,17 @@ derive_xrb! { /// [event]: crate::message::Event /// [`ConvertSelection` request]: super::request::ConvertSelection /// [`SendEvent` request]: super::request::SendEvent + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct Selection: Event(31) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [request]: crate::message::Request /// [event]: crate::message::Event + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, /// The time at which this `Selection` event was generated. @@ -2210,10 +2210,10 @@ derive_xrb! { [_; ..], } - #[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, X11Size, Readable, Writable)] /// The reason why a [`Colormap` event] was generated. /// /// [`Colormap` event]: Colormap + #[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, X11Size, Readable, Writable)] pub enum ColormapDetail { /// The `window`'s [`colormap` attribute] was changed. /// @@ -2225,11 +2225,11 @@ derive_xrb! { InstalledOrUninstalled, } - #[derive(Debug, Hash, PartialEq, Eq, X11Size, Readable, Writable)] /// Whether a [window]'s [colormap] is currently installed. /// /// [window]: Window /// [colormap]: crate::Colormap + #[derive(Debug, Hash, PartialEq, Eq, X11Size, Readable, Writable)] pub enum ColormapState { /// The [window]'s [colormap] is not currently installed. /// @@ -2243,8 +2243,6 @@ derive_xrb! { Installed, } - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated when a [window]'s [colormap] is installed, /// uninstalled, or its [`colormap` attribute] is changed. /// @@ -2258,15 +2256,17 @@ derive_xrb! { /// [`colormap` attribute]: crate::Attributes::colormap /// /// [`COLORMAP_CHANGE`]: crate::EventMask::COLORMAP_CHANGE + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct Colormap: Event(32) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [request]: crate::message::Request /// [event]: crate::message::Event + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, /// The window that this [event] relates to. @@ -2291,11 +2291,11 @@ derive_xrb! { } } -#[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, X11Size, Readable, Writable)] /// Used in the [`ClientMessage` event] to represent whether its `data` is 20 /// `i8` values, 10 `i16` values, or 5 `i32` values. /// /// [`ClientMessage` event]: ClientMessage +#[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, X11Size, Readable, Writable)] pub enum ClientMessageFormat { /// 20 `i8` values: [`ClientMessageData::I8`]. I8 = 8, @@ -2305,10 +2305,10 @@ pub enum ClientMessageFormat { I32 = 32, } -#[derive(Clone, Eq, PartialEq, Hash, Debug, Writable)] /// The `data` contained in a [`ClientMessage` event]. /// /// [`ClientMessage` event]: ClientMessage +#[derive(Clone, Eq, PartialEq, Hash, Debug, Writable)] #[no_discrim] pub enum ClientMessageData { /// Data comprised of 20 `i8` values. @@ -2345,8 +2345,6 @@ impl ReadableWithContext for ClientMessageData { } derive_xrb! { - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated by a [`SendEvent` request]. /// /// # Recipients @@ -2356,19 +2354,21 @@ derive_xrb! { /// [event]: crate::message::Event /// [`SendEvent` request]: super::request::SendEvent /// [window]: Window + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct ClientMessage: Event(33) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [request]: crate::message::Request /// [event]: crate::message::Event + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, - #[metabyte] /// Whether `data` is `[i8; 20]`, `[i16; 10]`, or `[i32; 5]`. + #[metabyte] let format: ClientMessageFormat = data => match data { ClientMessageData::I8(_) => ClientMessageFormat::I8, ClientMessageData::I16(_) => ClientMessageFormat::I16, @@ -2380,19 +2380,19 @@ derive_xrb! { /// How the `data` is to be interpreted by the `recipient`. pub r#type: Atom, - #[context(format => *format)] /// The data contained in this [event]. /// /// [event]: crate::message::Event + #[context(format => *format)] pub data: ClientMessageData, } } -#[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, X11Size, Readable, Writable)] /// Detail about which [request] generated a [`MappingChange` event]. /// /// [request]: crate::message::Request /// [`MappingChange` event]: MappingChange +#[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, X11Size, Readable, Writable)] pub enum MappingRequest { /// The [`MappingChange` event] was generated by a /// [`SetModifierMapping` request]. @@ -2417,8 +2417,6 @@ pub enum MappingRequest { } derive_xrb! { - #[derive(Debug, Derivative, X11Size, Readable, Writable)] - #[derivative(Hash, PartialEq, Eq)] /// An [event] generated when a [`SetModifierMapping`], /// [`ChangeKeyboardMapping`], or [`SetCursorMapping`] request is successful. /// @@ -2429,15 +2427,17 @@ derive_xrb! { /// [`SetModifierMapping`]: super::request::SetModifierMapping /// [`ChangeKeyboardMapping`]: super::request::ChangeKeyboardMapping /// [`SetCursorMapping`]: super::request::SetCursorMapping + #[derive(Debug, Derivative, X11Size, Readable, Writable)] + #[derivative(Hash, PartialEq, Eq)] pub struct MappingChange: Event(34) { - #[sequence] - #[derivative(PartialEq = "ignore", Hash = "ignore")] /// The [sequence number] associated with the last [request] related /// to this [event] that was received before this [event] was generated. /// /// [sequence number]: crate::message::Event::sequence /// [request]: crate::message::Request /// [event]: crate::message::Event + #[sequence] + #[derivative(PartialEq = "ignore", Hash = "ignore")] pub sequence: u16, /// The [request] that generated this `MappingChange` event. From ef85b76164a70e84998dac9174e8078c885d5ccf Mon Sep 17 00:00:00 2001 From: Syudagye Date: Tue, 24 Jan 2023 15:14:21 +0100 Subject: [PATCH 2/3] Update `CONTRIBUTING.md` with attrs and doc code style --- CONTRIBUTING.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f5457c50..ca40390b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -105,7 +105,31 @@ examples would be comparing the events in the events section of the [`x11::event`]: https://github.com/XdotRS/xrb/blob/main/src/x11/event.rs ## Code style -TODO + +### Attributes and Documentation + +A lot of types and fields in xrb uses attributes, such as `#[derive(...)]` or other custom ones. +To keep the code easely readable, those a preferably put after documentation comments. + +Here is an example: +```rust +/// # Foo +/// Documentation about [Foo] +#[doc(alias("foo"))] +#[derive(Debug, Hash, X11Size)] +pub struct Foo { + /// Documentation about the [data] field + #[custom_attribute_field] + pub data: Any, + + /// Other doc + pub other_field: Any, +} +``` + +Doing this helps grouping code related syntax together, so when documentation is taking a lot of place, +it's not splitting elements far away from each other (if, for example attributes are placed before the doc comments). + ## Useful resources - [X Window System protocol version 11](https://x.org/releases/X11R7.7/doc/xproto/x11protocol.html) From c1102c03657c2e8c23b91e8815d87bb963e0ddd2 Mon Sep 17 00:00:00 2001 From: Syudagye <44324659+Syudagye@users.noreply.github.com> Date: Tue, 24 Jan 2023 19:48:41 +0100 Subject: [PATCH 3/3] Update CONTRIBUTING.md Co-authored-by: Antikyth <104020300+Antikyth@users.noreply.github.com> --- CONTRIBUTING.md | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ca40390b..8ac29e16 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -106,30 +106,39 @@ examples would be comparing the events in the events section of the ## Code style -### Attributes and Documentation +### Placement of attributes +Many types and fields in XRB use attributes. To keep the source code consistent and easily readable, attributes should be put _after_ doc comments. -A lot of types and fields in xrb uses attributes, such as `#[derive(...)]` or other custom ones. -To keep the code easely readable, those a preferably put after documentation comments. - -Here is an example: +For example, do this: ```rust -/// # Foo -/// Documentation about [Foo] -#[doc(alias("foo"))] +/// A foo which does bar. +#[doc(alias = "baz")] #[derive(Debug, Hash, X11Size)] pub struct Foo { - /// Documentation about the [data] field - #[custom_attribute_field] - pub data: Any, + /// Data which represents xyz. + #[custom_attribute] + pub data: Any, - /// Other doc - pub other_field: Any, + /// The other field within this `Foo`. + pub other_field: Any, +} +``` +But **not** this: +```rust +#[derive(Debug, Hash, X11Size)] +/// A foo which does bar. +#[doc(alias = "baz")] +pub struct DoNotDoThis { + #[custom_attribute] + /// Data which represents xyz. + pub data: Any, + + /// The other field within this `DoNotDoThis`. + pub other_field: Any, } ``` -Doing this helps grouping code related syntax together, so when documentation is taking a lot of place, -it's not splitting elements far away from each other (if, for example attributes are placed before the doc comments). - +This consistently groups related syntax together - you know you'll always find the attributes after the documentation, if the documentation is quite long for example, and that you're looking at all of the attributes at once. ## Useful resources - [X Window System protocol version 11](https://x.org/releases/X11R7.7/doc/xproto/x11protocol.html)