summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2023-05-11 15:35:27 -0400
committerMatthias Clasen <mclasen@redhat.com>2023-05-11 15:35:27 -0400
commit625c7c3d266986faec79156f10b3276120b31a5b (patch)
tree8d618548ea4601cf92b8598dc9b080495a59589a
parent4ea2aac5612a58182711eda7a5dc8b5175d567a1 (diff)
downloadgtk+-625c7c3d266986faec79156f10b3276120b31a5b.tar.gz
widgetfocus: Sort children better for TAB
When tabbing in a box, we really want to sort children just along the main axis. Make it so.
-rw-r--r--gtk/gtkwidgetfocus.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/gtk/gtkwidgetfocus.c b/gtk/gtkwidgetfocus.c
index df1c562ac6..4dc8f28fd5 100644
--- a/gtk/gtkwidgetfocus.c
+++ b/gtk/gtkwidgetfocus.c
@@ -17,6 +17,8 @@
#include "gtkwidgetprivate.h"
#include "gtknative.h"
+#include "gtkboxlayout.h"
+#include "gtkorientable.h"
typedef struct _CompareInfo CompareInfo;
@@ -434,7 +436,29 @@ gtk_widget_focus_sort (GtkWidget *widget,
{
case GTK_DIR_TAB_FORWARD:
case GTK_DIR_TAB_BACKWARD:
- focus_sort_tab (widget, direction, focus_order);
+ {
+ GtkLayoutManager *layout = gtk_widget_get_layout_manager (widget);
+ if (GTK_IS_BOX_LAYOUT (layout))
+ {
+ GtkOrientation orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (layout));
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ if (direction == GTK_DIR_TAB_FORWARD)
+ focus_sort_left_right (widget, GTK_DIR_RIGHT, focus_order);
+ else
+ focus_sort_left_right (widget, GTK_DIR_LEFT, focus_order);
+ }
+ else
+ {
+ if (direction == GTK_DIR_TAB_FORWARD)
+ focus_sort_up_down (widget, GTK_DIR_DOWN, focus_order);
+ else
+ focus_sort_up_down (widget, GTK_DIR_UP, focus_order);
+ }
+ }
+ else
+ focus_sort_tab (widget, direction, focus_order);
+ }
break;
case GTK_DIR_UP:
case GTK_DIR_DOWN: