-
Notifications
You must be signed in to change notification settings - Fork 202
GTK/Cocoa: give synthetic events a fresh timestamp instead of getLast… #3559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1679,7 +1679,18 @@ void sendEvent (int eventType, Event event, boolean send) { | |
| event.display = display; | ||
| event.widget = this; | ||
| if (event.time == 0) { | ||
| event.time = display.getLastEventTime (); | ||
| /* | ||
| * display.getLastEventTime() only reflects the time of the last *native* | ||
| * GDK event that was processed; it is not updated by synthetic events | ||
| * dispatched directly (e.g. notifyListeners()) without going through the | ||
| * native event queue. Relying on it here would make consecutive | ||
| * synthetic events (as commonly created by tests) carry the same, stale | ||
| * time, which can incorrectly look like a repeated/duplicate event to | ||
| * code (e.g. KeyBindingDispatcher) that de-duplicates by event time. | ||
| * Use a distinct, always-advancing timestamp instead, consistent with | ||
| * how other synthetic events (see sendJDKInternalEvent) are timestamped. | ||
| */ | ||
| event.time = (int) (System.nanoTime() / 1_000_000L); | ||
|
fedejeanne marked this conversation as resolved.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So 2 synthetic events fired one after the other will still share the same millisecond (quite likely for a test execution) and de-duplication will not happen , what am I missing?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Same as above: the deduplication logic still compares
Can you please provide an example? I don't understand it. The way I see it, the current code in all 4 (actually, all 6) implementations of
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See https://xorg.freedesktop.org/archive/current/doc/xproto/x11protocol.html#glossary:Timestamp "A timestamp is a time value, expressed in milliseconds. It typically is the time since the last server reset. Timestamp values wrap around (after about 49.7 days)." So these timestamps are with different base and using Java timestamp will put some value in the far, far future. |
||
| } | ||
| if (send) { | ||
| sendEvent (event); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, but the chances are very slim that 2 back-to-back events manage to get created and sent in the same millisecond and if they do then the deduplication logic should still notice that they are not the same event (
event1 == event2yieldsfalse), they were merely sent at the same time.I don't understand that: do you mean the same logic that is being altered by this same PR and contain the exact same fix (
event.time = (int) (System.nanoTime() / 1_000_000L);)?