diff options
author | rohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-05 20:07:09 +0000 |
---|---|---|
committer | rohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-05 20:07:09 +0000 |
commit | 1515a1d6e4355ef55dc9ea9e1113d4bf0f8362c9 (patch) | |
tree | f7d4fc045d85c52f03a3d8786694639c723a33b5 /chrome/browser/window_sizer_mac.mm | |
parent | 2f7b27eec08656852564942e09af296a76e6dc1f (diff) | |
download | chromium_src-1515a1d6e4355ef55dc9ea9e1113d4bf0f8362c9.zip chromium_src-1515a1d6e4355ef55dc9ea9e1113d4bf0f8362c9.tar.gz chromium_src-1515a1d6e4355ef55dc9ea9e1113d4bf0f8362c9.tar.bz2 |
[Mac] Implement WindowSizer::GetDefaultPopupOrigin()
BUG=http://crbug.com/30239
TEST=Popups should not appear under the Dock when the Dock is on the left.
Review URL: http://codereview.chromium.org/510001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35548 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/window_sizer_mac.mm')
-rw-r--r-- | chrome/browser/window_sizer_mac.mm | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/chrome/browser/window_sizer_mac.mm b/chrome/browser/window_sizer_mac.mm index aa91211..127fb66 100644 --- a/chrome/browser/window_sizer_mac.mm +++ b/chrome/browser/window_sizer_mac.mm @@ -4,6 +4,9 @@ #import <Cocoa/Cocoa.h> +#include "chrome/browser/browser.h" +#include "chrome/browser/browser_list.h" +#include "chrome/browser/browser_window.h" #include "chrome/browser/window_sizer.h" // How much horizontal and vertical offset there is between newly @@ -116,5 +119,26 @@ WindowSizer::CreateDefaultMonitorInfoProvider() { // static gfx::Point WindowSizer::GetDefaultPopupOrigin(const gfx::Size& size) { - return gfx::Point(0, 0); + NSRect work_area = [[NSScreen mainScreen] visibleFrame]; + NSRect main_area = [[[NSScreen screens] objectAtIndex:0] frame]; + NSPoint corner = NSMakePoint(NSMinX(work_area), NSMaxY(work_area)); + + if (Browser* b = BrowserList::GetLastActive()) { + NSWindow* window = b->window()->GetNativeHandle(); + NSRect window_frame = [window frame]; + + // Limit to not overflow the work area right and bottom edges. + NSPoint limit = NSMakePoint( + std::min(NSMinX(window_frame) + kWindowTilePixels, + NSMaxX(work_area) - size.width()), + std::max(NSMaxY(window_frame) - kWindowTilePixels, + NSMinY(work_area) + 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 = NSMakePoint(std::max(corner.x, limit.x), + std::min(corner.y, limit.y)); + } + + return gfx::Point(corner.x, NSHeight(main_area) - corner.y); } |