GNOME Bugzilla – Bug 658928
Can't use child of a GtkScrolledWindow as a geometry widget
Last modified: 2018-02-10 04:36:00 UTC
Created attachment 196387 [details] Python program to demonstrate this bug gtk_window_set_geometry_hints doesn't work correctly if the geometry widget is the child of a GtkScrolledWindow. I've written a test program to demonstrate it. It appears that GTK tries to apply the geometry but fails to take into account the scrollbar etc. I get a stream of warnings: Gtk-WARNING **: Toplevel size doesn't seem to directly depend on the size of the geometry widget from gtk_window_set_geometry_hints(). The geometry widget might not be in the window, or it might not be packed into the window appropriately Certain events, eg entering enough text to cause the horizontal scrollbar to appear, cause the program to go into an infinite loop, generating these messages without responding to further events. This might be related to Bug 649680 but this one happens regardless of window manager and I think it's a separate issue.
I've had a look at gtk's code and added a bit of logging and found something I think is significant. The problem is where gtk_window_compute_hints() tries to work out how much extra space there is between the geometry widget and the top-level window. It calls _gtk_widget_override_size_request() with a width and height of 10000 before reading the size difference between the two widgets, but the trouble appears to be that the GtkScrolledWindow "absorbs" the size change, leaving the top-level unchanged, so it gets large negative values for extra_width and extra_height. I don't know how this can be fixed, but also significant is that programs like roxterm and gnome-terminal aren't affected by this, but they also use geometry widgets in scrolled windows. Perhaps it's because they also use GtkNotebook?
Actually gnome-terminal doesn't use a GtkScrolledWindow as container for the VteTerminal, but just a hbox containing the VteTerminal and a GtkScrollbar.
OK, roxterm probably does the same - I should have known, being the author! So at least there appears to be a workaround to avoid this problem. It isn't anything to do with the GtkNotebook, because in the meantime I've added one to my python test program and I still got the warnings.
I thought about rewriting my GtkSourceView-based text editor without GtkScrolledWindow, but it looks like it would be non-trivial at best. So I would really like this fixed, but it looks like it would be a big job :-(.
We're moving to gitlab! As part of this move, we are closing bugs that haven't seen activity in more than 5 years. If this issue is still imporant to you and still relevant with GTK+ 3.22 or master, please consider creating a gitlab issue for it.