From 8ff94ea1f2efce0090322f37d5aa9f3060a5947b Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 5 Aug 2021 12:29:24 -0400 Subject: [PATCH 1/2] text: Move setup code out of a loop Just a cleanup, no functional change. --- gtk/gtktext.c | 57 ++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/gtk/gtktext.c b/gtk/gtktext.c index 62f7c90e4c..1cb086dd1f 100644 --- a/gtk/gtktext.c +++ b/gtk/gtktext.c @@ -5049,39 +5049,40 @@ gtk_text_move_visually (GtkText *self, int index; PangoLayout *layout = gtk_text_ensure_layout (self, FALSE); const char *text; + gboolean split_cursor; + gboolean strong; text = pango_layout_get_text (layout); - + index = g_utf8_offset_to_pointer (text, start) - text; + + g_object_get (gtk_widget_get_settings (GTK_WIDGET (self)), + "gtk-split-cursor", &split_cursor, + NULL); + + if (split_cursor) + strong = TRUE; + else + { + GdkDisplay *display; + GdkSeat *seat; + GdkDevice *keyboard = NULL; + PangoDirection direction = PANGO_DIRECTION_LTR; + + display = gtk_widget_get_display (GTK_WIDGET (self)); + seat = gdk_display_get_default_seat (display); + if (seat) + keyboard = gdk_seat_get_keyboard (seat); + if (keyboard) + direction = gdk_device_get_direction (keyboard); + + strong = direction == priv->resolved_dir; + } + while (count != 0) { int new_index, new_trailing; - gboolean split_cursor; - gboolean strong; - - g_object_get (gtk_widget_get_settings (GTK_WIDGET (self)), - "gtk-split-cursor", &split_cursor, - NULL); - - if (split_cursor) - strong = TRUE; - else - { - GdkDisplay *display; - GdkSeat *seat; - GdkDevice *keyboard = NULL; - PangoDirection direction = PANGO_DIRECTION_LTR; - - display = gtk_widget_get_display (GTK_WIDGET (self)); - seat = gdk_display_get_default_seat (display); - if (seat) - keyboard = gdk_seat_get_keyboard (seat); - if (keyboard) - direction = gdk_device_get_direction (keyboard); - - strong = direction == priv->resolved_dir; - } if (count > 0) { @@ -5098,11 +5099,11 @@ gtk_text_move_visually (GtkText *self, index = 0; else if (new_index != G_MAXINT) index = new_index; - + while (new_trailing--) index = g_utf8_next_char (text + index) - text; } - + return g_utf8_pointer_to_offset (text, text + index); } From e5e7f5dd88784173a8dd31e4a5c4a24d19131e37 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 5 Aug 2021 12:41:04 -0400 Subject: [PATCH 2/2] ci: Disable treeview-headers-hidden reftest Somebody needs to figure out why it fails in ci so frequently. --- testsuite/reftests/meson.build | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/testsuite/reftests/meson.build b/testsuite/reftests/meson.build index f2dc31e570..c166233ad9 100644 --- a/testsuite/reftests/meson.build +++ b/testsuite/reftests/meson.build @@ -441,8 +441,11 @@ testdata = [ 'treeview-fixed-height.css', 'treeview-fixed-height.ref.ui', 'treeview-fixed-height.ui', - 'treeview-headers-hidden.ref.ui', - 'treeview-headers-hidden.ui', + # this test fails with an off-by-one in ci too frequently + # to be left enabled. Remove it until somebody figures out + # what is going on there. + #'treeview-headers-hidden.ref.ui', + #'treeview-headers-hidden.ui', 'unresolvable.css', 'unresolvable.ref.ui', 'unresolvable.ui',