[gtk+] label: Stop using screen width/height
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] label: Stop using screen width/height
- Date: Thu, 28 Apr 2016 03:19:49 +0000 (UTC)
commit 29396a1e5eb354010cba627b8a49b3ca2f4b776d
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Apr 10 23:43:34 2016 -0400
label: Stop using screen width/height
Popups should always be placed relative to a monitor.
gtk/gtklabel.c | 18 +++++++++++-------
1 files changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 6464157..6498a3b 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -6560,31 +6560,35 @@ popup_position_func (GtkMenu *menu,
GtkWidget *widget;
GtkAllocation allocation;
GtkRequisition req;
- GdkScreen *screen;
+ GdkDisplay *display;
+ GdkMonitor *monitor;
+ GdkRectangle workarea;
label = GTK_LABEL (user_data);
widget = GTK_WIDGET (label);
g_return_if_fail (gtk_widget_get_realized (widget));
- screen = gtk_widget_get_screen (widget);
- gdk_window_get_origin (gtk_widget_get_window (widget), x, y);
+ 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);
+ gdk_window_get_origin (gtk_widget_get_window (widget), x, y);
gtk_widget_get_allocation (widget, &allocation);
*x += allocation.x;
*y += allocation.y;
- gtk_widget_get_preferred_size (GTK_WIDGET (menu),
- &req, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);
gtk_widget_get_allocation (widget, &allocation);
*x += allocation.width / 2;
*y += allocation.height;
- *x = CLAMP (*x, 0, MAX (0, gdk_screen_get_width (screen) - req.width));
- *y = CLAMP (*y, 0, MAX (0, gdk_screen_get_height (screen) - req.height));
+ *x = CLAMP (*x, 0, MAX (0, workarea.width - req.width));
+ *y = CLAMP (*y, 0, MAX (0, workarea.height - req.height));
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]