rust-windowing / winit

Window handling library in pure Rust
https://docs.rs/winit/
Apache License 2.0
4.73k stars 888 forks source link

wayland: don't bind to touch events if they are not used #1555

Open David96 opened 4 years ago

David96 commented 4 years ago

As I understand, this library currently doesn't support touch on wayland but it seems to setup listeners for it anyway. This causes compositors to not be able to determine whether they should emulate mouse events for applications using this library (tested with alacritty).

kchibisov commented 4 years ago

It implements touch only if it was advertise by your compositor. https://github.com/rust-windowing/winit/blob/26775fa0b621c225753cefb2a3babead3be33f46/src/platform_impl/linux/wayland/event_loop.rs#L926

And, it supports touch as you can see.

David96 commented 4 years ago

Yes it implements touch, but it doesn't necessarily use it. I'm currently working on https://github.com/swaywm/sway/pull/5229 and if an application sets up touch listeners without actually using them there's no way to fall back to pointer emulation.

The wayland metaissue states it wouldn't support touch that's why I thought it wouldn't at all use those listeners, I was wrong there then. Still, this issue remains.

emersion commented 4 years ago

Some winit users (e.g. Alacritty) don't support touch, they ignore touch events. In this case the compositor can't fallback to pointer event simulation, because winit binds to wl_touch (meaning it accepts touch events).

So it would be nice to have a way for winit users to say "I don't support touch". In this case winit could either not bind to wl_touch or either implement pointer event simulation itself.

kchibisov commented 4 years ago

Hm, I see, I'm not sure what stops alacritty from using touch events here though. It sounds like a reasonable flag to add into winit on the other side.

David96 commented 4 years ago

I don't think anything stops alacritty from using them. But as long as it doesn't, it would be nice to know on the compositor side, so the compositor can emulate pointer events ;)

emersion commented 4 years ago

Yeah. While it shouldn't be too hard for Alacritty to implement touch support, I think other winit users will still be missing touch handlers, so it'd be nice to fix them too. Additionally the same idea could be re-used for tablet input devices when winit adds support for those.