<NME> mod.rs
<BEF> //! Protocol-related utilities
//!
//! This module contains several handlers to manage the Wayland protocol
//! and the clients.
//!
//! ## General structure
//!
//! Most utilities provided in this module work in the same way:
//!
//! - A module specific `*State` struct will take the wayland display as argument and
//!   insert one or more globals into it through its constructor.
//! - The module-`State` will have to be stored inside your global compositor state.
//!   (The same type you parametrized [`wayland_server::Display`] over.)
//! - You need to implement a module-specific `*Handler`-trait for your compositor state.
//!   This implementation will be called when wayland events require custom handling.
//! - Call the matching `delegate_*!` macro from smithay on your state to implement
//!   some required `wayland_server` traits.
//! - If you want to remove a previously inserted global, just drop the `*State`.
//!
//! ## Provided helpers
//!
//! ### Core functionality
//!
//! The most fundamental module is the [`compositor`] module, which provides the necessary
//! logic to handle the fundamental component by which clients build their windows: surfaces.
//! Following this, the [`shell`] module contains the logic allowing clients to use their
//! surface to build concrete windows with the usual interactions. Different kind of shells
//! exist, but in general you will want to support at least the [`xdg`](shell::xdg) variant,
//! which is the standard used by most applications.
//!
//! Then, the [`seat`] module contains logic related to input handling. These helpers are used
//! to forward input (such as pointer action or keystrokes) to clients, and manage the input
//! focus of clients. Tightly coupled with it is the [`data_device`] module, which handles
//! cross-client interactions such as accessing the clipboard, or drag'n'drop actions.
//!
//! The [`shm`] module provides the necessary logic for client to provide buffers defining the
//! contents of their windows using shared memory. This is the main mechanism used by clients
//! that are not hardware accelerated. As a complement, the [`dmabuf`] module provides support
//! hardware-accelerated clients; it is tightly linked to the
//! [`backend::allocator`](crate::backend::allocator) module.
//!
//! The [`output`] module helps forwarding to clients information about the display monitors that
//! are available. This notably plays a key role in HiDPI handling, and more generally notifying
//! clients about whether they are currently visible or not (allowing them to stop drawing if they
//! are not, for example).
//!

pub mod buffer;
pub mod compositor;
pub mod data_device;
pub mod dmabuf;
//! over the synchronization for accessing graphics buffer with the compositor, for low-latency
//! rendering. It is however still experimental, and largely untested.

use std::sync::atomic::{AtomicUsize, Ordering};

pub mod compositor;
// pub mod data_device;
pub mod socket;
pub mod tablet_manager;
pub mod text_input;
pub mod viewporter;
pub mod virtual_keyboard;
pub mod xdg_activation;
///
/// Is is also used internally by some parts of Smithay.
pub static SERIAL_COUNTER: SerialCounter = SerialCounter {
    serial: AtomicUsize::new(0),
};

/// A serial type, whose comparison takes into account the wrapping-around behavior of the
        if distance < u32::MAX / 2 {
            self.0.partial_cmp(&other.0)
        } else {
            // wrap-around occured, invert comparison
            other.0.partial_cmp(&self.0)
        }
    }
/// as needed.
#[derive(Debug)]
pub struct SerialCounter {
    // TODO: replace with an AtomicU32 when stabilized
    serial: AtomicUsize,
}

impl SerialCounter {
    /// Retrieve the next serial from the counter
    pub fn next_serial(&self) -> Serial {
        Serial(self.serial.fetch_add(1, Ordering::AcqRel) as u32)
    }
}


    fn create_serial_counter(initial_value: u32) -> SerialCounter {
        SerialCounter {
            serial: AtomicUsize::new(initial_value as usize),
        }
    }


<MSG> wayland-frontend: Resolve SerialCounter todo

<DFF> @@ -52,7 +52,7 @@
 //! over the synchronization for accessing graphics buffer with the compositor, for low-latency
 //! rendering. It is however still experimental, and largely untested.
 
-use std::sync::atomic::{AtomicUsize, Ordering};
+use std::sync::atomic::{AtomicU32, Ordering};
 
 pub mod compositor;
 // pub mod data_device;
@@ -71,7 +71,7 @@ pub mod shm;
 ///
 /// Is is also used internally by some parts of Smithay.
 pub static SERIAL_COUNTER: SerialCounter = SerialCounter {
-    serial: AtomicUsize::new(0),
+    serial: AtomicU32::new(0),
 };
 
 /// A serial type, whose comparison takes into account the wrapping-around behavior of the
@@ -97,7 +97,7 @@ impl PartialOrd for Serial {
         if distance < u32::MAX / 2 {
             self.0.partial_cmp(&other.0)
         } else {
-            // wrap-around occured, invert comparison
+            // wrap-around occurred, invert comparison
             other.0.partial_cmp(&self.0)
         }
     }
@@ -125,14 +125,13 @@ impl From<Serial> for u32 {
 /// as needed.
 #[derive(Debug)]
 pub struct SerialCounter {
-    // TODO: replace with an AtomicU32 when stabilized
-    serial: AtomicUsize,
+    serial: AtomicU32,
 }
 
 impl SerialCounter {
     /// Retrieve the next serial from the counter
     pub fn next_serial(&self) -> Serial {
-        Serial(self.serial.fetch_add(1, Ordering::AcqRel) as u32)
+        Serial(self.serial.fetch_add(1, Ordering::AcqRel))
     }
 }
 
@@ -142,7 +141,7 @@ mod tests {
 
     fn create_serial_counter(initial_value: u32) -> SerialCounter {
         SerialCounter {
-            serial: AtomicUsize::new(initial_value as usize),
+            serial: AtomicU32::new(initial_value),
         }
     }
 

wayland-frontend: Resolve SerialCounter todo