summaryrefslogtreecommitdiff
path: root/gtk/gtkcombobox.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2016-04-10 23:42:57 -0400
committerMatthias Clasen <mclasen@redhat.com>2016-04-27 23:18:16 -0400
commite9a58190af6e9a326f1da04af471f4315efa895f (patch)
tree438017aeb7d6be86232893e63624bd5b01e945eb /gtk/gtkcombobox.c
parentb5fb9ae3b74ae0c1d2a20bd24457ea228dd3f9e3 (diff)
downloadgtk+-e9a58190af6e9a326f1da04af471f4315efa895f.tar.gz
combobox: Stop using screen width/height
Popups should always be placed relative to a monitor.
Diffstat (limited to 'gtk/gtkcombobox.c')
-rw-r--r--gtk/gtkcombobox.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index fe21a1fa9d..481c1808c6 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -2007,10 +2007,12 @@ gtk_combo_box_menu_position_over (GtkMenu *menu,
GtkAllocation content_allocation;
GtkAllocation child_allocation;
GList *children;
- gint screen_width;
gint menu_xpos;
gint menu_ypos;
gint menu_width;
+ GdkDisplay *display;
+ GdkMonitor *monitor;
+ GdkRectangle workarea;
active = gtk_menu_get_active (GTK_MENU (priv->popup_widget));
@@ -2056,12 +2058,14 @@ gtk_combo_box_menu_position_over (GtkMenu *menu,
&menu_xpos, &menu_ypos);
/* Clamp the position on screen */
- screen_width = gdk_screen_get_width (gtk_widget_get_screen (widget));
-
- if (menu_xpos < 0)
- menu_xpos = 0;
- else if ((menu_xpos + menu_width) > screen_width)
- menu_xpos -= ((menu_xpos + menu_width) - screen_width);
+ display = gtk_widget_get_display (widget);
+ monitor = gdk_display_get_monitor_at_window (display, gtk_widget_get_window (widget));
+ gdk_monitor_get_workarea (monitor, &workarea);
+
+ if (menu_xpos < workarea.x)
+ menu_xpos = workarea.x;
+ else if ((menu_xpos + menu_width) > workarea.x + workarea.width)
+ menu_xpos -= (menu_xpos + menu_width) - (workarea.x + workarea.width);
*x = menu_xpos;
*y = menu_ypos;