Custom container with its own GdkSurface crashes upon gtk_widget_size_allocate()
Steps to reproduce
- Extract the tar archive containing the snippet simple_button_app.c, a Makefile, and a custom container implementation (os_custom)
- Run make.
- Run the simple_button_app application. Try dragging any corner of the window -- the application will immediately crash.
Current behavior
Dragging any corner of the window to resize the window will crash. The error message provided is:
Gtk:ERROR:../gtk/gtkwidget.c:3786:gtk_widget_get_surface_allocation: assertion failed: (GTK_IS_WINDOW (parent) || GTK_IS_POPOVER (parent))
Expected outcome
The window resizes without crashing.
Version information
3.94.0
Additional information
The widget hierarchy for this little snippet is as follows (SwtFixed is the custom container):
GtkWindow
GtkBox
GtkScrolledWindow
SwtFixed
SwtFixed
GtkButton
Some debugging tells me that gtk_widget_size_allocate() ends up calling gtk_widget_get_surface_allocation(). This method traverses up the widget tree until it finds a widget that is not NULL, and also does not have its own surface. However, the custom container has its own surface, so this check fails on the the SwtFixed child of GtkScrolledWindow, and the loop breaks. The assert statement which follows fails because SwtFixed is neither a window, nor a popover.
This used to work fine in GTK3, and git log tells me that gtk_widget_get_[surface/window]_allocation() was introduced around a year ago. I'm not sure I understand the logic here, is it unreasonable simple_button_app.tarthat a custom container might create its own surface?