linux-packaging-mono/external/bockbuild/packages/patches/gtk/0005-gtk-don-t-scroll-combo-box-menus-if-less-than-3-item.patch
Xamarin Public Jenkins (auto-signing) 6bdd276d05 Imported Upstream version 5.0.0.42
Former-commit-id: fd56571888259555122d8a0f58c68838229cea2b
2017-04-10 11:41:01 +00:00

62 lines
2.1 KiB
Diff

From df766e7dc27c8bc373dd5eaeaa5bddb7702605fd Mon Sep 17 00:00:00 2001
From: Michael Natterer <mitch@gimp.org>
Date: Fri, 23 Nov 2012 15:28:26 +0100
Subject: [PATCH 05/68] gtk: don't scroll combo box menus if less than 3
itemss are visible
---
gtk/gtkcombobox.c | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index d997d0d..3b58f32 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -1781,6 +1781,44 @@ gtk_combo_box_menu_position (GtkMenu *menu,
menu_item);
gtk_combo_box_menu_position_over (menu, x, y, push_in, user_data);
+
+ if (menu_item)
+ {
+ GdkScreen *screen;
+ GtkWidget *widget = GTK_WIDGET (combo_box);
+ gint monitor_num;
+ GdkRectangle monitor;
+ gint px, py;
+ gint menu_height;
+ gint scroll_offset = 0;
+
+ screen = gtk_widget_get_screen (widget);
+ gdk_display_get_pointer (gdk_screen_get_display (screen),
+ NULL, &px, &py, NULL);
+
+ monitor_num = gdk_screen_get_monitor_at_point (screen, px, py);
+
+ gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
+
+ menu_height = GTK_WIDGET (menu)->requisition.height;
+
+ if (*y + menu_height > monitor.y + monitor.height)
+ {
+ scroll_offset -= *y + menu_height - (monitor.y + monitor.height);
+ }
+ else if (*y < monitor.y)
+ {
+ scroll_offset += monitor.y - *y;
+ }
+
+ /* don't scroll the menu if less than 3 items would be visible,
+ * use 4 to roughly take the scroll buttons into account
+ */
+ if (scroll_offset != 0 &&
+ (menu->toplevel->requisition.height - ABS (scroll_offset) <
+ 5 * menu_item->requisition.height))
+ gtk_combo_box_menu_position_below (menu, x, y, push_in, user_data);
+ }
}
if (!gtk_widget_get_visible (GTK_MENU (priv->popup_widget)->toplevel))
--
1.7.10.2 (Apple Git-33)