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