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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/automation/automation_provider_mac.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include <QuartzCore/CAOpenGLLayer.h> 5 #include <QuartzCore/CAOpenGLLayer.h>
6 6
7 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h" 7 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h"
8 8
9 #import "base/chrome_application_mac.h" 9 #import "base/chrome_application_mac.h"
10 #include "base/histogram.h" 10 #include "base/histogram.h"
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 } 587 }
588 588
589 void RenderWidgetHostViewMac::ShutdownHost() { 589 void RenderWidgetHostViewMac::ShutdownHost() {
590 shutdown_factory_.RevokeAll(); 590 shutdown_factory_.RevokeAll();
591 render_widget_host_->Shutdown(); 591 render_widget_host_->Shutdown();
592 // Do not touch any members at this point, |this| has been deleted. 592 // Do not touch any members at this point, |this| has been deleted.
593 } 593 }
594 594
595 namespace { 595 namespace {
596 596
597 // Adjusts an NSRect in screen coordinates to have an origin in the upper left, 597 // Adjusts an NSRect in Cocoa screen coordinates to have an origin in the upper
598 // and stuffs it into a gfx::Rect. This is likely incorrect for a multiple- 598 // left of the primary screen (Carbon coordinates), and stuffs it into a
599 // monitor setup. 599 // gfx::Rect.
600 gfx::Rect NSRectToRect(const NSRect rect, NSScreen* screen) { 600 gfx::Rect NSRectToRect(const NSRect rect) {
601 gfx::Rect new_rect(NSRectToCGRect(rect)); 601 gfx::Rect new_rect(NSRectToCGRect(rect));
602 new_rect.set_y([screen frame].size.height - new_rect.y() - new_rect.height()); 602 if ([[NSScreen screens] count] > 0) {
603 new_rect.set_y([[[NSScreen screens] objectAtIndex:0] frame].size.height -
604 new_rect.y() - new_rect.height());
605 }
603 return new_rect; 606 return new_rect;
604 } 607 }
605 608
606 } // namespace 609 } // namespace
607 610
608 gfx::Rect RenderWidgetHostViewMac::GetWindowRect() { 611 gfx::Rect RenderWidgetHostViewMac::GetWindowRect() {
609 // TODO(shess): In case of !window, the view has been removed from 612 // TODO(shess): In case of !window, the view has been removed from
610 // the view hierarchy because the tab isn't main. Could retrieve 613 // the view hierarchy because the tab isn't main. Could retrieve
611 // the information from the main tab for our window. 614 // the information from the main tab for our window.
612 NSWindow* enclosing_window = [cocoa_view_ window]; 615 NSWindow* enclosing_window = [cocoa_view_ window];
613 if (!cocoa_view_ || !enclosing_window) { 616 if (!cocoa_view_ || !enclosing_window) {
614 return gfx::Rect(); 617 return gfx::Rect();
615 } 618 }
616 619
617 // During dragging of a torn-off tab, [cocoa_view_ window] is a floating panel 620 // During dragging of a torn-off tab, [cocoa_view_ window] is a floating panel
618 // attached to the actual browser window that the tab is visually part of; we 621 // attached to the actual browser window that the tab is visually part of; we
619 // want the bounds of the browser window rather than the panel. 622 // want the bounds of the browser window rather than the panel.
620 if ([enclosing_window parentWindow]) 623 if ([enclosing_window parentWindow])
621 enclosing_window = [enclosing_window parentWindow]; 624 enclosing_window = [enclosing_window parentWindow];
622 625
623 NSRect bounds = [cocoa_view_ bounds]; 626 NSRect bounds = [cocoa_view_ bounds];
624 bounds = [cocoa_view_ convertRect:bounds toView:nil]; 627 bounds = [cocoa_view_ convertRect:bounds toView:nil];
625 bounds.origin = [enclosing_window convertBaseToScreen:bounds.origin]; 628 bounds.origin = [enclosing_window convertBaseToScreen:bounds.origin];
626 return NSRectToRect(bounds, [[cocoa_view_ window] screen]); 629 return NSRectToRect(bounds);
627 } 630 }
628 631
629 gfx::Rect RenderWidgetHostViewMac::GetRootWindowRect() { 632 gfx::Rect RenderWidgetHostViewMac::GetRootWindowRect() {
630 // TODO(shess): In case of !window, the view has been removed from 633 // TODO(shess): In case of !window, the view has been removed from
631 // the view hierarchy because the tab isn't main. Could retrieve 634 // the view hierarchy because the tab isn't main. Could retrieve
632 // the information from the main tab for our window. 635 // the information from the main tab for our window.
633 NSWindow* enclosing_window = [cocoa_view_ window]; 636 NSWindow* enclosing_window = [cocoa_view_ window];
634 if (!enclosing_window) { 637 if (!enclosing_window) {
635 return gfx::Rect(); 638 return gfx::Rect();
636 } 639 }
637 640
638 // During dragging of a torn-off tab, [cocoa_view_ window] is a floating panel 641 // During dragging of a torn-off tab, [cocoa_view_ window] is a floating panel
639 // attached to the actual browser window that the tab is visually part of; we 642 // attached to the actual browser window that the tab is visually part of; we
640 // want the bounds of the browser window rather than the panel. 643 // want the bounds of the browser window rather than the panel.
641 if ([enclosing_window parentWindow]) 644 if ([enclosing_window parentWindow])
642 enclosing_window = [enclosing_window parentWindow]; 645 enclosing_window = [enclosing_window parentWindow];
643 646
644 NSRect bounds = [enclosing_window frame]; 647 NSRect bounds = [enclosing_window frame];
645 return NSRectToRect(bounds, [enclosing_window screen]); 648 return NSRectToRect(bounds);
646 } 649 }
647 650
648 void RenderWidgetHostViewMac::SetActive(bool active) { 651 void RenderWidgetHostViewMac::SetActive(bool active) {
649 if (render_widget_host_) 652 if (render_widget_host_)
650 render_widget_host_->SetActive(active); 653 render_widget_host_->SetActive(active);
651 } 654 }
652 655
653 void RenderWidgetHostViewMac::SetWindowVisibility(bool visible) { 656 void RenderWidgetHostViewMac::SetWindowVisibility(bool visible) {
654 if (render_widget_host_) { 657 if (render_widget_host_) {
655 render_widget_host_->Send(new ViewMsg_SetWindowVisibility( 658 render_widget_host_->Send(new ViewMsg_SetWindowVisibility(
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after
1659 } 1662 }
1660 1663
1661 - (void)pasteAsPlainText:(id)sender { 1664 - (void)pasteAsPlainText:(id)sender {
1662 if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { 1665 if (renderWidgetHostView_->render_widget_host_->IsRenderView()) {
1663 static_cast<RenderViewHost*>(renderWidgetHostView_->render_widget_host_)-> 1666 static_cast<RenderViewHost*>(renderWidgetHostView_->render_widget_host_)->
1664 ForwardEditCommand("PasteAndMatchStyle", ""); 1667 ForwardEditCommand("PasteAndMatchStyle", "");
1665 } 1668 }
1666 } 1669 }
1667 1670
1668 @end 1671 @end
OLDNEW
« 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