fepitre / rpms / gtk3

Forked from rpms/gtk3 4 years ago
Clone

Blame SOURCES/0001-menu-Do-a-proper-min-height-request.patch

0fe339
--- a/gtk/gtkmenu.c
0fe339
+++ b/gtk/gtkmenu.c
0fe339
@@ -3237,18 +3237,21 @@
0fe339
                                          gint      *minimum_size,
0fe339
                                          gint      *natural_size)
0fe339
 {
0fe339
-  GtkBorder       padding;
0fe339
+  GtkBorder       padding, arrow_border;
0fe339
   GtkMenu        *menu = GTK_MENU (widget);
0fe339
   GtkMenuPrivate *priv = menu->priv;
0fe339
+  GdkScreen      *screen;
0fe339
+  GdkRectangle    monitor;
0fe339
   guint          *min_heights, *nat_heights;
0fe339
   guint           border_width;
0fe339
   gint            n_heights, i;
0fe339
-  gint            min_height, nat_height;
0fe339
+  gint            min_height, single_height, nat_height;
0fe339
 
0fe339
   border_width = gtk_container_get_border_width (GTK_CONTAINER (menu));
0fe339
   get_menu_padding (widget, &padding);
0fe339
 
0fe339
   min_height = nat_height = (2 * border_width) + padding.top + padding.bottom;
0fe339
+  single_height = 0;
0fe339
 
0fe339
   n_heights =
0fe339
     calculate_line_heights (menu, for_size, &min_heights, &nat_heights);
0fe339
@@ -3256,16 +3259,21 @@
0fe339
   for (i = 0; i < n_heights; i++)
0fe339
     {
0fe339
       min_height += min_heights[i];
0fe339
+      single_height = MAX (single_height, min_heights[i]);
0fe339
       nat_height += nat_heights[i];
0fe339
     }
0fe339
 
0fe339
-  if (priv->have_position)
0fe339
-    {
0fe339
-      GdkScreen *screen = gtk_widget_get_screen (priv->toplevel);
0fe339
-      GdkRectangle monitor;
0fe339
+  screen = gtk_widget_get_screen (priv->toplevel);
0fe339
+  gdk_screen_get_monitor_workarea (screen, MAX (priv->monitor_num, 0), &monitor);
0fe339
 
0fe339
-      gdk_screen_get_monitor_workarea (screen, priv->monitor_num, &monitor);
0fe339
+  get_arrows_border (menu, &arrow_border);
0fe339
+  single_height += (2 * border_width) 
0fe339
+                   + padding.top + padding.bottom
0fe339
+                   + arrow_border.top + arrow_border.bottom;
0fe339
+  min_height = MIN (min_height, MAX (monitor.height, single_height));
0fe339
 
0fe339
+  if (priv->have_position)
0fe339
+    {
0fe339
       if (priv->position_y + min_height > monitor.y + monitor.height)
0fe339
         min_height = monitor.y + monitor.height - priv->position_y;
0fe339