[gtk/new-style-menu] box layout: Handle native children



commit 2ace97fdfa3bec15d78e130f6129abf9b26371c9
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jun 7 03:20:45 2019 +0000

    box layout: Handle native children
    
    These need to be skipped in measuring,
    and we need to call gtk_native_check_resize
    on them during allocation.
    
    This was showing up as the new-style
    context menu in widget-factory forcing
    its relative-to box to grow when its
    shown.

 gtk/gtkboxlayout.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
---
diff --git a/gtk/gtkboxlayout.c b/gtk/gtkboxlayout.c
index 6660dcafd4..98d87701eb 100644
--- a/gtk/gtkboxlayout.c
+++ b/gtk/gtkboxlayout.c
@@ -28,6 +28,7 @@
 #include "gtkstylecontextprivate.h"
 #include "gtktypebuiltins.h"
 #include "gtkwidgetprivate.h"
+#include "gtknative.h"
 
 /**
  * SECTION:gtkboxlayout
@@ -173,6 +174,9 @@ count_expand_children (GtkWidget *widget,
        child != NULL;
        child = _gtk_widget_get_next_sibling (child))
     {
+      if (GTK_IS_NATIVE (child))
+        continue;
+
       if (_gtk_widget_get_visible (child))
         {
           *visible_children += 1;
@@ -219,6 +223,9 @@ gtk_box_layout_compute_size (GtkBoxLayout *self,
       int child_min = 0;
       int child_nat = 0;
 
+      if (GTK_IS_NATIVE (child))
+        continue;
+
       if (!_gtk_widget_get_visible (child))
         continue;
 
@@ -293,6 +300,9 @@ gtk_box_layout_compute_opposite_size (GtkBoxLayout *self,
        child != NULL;
        child = _gtk_widget_get_next_sibling (child))
     {
+      if (GTK_IS_NATIVE (child))
+        continue;
+
       if (_gtk_widget_get_visible (child))
         {
           gtk_widget_measure (child,
@@ -341,6 +351,9 @@ gtk_box_layout_compute_opposite_size (GtkBoxLayout *self,
        child != NULL;
        child = _gtk_widget_get_next_sibling (child))
     {
+      if (GTK_IS_NATIVE (child))
+        continue;
+
       /* If widget is not visible, skip it. */
       if (!_gtk_widget_get_visible (child))
         continue;
@@ -481,6 +494,15 @@ gtk_box_layout_allocate (GtkLayoutManager *layout_manager,
   gint child_size;
   gint spacing;
 
+  /* Handle native children first, and skip them in everything below */
+  for (child = _gtk_widget_get_first_child (widget);
+       child != NULL;
+       child = _gtk_widget_get_next_sibling (child))
+    {
+      if (GTK_IS_NATIVE (child))
+        gtk_native_check_resize (GTK_NATIVE (child));
+    }
+
   count_expand_children (widget, self->orientation, &nvis_children, &nexpand_children);
 
   /* If there is no visible child, simply return. */
@@ -505,6 +527,9 @@ gtk_box_layout_allocate (GtkLayoutManager *layout_manager,
        child != NULL;
        child = _gtk_widget_get_next_sibling (child))
     {
+      if (GTK_IS_NATIVE (child))
+        continue;
+
       if (!_gtk_widget_get_visible (child))
         continue;
 
@@ -556,6 +581,9 @@ gtk_box_layout_allocate (GtkLayoutManager *layout_manager,
        child != NULL;
        child = _gtk_widget_get_next_sibling (child))
     {
+      if (GTK_IS_NATIVE (child))
+        continue;
+
       /* If widget is not visible, skip it. */
       if (!_gtk_widget_get_visible (child))
         continue;
@@ -661,6 +689,9 @@ gtk_box_layout_allocate (GtkLayoutManager *layout_manager,
        child != NULL;
        child = _gtk_widget_get_next_sibling (child))
     {
+      if (GTK_IS_NATIVE (child))
+        continue;
+
       /* If widget is not visible, skip it. */
       if (!_gtk_widget_get_visible (child))
         continue;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]