GNOME Bugzilla – Bug 696623
GtkOverlay with a revealer produces warnings setting a margin
Last modified: 2013-03-28 12:22:54 UTC
(gedit:21936): Gtk-WARNING **: gtk_widget_size_allocate(): attempt to allocate widget with width -11 and height 0 This is what I get in gedit. A revealer allocates 0,0 so setting a margin the overlay makes it request a negative width.
Created attachment 240024 [details] [review] GtkOverlay: Don't allocate child except in size_allocate We were calling gtk_overlay_child_allocate() both in realize and in add as we wanted to create and position the child windows for the widgets. However, this call also actually called gtk_widget_size_allocate() on the child, which it shouldn't. In some cases the overlay is realized before being allocated, and thus it will allocate the child at 0x0 which is an invalid size for it to be in. In particular, if the child has margins set this will result in negative allocations and warnings. This fix just avoids actually allocating the child except in the actual size_allocate() call on the overlay.
Created attachment 240032 [details] [review] GtkOverlay: Don't allocate child except in size_allocate We were calling gtk_overlay_child_allocate() both in realize and in add as we wanted to create and position the child windows for the widgets. However, this call also actually called gtk_widget_size_allocate() on the child, which it shouldn't. In some cases the overlay is realized before being allocated, and thus it will allocate the child at 0x0 which is an invalid size for it to be in. In particular, if the child has margins set this will result in negative allocations and warnings. This fix splits out the allocation computation so that gtk_overlay_create_child_window can use it without callers having to call gtk_overlay_child_allocate() to move the windows.
Created attachment 240035 [details] [review] GtkOverlay: Respect overlay child min size Never allocate an overlayed child less than its minimum request. If the minimum doesn't fit we will gracefully clip via the widget window.
Attachment 240032 [details] pushed as b54f277 - GtkOverlay: Don't allocate child except in size_allocate Attachment 240035 [details] pushed as e495d31 - GtkOverlay: Respect overlay child min size