[gtk+] treeview: Stop using screen width/height
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] treeview: Stop using screen width/height
- Date: Thu, 28 Apr 2016 03:19:54 +0000 (UTC)
commit 6ae2c24bdef30b743965afe9e9cc9556c0001eff
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Apr 10 23:44:28 2016 -0400
treeview: Stop using screen width/height
Popups should always be placed relative to a monitor.
gtk/gtktreeview.c | 24 +++++++++++++++---------
1 files changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 98d3165..dfa9232 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -15066,28 +15066,34 @@ gtk_tree_view_search_position_func (GtkTreeView *tree_view,
gint x, y;
gint tree_x, tree_y;
gint tree_width, tree_height;
- GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (tree_view));
+ GdkDisplay *display;
+ GdkMonitor *monitor;
+ GdkRectangle workarea;
GdkWindow *tree_window = gtk_widget_get_window (GTK_WIDGET (tree_view));
GtkRequisition requisition;
gtk_widget_realize (search_window);
+ display = gtk_widget_get_display (GTK_WIDGET (tree_view));
+ monitor = gdk_display_get_monitor_at_window (display, tree_window);
+ gdk_monitor_get_workarea (monitor, &workarea);
+
gdk_window_get_origin (tree_window, &tree_x, &tree_y);
tree_width = gdk_window_get_width (tree_window);
tree_height = gdk_window_get_height (tree_window);
gtk_widget_get_preferred_size (search_window, &requisition, NULL);
- if (tree_x + tree_width > gdk_screen_get_width (screen))
- x = gdk_screen_get_width (screen) - requisition.width;
- else if (tree_x + tree_width - requisition.width < 0)
- x = 0;
+ if (tree_x + tree_width > workarea.x + workarea.width)
+ x = workarea.x + workarea.width - requisition.width;
+ else if (tree_x + tree_width - requisition.width < workarea.x)
+ x = workarea.x;
else
x = tree_x + tree_width - requisition.width;
- if (tree_y + tree_height + requisition.height > gdk_screen_get_height (screen))
- y = gdk_screen_get_height (screen) - requisition.height;
- else if (tree_y + tree_height < 0) /* isn't really possible ... */
- y = 0;
+ if (tree_y + tree_height + requisition.height > workarea.y + workarea.height)
+ y = workarea.y + workarea.height - requisition.height;
+ else if (tree_y + tree_height < workarea.y) /* isn't really possible ... */
+ y = workarea.y;
else
y = tree_y + tree_height;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]