implement pen for X11
Issue: https://github.com/rust-windowing/winit/issues/99
- [ ] Tested on all platforms changed
- [ ] Added an entry to
CHANGELOG.mdif knowledge of this change could be valuable to users - [ ] Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
- [ ] Created or updated an example program if it would help users understand this functionality
- [ ] Updated feature matrix, if new features were added or implemented
I ported my previous pen work (https://github.com/rust-windowing/winit/pull/1879) over to the API from Android/Windows PR (https://github.com/rust-windowing/winit/pull/2396).
Though I have a couple of concerns with that API. I'm not sure if it is best to add the pen pressure on top of the normal touch event. I think an application developer would want to treat pens and touches quite differently. For example, you probably don't want a pinch-to-zoom gesture with one finger and the pen. Though I can also see that if the pen is the sole input, you would also treat it as a touch.
It also seems we break the "contract" of the touch phase, because we need to emit move emits between stop and start when the pen is hovering over the screen.
We could also simplify Touch event by putting pen_state into force. The unsupported values can just be set to a sensible default.
Note, the Apple Pencil 2 also supports hovering and has a button, so the additional PenState variable could probably be filled for that as well. Though I'm not an apple developer.
It is also not clear to me what the difference between SharedState and putting state into the EventProcessor struct directly. Specifically, where should I put the PenStatus struct?
I'm also not sure which button to map to barrel and eraser. My pen has two side buttons, I mapped the lower to the eraser. Maybe if someone's pen has an actual eraser, they could comment to which button X11 maps that.
Lastly, I would also like to have pen support on wayland, but right now seems an inopportune time to implement that since SCTK is currently being rewritten from scratch, so I don't want to spend much effort on adding pen support to the current version, which is used by winit. It also seems like a lot of work to port winit to the new version of SCTK since its API changes significantly.
pen data shouldn't be merged with touch imo as it will complicate the touch events much. pen tablets are different from mouses and touchscreens in many ways, and they deserve their own event types. also, events can be easily combined on the app side if developers want to treat pen events as touches
i did some experiments about basic wayland pen support before. it starts to work inside the client area, but the default window decor doesn't respond to pen events :( . seems like a sctk issue, not sure though
Any updates?
@Bloeckchengrafik I was not really happy with gluing everything onto the touch event, and I haven't really had the time to work on that since. I do plan on building an app with pen support, but I can't say if and when that will happen.
@kchibisov @madsmtm @daxpedda Do we have a plan-of-attack for pen events like this? I think that other platforms have concepts of this type of event as well.
Do we have a plan-of-attack for pen events like this?
Not yet, but we'd need to decide whether we emulate internally certain things or we just don't try to use tablet when it's not present.
Implementing pen events for Web would be simple, everything is already in place to add it.