[Xfce4-commits] <midori:master> Position the suggestion popup, towards the top if below is too narrow
Christian Dywan
noreply at xfce.org
Sun Jan 31 22:30:02 CET 2010
Updating branch refs/heads/master
to f5489973f5cd6744f3ae35c7fbbdd8e01d5720b0 (commit)
from 4f9d726c5553952e025b68a65cc3424cce6ef73e (commit)
commit f5489973f5cd6744f3ae35c7fbbdd8e01d5720b0
Author: Christian Dywan <christian at twotoasts.de>
Date: Sun Jan 31 22:12:58 2010 +0100
Position the suggestion popup, towards the top if below is too narrow
midori/midori-locationaction.c | 29 +++++++++++++++--------------
1 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/midori/midori-locationaction.c b/midori/midori-locationaction.c
index 59b8d3c..5c75b46 100644
--- a/midori/midori-locationaction.c
+++ b/midori/midori-locationaction.c
@@ -280,22 +280,25 @@ midori_location_action_popup_position (GtkWidget* popup,
gint wx, wy;
GtkRequisition menu_req;
GtkRequisition widget_req;
+ GdkScreen* screen;
+ gint monitor_num;
+ GdkRectangle monitor;
- if (GTK_WIDGET_NO_WINDOW (widget))
- {
- gdk_window_get_position (widget->window, &wx, &wy);
- wx += widget->allocation.x;
- wy += widget->allocation.y;
- }
- else
- gdk_window_get_origin (widget->window, &wx, &wy);
+ gdk_window_get_origin (widget->window, &wx, &wy);
gtk_widget_size_request (popup, &menu_req);
gtk_widget_size_request (widget, &widget_req);
- gtk_window_move (GTK_WINDOW (popup),
- wx, wy + widget_req.height);
- gtk_window_resize (GTK_WINDOW (popup),
- widget->allocation.width, 1);
+ screen = gtk_widget_get_screen (widget);
+ monitor_num = gdk_screen_get_monitor_at_window (screen, widget->window);
+ gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+
+ if (wy + widget_req.height + menu_req.height <= monitor.y + monitor.height
+ || wy - monitor.y < (monitor.y + monitor.height) - (wy + widget_req.height))
+ wy += widget_req.height;
+ else
+ wy -= menu_req.height;
+ gtk_window_move (GTK_WINDOW (popup), wx, wy);
+ gtk_window_resize (GTK_WINDOW (popup), widget->allocation.width, 1);
}
static gboolean
@@ -488,8 +491,6 @@ midori_location_action_popup_timeout_cb (gpointer data)
column = gtk_tree_view_get_column (GTK_TREE_VIEW (action->treeview), 0);
gtk_tree_view_column_cell_get_size (column, NULL, NULL, NULL, NULL, &height);
- /* FIXME: This really should consider monitor geometry */
- /* FIXME: Consider y position versus height */
screen_height = gdk_screen_get_height (gtk_widget_get_screen (action->popup));
height = MIN (matches * height, screen_height / 1.5);
gtk_widget_set_size_request (action->treeview, -1, height);
More information about the Xfce4-commits
mailing list