Skip to content

list-base: Move long press gesture to child view

Gary Li requested to merge li-gary/nautilus:fix-long-press-touch into main

When the user tries to select by touch dragging in a rubberband, GtkListBase's drag gesture is triggered. However, after the delay timeout of the long press has passed, the long press gesture is also triggered and cancels the user's selection.

This is because both long press and drag gesture event controllers are set in the bubble phase. The drag threshold is used by both long press and drag. When this threshold is exceeded, the drag gesture will claim the sequence and no further updates will be sent to the long press gesture. This leads to the long press timeout being triggered even though it is cancelled later.

Move the long press gesture to the same widget that has the drag gesture. To do so, create a new method in NautilusListBase for gestures that should be attached to the child and not directly to the list base.

I monkey-patched GTK to revert the dropped GTK_DEBUG_TOUCHSCREEN flag in the inspector as I don't have access to a touch-enabled Linux device. Also patched some debug logs to the long-press and drag gestures to help me understand what was going on for a rubberband selection:

bad:
begin longpress timeout
gesture drag begin
long press: denied, ending
gesture drag begin
begin longpress timeout
long_press update: 668.99 473.54
long_press update: 665.89 469.41
CLAIMED SEQUENCE
long_press_timeout triggered!
long press cancelled!
long press cancelled!



fixed:
begin longpress timeout
gesture drag begin
long press: denied, ending
begin longpress timeout
gesture drag begin
long_press update: 651.04 458.07
long_press update: 649.17 457.14
long_press update: 646.14 455.12
long_press update: 642.84 451.82
long press exceeded threshold, removing
CLAIMED SEQUENCE
long press: denied, ending

This is my first foray working with GTK gestures and event controllers, so feedback is very welcome! Working demo using GTK_DEBUG_TOUCHSCREEN on a desktop:

successful_drag_selection

successful_scrolling

Fixes #2872 Fixes #3388

Merge request reports