c2c0ba54781e2b4c0352dcc15ad5f0c85815681f
[mono.git] / bockbuild / mac-sdk / patches / gtk / 0005-gtk-don-t-scroll-combo-box-menus-if-less-than-3-item.patch
1 From df766e7dc27c8bc373dd5eaeaa5bddb7702605fd Mon Sep 17 00:00:00 2001
2 From: Michael Natterer <mitch@gimp.org>
3 Date: Fri, 23 Nov 2012 15:28:26 +0100
4 Subject: [PATCH 05/68] gtk: don't scroll combo box menus if less than 3
5  itemss are visible
6
7 ---
8  gtk/gtkcombobox.c |   38 ++++++++++++++++++++++++++++++++++++++
9  1 file changed, 38 insertions(+)
10
11 diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
12 index d997d0d..3b58f32 100644
13 --- a/gtk/gtkcombobox.c
14 +++ b/gtk/gtkcombobox.c
15 @@ -1781,6 +1781,44 @@ gtk_combo_box_menu_position (GtkMenu  *menu,
16                                     menu_item);
17
18        gtk_combo_box_menu_position_over (menu, x, y, push_in, user_data);
19 +
20 +      if (menu_item)
21 +        {
22 +          GdkScreen *screen;
23 +          GtkWidget *widget = GTK_WIDGET (combo_box);
24 +          gint monitor_num;
25 +          GdkRectangle monitor;
26 +          gint px, py;
27 +          gint menu_height;
28 +          gint scroll_offset = 0;
29 +
30 +          screen = gtk_widget_get_screen (widget);
31 +          gdk_display_get_pointer (gdk_screen_get_display (screen),
32 +                                   NULL, &px, &py, NULL);
33 +
34 +          monitor_num = gdk_screen_get_monitor_at_point (screen, px, py);
35 +
36 +          gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
37 +
38 +          menu_height = GTK_WIDGET (menu)->requisition.height;
39 +
40 +          if (*y + menu_height > monitor.y + monitor.height)
41 +            {
42 +              scroll_offset -= *y + menu_height - (monitor.y + monitor.height);
43 +            }
44 +          else if (*y < monitor.y)
45 +            {
46 +              scroll_offset += monitor.y - *y;
47 +            }
48 +
49 +          /* don't scroll the menu if less than 3 items would be visible,
50 +           * use 4 to roughly take the scroll buttons into account
51 +           */
52 +          if (scroll_offset != 0 &&
53 +              (menu->toplevel->requisition.height - ABS (scroll_offset) <
54 +               5 * menu_item->requisition.height))
55 +            gtk_combo_box_menu_position_below (menu, x, y, push_in, user_data);
56 +        }
57      }
58
59    if (!gtk_widget_get_visible (GTK_MENU (priv->popup_widget)->toplevel))
60 --
61 1.7.10.2 (Apple Git-33)