summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/menu_gtk.cc
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-17 18:23:26 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-17 18:23:26 +0000
commit4ac582aeccbc08f8304c8fb5491b882ab7f97e8f (patch)
treeb79b280d409cebb2bd51425690d4315fb37e9ec8 /chrome/browser/gtk/menu_gtk.cc
parent01f829ab3cc802b79942f5a988f6a72e7a2b594d (diff)
downloadchromium_src-4ac582aeccbc08f8304c8fb5491b882ab7f97e8f.zip
chromium_src-4ac582aeccbc08f8304c8fb5491b882ab7f97e8f.tar.gz
chromium_src-4ac582aeccbc08f8304c8fb5491b882ab7f97e8f.tar.bz2
gtk: Fix menu display logic for people with top/down xinerama setups.
BUG=14184 TEST=see bug Review URL: http://codereview.chromium.org/1026006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41855 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/menu_gtk.cc')
-rw-r--r--chrome/browser/gtk/menu_gtk.cc16
1 files changed, 9 insertions, 7 deletions
diff --git a/chrome/browser/gtk/menu_gtk.cc b/chrome/browser/gtk/menu_gtk.cc
index 67d7208..3b77e9a 100644
--- a/chrome/browser/gtk/menu_gtk.cc
+++ b/chrome/browser/gtk/menu_gtk.cc
@@ -440,13 +440,15 @@ void MenuGtk::WidgetMenuPositionFunc(GtkMenu* menu,
if (!start_align)
*x += widget->allocation.width - menu_req.width;
- // If the menu would run off the bottom of the screen, and there is more
- // screen space up than down, then pop upwards. Also move the anchor point
- // to the top of the widget rather than the bottom.
- if (*y + menu_req.height >= screen_rect.height &&
- *y > screen_rect.height / 2) {
- *y -= menu_req.height + widget->allocation.height;
- }
+ // If the menu would run off the bottom of the screen, and there is enough
+ // screen space upwards to accommodate the menu, then pop upwards. Also move
+ // the anchor point to the top of the widget rather than the bottom.
+ const int screen_top = screen_rect.y;
+ const int screen_bottom = screen_rect.y + screen_rect.height;
+ const int menu_bottom = *y + menu_req.height;
+ const int alternate_y = *y - (menu_req.height + widget->allocation.height);
+ if (menu_bottom >= screen_bottom && alternate_y >= screen_top)
+ *y = alternate_y;
*push_in = FALSE;
}