Skip to content

Suppress duplicated key event handling in Linux/GTK3 #4199#4200

Open
fedejeanne wants to merge 1 commit into
eclipse-platform:masterfrom
fedejeanne:fix-linux-gtk-double-traversal
Open

Suppress duplicated key event handling in Linux/GTK3 #4199#4200
fedejeanne wants to merge 1 commit into
eclipse-platform:masterfrom
fedejeanne:fix-linux-gtk-double-traversal

Conversation

@fedejeanne

Copy link
Copy Markdown
Member

Fixes #4199

How to test

Navigate the views with Ctrl + PgUp / Ctrl + PgDn like I did in the video in #4199, no view should be skipped.

@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Test Results

   855 files  ±0     855 suites  ±0   59m 26s ⏱️ + 8m 48s
 8 120 tests ±0   7 876 ✅  - 1  243 💤 ±0  1 ❌ +1 
20 262 runs  ±0  19 607 ✅  - 1  654 💤 ±0  1 ❌ +1 

For more details on these failures, see this check.

Results for commit 319c5cd. ± Comparison against base commit 5fe0fc9.

♻️ This comment has been updated with latest results.

@iloveeclipse iloveeclipse left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some test fails btw...

@iloveeclipse

Copy link
Copy Markdown
Member

Beside test failure, the patch seem to work. Tried on RHEL 9.6 / X11

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>
@fedejeanne
fedejeanne force-pushed the fix-linux-gtk-double-traversal branch from e66fdd7 to 319c5cd Compare July 23, 2026 08:02
@iloveeclipse

Copy link
Copy Markdown
Member

There are some test fails btw...

Reproducible locally, the test was added via 172b704 for https://bugs.eclipse.org/bugs/show_bug.cgi?id=294509, unfortunately bugzilla is down ATM.

expected: <true> but was: <false>
org.opentest4j.AssertionFailedError: expected: <true> but was: <false>
	at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
	at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
	at org.junit.jupiter.api.AssertTrue.failNotTrue(AssertTrue.java:63)
	at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:36)
	at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:31)
	at org.junit.jupiter.api.Assertions.assertTrue(Assertions.java:183)
	at org.eclipse.e4.ui.bindings.tests.KeyDispatcherTest.testExecuteMultiStrokeBinding(KeyDispatcherTest.java:289)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)

@iloveeclipse

Copy link
Copy Markdown
Member

OK, the test is supposed to test this:

Multi-stroke keybindings like ALT+SHIFT+Q, Q need to recognize a partial key sequence, like ALT+SHIFT+Q.

@fedejeanne

Copy link
Copy Markdown
Member Author

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:

  • The functionality Alt + Shift + Q, Q (and other similar ones) still work
  • When commenting out the test testExecuteOneCommand, all other tests pass
  • When reordering the tests (with help of the JUnit5 annotations org.junit.jupiter.api.TestMethodOrder and org.junit.jupiter.api.Order) and letting testExecuteOneCommand run last, the failing test becomes testExecuteOneCommand

This smells like a bad state after a test ran.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Linux] Tab navigation skips a tab

2 participants