Bug 237292 - [GTK] setDragImage ignores offset
Summary: [GTK] setDragImage ignores offset
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: Other
Hardware: PC Linux
: P3 Normal
Assignee: Michael Catanzaro
URL:
Keywords: Gtk
Depends on:
Blocks:
 
Reported: 2022-02-28 15:00 PST by Per Bothner
Modified: 2022-03-02 07:24 PST (History)
3 users (show)

See Also:


Attachments
test of setDragImage offset (1.36 KB, text/html)
2022-02-28 15:00 PST, Per Bothner
no flags Details
Patch (15.17 KB, patch)
2022-03-01 13:01 PST, Michael Catanzaro
no flags Details | Formatted Diff | Diff
Patch (14.99 KB, patch)
2022-03-01 15:49 PST, Michael Catanzaro
ews-feeder: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.