62 lines
2.1 KiB
Diff
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)
|