-
Notifications
You must be signed in to change notification settings - Fork 90
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
chris-morgan
wants to merge
27
commits into
Smithay:master
Choose a base branch
from
chris-morgan:tablet
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Support tablet-v2 #489
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
cc89205
Support most of tablet-v2
chris-morgan 8b7e66c
[WIP] Expand the tablet example for pseudo-drawing
chris-morgan 0f46927
One approach to collecting tablet metadata
chris-morgan 3726fe1
Tablet info events: new approach, always collect
chris-morgan 46935e5
Naming: “description”
chris-morgan 23a61b9
Restructure code somewhat
chris-morgan bbe0c36
Try a more radical module and naming structure
chris-morgan c078af0
Fiddle with tablet_tool::InitEvent naming
chris-morgan bb8f021
Accumulate description for tablet tool handlers
chris-morgan bef0765
Use bitflags for tool capabilities
chris-morgan 0a182c1
Quite a bit of poorly-separated work
chris-morgan 00824ba
Remove dead code
chris-morgan 399941c
Revise some tablet naming
chris-morgan e23dea0
Update some docs, remove obsolete bits
chris-morgan 908437f
Refine how Tools is exposed
chris-morgan e2048b2
Make tablet seat handler methods optional
chris-morgan f7e34e0
(Advice sought) Remove seat from tablet seat handler methods
chris-morgan 93afc63
Document that no other axis methods are warranted
chris-morgan ac0b3de
Remove more dead code
chris-morgan 36aaf47
More shuffling tool stuff around, for the better
chris-morgan 107f662
Add cursors to the tablet tool example
chris-morgan 0e92ecd
Make TabletManager largely implicit, via SeatState
chris-morgan 34a9a20
Refactor manager globals, expose cursor shape manager
chris-morgan 522845e
Tidy up example a bit, improve logging
chris-morgan 20875b3
Support cursor shapes on tablet tools, a bit
chris-morgan 155147b
Refactor SeatState::new for subjective prettiness
chris-morgan 6ea3530
Make {tablet, tablet_tool}::Info non-exhaustive
chris-morgan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| use std::mem; | ||
| use std::sync::Mutex; | ||
|
|
||
| use wayland_client::{ | ||
| Connection, | ||
| Dispatch, | ||
| QueueHandle, | ||
| }; | ||
| use wayland_protocols::wp::tablet::zv2::client::zwp_tablet_v2::{self, ZwpTabletV2}; | ||
|
|
||
| pub trait Handler: Sized { | ||
| /// This is fired at the time of the `zwp_tablet_v2.done` event, | ||
| /// and collects any preceding `name`, `id` and `path` events into an [`Info`]. | ||
| fn info( | ||
| &mut self, | ||
| conn: &Connection, | ||
| qh: &QueueHandle<Self>, | ||
| tablet: &ZwpTabletV2, | ||
| info: Info, | ||
| ); | ||
|
|
||
| /// Sent when the tablet has been removed from the system. | ||
| /// When a tablet is removed, some tools may be removed. | ||
| /// | ||
| /// This method is responsible for running `tablet.destroy()`. ← TODO: true or not? | ||
| fn removed( | ||
| &mut self, | ||
| conn: &Connection, | ||
| qh: &QueueHandle<Self>, | ||
| tablet: &ZwpTabletV2, | ||
| ); | ||
| } | ||
|
|
||
| /// The description of a tablet device. | ||
| #[derive(Debug, Default)] | ||
| #[non_exhaustive] | ||
| pub struct Info { | ||
| /// The descriptive name of the tablet device. | ||
| pub name: Option<String>, | ||
| /// The USB vendor and product IDs for the tablet device. | ||
| pub id: Option<(u32, u32)>, | ||
| /// System-specific device paths for the tablet. | ||
| /// | ||
| /// Path format is unspecified. | ||
| /// Clients must figure out what to do with them, if they care. | ||
| pub paths: Vec<String>, | ||
| } | ||
|
|
||
| #[doc(hidden)] | ||
| #[derive(Debug)] | ||
| pub struct Data { | ||
| info: Mutex<Info>, | ||
| } | ||
|
|
||
| impl Data { | ||
| pub fn new() -> Self { | ||
| Self { info: Default::default() } | ||
| } | ||
| } | ||
|
|
||
| impl<D> Dispatch<ZwpTabletV2, Data, D> | ||
| for super::TabletManager | ||
| where | ||
| D: Dispatch<ZwpTabletV2, Data> + Handler, | ||
| { | ||
| fn event( | ||
| data: &mut D, | ||
| tablet: &ZwpTabletV2, | ||
| event: zwp_tablet_v2::Event, | ||
| udata: &Data, | ||
| conn: &Connection, | ||
| qh: &QueueHandle<D>, | ||
| ) { | ||
| let mut guard = udata.info.lock().unwrap(); | ||
| match event { | ||
| zwp_tablet_v2::Event::Name { name } => guard.name = Some(name), | ||
| zwp_tablet_v2::Event::Id { vid, pid } => guard.id = Some((vid, pid)), | ||
| zwp_tablet_v2::Event::Path { path } => guard.paths.push(path), | ||
| zwp_tablet_v2::Event::Done => { | ||
| let info = mem::take(&mut *guard); | ||
| drop(guard); | ||
| data.info(conn, qh, tablet, info); | ||
| }, | ||
| zwp_tablet_v2::Event::Removed => { | ||
| data.removed(conn, qh, tablet); | ||
| }, | ||
| _ => unreachable!(), | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be a good time to destroy the object, but I suppose it isn't strictly responsible for it.