listbase: Only grab_focus() if the cursor moved

If there is no movement, grab_focus() on the already focused widget
just causes weird inconsistencies and we don't want those.
This commit is contained in:
Benjamin Otte 2023-03-21 13:47:24 +01:00
parent 7285830dfb
commit fa7a5773d4

View 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;
}