summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-13 01:16:16 +0000
committerstuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-13 01:16:16 +0000
commit3d7ab72b0c0a6b43fa69985e6d6b39ec66dac6af (patch)
treecf228416beee46ad98fc37879de8cada7348c394
parent3fc061bf7d66db91ad6e2357420f0e16ffcb3827 (diff)
downloadchromium_src-3d7ab72b0c0a6b43fa69985e6d6b39ec66dac6af.zip
chromium_src-3d7ab72b0c0a6b43fa69985e6d6b39ec66dac6af.tar.gz
chromium_src-3d7ab72b0c0a6b43fa69985e6d6b39ec66dac6af.tar.bz2
Fix Mac window frame coordinate conversion on multiple monitor setups
The same bug exists in our event coordinate conversion code in WebInputEventFactory, so this is half of a two-sided patch; WebKit side is: https://bugs.webkit.org/show_bug.cgi?id=35950 BUG=36621 TEST=In conjuction with the WebKit patch, mouseovers in Carbon plugins will work when the plugin is on a non-primary monitor with a different height than the primary monitor. Review URL: http://codereview.chromium.org/751002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41516 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/automation/automation_provider_mac.mm9
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_mac.mm17
2 files changed, 15 insertions, 11 deletions
diff --git a/chrome/browser/automation/automation_provider_mac.mm b/chrome/browser/automation/automation_provider_mac.mm
index b475f4d..e17d59c 100644
--- a/chrome/browser/automation/automation_provider_mac.mm
+++ b/chrome/browser/automation/automation_provider_mac.mm
@@ -22,10 +22,11 @@ void AutomationProvider::SetWindowBounds(int handle, const gfx::Rect& bounds,
if (window) {
NSRect new_bounds = NSRectFromCGRect(bounds.ToCGRect());
- // This is likely incorrect for a multiple-monitor setup; OK because this
- // is used only for testing purposes.
- new_bounds.origin.y = [[window screen] frame].size.height -
- new_bounds.origin.y - new_bounds.size.height;
+ if ([[NSScreen screens] count] > 0) {
+ new_bounds.origin.y =
+ [[[NSScreen screens] objectAtIndex:0] frame].size.height -
+ new_bounds.origin.y - new_bounds.size.height;
+ }
[window setFrame:new_bounds display:NO];
*success = true;
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 40e9c66..178a670 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm
@@ -600,12 +600,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;
}
@@ -629,7 +632,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() {
@@ -648,7 +651,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) {