From 3f7afb653a009759529544571b2d305cc97b3adb Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Mon, 8 Aug 2022 18:24:42 +0000 Subject: [PATCH] input: Fix tests --- src/input/mod.rs | 26 ++++++++++++++------- src/wayland/data_device/mod.rs | 6 +++++ src/wayland/primary_selection/mod.rs | 6 +++++ src/wayland/seat/mod.rs | 34 +++++++++++++++++++--------- src/wayland/shell/xdg/mod.rs | 6 ++--- src/wayland/tablet_manager/mod.rs | 12 +++++++--- 6 files changed, 64 insertions(+), 26 deletions(-) diff --git a/src/input/mod.rs b/src/input/mod.rs index 1332a451d8..05f05da4ea 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -16,7 +16,7 @@ //! ### Initialization //! //! ``` -//! use smithay::input::{Seat, SeatState, SeatHandler}; +//! use smithay::input::{Seat, SeatState, SeatHandler, keyboard::KeyboardHandler, pointer::CursorImageStatus}; //! //! struct State { //! seat_state: SeatState, @@ -196,11 +196,15 @@ impl Seat { /// # Examples /// /// ```no_run - /// # extern crate wayland_server; + /// # use smithay::input::{Seat, SeatState, SeatHandler, keyboard::KeyboardHandler, pointer::CursorImageStatus}; /// # - /// # use smithay::wayland::seat::Seat; - /// # - /// # let mut seat: Seat<()> = unimplemented!(); + /// # struct State; + /// # impl SeatHandler for State { + /// # fn seat_state(&mut self) -> &mut SeatState { unimplemented!() } + /// # fn focus_changed(&mut self, seat: &Seat, focused: Option<&dyn KeyboardHandler>) { unimplemented!() } + /// # fn cursor_image(&mut self, seat: &Seat, image: CursorImageStatus) { unimplemented!() } + /// # } + /// # let mut seat: Seat = unimplemented!(); /// let pointer_handle = seat.add_pointer(); /// ``` pub fn add_pointer(&mut self) -> PointerHandle { @@ -252,9 +256,15 @@ impl Seat { /// # Examples /// /// ```no_run - /// # extern crate smithay; - /// # use smithay::wayland::seat::{Seat, XkbConfig}; - /// # let mut seat: Seat<()> = unimplemented!(); + /// # use smithay::input::{Seat, SeatState, SeatHandler, keyboard::{KeyboardHandler, XkbConfig}, pointer::CursorImageStatus}; + /// # + /// # struct State; + /// # impl SeatHandler for State { + /// # fn seat_state(&mut self) -> &mut SeatState { unimplemented!() } + /// # fn focus_changed(&mut self, seat: &Seat, focused: Option<&dyn KeyboardHandler>) { unimplemented!() } + /// # fn cursor_image(&mut self, seat: &Seat, image: CursorImageStatus) { unimplemented!() } + /// # } + /// # let mut seat: Seat = unimplemented!(); /// let keyboard = seat /// .add_keyboard( /// XkbConfig { diff --git a/src/wayland/data_device/mod.rs b/src/wayland/data_device/mod.rs index 141bc6fdd5..da8afc0c03 100644 --- a/src/wayland/data_device/mod.rs +++ b/src/wayland/data_device/mod.rs @@ -31,6 +31,7 @@ //! # #[macro_use] extern crate smithay; //! use smithay::delegate_data_device; //! use smithay::wayland::data_device::{ClientDndGrabHandler, DataDeviceState, DataDeviceHandler, ServerDndGrabHandler}; +//! # use smithay::input::{Seat, SeatState, SeatHandler, keyboard::KeyboardHandler, pointer::CursorImageStatus}; //! //! # struct State { data_device_state: DataDeviceState } //! # let mut display = wayland_server::Display::::new().unwrap(); @@ -44,6 +45,11 @@ //! // .. //! //! // implement the necessary traits +//! # impl SeatHandler for State { +//! # fn seat_state(&mut self) -> &mut SeatState { unimplemented!() } +//! # fn focus_changed(&mut self, seat: &Seat, focused: Option<&dyn KeyboardHandler>) { unimplemented!() } +//! # fn cursor_image(&mut self, seat: &Seat, image: CursorImageStatus) { unimplemented!() } +//! # } //! impl ClientDndGrabHandler for State {} //! impl ServerDndGrabHandler for State {} //! impl DataDeviceHandler for State { diff --git a/src/wayland/primary_selection/mod.rs b/src/wayland/primary_selection/mod.rs index 5c9ccd747c..225a367f2d 100644 --- a/src/wayland/primary_selection/mod.rs +++ b/src/wayland/primary_selection/mod.rs @@ -28,6 +28,7 @@ //! # #[macro_use] extern crate smithay; //! use smithay::delegate_primary_selection; //! use smithay::wayland::primary_selection::{PrimarySelectionState, PrimarySelectionHandler}; +//! # use smithay::input::{Seat, SeatHandler, SeatState, keyboard::KeyboardHandler, pointer::CursorImageStatus}; //! //! # struct State { primary_selection_state: PrimarySelectionState } //! # let mut display = wayland_server::Display::::new().unwrap(); @@ -41,6 +42,11 @@ //! // .. //! //! // implement the necessary traits +//! # impl SeatHandler for State { +//! # fn seat_state(&mut self) -> &mut SeatState { unimplemented!() } +//! # fn focus_changed(&mut self, seat: &Seat, focused: Option<&dyn KeyboardHandler>) { unimplemented!() } +//! # fn cursor_image(&mut self, seat: &Seat, image: CursorImageStatus) { unimplemented!() } +//! # } //! impl PrimarySelectionHandler for State { //! fn primary_selection_state(&self) -> &PrimarySelectionState { &self.primary_selection_state } //! // ... override default implementations here to customize handling ... diff --git a/src/wayland/seat/mod.rs b/src/wayland/seat/mod.rs index 956afb7172..c1bc3b96c7 100644 --- a/src/wayland/seat/mod.rs +++ b/src/wayland/seat/mod.rs @@ -10,27 +10,34 @@ //! ``` //! # extern crate wayland_server; //! use smithay::delegate_seat; -//! use smithay::wayland::seat::{Seat, SeatState, SeatHandler}; +//! use smithay::input::{Seat, SeatState, SeatHandler, keyboard::KeyboardHandler, pointer::CursorImageStatus}; //! //! # struct State { seat_state: SeatState }; //! # let mut display = wayland_server::Display::::new().unwrap(); //! # let display_handle = display.handle(); -//! // create the seat -//! let seat = Seat::::new( -//! &display_handle, // the display -//! "seat-0", // the name of the seat, will be advertized to clients -//! None // insert a logger here -//! ); //! -//! let seat_state = SeatState::::new(); +//! let mut seat_state = SeatState::::new(); //! // add the seat state to your state //! // ... //! +//! // create the wl_seat +//! let seat = seat_state.new_wl_seat( +//! &display_handle, // the display +//! "seat-0", // the name of the seat, will be advertized to clients +//! None // insert a logger here +//! ); +//! //! // implement the required traits //! impl SeatHandler for State { //! fn seat_state(&mut self) -> &mut SeatState { //! &mut self.seat_state //! } +//! fn focus_changed(&mut self, seat: &Seat, focused: Option<&dyn KeyboardHandler>) { +//! // ... +//! } +//! fn cursor_image(&mut self, seat: &Seat, image: CursorImageStatus) { +//! // ... +//! } //! } //! delegate_seat!(State); //! ``` @@ -159,10 +166,15 @@ impl Seat { /// # Examples /// /// ```no_run - /// # extern crate wayland_server; + /// # use smithay::input::{Seat, SeatState, SeatHandler, keyboard::KeyboardHandler, pointer::CursorImageStatus}; /// # - /// # use smithay::wayland::seat::Seat; - /// # let mut seat: Seat<()> = unimplemented!(); + /// # struct State; + /// # impl SeatHandler for State { + /// # fn seat_state(&mut self) -> &mut SeatState { unimplemented!() } + /// # fn focus_changed(&mut self, seat: &Seat, focused: Option<&dyn KeyboardHandler>) { unimplemented!() } + /// # fn cursor_image(&mut self, seat: &Seat, image: CursorImageStatus) { unimplemented!() } + /// # } + /// # let mut seat: Seat = unimplemented!(); /// let touch_handle = seat.add_touch(); /// ``` pub fn add_touch(&mut self) -> TouchHandle { diff --git a/src/wayland/shell/xdg/mod.rs b/src/wayland/shell/xdg/mod.rs index 7fdc712088..c492f16648 100644 --- a/src/wayland/shell/xdg/mod.rs +++ b/src/wayland/shell/xdg/mod.rs @@ -27,10 +27,8 @@ //! # //! use smithay::delegate_xdg_shell; //! use smithay::reexports::wayland_server::protocol::wl_seat; -//! use smithay::wayland::{ -//! shell::xdg::{XdgShellState, XdgShellHandler, ToplevelSurface, PopupSurface, PositionerState}, -//! Serial, -//! }; +//! use smithay::wayland::shell::xdg::{XdgShellState, XdgShellHandler, ToplevelSurface, PopupSurface, PositionerState}; +//! use smithay::utils::Serial; //! //! # struct State { xdg_shell_state: XdgShellState } //! # let mut display = wayland_server::Display::::new().unwrap(); diff --git a/src/wayland/tablet_manager/mod.rs b/src/wayland/tablet_manager/mod.rs index f33cecb3d1..da297cedc1 100644 --- a/src/wayland/tablet_manager/mod.rs +++ b/src/wayland/tablet_manager/mod.rs @@ -5,20 +5,20 @@ //! ``` //! # extern crate wayland_server; //! use smithay::{delegate_seat, delegate_tablet_manager}; -//! use smithay::wayland::seat::{Seat, SeatState, SeatHandler}; +//! use smithay::input::{Seat, SeatState, SeatHandler, keyboard::KeyboardHandler, pointer::CursorImageStatus}; //! use smithay::wayland::tablet_manager::{TabletManagerState, TabletDescriptor}; //! //! # struct State { seat_state: SeatState }; //! # let mut display = wayland_server::Display::::new().unwrap(); //! # let display_handle = display.handle(); //! -//! let seat_state = SeatState::::new(); +//! let mut seat_state = SeatState::::new(); //! let tablet_state = TabletManagerState::new::(&display_handle); //! // add the seat state to your state //! // ... //! //! // create the seat -//! let seat = Seat::::new( +//! let seat = seat_state.new_wl_seat( //! &display_handle, // the display //! "seat-0", // the name of the seat, will be advertized to clients //! None // insert a logger here @@ -42,6 +42,12 @@ //! fn seat_state(&mut self) -> &mut SeatState { //! &mut self.seat_state //! } +//! fn focus_changed(&mut self, seat: &Seat, focused: Option<&dyn KeyboardHandler>) { +//! // ... +//! } +//! fn cursor_image(&mut self, seat: &Seat, image: CursorImageStatus) { +//! // ... +//! } //! } //! delegate_seat!(State); //! delegate_tablet_manager!(State);