listbase: Only grab_focus() if the cursor moved
authorBenjamin Otte <otte@redhat.com>
Tue, 21 Mar 2023 12:47:24 +0000 (13:47 +0100)
committerBenjamin Otte <otte@redhat.com>
Thu, 23 Mar 2023 03:45:03 +0000 (04:45 +0100)
If there is no movement, grab_focus() on the already focused widget
just causes weird inconsistencies and we don't want those.

gtk/gtklistbase.c

index a5d85aabb767fe18bc0f4d9d537b9bac9b97e9c3..4f0d5757775462cdd3f60d00b668d43209395fb5 100644 (file)
@@ -1091,15 +1091,16 @@ gtk_list_base_move_cursor (GtkWidget *widget,
   GtkListBase *self = GTK_LIST_BASE (widget);
   int amount;
   guint orientation;
-  guint pos;
+  guint old_pos, new_pos;
   gboolean select, modify, extend;
 
   g_variant_get (args, "(ubbbi)", &orientation, &select, &modify, &extend, &amount);
 
-  pos = gtk_list_base_get_focus_position (self);
-  pos = gtk_list_base_move_focus (self, pos, orientation, amount);
+  old_pos = gtk_list_base_get_focus_position (self);
+  new_pos = gtk_list_base_move_focus (self, old_pos, orientation, amount);
 
-  gtk_list_base_grab_focus_on_item (GTK_LIST_BASE (self), pos, select, modify, extend);
+  if (old_pos != new_pos)
+    gtk_list_base_grab_focus_on_item (GTK_LIST_BASE (self), new_pos, select, modify, extend);
 
   return TRUE;
 }