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

Unified Diff: chrome/browser/renderer_host/render_widget_host_view_mac.mm

Issue 751002: Fix Mac window frame coordinate conversion on multiple monitor setups (Closed)
Patch Set: Fix another instance Created 10 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/automation/automation_provider_mac.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/renderer_host/render_widget_host_view_mac.mm
diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.mm b/chrome/browser/renderer_host/render_widget_host_view_mac.mm
index 079cecd6b12ffa72a9082842291d7ea9fc45a2bb..829ed2e813858598613d0ee1f8af12dafbd851df 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm
@@ -594,12 +594,15 @@ void RenderWidgetHostViewMac::ShutdownHost() {
namespace {
-// Adjusts an NSRect in screen coordinates to have an origin in the upper left,
-// and stuffs it into a gfx::Rect. This is likely incorrect for a multiple-
-// monitor setup.
-gfx::Rect NSRectToRect(const NSRect rect, NSScreen* screen) {
+// Adjusts an NSRect in Cocoa screen coordinates to have an origin in the upper
+// left of the primary screen (Carbon coordinates), and stuffs it into a
+// gfx::Rect.
+gfx::Rect NSRectToRect(const NSRect rect) {
gfx::Rect new_rect(NSRectToCGRect(rect));
- new_rect.set_y([screen frame].size.height - new_rect.y() - new_rect.height());
+ if ([[NSScreen screens] count] > 0) {
+ new_rect.set_y([[[NSScreen screens] objectAtIndex:0] frame].size.height -
+ new_rect.y() - new_rect.height());
+ }
return new_rect;
}
@@ -623,7 +626,7 @@ gfx::Rect RenderWidgetHostViewMac::GetWindowRect() {
NSRect bounds = [cocoa_view_ bounds];
bounds = [cocoa_view_ convertRect:bounds toView:nil];
bounds.origin = [enclosing_window convertBaseToScreen:bounds.origin];
- return NSRectToRect(bounds, [[cocoa_view_ window] screen]);
+ return NSRectToRect(bounds);
}
gfx::Rect RenderWidgetHostViewMac::GetRootWindowRect() {
@@ -642,7 +645,7 @@ gfx::Rect RenderWidgetHostViewMac::GetRootWindowRect() {
enclosing_window = [enclosing_window parentWindow];
NSRect bounds = [enclosing_window frame];
- return NSRectToRect(bounds, [enclosing_window screen]);
+ return NSRectToRect(bounds);
}
void RenderWidgetHostViewMac::SetActive(bool active) {
« no previous file with comments | « chrome/browser/automation/automation_provider_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698