qskinny icon indicating copy to clipboard operation
qskinny copied to clipboard

2 finger gesture handlers (e.g. pinch)

Open peter-ha opened this issue 1 year ago • 0 comments

For reference, here are my findings from other projects:

Chromium pinch:

https://source.chromium.org/chromium/chromium/src/+/main:ui/events/gesture_detection/gesture_provider.cc;bpv=1;bpt=1

  • normal gesture detectors are handled in class GestureDetector, e.g. short press, long press, double tap etc.
  • other gestures like swipe and pinch are handled directly in GestureDetector::OnTouchEvent():
    E.g. in there they check whether it is a swipe and/or a double tap, or a two finger tap etc. It seems gesture recognizers are not added to controls on demand.
  • Strangely, there is the above class GestureDetector, and for Pinch there is another unrelated class ScaleGestureDetector. So an incoming touch event is fed into the GestureDetector class and also simultaneaously into the ScaleGestureDetector class (see GestureProvider::GestureListenerImpl::OnTouchEvent()). In general it seems Chromium doesn't consider differentiating between pinch and e.g. two finger swipe very important.
  • there is also a "two finger tap" gesture; I didn't investigate what it is used for

libevent pinch (used by e.g. Wayland):

https://gitlab.freedesktop.org/libinput/libinput/-/blob/main/src/evdev-mt-touchpad-gestures.c#L1025

  • Doesn't seem very sophisticated regarding differentiating from other two finger gestures; e.g. it checks that fingers are not moving in the same directions (like a two finger swipe/pan would do), and makes sure both fingers are moved beyond a certain threshold.
  • Maybe in the future also used by Qt for eglfs through native gestures (like Qt does for Mac already): https://bugreports.qt.io/browse/QTBUG-92098

peter-ha avatar Dec 06 '23 15:12 peter-ha