[webkit-gtk] Opening default context menu on mouse release

Peter Hofmann webkitlists at uninformativ.de
Sun May 21 03:08:18 PDT 2017


On Wed, May 17, 2017 at 09:03:58AM +0200, Carlos Garcia Campos wrote:
> Yes, it does. You can connect to context-menu signal, take a reference
> of the given WebKitContextMenu, and return TRUE to ensure WebKit
> doesn't show it. Then you can start your timer and then check threshold
> (you could use the gtk dnd threshold, for example, with
> gtk_drag_check_threshold). If not a gesture you can use the
> WebKitContextMenu to build a gtk popup menu.

that sounds promising.

How would you show a WebKitContextMenu? I couldn't find a function in
webkit2gtk's API to directly pop up that menu. I guess I'd have to
inspect the WebKitContextMenu and build a new Gtk menu on my own.

Here's a naive attempt (no fiddling with timers, though):


It appears to work -- kind of. The correct menu show up (if it's not a
gesture), but selecting a menu item has no effect. I'm probably missing
some signal handlers here.

In any case, I don't think I'd want to implement this in my actual
browser. Converting a WebKitContextMenu into a Gtk menu basically means
reimplementing a part of webkit2gtk: There already has to be some piece
of code in webkit2gtk that performs this menu conversion, it's just not
exposed as an API call.

I'll have a look at Andres Gomez' idea about using native Gtk gestures
next[0]. (I indeed did not know they exist.)

By the way, if my problem can't be solved, then it's not a big deal. :)
It would have been nice to re-use WebKit's original context menu, but
there's always the option to ignore that menu and use my very own. (I
think that's what the mouse gestures addon in Midori does.)

Thanks again!

[0]: https://lists.webkit.org/pipermail/webkit-gtk/2017-May/003053.html

More information about the webkit-gtk mailing list