Bug 237292

Summary: [GTK] setDragImage ignores offset
Product: WebKit Reporter: Per Bothner <per>
Component: WebKitGTKAssignee: Michael Catanzaro <mcatanzaro>
Status: RESOLVED FIXED    
Severity: Normal CC: bugs-noreply, cgarcia, mcatanzaro
Priority: P3 Keywords: Gtk
Version: Other   
Hardware: PC   
OS: Linux   
Attachments:
Description Flags
test of setDragImage offset
none
Patch
none
Patch ews-feeder: commit-queue-

Description Per Bothner 2022-02-28 15:00:02 PST
Created attachment 453436 [details]
test of setDragImage offset

WebKitGtk (Epiphany/Gnome Web and Wry, tested on Fedora 35, updated) seem to ignore the xOffset/yOffset parameters passed to setDragImage.
The strange thing is that Safari works (tested on Catalina, updated) - and both report version 605.1.15.
FireFox and Google Chrome work as expected.

To reproduce, view the attached file in a browser. Do a mousedown over the word "here" and then drag the mouse without releasing.
A drag image is created of the "Drag here"+"Lower contents" elements, and follows the mouse as expected.
However, the image of the word "here" is supposed to be under the mouse cursor.
Instead the drag image is displaced so the center of the drag image is under the mouse cursor.
Comment 1 Michael Catanzaro 2022-03-01 11:18:49 PST
Looks like we need to somehow plumb the coordinates from WebCore::DataTransfer::updateDragImage and WebCore::DataTransfer::createDragImage, where they're available, to WebKit::DragSource::begin (both GTK 3 and GTK 4 versions), where they're needed but don't seem to be available. The GTK 3 version uses cairo_surface_set_device_offset() to center the image, while the GTK 4 version uses gdk_drag_set_hotspot().
Comment 2 Michael Catanzaro 2022-03-01 12:49:03 PST
Thanks for the good example/test. This helped a lot.
Comment 3 Michael Catanzaro 2022-03-01 13:01:29 PST
Created attachment 453531 [details]
Patch
Comment 4 Michael Catanzaro 2022-03-01 15:49:30 PST
Created attachment 453543 [details]
Patch
Comment 5 EWS 2022-03-02 07:08:06 PST
Committed r290728 (247975@main): <https://commits.webkit.org/247975@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 453543 [details].
Comment 6 Per Bothner 2022-03-02 07:24:53 PST
Thanks for the quick fix! Looking forward to it appearing in Fedora and other distributions.