Commit 95959ef4 authored by Benjamin Otte's avatar Benjamin Otte

overlay: Handle overlays when no main widget exists

Just pretend that the main widget is an empty widget the size of the
overlay.
Makes it possible to write testcases where no size requests are run on
overlay widgets before size_allocate() is called.

Testcase included.
parent c849b8ed
......@@ -214,8 +214,8 @@ gtk_overlay_get_main_widget_allocation (GtkOverlay *overlay,
{
main_alloc.x = 0;
main_alloc.y = 0;
main_alloc.width = 1;
main_alloc.height = 1;
main_alloc.width = gtk_widget_get_allocated_width (GTK_WIDGET (overlay));
main_alloc.height = gtk_widget_get_allocated_height (GTK_WIDGET (overlay));
}
if (main_alloc_out)
......@@ -325,10 +325,8 @@ gtk_overlay_size_allocate (GtkWidget *widget,
GTK_WIDGET_CLASS (gtk_overlay_parent_class)->size_allocate (widget, allocation);
main_widget = gtk_bin_get_child (GTK_BIN (overlay));
if (!main_widget || !gtk_widget_get_visible (main_widget))
return;
gtk_widget_size_allocate (main_widget, allocation);
if (main_widget && gtk_widget_get_visible (main_widget))
gtk_widget_size_allocate (main_widget, allocation);
for (children = priv->children; children; children = children->next)
gtk_overlay_child_allocate (overlay, children->data);
......
......@@ -314,6 +314,8 @@ testdata = \
opacity.css \
opacity.ui \
opacity.ref.ui \
overlay-no-main-widget.ref.ui \
overlay-no-main-widget.ui \
paned-undersized.css \
paned-undersized.ref.ui \
paned-undersized.ui \
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.1 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<object class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<child>
<object class="GtkOverlay" id="overlay1">
<property name="width_request">100</property>
<property name="height_request">100</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
</object>
</child>
<child type="overlay">
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">VISIBLE</property>
</object>
</child>
</object>
</child>
</object>
</interface>
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.1 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<object class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<child>
<object class="GtkOverlay" id="overlay1">
<property name="width_request">100</property>
<property name="height_request">100</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<placeholder/>
</child>
<child type="overlay">
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">VISIBLE</property>
</object>
</child>
</object>
</child>
</object>
</interface>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment