What's the right way to rerender a GtkPicture on resizing

I have a GtkPicture that can be resized by the user.

I would like to detect when that resize happens, so that I can start rendering content at the new size in the background, and when it is done, give it to the GtkPicture to display. In the meantime, the GtkPicture would show a stretched version of the old content.

This was easily possible in GTK3 using the size_allocate signal. But GTK4 has aggressively removed any such ways to hook into the resize process. So I would like to ask what the “right” way to do this is.

  • I have tried wrapping it in a custom widget which adds back the missing size_allocate signal, but that somehow interferes with GtkPicture’s resizing.

  • I have tried setting a custom layout manager on the GtkPicture that does nothing other than to emit a signal on allocation. This works very nicely, but doesn’t seem to be an intended use of layout managers and may therefore break in the future.

  • If the answer is that I should create a custom GtkWidget that draws its own content and emits the signal on resize, then that’s not very good, because it shouldn’t be necessary to reimplement exactly the functionality of GtkPicture from scratch just to add a small piece of functionality that could still easily be added if widgets had a functional size_allocate signal.