pub struct Seat { /* private fields */ }
Expand description
A Seat handle
This struct gives you access to the control of the capabilities of the associated seat.
It is directly inserted in the event loop by its new
method.
This is an handle to the inner logic, it can be cloned and shared accross threads.
See module-level documentation for details of use.
Implementations§
source§impl Seat
impl Seat
sourcepub fn new<U, R, L>(
display: &mut Display,
name: String,
token: CompositorToken<U, R>,
logger: L
) -> (Seat, Global<WlSeat>)where
U: 'static,
R: Role<CursorImageRole> + 'static,
L: Into<Option<Logger>>,
pub fn new<U, R, L>(
display: &mut Display,
name: String,
token: CompositorToken<U, R>,
logger: L
) -> (Seat, Global<WlSeat>)where
U: 'static,
R: Role<CursorImageRole> + 'static,
L: Into<Option<Logger>>,
Create a new seat global
A new seat global is created with given name and inserted into this event loop.
You are provided with the state token to retrieve it (allowing you to add or remove capabilities from it), and the global handle, in case you want to remove it.
sourcepub fn from_resource(seat: &Resource<WlSeat>) -> Option<Seat>
pub fn from_resource(seat: &Resource<WlSeat>) -> Option<Seat>
Attempt to retrieve a Seat
from an existing resource
sourcepub fn user_data(&self) -> &UserDataMap
pub fn user_data(&self) -> &UserDataMap
Acces the UserDataMap
associated with this Seat
sourcepub fn add_pointer<U, R, F>(
&mut self,
token: CompositorToken<U, R>,
cb: F
) -> PointerHandlewhere
U: 'static,
R: Role<CursorImageRole> + 'static,
F: FnMut(CursorImageStatus) + Send + 'static,
pub fn add_pointer<U, R, F>(
&mut self,
token: CompositorToken<U, R>,
cb: F
) -> PointerHandlewhere
U: 'static,
R: Role<CursorImageRole> + 'static,
F: FnMut(CursorImageStatus) + Send + 'static,
Adds the pointer capability to this seat
You are provided a PointerHandle
, which allows you to send input events
to this pointer. This handle can be cloned and sent across threads.
Calling this method on a seat that already has a pointer capability will overwrite it, and will be seen by the clients as if the mouse was unplugged and a new one was plugged.
You need to provide a compositor token, as well as a callback that will be notified whenever a client requests to set a custom cursor image.
Examples
let pointer_handle = seat.add_pointer(
compositor_token.clone(),
|new_status| { /* a closure handling requests from clients tot change the cursor icon */ }
);
sourcepub fn get_pointer(&self) -> Option<PointerHandle>
pub fn get_pointer(&self) -> Option<PointerHandle>
Access the pointer of this seat if any
sourcepub fn remove_pointer(&mut self)
pub fn remove_pointer(&mut self)
Remove the pointer capability from this seat
Clients will be appropriately notified.
sourcepub fn add_keyboard<F>(
&mut self,
xkb_config: XkbConfig<'_>,
repeat_delay: i32,
repeat_rate: i32,
focus_hook: F
) -> Result<KeyboardHandle, KeyboardError>where
F: FnMut(&Seat, Option<&Resource<WlSurface>>) + 'static,
pub fn add_keyboard<F>(
&mut self,
xkb_config: XkbConfig<'_>,
repeat_delay: i32,
repeat_rate: i32,
focus_hook: F
) -> Result<KeyboardHandle, KeyboardError>where
F: FnMut(&Seat, Option<&Resource<WlSurface>>) + 'static,
Adds the keyboard capability to this seat
You are provided a KeyboardHandle
, which allows you to send input events
to this keyboard. This handle can be cloned and sent across threads.
You also provide a Model/Layout/Variant/Options specification of the keymap to be used for this keyboard, as well as any repeat-info that will be forwarded to the clients.
Calling this method on a seat that already has a keyboard capability will overwrite it, and will be seen by the clients as if the keyboard was unplugged and a new one was plugged.
Examples
let keyboard = seat
.add_keyboard(
XkbConfig {
layout: "de",
variant: "nodeadkeys",
..XkbConfig::default()
},
1000,
500,
|seat, focus| {
/* This closure is called whenever the keyboard focus
* changes, with the new focus as argument */
}
)
.expect("Failed to initialize the keyboard");
sourcepub fn get_keyboard(&self) -> Option<KeyboardHandle>
pub fn get_keyboard(&self) -> Option<KeyboardHandle>
Access the keyboard of this seat if any
sourcepub fn remove_keyboard(&mut self)
pub fn remove_keyboard(&mut self)
Remove the keyboard capability from this seat
Clients will be appropriately notified.