emilk / egui

egui: an easy-to-use immediate mode GUI in Rust that runs on both web and native
https://www.egui.rs/
Apache License 2.0
21.91k stars 1.58k forks source link

Multi-touch with touchpads #2593

Open mattfbacon opened 1 year ago

mattfbacon commented 1 year ago

I noticed that egui has multi-touch support in the API via InputState::multi_touch. However I have not been able to produce any multi-touch events on my Linux laptop using libinput on sway.

I saw in the initial issue and PR that it is more focused toward touchscreens rather than touchpads. However, in applications that support zooming and panning, a true multi-touch experience on a touchpad is great for UX. As such, I am wondering if egui (or eframe, not sure where the support for this has to go) could add support for multi-touch on touchpads.

I would be willing to implement this if someone more familiar with the organization of the codebase could tell me where to start.

emilk commented 1 year ago

This would be great! I think you need to start implementing it in winit though if you want to have it in eframe

mattfbacon commented 1 year ago

I'm just confused about how it all comes together. I know that libinput is capable of recognizing multitouch touchpads. However I also know that applications shouldn't use libinput and should get their events from the Wayland compositor. But it doesn't seem like the compositor has a way to send these events to the client, so I don't know how apps like Eye of Gnome and Firefox get the events.

BTW thanks for adding the feature request label. I couldn't set it properly. It's not a bug, of course.

ShadowJonathan commented 1 year ago

This is also interesting for MacOS, where the "Magic" Trackpad, and the MacBook's builtin trackpad, sound to me they could be inputting these kinds of multi_touch events.

A lot of apple-native apps make use of it, so being able to use something like two-finger drags to drag something away, would be interesting to explore.

mattfbacon commented 1 year ago

I think it would be possible to link https://wayland.app/protocols/pointer-gestures-unstable-v1 to https://docs.rs/winit/latest/winit/event/enum.WindowEvent.html#variant.TouchpadMagnify etc. I'll look into it.

Does egui support these winit events? Seems not based on the Event enum.