summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-05 00:57:09 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-05 00:57:09 +0000
commit321539f84acd68316617fa658be4e4ce3ff517f3 (patch)
tree1102c13c20c149757be0898cdb8211ce0343dcec /chrome/browser/gtk
parent6ba2ec2e23f79f1882263a4fb1cd12efc0651e88 (diff)
downloadchromium_src-321539f84acd68316617fa658be4e4ce3ff517f3.zip
chromium_src-321539f84acd68316617fa658be4e4ce3ff517f3.tar.gz
chromium_src-321539f84acd68316617fa658be4e4ce3ff517f3.tar.bz2
Constrain the gtk menu popup to the bounds of the current monitor.
Review URL: http://codereview.chromium.org/106001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15262 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r--chrome/browser/gtk/menu_gtk.cc13
1 files changed, 9 insertions, 4 deletions
diff --git a/chrome/browser/gtk/menu_gtk.cc b/chrome/browser/gtk/menu_gtk.cc
index 0b2bda0..0ac4cdd 100644
--- a/chrome/browser/gtk/menu_gtk.cc
+++ b/chrome/browser/gtk/menu_gtk.cc
@@ -247,6 +247,13 @@ void MenuGtk::MenuPositionFunc(GtkMenu* menu,
gtk_widget_size_request(GTK_WIDGET(menu), &menu_req);
gdk_window_get_origin(widget->window, x, y);
+ GdkScreen *screen = gtk_widget_get_screen(widget);
+ gint monitor = gdk_screen_get_monitor_at_point(screen, *x, *y);
+
+ GdkRectangle screen_rect;
+ gdk_screen_get_monitor_geometry(screen, monitor,
+ &screen_rect);
+
*x += widget->allocation.x;
*y += widget->allocation.y + widget->allocation.height;
@@ -256,11 +263,9 @@ void MenuGtk::MenuPositionFunc(GtkMenu* menu,
if (!g_object_get_data(G_OBJECT(widget), "left-align-popup"))
*x += widget->allocation.width - menu_req.width;
- // TODO(erg): Deal with this scrolling off the bottom of the screen.
+ if (*y + menu_req.height >= screen_rect.height)
+ *y -= menu_req.height;
- // Regretfully, we can't rely on push_in to alter the coordinates above to
- // always make the menu fit on screen. It'd make the above calculations just
- // work though...
*push_in = FALSE;
}