diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-29 21:53:27 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-29 21:53:27 +0000 |
commit | a4c368180132f1f5fc2e57af75115b0d36b542a7 (patch) | |
tree | 44069f6a2e8fbec60b3347736941fd1da20c7a00 /chrome/browser/window_sizer_linux.cc | |
parent | c3b0173e79820fbb5252d873fc14ea70c1132bcc (diff) | |
download | chromium_src-a4c368180132f1f5fc2e57af75115b0d36b542a7.zip chromium_src-a4c368180132f1f5fc2e57af75115b0d36b542a7.tar.gz chromium_src-a4c368180132f1f5fc2e57af75115b0d36b542a7.tar.bz2 |
Fixes a slew of random link/compile errors for views on gtk.
BUG=none
TEST=none
TBR=ben
Review URL: http://codereview.chromium.org/115948
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17246 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/window_sizer_linux.cc')
-rw-r--r-- | chrome/browser/window_sizer_linux.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/chrome/browser/window_sizer_linux.cc b/chrome/browser/window_sizer_linux.cc index fc5fc0d..f8800a7 100644 --- a/chrome/browser/window_sizer_linux.cc +++ b/chrome/browser/window_sizer_linux.cc @@ -8,6 +8,7 @@ #include "base/logging.h" #include "chrome/browser/browser.h" +#include "chrome/browser/browser_list.h" // How much horizontal and vertical offset there is between newly // opened windows. We don't care on Linux since the window manager generally @@ -102,3 +103,26 @@ WindowSizer::MonitorInfoProvider* WindowSizer::CreateDefaultMonitorInfoProvider() { return new DefaultMonitorInfoProvider(); } + +// static +gfx::Point WindowSizer::GetDefaultPopupOrigin(const gfx::Size& size) { + scoped_ptr<MonitorInfoProvider> provider(CreateDefaultMonitorInfoProvider()); + gfx::Rect monitor_bounds = provider->GetPrimaryMonitorWorkArea(); + gfx::Point corner(monitor_bounds.x(), monitor_bounds.y()); + if (Browser* browser = BrowserList::GetLastActive()) { + GtkWindow* window = + reinterpret_cast<GtkWindow*>(browser->window()->GetNativeHandle()); + int x = 0, y = 0; + gtk_window_get_position(window, &x, &y); + // Limit to not overflow the work area right and bottom edges. + gfx::Point limit( + std::min(x + kWindowTilePixels, monitor_bounds.right() - size.width()), + std::min(y + kWindowTilePixels, monitor_bounds.bottom() - size.height())); + // Adjust corner to now overflow the work area left and top edges, so + // that if a popup does not fit the title-bar is remains visible. + corner = gfx::Point( + std::max(corner.x(), limit.x()), + std::max(corner.y(), limit.y())); + } + return corner; +} |