Bug 64459 - [GTK] WebKitWebView should obey gtk-dnd-drag-threshold setting
Summary: [GTK] WebKitWebView should obey gtk-dnd-drag-threshold setting
Status: UNCONFIRMED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-13 09:52 PDT by arno.
Modified: 2017-03-11 11:01 PST (History)
3 users (show)

See Also:


Attachments
patch (4.13 KB, patch)
2011-07-13 15:13 PDT, arno.
mrobinson: review-
Details | Formatted Diff | Diff
Patch rebased against current git (3.75 KB, patch)
2012-08-17 03:43 PDT, Sven Schwedas
no flags Details | Formatted Diff | Diff
Compilation errors fixed (3.88 KB, patch)
2012-08-17 05:39 PDT, Sven Schwedas
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description arno. 2011-07-13 09:52:00 PDT
Hi,
gtk defines a gtk-dnd-drag-threshold property, and many gtk widgets use it to prevent drag from starting when user moves mouse with a really small movement. This is really important for accessibility (think, ill or old people whose hands shake a lot).
I would be nice if WebKitWebView would not start a drag if gtk_drag_check_threshold returns false.

I've investigated a bit, and discovered Gtk Widget usually make that check in in motion_notify_event callback, and do not call gtk_drag_begin if it's false. But making this check in webkit_web_view_motion_event would prevent all mouse move events, not only drags.

Then, I don't known how to handle that.
Comment 1 Martin Robinson 2011-07-13 10:21:39 PDT
(In reply to comment #0)
> Hi,
> gtk defines a gtk-dnd-drag-threshold property, and many gtk widgets use it to prevent drag from starting when user moves mouse with a really small movement. This is really important for accessibility (think, ill or old people whose hands shake a lot).
> I would be nice if WebKitWebView would not start a drag if gtk_drag_check_threshold returns false.


The drag hysteresis is controlled via constants in EventHandler.cpp. In GTK+ we could potentially make them depend on GTK+ settings. Another option would be to make drag-and-drop a runtime setting, versus simply compile time. Do you mind explaining your usecase?
Comment 2 arno. 2011-07-13 15:13:25 PDT
Created attachment 100718 [details]
patch

(In reply to comment #1)
> (In reply to comment #0)
> > Hi,
> > gtk defines a gtk-dnd-drag-threshold property, and many gtk widgets use it to prevent drag from starting when user moves mouse with a really small movement. This is really important for accessibility (think, ill or old people whose hands shake a lot).
> > I would be nice if WebKitWebView would not start a drag if gtk_drag_check_threshold returns false.
> 
> 
> The drag hysteresis is controlled via constants in EventHandler.cpp. In GTK+ we could potentially make them depend on GTK+ settings. Another option would be to make drag-and-drop a runtime setting, versus simply compile time. Do you mind explaining your usecase?

My current usecase is building a minimal browser. Right click and drag must be disabled. As far as I known, right click can be disabled on the system, but drag cannot. Using has also some advantages: it would be possible to put a high threshold, a make a browser more appropriated for people with some disabilities. Then it's more coherent with other gkt widgets.

I attach a patch wich checks gtk-dnd-drag-threshold property, and makes uses it if it's bigger than *DragHysteresis constants. To get the GtkWidget, I used the logic from widgetFromFrame (PasteboardHelper.cpp). I wonder if there is some util file where that function could go.
Comment 3 Carlos Garcia Campos 2011-09-07 23:57:48 PDT
Comment on attachment 100718 [details]
patch

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

> Source/WebCore/page/gtk/EventHandlerGtk.cpp:144
> +    Page* page = m_frame->page();
> +    if (page) {
> +        Chrome* chrome = page->chrome();
> +        if (chrome) {
> +            GtkWidget* client = GTK_WIDGET(chrome->platformPageClient());
> +            gint widgetDragHysteresis = 0;
> +            if (client) {
> +                g_object_get(gtk_widget_get_settings(client),
> +                    "gtk-dnd-drag-threshold", &widgetDragHysteresis,
> +                    0);
> +                threshold = max(widgetDragHysteresis, threshold);
> +            }
> +        }
> +    }

Since WebKitGtk is not currently multi-head safe, I think all of this can be simplified as:

g_object_get(gtk_settings_get_default(), "gtk-dnd-drag-threshold", &gtkDndThreshold, NULL);
threshold = max(gtkDdnThreshold, threshold);
Comment 4 Martin Robinson 2011-09-08 08:38:01 PDT
(In reply to comment #3)

> g_object_get(gtk_settings_get_default(), "gtk-dnd-drag-threshold", &gtkDndThreshold, NULL);
> threshold = max(gtkDdnThreshold, threshold);

From what I understand this change will also make this patch more compatible with WebKit2. I think it's a great idea.
Comment 5 Martin Robinson 2011-09-08 08:38:44 PDT
(In reply to comment #3)

> Since WebKitGtk is not currently multi-head safe, I think all of this can be simplified as:

Perhaps we should start working on making it so, though? Is it worth it? In any case, this code should be used as a fallback for the WebKit2 case.
Comment 6 Sven Schwedas 2011-10-04 05:33:25 PDT
Any status update on this? I'd really need this – tablets and touchscreens are more or less unusable thanks to constant accidental drags.

@Arno could you please update the patch for 1.6.1, so I can at least patch my local webkit?
Comment 7 Sven Schwedas 2011-10-05 06:02:26 PDT
(In reply to comment #3)
> Since WebKitGtk is not currently multi-head safe, I think all of this can be simplified as:
> 
> g_object_get(gtk_settings_get_default(), "gtk-dnd-drag-threshold", &gtkDndThreshold, NULL);
> threshold = max(gtkDdnThreshold, threshold);

I just tried the patch with this change, and it seems to be working fine. Could we get this into master asap?
Comment 8 Sven Schwedas 2012-08-17 03:43:07 PDT
Created attachment 159072 [details]
Patch rebased against current git

Patch rebased against current git, including changes from #3. Original authors Arno Renevier <arno@renevier.net> / Carlos Garcia Campos <cgarcia@igalia.com>
Comment 9 Sven Schwedas 2012-08-17 05:39:42 PDT
Created attachment 159103 [details]
Compilation errors fixed

Patch now compiling and tested. Honours the gtk-dnd-drag-threshold settings in gtkrc/settings.ini.