Repository navigation
Conversation
anydoby
force-pushed
the
gtk-tree-arrow-navigation
branch
from
October 18, 2026 13:44
26ac19c to
0e4feda
Compare
anydoby
marked this pull request as ready for review
October 18, 2026 14:20
Contributor
Test Results 1 013 files - 4 1 013 suites - 4 1h 35m 59s ⏱️ + 9m 43s For more details on these failures, see this check. Results for commit b7e25f3. ± Comparison against base commit 854e4c1. This pull request removes 5 and adds 2 tests. Note that renamed tests count towards both. |
Member
|
Merge commits are not allowed. |
Member
|
Review comments:
boolean navigateWithArrowKey (int keyval, int state) {
if (keyval != GDK.GDK_Left && keyval != GDK.GDK_KP_Left && keyval != GDK.GDK_Right && keyval != GDK.GDK_KP_Right) return false;
if ((state & (GDK.GDK_SHIFT_MASK | GDK.GDK_CONTROL_MASK | GDK.GDK_MOD1_MASK | GDK.GDK_SUPER_MASK | GDK.GDK_META_MASK | GDK.GDK_HYPER_MASK)) != 0) return false;
if (!GTK.gtk_widget_has_focus (handle)) return false;
long [] path = new long [1];
GTK.gtk_tree_view_get_cursor (handle, path, null);
if (path [0] == 0) return false;
boolean right = (keyval == GDK.GDK_Right || keyval == GDK.GDK_KP_Right) != ((style & SWT.RIGHT_TO_LEFT) != 0);
boolean expanded = GTK.gtk_tree_view_row_expanded (handle, path [0]);
boolean handled;
if (right != expanded) {
handled = right ? GTK.gtk_tree_view_expand_row (handle, path [0], false) : GTK.gtk_tree_view_collapse_row (handle, path [0]);
} else {
if (right) GTK.gtk_tree_path_append_index (path [0], 0);
handled = right || (GTK.gtk_tree_path_get_depth (path [0]) > 1 && GTK.gtk_tree_path_up (path [0]));
if (handled) GTK.gtk_tree_view_set_cursor (handle, path [0], 0, false);
}
GTK.gtk_tree_path_free (path [0]);
return handled;
}
|
GtkTreeView only expands and collapses rows with children for Left and Right, and does nothing on a leaf. Navigate like the Windows tree instead, on GTK3 and GTK4: - Right expands a collapsed row and moves to the first child of an expanded row. - Left collapses an expanded row and moves to the parent of any other row. Keys with modifiers and the keys of the search entry are still left to GtkTreeView. This replaces the Left and Right key bindings of swt_functional_gtk_3_20.css. Assisted-by: Anthropic Claude Code (claude-opus-5-5)
anydoby
force-pushed
the
gtk-tree-arrow-navigation
branch
from
October 21, 2026 16:18
b7e25f3 to
e5486e0
Compare
Author
|
Thanks for the review @akurtakov. Tests are gone now :( I rebased/squashed. Macos test failed since the Right on an expanded item doesn't move to the first child. Actually the way it works on a mac is fine usability-wise. I only had problems with Linux :) |
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.
On GTK, Left and Right in a
Treeonly expand and collapse the cursor row when it has children. On a leaf they do nothing. On Windows they also move through the tree, and that is what users coming from Windows expect, for example in the Project Explorer.This change makes GTK3 and GTK4 navigate the same way:
Keys with modifiers and the keys of the search entry are still left to
GtkTreeView. The handling runs after theSWT.KeyDownlisteners, so a listener that setsdoit = falsestill stops it. The GTK4 handler from #3694 now uses the same code, and the Left and Right key bindings inswt_functional_gtk_3_20.cssare removed, since the Java code replaces them.macOS differs for Right: an earlier version of this PR had a test for it, and on macOS Right on an expanded item does not move to its first child. Left behaves the same as on macOS.
Testing
xdotoolto a snippet in a nested X server, on GTK4 4.22.4 and GTK3 3.24.52, with the SWT I20261017-2300 build plus this change: Right and Left through nested items, a lazily populated item (filled in anSWT.Expandlistener), the keypad arrows, and Shift+Right. All behave as described above, andSWT.Selectionis sent for each cursor move. The unpatched build only expands and collapses.Test_org_eclipse_swt_widgets_Treeon GTK3 / X11 (nested Xephyr): 140 tests pass, including two localDisplay.posttests for Left and Right that are not part of this PR.🤖 Generated with Claude Code