Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1533)

Side by Side Diff: chrome/browser/window_sizer_mac.mm

Issue 510001: [Mac] Implement WindowSizer::GetDefaultPopupOrigin()... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/cocoa/browser_window_controller.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #include "chrome/browser/browser.h"
8 #include "chrome/browser/browser_list.h"
9 #include "chrome/browser/browser_window.h"
7 #include "chrome/browser/window_sizer.h" 10 #include "chrome/browser/window_sizer.h"
8 11
9 // How much horizontal and vertical offset there is between newly 12 // How much horizontal and vertical offset there is between newly
10 // opened windows. 13 // opened windows.
11 const int WindowSizer::kWindowTilePixels = 22; 14 const int WindowSizer::kWindowTilePixels = 22;
12 15
13 namespace { 16 namespace {
14 17
15 class DefaultMonitorInfoProvider : public WindowSizer::MonitorInfoProvider { 18 class DefaultMonitorInfoProvider : public WindowSizer::MonitorInfoProvider {
16 public: 19 public:
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 } // namespace 112 } // namespace
110 113
111 // static 114 // static
112 WindowSizer::MonitorInfoProvider* 115 WindowSizer::MonitorInfoProvider*
113 WindowSizer::CreateDefaultMonitorInfoProvider() { 116 WindowSizer::CreateDefaultMonitorInfoProvider() {
114 return new DefaultMonitorInfoProvider(); 117 return new DefaultMonitorInfoProvider();
115 } 118 }
116 119
117 // static 120 // static
118 gfx::Point WindowSizer::GetDefaultPopupOrigin(const gfx::Size& size) { 121 gfx::Point WindowSizer::GetDefaultPopupOrigin(const gfx::Size& size) {
119 return gfx::Point(0, 0); 122 NSRect work_area = [[NSScreen mainScreen] visibleFrame];
123 NSRect main_area = [[[NSScreen screens] objectAtIndex:0] frame];
124 NSPoint corner = NSMakePoint(NSMinX(work_area), NSMaxY(work_area));
125
126 if (Browser* b = BrowserList::GetLastActive()) {
127 NSWindow* window = b->window()->GetNativeHandle();
128 NSRect window_frame = [window frame];
129
130 // Limit to not overflow the work area right and bottom edges.
131 NSPoint limit = NSMakePoint(
132 std::min(NSMinX(window_frame) + kWindowTilePixels,
133 NSMaxX(work_area) - size.width()),
134 std::max(NSMaxY(window_frame) - kWindowTilePixels,
135 NSMinY(work_area) + size.height()));
136
137 // Adjust corner to now overflow the work area left and top edges, so
138 // that if a popup does not fit the title-bar is remains visible.
139 corner = NSMakePoint(std::max(corner.x, limit.x),
140 std::min(corner.y, limit.y));
141 }
142
143 return gfx::Point(corner.x, NSHeight(main_area) - corner.y);
120 } 144 }
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/browser_window_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698