Repository navigation
Conversation
The first button press after an application started called -initializeMouse, which registers with the distributed notification center. That registration waits for gdnc in a nested run loop, which reads the pending ButtonRelease and queues the mouse-up before the press has queued its mouse-down. A table then highlighted the clicked row but never selected it, and the selection only worked on the second click. Read the settings and register once in -initWithAttributes: instead.
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.
Problem
Right after an application starts, a quick click on a table row highlights the row but does not select it: no
tableViewSelectionDidChange:, no action. Only the second click works. Slow clicks (button held for ~150 ms) are not affected.Cause
The first
ButtonPresscalls-initializeMousefrom-processEvent:, before the mouse-down event is queued.-initializeMouseregisters withNSDistributedNotificationCenter, which waits for gdnc's reply in a nested run loop (NSConnectionReplyMode). The X event source is also active in that mode, so the nested loop processes the pendingButtonReleaseand queues the mouse-up first. When-processEvent:returns, the mouse-down is appended after it, so the queue holds[mouse-up, mouse-down]. The table sees the mouse-down last and waits in its tracking loop for a mouse-up that was already delivered.Backtrace of the
ButtonReleasebeing processed inside the press (abridged):Fix
Call
-initializeMouseonce from-initWithAttributes:instead of lazily on the first button press, so no press has to wait for another process.How to reproduce
firstclick.m:readybeing printed click "Row 1" once with a very short press.xdotoolproduces such a click reliably (press and release arrive together); a fast real click does the same:Without this patch:
With this patch:
The bug needs gdnc to be involved, i.e. the first
ButtonPressmust trigger the distributed notification registration, so always test on a freshly started process.Tested on Linux (X11, cairo backend): in repeated runs the first click was lost every time without the patch and never with it. With the patch, double-click detection and the mouse defaults (
GSDoubleClickTime,GSMouseMoveThreshold,GSMouseScrollMultiplier,GSMenuButtonEnabled/GSMenuButtonEvent) are read at startup and still follow later changes through the sameNSUserDefaultsDidChangeNotificationobserver.cc @pkgdemon