[PATCH]fix GtkComboBox gtk_menu_popup`s gtk_combo_box_menu_position bug



Hi Gtk developers,

When I developed application for Magic Linux desktop in 2006, I use PyGtk with Gtk-2.x http://forum.linuxfans.org/viewthread.php?tid=160241 there was a GtkComboBox gtk_menu_popup`s gtk_combo_box_menu_position bug https://pbs.twimg.com/media/CGeTgQUU8AApmpF.png

And when I am developing ***something*** in 2015, there is still such issue, wrong menu_ypos value, so I try to fix the bug for 10+ years! it is a monkey patch ;P


diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index ccda6ad..c4105b4 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -1916,6 +1916,7 @@ gtk_combo_box_menu_position_over (GtkMenu *menu,
   gint            menu_xpos;
   gint            menu_ypos;
   gint            menu_width;
+  gint            child_height = 0;

   combo_box = GTK_COMBO_BOX (user_data);
   widget = GTK_WIDGET (combo_box);
@@ -1951,6 +1952,7 @@ gtk_combo_box_menu_position_over (GtkMenu *menu,
           gtk_widget_get_allocation (child, &child_allocation);

           menu_ypos -= child_allocation.height;
+          child_height += child_allocation.height;
         }

       children = children->next;
@@ -1972,7 +1974,7 @@ gtk_combo_box_menu_position_over (GtkMenu *menu,
     menu_xpos -= ((menu_xpos + menu_width) - screen_width);

   *x = menu_xpos;
-  *y = menu_ypos;
+  *y = child_height ? menu_ypos : 0;

   *push_in = TRUE;
 }

--
Regards,
Leslie Zhai






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