Merge pull request #390 from ZoiteChat/fix-issue-369

defer channel tree scrolling until realized
This commit is contained in:
deepend-tildeclub
2026-09-14 05:36:00 -07:00
committed by GitHub

View File

@@ -300,6 +300,14 @@ cv_tree_focus (chan *ch)
path = gtk_tree_model_get_path (model, &ch->iter); path = gtk_tree_model_get_path (model, &ch->iter);
if (path) if (path)
{
if (!gtk_widget_get_realized (GTK_WIDGET (tree)))
{
/* Layout changes can restore focus before the new tree is realized.
* Let GTK track the row and scroll once its geometry is available. */
gtk_tree_view_scroll_to_cell (tree, path, NULL, TRUE, 0.5, 0.5);
}
else
{ {
/* This full section does what /* This full section does what
* gtk_tree_view_scroll_to_cell (tree, path, NULL, TRUE, 0.5, 0.5); * gtk_tree_view_scroll_to_cell (tree, path, NULL, TRUE, 0.5, 0.5);
@@ -322,6 +330,7 @@ cv_tree_focus (chan *ch)
dest_y = 0; dest_y = 0;
gtk_tree_view_scroll_to_point (tree, -1, dest_y); gtk_tree_view_scroll_to_point (tree, -1, dest_y);
} }
}
/* theft done, now make it focused like */ /* theft done, now make it focused like */
gtk_tree_view_set_cursor (tree, path, NULL, FALSE); gtk_tree_view_set_cursor (tree, path, NULL, FALSE);
gtk_tree_path_free (path); gtk_tree_path_free (path);