Skip to content

Support tablet-v2 #489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 27 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
94a60f8
Support most of tablet-v2
chris-morgan Mar 16, 2025
eb83d74
[WIP] Expand the tablet example for pseudo-drawing
chris-morgan Mar 18, 2025
5d11d0b
One approach to collecting tablet metadata
chris-morgan Mar 19, 2025
8ae623e
Tablet info events: new approach, always collect
chris-morgan Mar 19, 2025
0c8f542
Naming: “description”
chris-morgan Mar 19, 2025
1ced013
Restructure code somewhat
chris-morgan Mar 19, 2025
61e0e44
Try a more radical module and naming structure
chris-morgan Mar 19, 2025
d6741e1
Fiddle with tablet_tool::InitEvent naming
chris-morgan Mar 19, 2025
a649d55
Accumulate description for tablet tool handlers
chris-morgan Mar 19, 2025
29b63c4
Use bitflags for tool capabilities
chris-morgan Mar 19, 2025
efdd0b4
Quite a bit of poorly-separated work
chris-morgan Mar 26, 2025
0004673
Remove dead code
chris-morgan Mar 26, 2025
666c52c
Revise some tablet naming
chris-morgan Mar 26, 2025
b7cb645
Update some docs, remove obsolete bits
chris-morgan Mar 26, 2025
568a552
Refine how Tools is exposed
chris-morgan Mar 26, 2025
98f3aad
Make tablet seat handler methods optional
chris-morgan Mar 26, 2025
2b8df7d
(Advice sought) Remove seat from tablet seat handler methods
chris-morgan Mar 26, 2025
387d718
Document that no other axis methods are warranted
chris-morgan Mar 28, 2025
5cd8a95
Remove more dead code
chris-morgan Mar 29, 2025
53eabb9
More shuffling tool stuff around, for the better
chris-morgan Mar 29, 2025
b19c603
Add cursors to the tablet tool example
chris-morgan Mar 29, 2025
ae0667f
Make TabletManager largely implicit, via SeatState
chris-morgan Mar 29, 2025
d13e2ec
Refactor manager globals, expose cursor shape manager
chris-morgan Mar 29, 2025
9e4c056
Tidy up example a bit, improve logging
chris-morgan Mar 29, 2025
c9fe2f6
Support cursor shapes on tablet tools, a bit
chris-morgan Mar 29, 2025
7d7f20d
Refactor SeatState::new for subjective prettiness
chris-morgan Mar 29, 2025
5dd2be3
Make {tablet, tablet_tool}::Info non-exhaustive
chris-morgan Mar 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/seat/tablet_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ impl TabletManager {
qh: &QueueHandle<D>,
) -> Result<ZwpTabletSeatV2, GlobalError>
where
D: Dispatch<ZwpTabletSeatV2, super::tablet_seat::Data> + 'static,
D: Dispatch<ZwpTabletSeatV2, ()> + 'static,
{
let udata = super::tablet_seat::Data { wl_seat: seat.clone() };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine in my opinion. As you say, it is possible for the user to map tablet set to seat.

Ok(self.tablet_manager.get()?.get_tablet_seat(seat, qh, udata))
Ok(self.tablet_manager.get()?.get_tablet_seat(seat, qh, ()))
}
}

Expand Down Expand Up @@ -66,7 +65,7 @@ macro_rules! delegate_tablet {
$crate::reexports::protocols::wp::tablet::zv2::client::zwp_tablet_manager_v2::ZwpTabletManagerV2: $crate::globals::GlobalData
] => $crate::seat::TabletManager);
$crate::reexports::client::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
$crate::reexports::protocols::wp::tablet::zv2::client::zwp_tablet_seat_v2::ZwpTabletSeatV2: $crate::seat::tablet_seat::Data
$crate::reexports::protocols::wp::tablet::zv2::client::zwp_tablet_seat_v2::ZwpTabletSeatV2: ()
] => $crate::seat::TabletManager);
$crate::reexports::client::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
$crate::reexports::protocols::wp::tablet::zv2::client::zwp_tablet_v2::ZwpTabletV2: $crate::seat::tablet::Data
Expand Down
22 changes: 6 additions & 16 deletions src/seat/tablet_seat.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use wayland_client::{
event_created_child,
protocol::wl_seat::WlSeat,
Connection,
Dispatch,
QueueHandle,
Expand Down Expand Up @@ -30,7 +29,6 @@ pub trait Handler: Sized {
conn: &Connection,
qh: &QueueHandle<Self>,
tablet_seat: &ZwpTabletSeatV2,
seat: &WlSeat,
id: ZwpTabletV2,
) {}

Expand All @@ -42,7 +40,6 @@ pub trait Handler: Sized {
conn: &Connection,
qh: &QueueHandle<Self>,
tablet_seat: &ZwpTabletSeatV2,
seat: &WlSeat,
id: ZwpTabletToolV2,
) {}

Expand All @@ -54,21 +51,14 @@ pub trait Handler: Sized {
conn: &Connection,
qh: &QueueHandle<Self>,
tablet_seat: &ZwpTabletSeatV2,
seat: &WlSeat,
id: ZwpTabletPadV2,
) {}
}

#[doc(hidden)]
#[derive(Debug)]
pub struct Data {
pub(crate) wl_seat: WlSeat,
}

impl<D> Dispatch<ZwpTabletSeatV2, Data, D>
impl<D> Dispatch<ZwpTabletSeatV2, (), D>
for super::TabletManager
where
D: Dispatch<ZwpTabletSeatV2, Data>
D: Dispatch<ZwpTabletSeatV2, ()>
+ Dispatch<ZwpTabletV2, super::tablet::Data>
+ Dispatch<ZwpTabletToolV2, super::tablet_tool::Data>
+ Dispatch<ZwpTabletPadV2, super::tablet_pad::Data>
Expand All @@ -85,19 +75,19 @@ where
data: &mut D,
tablet_seat: &ZwpTabletSeatV2,
event: zwp_tablet_seat_v2::Event,
udata: &Data,
_udata: &(),
conn: &Connection,
qh: &QueueHandle<D>,
) {
match event {
zwp_tablet_seat_v2::Event::TabletAdded { id } => {
data.tablet_added(conn, qh, tablet_seat, &udata.wl_seat, id);
data.tablet_added(conn, qh, tablet_seat, id);
},
zwp_tablet_seat_v2::Event::ToolAdded { id } => {
data.tool_added(conn, qh, tablet_seat, &udata.wl_seat, id);
data.tool_added(conn, qh, tablet_seat, id);
},
zwp_tablet_seat_v2::Event::PadAdded { id } => {
data.pad_added(conn, qh, tablet_seat, &udata.wl_seat, id);
data.pad_added(conn, qh, tablet_seat, id);
},
_ => unreachable!(),
}
Expand Down