summaryrefslogtreecommitdiff
path: root/gtk/gtktoolbar.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2005-08-15 16:36:31 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2005-08-15 16:36:31 +0000
commit24a55633ce7180ab51772bb11e05e5f0e9345f6e (patch)
tree8230ac3edc1fa52fa38ea9a388b879f72f152e47 /gtk/gtktoolbar.c
parentc92959a4485fa1d09404fcc21a17672c565a69e1 (diff)
downloadgtk+-24a55633ce7180ab51772bb11e05e5f0e9345f6e.tar.gz
Add some more tests for menu placement.
2005-08-15 Matthias Clasen <mclasen@redhat.com> * tests/testtoolbar.c: Add some more tests for menu placement. * gtk/gtkmenutoolbutton.c (menu_position_func): * gtk/gtktoolbar.c (menu_position_func): Improve positioning of toolbutton menus and of the overflow menu. (#312937, #153870, Christian Persch, Paolo Borelli)
Diffstat (limited to 'gtk/gtktoolbar.c')
-rw-r--r--gtk/gtktoolbar.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c
index a567357d64..db6551cbf0 100644
--- a/gtk/gtktoolbar.c
+++ b/gtk/gtktoolbar.c
@@ -2538,18 +2538,35 @@ menu_position_func (GtkMenu *menu,
GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
GtkRequisition req;
GtkRequisition menu_req;
+ GdkRectangle monitor;
+ gint monitor_num;
+ GdkScreen *screen;
- gdk_window_get_origin (GTK_BUTTON (priv->arrow_button)->event_window, x, y);
gtk_widget_size_request (priv->arrow_button, &req);
gtk_widget_size_request (GTK_WIDGET (menu), &menu_req);
+ screen = gtk_widget_get_screen (GTK_WIDGET (menu));
+ monitor_num = gdk_screen_get_monitor_at_window (screen, priv->arrow_button->window);
+ if (monitor_num < 0)
+ monitor_num = 0;
+ gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+
+ gdk_window_get_origin (GTK_BUTTON (priv->arrow_button)->event_window, x, y);
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
{
- *y += priv->arrow_button->allocation.height;
if (gtk_widget_get_direction (GTK_WIDGET (toolbar)) == GTK_TEXT_DIR_LTR)
*x += priv->arrow_button->allocation.width - req.width;
else
*x += req.width - menu_req.width;
+
+ if ((*y + priv->arrow_button->allocation.height + menu_req.height) <= monitor.y + monitor.height)
+ *y += priv->arrow_button->allocation.height;
+ else if ((*y - menu_req.height) >= monitor.y)
+ *y -= menu_req.height;
+ else if (monitor.y + monitor.height - (*y + priv->arrow_button->allocation.height) > *y)
+ *y += priv->arrow_button->allocation.height;
+ else
+ *y -= menu_req.height;
}
else
{
@@ -2557,10 +2574,13 @@ menu_position_func (GtkMenu *menu,
*x += priv->arrow_button->allocation.width;
else
*x -= menu_req.width;
- *y += priv->arrow_button->allocation.height - req.height;
+
+ if (*y + menu_req.height > monitor.y + monitor.height &&
+ *y + priv->arrow_button->allocation.height - monitor.y > monitor.y + monitor.height - *y)
+ *y += priv->arrow_button->allocation.height - menu_req.height;
}
-
- *push_in = TRUE;
+
+ *push_in = FALSE;
}
static void