Skip to content
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

Initial wl_touch support #217

Merged
merged 2 commits into from
Dec 28, 2023
Merged

Initial wl_touch support #217

merged 2 commits into from
Dec 28, 2023

Conversation

ids1024
Copy link
Member

@ids1024 ids1024 commented Nov 7, 2023

A very rough implementation, that is sufficient to get a touchscreen device working.

I'm not sure how we should detect which output is associated with a touchscreen device.

The Smithay APIs for touch events could probably be improved a bit.

Copy link
Member

@Drakulix Drakulix left a comment

Choose a reason for hiding this comment

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

The Smithay APIs for touch events could probably be improved a bit.

Really? 🤣 /s

While this is a good starting point, there is no good way to implement touch grabs right now. So this is really not usable for tablet-like devices, just kinda usable for laptops with touchscreens, I guess.

So I am not sure, if we want to merge this in the meantime or first rework the smithay api to be more like the Pointer and Keyboard apis.

src/input/mod.rs Outdated
if let Some((target, pos)) = under {
if let Some(wl_surface) = target.wl_surface() {
let serial = SERIAL_COUNTER.next_serial();
let mut touch = seat.get_touch().unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

We should check here, if the client has actually bound wl_touch and do pointer emulation otherwise.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do any other compositors emulate wl_pointer for touch events like that? Or is it generally assumed clients are responsible for that? That should be safe to do though, for any clients that don't.

Copy link
Member

Choose a reason for hiding this comment

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

Honestly I am not sure. I never looked into this a lot, but at least Xwayland will never bind wl_touch, so we need to do emulation for some clients anyway or there is no way to interact with them.

Copy link
Member Author

Choose a reason for hiding this comment

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

I haven't tested it, but https://gitlab.freedesktop.org/xorg/xserver/-/blob/master/hw/xwayland/xwayland-input.c does call wl_seat_get_touch and have other wl_touch related code.

So I'm not sure how touch works in X11, but checking if the client binds wl_touch shouldn't change anything.

Copy link
Member

Choose a reason for hiding this comment

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

Oh interesting! That is new to me, but pretty cool.

Copy link
Member Author

Choose a reason for hiding this comment

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

Presumably it needs wl_touch to generate the multi-touch events specified in Xinput 2.2: https://gitlab.freedesktop.org/xorg/proto/xorgproto/-/blob/master/specs/XI2proto.txt.

That protocol also has a section titled "Pointer emulation from multitouch events". Presumably that's handled in XWayland and doesn't require anything from us.

src/input/mod.rs Outdated Show resolved Hide resolved
@ids1024
Copy link
Member Author

ids1024 commented Nov 8, 2023

While this is a good starting point, there is no good way to implement touch grabs right now. So this is really not usable for tablet-like devices, just kinda usable for laptops with touchscreens, I guess.

So I am not sure, if we want to merge this in the meantime or first rework the smithay api to be more like the Pointer and Keyboard apis.

Yeah, as is this works well enough on a laptop with a touch screen (maybe with some issues in edge cases) but wouldn't actually be usable on a tablet unless SSDs and other in-compositor UI handles touch events, an on screen keyboard is added, etc.

It may be reasonable to merge this once the major hacks here (using seat.active_output()) are fixed, but we will need to update Smithay's APIs.

`builtin_output` is similar to `get_builtin_output_name` in Sway.

For full support, we need support for touch targets/grabs, touch support
for SSDs, and a way to configure what output is mapped to what input.

But this is usable for apps that support touch on a laptop with a
touchscreen.
@ids1024 ids1024 changed the title WIP wl_touch support Initial wl_touch support Dec 21, 2023
@ids1024 ids1024 marked this pull request as ready for review December 21, 2023 20:50
@ids1024
Copy link
Member Author

ids1024 commented Dec 21, 2023

I've added a check for the "builtin monitor" similar to the default used in Sway.

This seems to be working fine with external monitors and fractional scaling. So I think it's good enough for initial touch support.

Copy link
Member

@Drakulix Drakulix left a comment

Choose a reason for hiding this comment

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

I kinda hate merging this would proper support for grabs an what not.. but I guess having it in this state is better than not having it.

src/input/mod.rs Show resolved Hide resolved
@Drakulix
Copy link
Member

Drakulix commented Dec 22, 2023

I wonder if we could make the mapped display a property of our input-config at least? So that users could override it and we just take the builtin display as a default?

@ids1024
Copy link
Member Author

ids1024 commented Dec 28, 2023

added a map_to_output option, like Sway has.

@Drakulix Drakulix merged commit 45946fc into master_jammy Dec 28, 2023
4 checks passed
@ids1024 ids1024 deleted the wl-touch_jammy branch January 5, 2024 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants