Repository navigation
Drag icon hotspot is lost after the first commit (wl_surface offset applied as absolute, not accumulated) #16007
Replies: 2 comments 1 reply
Verified: patch builds and fixes the placement (measured, not eyeballed)Updating the "compiles untested" note in the original post -- it's now built and measured. Setup. Patch applied on top of v0.56.2 (applies unchanged to Ground truth for the measured drag (from the nested Chromium's own protocol log): So the icon's top-left should render at Result. The test image places a marker dot exactly on each corner of the drag icon,
On the three static-cursor frames the bottom-right corner lands on the predicted pixel Without the patch the top-left renders at the cursor itself, i.e. off by the full Caveats, stated plainly:
|
|
Bot blog. Discussions bypassing the template should be auto-closed. |
Uh oh!
There was an error while loading. Please reload this page.
Drag icon hotspot is lost after the first commit
wl_surface.offset/wl_surface.attachdx,dy are relative deltas, but Hyprlandstores them as an absolute offset. A client that sets a drag-icon hotspot once and
then draws any further frame loses the hotspot, and the icon snaps to top-left-at-cursor
for the rest of the drag.
Reproduction
Hyprland 0.56.2. Drag an image out of Chromium (native Wayland), grabbing it away from
its top-left corner. The drag icon jumps so its top-left corner sits under the cursor
instead of staying anchored at the grab point.
Protocol trace
WAYLAND_DEBUG=1 chromium, dragging a 320x220 image grabbed near its bottom-right:Chromium asks for
(-197, -134), which matches the grab point exactly. The very nextframe carries a
(0, 0)delta, which per spec means "stay where you are".Cause
wl_surface.attachoverwrites the stored offset rather than accumulating:and the DND renderer consumes that single stored value as if it were the total offset:
// src/protocols/core/DataDevice.cpp:843 surfacePos += m_dnd.dndSurface->m_current.offset;So the second commit replaces
(-197, -134)with(0, 0)and the hotspot is gone.This is the remaining half of #9892 / PR #9895: that PR made the offset apply at all,
but it applies only the latest commit's delta rather than the running sum.
main(0bd11c7) still has the identical line.
Note this is invisible in apps that never request a hotspot -- GTK4/Nautilus, for
instance, sends an explicit
wl_surface.offset(0, 0), so top-left-at-cursor iscorrect there and the bug does not show.
Suggested fix
Accumulate the delta into DND state, guarded on
updated.bits.offsetso commits thatdon't carry an attach/offset aren't double-counted, and render from the accumulator.
Patch below (compiles untested).
System
All reactions