x11: fix dnd-kitten drag immediately cancelled by spurious synthetic ButtonRelease#10025
Closed
Copilot wants to merge 1 commit into
Closed
x11: fix dnd-kitten drag immediately cancelled by spurious synthetic ButtonRelease#10025Copilot wants to merge 1 commit into
Copilot wants to merge 1 commit into
Conversation
When the dnd kitten initiates a drag, XGrabPointer is called from the tick callback after an async IPC round-trip. Calling XGrabPointer with CurrentTime long after the Button1 press causes some X11 compositors to emit a synthetic ButtonRelease (transitioning from the implicit press-grab to the explicit pointer grab), which immediately cancels the drag because no XdndPosition target has been found yet. Fix: save event->xbutton.time on each Button1 press and use that timestamp in XGrabPointer instead of CurrentTime. This is standard X11 DnD practice and tells the server the grab was active since the button press, preventing the spurious synthetic event. Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/16a2b7ff-bf7a-419a-883b-59a8c6def5f7 Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
kovidgoyal
May 18, 2026 04:12
View session
Owner
|
@copilot that does not fix it. Doing further debugging, I find the release event is not coming from the X server but instead is coming from _glfwFreeDragSourceData in glfw/input.c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the dnd kitten starts a drag,
XGrabPointeris called from the tick callback after an async IPC round-trip — significantly later than the original Button1 press. CallingXGrabPointer(CurrentTime)at that point causes some X11 compositors to emit a syntheticButtonReleaseto transition from the implicit button-press grab to the new explicit grab. Sincedrag.activeis alreadytrueand no XdndPosition target exists yet,handle_drag_button_releasecancels the drag immediately. Tab dragging is unaffected becauseXGrabPointeris called synchronously within the same event cycle as the triggering motion event.Changes
glfw/x11_platform.h— addTime last_button1_press_timeto thedragsub-structglfw/x11_window.cevent->xbutton.timeon every Button1 press_glfwPlatformStartDrag, pass the saved timestamp (falling back toCurrentTimeif zero) toXGrabPointerinstead ofCurrentTimeUsing the button-press timestamp is standard X11 DnD practice: it tells the server the grab was active from the moment the button was pressed, suppressing the spurious synthetic transition events regardless of how much wall time elapses before the explicit grab is requested.