mirror of
https://github.com/Smithay/smithay.git
synced 2024-09-28 03:21:14 +02:00
Add from_resource
to KeyboardHandle
/PointerHandle
/TouchHandle
Some checks are pending
Continuous Integration / format (push) Waiting to run
Continuous Integration / clippy-check (push) Waiting to run
Continuous Integration / check-msrv (push) Blocked by required conditions
Continuous Integration / check-minimal (push) Blocked by required conditions
Continuous Integration / smithay-check-features (push) Waiting to run
Continuous Integration / smithay-tests (push) Blocked by required conditions
Continuous Integration / smallvil-check (push) Blocked by required conditions
Continuous Integration / anvil-check-features (push) Blocked by required conditions
Continuous Integration / WLCS: ${{ matrix.job_name }} (buffer, BadBufferTest*, Bad Buffer Test) (push) Blocked by required conditions
Continuous Integration / WLCS: ${{ matrix.job_name }} (core, SelfTest*:FrameSubmission*, Core tests) (push) Blocked by required conditions
Continuous Integration / WLCS: ${{ matrix.job_name }} (output, XdgOutputV1Test*, Output tests) (push) Blocked by required conditions
Continuous Integration / WLCS: ${{ matrix.job_name }} (pointer-input, */SurfacePointerMotionTest*:RelativePointer*, Pointer input tests) (push) Blocked by required conditions
Continuous Integration / Documentation on Github Pages (push) Blocked by required conditions
Some checks are pending
Continuous Integration / format (push) Waiting to run
Continuous Integration / clippy-check (push) Waiting to run
Continuous Integration / check-msrv (push) Blocked by required conditions
Continuous Integration / check-minimal (push) Blocked by required conditions
Continuous Integration / smithay-check-features (push) Waiting to run
Continuous Integration / smithay-tests (push) Blocked by required conditions
Continuous Integration / smallvil-check (push) Blocked by required conditions
Continuous Integration / anvil-check-features (push) Blocked by required conditions
Continuous Integration / WLCS: ${{ matrix.job_name }} (buffer, BadBufferTest*, Bad Buffer Test) (push) Blocked by required conditions
Continuous Integration / WLCS: ${{ matrix.job_name }} (core, SelfTest*:FrameSubmission*, Core tests) (push) Blocked by required conditions
Continuous Integration / WLCS: ${{ matrix.job_name }} (output, XdgOutputV1Test*, Output tests) (push) Blocked by required conditions
Continuous Integration / WLCS: ${{ matrix.job_name }} (pointer-input, */SurfacePointerMotionTest*:RelativePointer*, Pointer input tests) (push) Blocked by required conditions
Continuous Integration / Documentation on Github Pages (push) Blocked by required conditions
It seems most protocols take a `wl_seat` as an argument rather than a capability type, but it seems reasonable for Smithay to expose this in some way to compositors still.
This commit is contained in:
parent
aa5ea75a24
commit
605b34ef53
3 changed files with 31 additions and 1 deletions
|
@ -21,7 +21,7 @@ use crate::{
|
|||
wayland::{input_method::InputMethodSeat, text_input::TextInputSeat},
|
||||
};
|
||||
|
||||
impl<D: SeatHandler + 'static> KeyboardHandle<D>
|
||||
impl<D> KeyboardHandle<D>
|
||||
where
|
||||
D: SeatHandler + 'static,
|
||||
<D as SeatHandler>::KeyboardFocus: WaylandFocus,
|
||||
|
@ -82,6 +82,16 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<D: SeatHandler + 'static> KeyboardHandle<D> {
|
||||
/// Attempt to retrieve a [`KeyboardHandle`] from an existing resource
|
||||
///
|
||||
/// May return `None` for a valid `WlKeyboard` that was created without
|
||||
/// the keyboard capability.
|
||||
pub fn from_resource(seat: &WlKeyboard) -> Option<Self> {
|
||||
seat.data::<KeyboardUserData<D>>()?.handle.clone()
|
||||
}
|
||||
}
|
||||
|
||||
/// User data for keyboard
|
||||
pub struct KeyboardUserData<D: SeatHandler> {
|
||||
pub(crate) handle: Option<KeyboardHandle<D>>,
|
||||
|
|
|
@ -39,6 +39,16 @@ struct V120UserData {
|
|||
/// WlSurface role of a cursor image icon
|
||||
pub const CURSOR_IMAGE_ROLE: &str = "cursor_image";
|
||||
|
||||
impl<D: SeatHandler + 'static> PointerHandle<D> {
|
||||
/// Attempt to retrieve a [`PointerHandle`] from an existing resource
|
||||
///
|
||||
/// May return `None` for a valid `WlPointer` that was created without
|
||||
/// the keyboard capability.
|
||||
pub fn from_resource(seat: &WlPointer) -> Option<Self> {
|
||||
seat.data::<PointerUserData<D>>()?.handle.clone()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub(crate) struct WlPointerHandle {
|
||||
pub(crate) last_enter: Mutex<Option<Serial>>,
|
||||
|
|
|
@ -22,6 +22,16 @@ impl<D: SeatHandler> TouchHandle<D> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<D: SeatHandler + 'static> TouchHandle<D> {
|
||||
/// Attempt to retrieve a [`TouchHandle`] from an existing resource
|
||||
///
|
||||
/// May return `None` for a valid `WlTouch` that was created without
|
||||
/// the keyboard capability.
|
||||
pub fn from_resource(seat: &WlTouch) -> Option<Self> {
|
||||
seat.data::<TouchUserData<D>>()?.handle.clone()
|
||||
}
|
||||
}
|
||||
|
||||
fn for_each_focused_touch<D: SeatHandler + 'static>(
|
||||
seat: &Seat<D>,
|
||||
surface: &WlSurface,
|
||||
|
|
Loading…
Reference in a new issue