[gtk+/gtk-3-22] ComboBox: Do not select item before menu realised



commit 7fca502115920fac57601cba8d0259b9f56e8774
Author: Daniel Boles <dboles src gnome org>
Date:   Thu Dec 1 12:38:43 2016 +0000

    ComboBox: Do not select item before menu realised
    
    For a menu mode CB with wrap_width == 0 and an active item, that item is
    selected in gtk_combo_box_menu_popup. Selection causes the MenuShell to
    activate and hence take a grab. This was done before the menu was popped
    up. A patch distributed in Debian sid - after being proposed on our BZ -
    revealed that on the 1st popup of any such ComboBox, within grab_add,
    the MenuShell's toplevel's GdkWindow is NULL. This causes a Gdk-CRITICAL
    assertion fail on the 1st time opening any such CB, on Debian and if
    that patch were merged to GTK+. By selecting after popup, we ensure the
    MenuShell is realised before its grab_add and so avoid the critical.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=771242

 gtk/gtkcombobox.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index 9ea703b..4fb3a23 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -2115,6 +2115,7 @@ gtk_combo_box_menu_popup (GtkComboBox    *combo_box,
   gint rect_anchor_dy = -2;
   gint child_height;
   GtkWidget *active;
+  GtkWidget *select;
   GtkWidget *child;
   GList *i;
 
@@ -2177,10 +2178,9 @@ gtk_combo_box_menu_popup (GtkComboBox    *combo_box,
     {
       /* FIXME handle nested menus better */
       active = gtk_menu_get_active (GTK_MENU (priv->popup_widget));
+      select = active;
 
-      if (active)
-        gtk_menu_shell_select_item (GTK_MENU_SHELL (priv->popup_widget), active);
-      else
+      if (!active)
         {
           for (i = GTK_MENU_SHELL (priv->popup_widget)->priv->children; i && !active; i = i->next)
             {
@@ -2224,6 +2224,9 @@ gtk_combo_box_menu_popup (GtkComboBox    *combo_box,
                                 GDK_GRAVITY_WEST,
                                 GDK_GRAVITY_NORTH_WEST,
                                 trigger_event);
+
+      if (select)
+        gtk_menu_shell_select_item (GTK_MENU_SHELL (priv->popup_widget), select);
     }
 }
 


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