forked from AuroraMiddleware/gtk
treeview: Stop using screen width/height
Popups should always be placed relative to a monitor.
This commit is contained in:
parent
29396a1e5e
commit
6ae2c24bde
@ -15066,28 +15066,34 @@ gtk_tree_view_search_position_func (GtkTreeView *tree_view,
|
|||||||
gint x, y;
|
gint x, y;
|
||||||
gint tree_x, tree_y;
|
gint tree_x, tree_y;
|
||||||
gint tree_width, tree_height;
|
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));
|
GdkWindow *tree_window = gtk_widget_get_window (GTK_WIDGET (tree_view));
|
||||||
GtkRequisition requisition;
|
GtkRequisition requisition;
|
||||||
|
|
||||||
gtk_widget_realize (search_window);
|
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);
|
gdk_window_get_origin (tree_window, &tree_x, &tree_y);
|
||||||
tree_width = gdk_window_get_width (tree_window);
|
tree_width = gdk_window_get_width (tree_window);
|
||||||
tree_height = gdk_window_get_height (tree_window);
|
tree_height = gdk_window_get_height (tree_window);
|
||||||
gtk_widget_get_preferred_size (search_window, &requisition, NULL);
|
gtk_widget_get_preferred_size (search_window, &requisition, NULL);
|
||||||
|
|
||||||
if (tree_x + tree_width > gdk_screen_get_width (screen))
|
if (tree_x + tree_width > workarea.x + workarea.width)
|
||||||
x = gdk_screen_get_width (screen) - requisition.width;
|
x = workarea.x + workarea.width - requisition.width;
|
||||||
else if (tree_x + tree_width - requisition.width < 0)
|
else if (tree_x + tree_width - requisition.width < workarea.x)
|
||||||
x = 0;
|
x = workarea.x;
|
||||||
else
|
else
|
||||||
x = tree_x + tree_width - requisition.width;
|
x = tree_x + tree_width - requisition.width;
|
||||||
|
|
||||||
if (tree_y + tree_height + requisition.height > gdk_screen_get_height (screen))
|
if (tree_y + tree_height + requisition.height > workarea.y + workarea.height)
|
||||||
y = gdk_screen_get_height (screen) - requisition.height;
|
y = workarea.y + workarea.height - requisition.height;
|
||||||
else if (tree_y + tree_height < 0) /* isn't really possible ... */
|
else if (tree_y + tree_height < workarea.y) /* isn't really possible ... */
|
||||||
y = 0;
|
y = workarea.y;
|
||||||
else
|
else
|
||||||
y = tree_y + tree_height;
|
y = tree_y + tree_height;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user