summaryrefslogtreecommitdiff
path: root/gtk/gtkmenubutton.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2016-04-10 23:01:10 -0400
committerMatthias Clasen <mclasen@redhat.com>2016-04-27 23:18:16 -0400
commitb5fb9ae3b74ae0c1d2a20bd24457ea228dd3f9e3 (patch)
treef15ff78a54d878f17efb41a37275407c5bf1bbec /gtk/gtkmenubutton.c
parent1b7d7c857f35e4834a522ced67dc0509445aae13 (diff)
downloadgtk+-b5fb9ae3b74ae0c1d2a20bd24457ea228dd3f9e3.tar.gz
gtk: Port to new monitor api
Use the GdkDisplay monitor api instead of the GdkScreen one.
Diffstat (limited to 'gtk/gtkmenubutton.c')
-rw-r--r--gtk/gtkmenubutton.c40
1 files changed, 18 insertions, 22 deletions
diff --git a/gtk/gtkmenubutton.c b/gtk/gtkmenubutton.c
index 79aece01d9..1f402fab7d 100644
--- a/gtk/gtkmenubutton.c
+++ b/gtk/gtkmenubutton.c
@@ -251,9 +251,9 @@ menu_position_up_down_func (GtkMenu *menu,
GtkWidget *widget = GTK_WIDGET (menu_button);
GtkWidget *toplevel;
GtkTextDirection direction;
- GdkRectangle monitor;
- gint monitor_num;
- GdkScreen *screen;
+ GdkRectangle workarea;
+ GdkDisplay *display;
+ GdkMonitor *monitor;
GdkWindow *window;
GtkAllocation menu_allocation, allocation, arrow_allocation;
GtkAlign align;
@@ -272,11 +272,9 @@ menu_position_up_down_func (GtkMenu *menu,
direction = gtk_widget_get_direction (widget);
window = gtk_widget_get_window (priv->align_widget ? priv->align_widget : widget);
- screen = gtk_widget_get_screen (GTK_WIDGET (menu));
- monitor_num = gdk_screen_get_monitor_at_window (screen, window);
- if (monitor_num < 0)
- monitor_num = 0;
- gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
+ display = gtk_widget_get_display (GTK_WIDGET (menu));
+ monitor = gdk_display_get_monitor_at_window (display, window);
+ gdk_monitor_get_workarea (monitor, &workarea);
gtk_widget_get_allocation (priv->align_widget ? priv->align_widget : widget, &allocation);
gtk_widget_get_allocation (widget, &arrow_allocation);
@@ -298,17 +296,17 @@ menu_position_up_down_func (GtkMenu *menu,
else if (menu_allocation.width > allocation.width)
*x -= menu_allocation.width - allocation.width;
- if (priv->arrow_type == GTK_ARROW_UP && *y - menu_allocation.height >= monitor.y)
+ if (priv->arrow_type == GTK_ARROW_UP && *y - menu_allocation.height >= workarea.y)
{
*y -= menu_allocation.height;
}
else
{
- if ((*y + arrow_allocation.height + menu_allocation.height) <= monitor.y + monitor.height)
+ if ((*y + arrow_allocation.height + menu_allocation.height) <= workarea.y + workarea.height)
*y += arrow_allocation.height;
- else if ((*y - menu_allocation.height) >= monitor.y)
+ else if ((*y - menu_allocation.height) >= workarea.y)
*y -= menu_allocation.height;
- else if (monitor.y + monitor.height - (*y + arrow_allocation.height) > *y)
+ else if (workarea.y + workarea.height - (*y + arrow_allocation.height) > *y)
*y += arrow_allocation.height;
else
*y -= menu_allocation.height;
@@ -328,9 +326,9 @@ menu_position_side_func (GtkMenu *menu,
GtkAllocation allocation;
GtkAllocation menu_allocation;
GtkWidget *widget = GTK_WIDGET (menu_button);
- GdkRectangle monitor;
- gint monitor_num;
- GdkScreen *screen;
+ GdkDisplay *display;
+ GdkMonitor *monitor;
+ GdkRectangle workarea;
GdkWindow *window;
GtkAlign align;
GtkTextDirection direction;
@@ -339,11 +337,9 @@ menu_position_side_func (GtkMenu *menu,
direction = gtk_widget_get_direction (widget);
align = gtk_widget_get_valign (GTK_WIDGET (menu));
- screen = gtk_widget_get_screen (GTK_WIDGET (menu));
- monitor_num = gdk_screen_get_monitor_at_window (screen, window);
- if (monitor_num < 0)
- monitor_num = 0;
- gdk_screen_get_monitor_workarea (screen, monitor_num, &monitor);
+ display = gtk_widget_get_display (GTK_WIDGET (menu));
+ monitor = gdk_display_get_monitor_at_window (display, window);
+ gdk_monitor_get_workarea (monitor, &workarea);
gdk_window_get_origin (gtk_button_get_event_window (GTK_BUTTON (menu_button)), x, y);
@@ -354,14 +350,14 @@ menu_position_side_func (GtkMenu *menu,
(priv->arrow_type == GTK_ARROW_LEFT && direction == GTK_TEXT_DIR_RTL))
{
- if (*x + allocation.width + menu_allocation.width <= monitor.x + monitor.width)
+ if (*x + allocation.width + menu_allocation.width <= workarea.x + workarea.width)
*x += allocation.width;
else
*x -= menu_allocation.width;
}
else
{
- if (*x - menu_allocation.width >= monitor.x)
+ if (*x - menu_allocation.width >= workarea.x)
*x -= menu_allocation.width;
else
*x += allocation.width;