Skip to content

Draft: Fix GtkTextView causing queue_allocate during snapshot

This is a (likely misguided) attempt to fix #6057. The first commit can be pulled separately.

I'm unfamiliar with the text view internals, so it is entirely possible and quite likely that I got things wrong here, and inadvertently have broken something. However, this appears to work well in my testing, both the examples in gtk-demo, and with my reproducer from #6057.

What doesn't work though is GtkSourceView (I tested g-t-e), because as far as I can see, it uses the tags mechanisms to do syntax highlighting. In snapshot (), it calls gtk_source_view_ensure_redrawn_rect_is_highlighted (), which then calls highlight_region () / unhighlight_region (), which adds and removes tags, which invalidates the text layout and the text view. But the text view now expects all validation/invalidation to be handled in the layout phase, so the new g_return_if_fail (priv->onscreen_validated) fires.

I would say (based on my limited understanding) that the right fix to this would be running gtk_source_view_ensure_redrawn_rect_is_highlighted () in the layout phase (size_allocate ()), before chaining up to GtkTextView's size_allocate () (which will do the validation). Alternatively, if it is true that syntax highlighting can only ever affect color and not layout, it might be possible to let the text view know that somehow so it doesn't get invalidated when the highlighting-related tags change.

cc @chergert

Merge request reports