Suppress duplicated key event handling in Linux/GTK3 #4199 - #4200
Suppress duplicated key event handling in Linux/GTK3 #4199#4200fedejeanne wants to merge 1 commit into
Conversation
Test Results 858 files ±0 858 suites ±0 48m 48s ⏱️ - 9m 25s For more details on these failures, see this check. Results for commit 98b1400. ± Comparison against base commit a680fa8. ♻️ This comment has been updated with latest results. |
iloveeclipse
left a comment
There was a problem hiding this comment.
There are some test fails btw...
|
Beside test failure, the patch seem to work. Tried on RHEL 9.6 / X11 |
e66fdd7 to
319c5cd
Compare
Reproducible locally, the test was added via 172b704 for https://bugs.eclipse.org/bugs/show_bug.cgi?id=294509, unfortunately bugzilla is down ATM. |
|
OK, the test is supposed to test this:
|
|
I am looking into it. I suspect something is wrong with the tests because even though they only fail when applying this PR, I also noticed that:
This smells like a bad state after a test ran. |
319c5cd to
176884a
Compare
|
It turns out the tests just needed the The tests pass locally, let's see if they pass in the CI. |
|
This pull request changes some projects for the first time in this development cycle. An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch. Git patchFurther information are available in Common Build Issues - Missing version increments. |
ce01588 to
16d280e
Compare
|
Failing tests ( |
|
Oh, darn: it turns out this PR does break those tests, just like it broke the previous one. Same reason: |
native key event (Linux/GTK) On GTK (Linux), a single physical key press can, in some situations, be delivered to KeyBindingDispatcher twice for the very same native event: once synchronously via an SWT.Traverse event dispatched from within the native gtk3_key_press_event handling, and once more later via the async message queue. Both deliveries resolve to and execute the exact same bound command, which for page-traversal shortcuts like Ctrl+PageUp / Ctrl+PageDown (Next/Previous Editor) causes an extra tab to be skipped, since the CTabFolder selection is advanced twice per key press. This does not reproduce on Windows or macOS, only on GTK. Fix: track the last executed command together with the native timestamp (Event#time) of its triggering event in executeCommand(...), and skip (without re-executing the handler) a call that matches both the same command and the same event timestamp, since that combination can only happen when the very same native key event is redelivered. Genuinely distinct key presses - including fast auto-repeat - always carry different timestamps, so normal navigation and repeated shortcuts are unaffected. This is reported as the 'bonus' issue in eclipse-platform#4135 (Javadoc View tab cycling two tabs per Ctrl+PageUp/PageDown on Linux). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
16d280e to
98b1400
Compare
|
I created this one so that the That fixes the problem with the tests so I am reverting the changes to Notice that the tests in this PR will still fail since they need the changes in SWT to succeed. I am drafting this PR until eclipse-platform/eclipse.platform.swt#3559 is approved and merged. |
|
Is it investigated where the duplication comes from? IMO the right fix is to not have the duplicated events at all instead of deduplicating in one place and potentially have the duplication elsewhere. The change in SWT to mix Java and X11/Wayland clocks is kind of scary as a start. |
There was a problem hiding this comment.
🟡 Changes recommended
Timestamp collisions can suppress legitimate key events, and the behavior lacks regression coverage.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Suppresses duplicate GTK3 key events to prevent tab navigation from skipping views.
Changes:
- Tracks the last executed command and event timestamp.
- Suppresses matching duplicate executions and adds trace logging.
File summaries
| File | Description |
|---|---|
KeyBindingDispatcher.java |
Adds timestamp-based key-event deduplication. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| throw new NotEnabledException("Command should have been disabled via activity: " + parameterizedCommand); //$NON-NLS-1$ | ||
| } | ||
|
|
||
| if (isDuplicateKeyEvent(parameterizedCommand, trigger)) { |
| if (trigger == null) { | ||
| return false; | ||
| } | ||
| boolean duplicate = parameterizedCommand == lastExecutedCommand && trigger.time == lastExecutedEventTime; |
|
@akurtakov the duplication happens because ... and each path execute 1 branch of the This is the diff between both stack-traces provided in #4199 :
I don't know why the event is dispatched twice though. By looking at the 1st stack-trace though I see this: org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:5068)... and in the 2nd stack-trace I see: org.eclipse.swt.internal.gtk3.GTK3.gtk_main_iteration_do(Native Method)Which means that the event must have been triggered by some call to |

Fixes #4199
Requires
How to test
Navigate the views with
Ctrl + PgUp/Ctrl + PgDnlike I did in the video in #4199, no view should be skipped.