Repository navigation
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
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.
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. I plan to close this one as it can create major and close to non discoverable issues with event handling. The issue it tries to fix should be totally different IMO - like ensuring that an event is either canceled to not propagate further or to not be fired at all (if it is double fired - native and swt side). Coming up with pure SWT reproducer to make debugging it would be a major part of the work.
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.
I see, so your fear is that by tampering with the event right before it goes into GTK will have unknown effects because the Java timestamp might be "in the future", correct? How about getting some value that makes sense and putting it in here? I am tempted to say let's use
Ok. I am closing it. Feel free to answer my question above anyway (just to quench my thirst for knowledge :D )
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. Sorry for the delay. I tend to miss quite some notifications lately - it's beyond my processing capabilities :) |
||
| } | ||
| if (send) { | ||
| sendEvent (event); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.