Bug 140747 - [GTK] Support using long-tap gesture to open context menu
Summary: [GTK] Support using long-tap gesture to open context menu
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Adrian Perez
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-21 15:53 PST by Adrian Perez
Modified: 2018-01-26 06:52 PST (History)
5 users (show)

See Also:


Attachments
Patch adding long press gesture (5.70 KB, patch)
2018-01-25 04:03 PST, Jan-Michael Brummer
cgarcia: review+
cgarcia: commit-queue-
Details | Formatted Diff | Diff
Patch adding long press gesture - V2 (8.17 KB, patch)
2018-01-26 05:54 PST, Jan-Michael Brummer
cgarcia: review+
cgarcia: commit-queue-
Details | Formatted Diff | Diff
Patch adding long press gesture - V3 (8.17 KB, patch)
2018-01-26 06:26 PST, Jan-Michael Brummer
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adrian Perez 2015-01-21 15:53:47 PST
Use GestureController/GtkGesture to bind long-tap to the context
menu (Note: initial support for gesture was already committed as
of bug #137812).
Comment 1 Jan-Michael Brummer 2018-01-25 04:03:40 PST
Created attachment 332256 [details]
Patch adding long press gesture

Adding a patch to open context menu through long press gesture.

It simulates a secondary mouse button press to open the menu.
Comment 2 Adrian Perez 2018-01-25 05:45:19 PST
Comment on attachment 332256 [details]
Patch adding long press gesture

Thanks a lot for the patch! I have taken a quick look, and it
looks correct to me. Note that I am reviewing informally, so we
will still need the actual r+ from an actual reviewer. Carlos
García (in CC) is a has touched the gestures code before (IIRC),
so probably he can rubber-stamp the patch for landing :-)
Comment 3 Michael Catanzaro 2018-01-25 07:35:07 PST
Comment on attachment 332256 [details]
Patch adding long press gesture

View in context: https://bugs.webkit.org/attachment.cgi?id=332256&action=review

It looks good to me too, but seems good to give Carlos a chance to review it indeed.

> Source/WebKit/UIProcess/gtk/GestureController.h:125
> +        LongPressGesture(WebPageProxy&);

explicit LongPressGesture(WebPageProxy&);
Comment 4 Carlos Garcia Campos 2018-01-26 01:54:27 PST
Comment on attachment 332256 [details]
Patch adding long press gesture

View in context: https://bugs.webkit.org/attachment.cgi?id=332256&action=review

> Source/WebKit/UIProcess/gtk/GestureController.cpp:302
> +    GUniquePtr<GdkEvent> pointerEvent(gdk_event_new(GDK_MOTION_NOTIFY));
> +    pointerEvent->motion.time = event->touch.time;
> +    pointerEvent->motion.x = event->touch.x;
> +    pointerEvent->motion.y = event->touch.y;
> +    pointerEvent->motion.x_root = event->touch.x_root;
> +    pointerEvent->motion.y_root = event->touch.y_root;
> +    pointerEvent->motion.state = event->touch.state;
> +    m_page.handleMouseEvent(NativeWebMouseEvent(pointerEvent.get(), 0));
> +
> +    pointerEvent.reset(gdk_event_new(GDK_BUTTON_PRESS));
> +    pointerEvent->button.button = GDK_BUTTON_SECONDARY;
> +    pointerEvent->button.time = event->touch.time;
> +    pointerEvent->button.x = event->touch.x;
> +    pointerEvent->button.y = event->touch.y;
> +    pointerEvent->button.x_root = event->touch.x_root;
> +    pointerEvent->button.y_root = event->touch.y_root;
> +    m_page.handleMouseEvent(NativeWebMouseEvent(pointerEvent.get(), 1));
> +
> +    pointerEvent->type = GDK_BUTTON_RELEASE;
> +    m_page.handleMouseEvent(NativeWebMouseEvent(pointerEvent.get(), 0));

This code is duplicated in tap gesture. We could move it to a helper function that simply receives the button (primary or secondary).
Comment 5 Jan-Michael Brummer 2018-01-26 05:54:58 PST
Created attachment 332370 [details]
Patch adding long press gesture - V2

Refactor mouse simulation into helper function.
Comment 6 Michael Catanzaro 2018-01-26 05:58:32 PST
Comment on attachment 332370 [details]
Patch adding long press gesture - V2

View in context: https://bugs.webkit.org/attachment.cgi?id=332370&action=review

> Source/WebKit/ChangeLog:6
> +        Reviewed by NOBODY (OOPS!).

You'll need to set the r? and cq? Bugzilla flags
Comment 7 Carlos Garcia Campos 2018-01-26 06:13:15 PST
Comment on attachment 332370 [details]
Patch adding long press gesture - V2

View in context: https://bugs.webkit.org/attachment.cgi?id=332370&action=review

> Source/WebKit/UIProcess/gtk/GestureController.cpp:89
> +void GestureController::Gesture::simulateMousePress(const GdkEvent *event, int button_type)

I would call this Click instead of Press since this is Motion + Press + Release. 

const GdkEvent *event -> const GdkEvent* event
int button_type -> unsigned buttonType (or just button, but don't use underscore).
Comment 8 Jan-Michael Brummer 2018-01-26 06:26:35 PST
Created attachment 332372 [details]
Patch adding long press gesture - V3

Updated version based on latest review.
Comment 9 WebKit Commit Bot 2018-01-26 06:52:31 PST
Comment on attachment 332372 [details]
Patch adding long press gesture - V3

Clearing flags on attachment: 332372

Committed r227675: <https://trac.webkit.org/changeset/227675>
Comment 10 WebKit Commit Bot 2018-01-26 06:52:32 PST
All reviewed patches have been landed.  Closing bug.