input: Fix tests

This commit is contained in:
Victoria Brekenfeld 2022-08-08 18:24:42 +00:00
parent 9f4cd862f8
commit 3f7afb653a
6 changed files with 64 additions and 26 deletions

View file

@ -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<Self>,
@ -196,11 +196,15 @@ impl<D: SeatHandler + 'static> Seat<D> {
/// # 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<Self> { unimplemented!() }
/// # fn focus_changed(&mut self, seat: &Seat<Self>, focused: Option<&dyn KeyboardHandler<Self>>) { unimplemented!() }
/// # fn cursor_image(&mut self, seat: &Seat<Self>, image: CursorImageStatus) { unimplemented!() }
/// # }
/// # let mut seat: Seat<State> = unimplemented!();
/// let pointer_handle = seat.add_pointer();
/// ```
pub fn add_pointer(&mut self) -> PointerHandle<D> {
@ -252,9 +256,15 @@ impl<D: SeatHandler + 'static> Seat<D> {
/// # 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<Self> { unimplemented!() }
/// # fn focus_changed(&mut self, seat: &Seat<Self>, focused: Option<&dyn KeyboardHandler<Self>>) { unimplemented!() }
/// # fn cursor_image(&mut self, seat: &Seat<Self>, image: CursorImageStatus) { unimplemented!() }
/// # }
/// # let mut seat: Seat<State> = unimplemented!();
/// let keyboard = seat
/// .add_keyboard(
/// XkbConfig {

View file

@ -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::<State>::new().unwrap();
@ -44,6 +45,11 @@
//! // ..
//!
//! // implement the necessary traits
//! # impl SeatHandler for State {
//! # fn seat_state(&mut self) -> &mut SeatState<Self> { unimplemented!() }
//! # fn focus_changed(&mut self, seat: &Seat<Self>, focused: Option<&dyn KeyboardHandler<Self>>) { unimplemented!() }
//! # fn cursor_image(&mut self, seat: &Seat<Self>, image: CursorImageStatus) { unimplemented!() }
//! # }
//! impl ClientDndGrabHandler for State {}
//! impl ServerDndGrabHandler for State {}
//! impl DataDeviceHandler for State {

View file

@ -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::<State>::new().unwrap();
@ -41,6 +42,11 @@
//! // ..
//!
//! // implement the necessary traits
//! # impl SeatHandler for State {
//! # fn seat_state(&mut self) -> &mut SeatState<Self> { unimplemented!() }
//! # fn focus_changed(&mut self, seat: &Seat<Self>, focused: Option<&dyn KeyboardHandler<Self>>) { unimplemented!() }
//! # fn cursor_image(&mut self, seat: &Seat<Self>, image: CursorImageStatus) { unimplemented!() }
//! # }
//! impl PrimarySelectionHandler for State {
//! fn primary_selection_state(&self) -> &PrimarySelectionState { &self.primary_selection_state }
//! // ... override default implementations here to customize handling ...

View file

@ -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<Self> };
//! # let mut display = wayland_server::Display::<State>::new().unwrap();
//! # let display_handle = display.handle();
//! // create the seat
//! let seat = Seat::<State>::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::<State>::new();
//! let mut seat_state = SeatState::<State>::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<Self> {
//! &mut self.seat_state
//! }
//! fn focus_changed(&mut self, seat: &Seat<Self>, focused: Option<&dyn KeyboardHandler<Self>>) {
//! // ...
//! }
//! fn cursor_image(&mut self, seat: &Seat<Self>, image: CursorImageStatus) {
//! // ...
//! }
//! }
//! delegate_seat!(State);
//! ```
@ -159,10 +166,15 @@ impl<D: SeatHandler + 'static> Seat<D> {
/// # 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<Self> { unimplemented!() }
/// # fn focus_changed(&mut self, seat: &Seat<Self>, focused: Option<&dyn KeyboardHandler<Self>>) { unimplemented!() }
/// # fn cursor_image(&mut self, seat: &Seat<Self>, image: CursorImageStatus) { unimplemented!() }
/// # }
/// # let mut seat: Seat<State> = unimplemented!();
/// let touch_handle = seat.add_touch();
/// ```
pub fn add_touch(&mut self) -> TouchHandle {

View file

@ -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::<State>::new().unwrap();

View file

@ -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<Self> };
//! # let mut display = wayland_server::Display::<State>::new().unwrap();
//! # let display_handle = display.handle();
//!
//! let seat_state = SeatState::<State>::new();
//! let mut seat_state = SeatState::<State>::new();
//! let tablet_state = TabletManagerState::new::<State>(&display_handle);
//! // add the seat state to your state
//! // ...
//!
//! // create the seat
//! let seat = Seat::<State>::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<Self> {
//! &mut self.seat_state
//! }
//! fn focus_changed(&mut self, seat: &Seat<Self>, focused: Option<&dyn KeyboardHandler<Self>>) {
//! // ...
//! }
//! fn cursor_image(&mut self, seat: &Seat<Self>, image: CursorImageStatus) {
//! // ...
//! }
//! }
//! delegate_seat!(State);
//! delegate_tablet_manager!(State);