diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c
index 7c0958f..e4972ce 100644
--- a/gtk/gtkpaned.c
+++ b/gtk/gtkpaned.c
@@ -685,6 +685,7 @@ gtk_paned_init (GtkPaned *paned)
   priv->handle_pos.y = -1;
 
   priv->drag_pos = -1;
+  priv->child1_size = -1;
 }
 
 static void
@@ -855,7 +856,7 @@ gtk_paned_get_preferred_size (GtkWidget      *widget,
 {
   GtkPaned *paned = GTK_PANED (widget);
   GtkPanedPrivate *priv = paned->priv;
-  gint child_min, child_nat;
+  gint child_min, child_nat, child2_size;
 
   *minimum = *natural = 0;
 
@@ -866,8 +867,17 @@ gtk_paned_get_preferred_size (GtkWidget      *widget,
       else
         gtk_widget_get_preferred_height (priv->child1, &child_min, &child_nat);
 
-      *minimum = child_min;
-      *natural = child_nat;
+      if (priv->orientation == orientation)
+        {
+          /* We use the lower of the desired size and the set size, but only if the set size is valid. */
+          *minimum = (child_min > priv->child1_size && priv->child1_size >= 0) ? priv->child1_size : child_min;
+          *natural = (child_nat > priv->child1_size && priv->child1_size >= 0) ? priv->child1_size : child_nat;
+        }
+      else
+        {
+          *minimum = child_min;
+          *natural = child_nat;
+        }
     }
 
   if (priv->child2 && gtk_widget_get_visible (priv->child2))
@@ -879,8 +889,18 @@ gtk_paned_get_preferred_size (GtkWidget      *widget,
 
       if (priv->orientation == orientation)
         {
-          *minimum += child_min;
-          *natural += child_nat;
+          /* As above, but calculate the size first */
+          if (priv->last_allocation >= 0 && priv->child1_size >= 0)
+            {
+              child2_size = priv->last_allocation - priv->child1_size;
+              *minimum += MIN (child_min, child2_size);
+              *natural += MIN (child_nat, child2_size);
+            }
+          else
+            {
+              *minimum += child_min;
+              *natural += child_nat;
+            }
         }
       else
         {
