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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 341983008: Listen to Display reconfiguration and notify DisplayObservers on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mac_display
Patch Set: plug to RWHVMac Created 6 years, 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_view_mac.h" 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h"
6 6
7 #import <objc/runtime.h> 7 #import <objc/runtime.h>
8 #include <OpenGL/gl.h> 8 #include <OpenGL/gl.h>
9 #include <QuartzCore/QuartzCore.h> 9 #include <QuartzCore/QuartzCore.h>
10 10
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 initWithRenderWidgetHostViewMac:this] autorelease]; 488 initWithRenderWidgetHostViewMac:this] autorelease];
489 489
490 background_layer_.reset([[CALayer alloc] init]); 490 background_layer_.reset([[CALayer alloc] init]);
491 [background_layer_ 491 [background_layer_
492 setBackgroundColor:CGColorGetConstantColor(kCGColorWhite)]; 492 setBackgroundColor:CGColorGetConstantColor(kCGColorWhite)];
493 [background_layer_ setGeometryFlipped:YES]; 493 [background_layer_ setGeometryFlipped:YES];
494 [background_layer_ setContentsGravity:kCAGravityTopLeft]; 494 [background_layer_ setContentsGravity:kCAGravityTopLeft];
495 [cocoa_view_ setLayer:background_layer_]; 495 [cocoa_view_ setLayer:background_layer_];
496 [cocoa_view_ setWantsLayer:YES]; 496 [cocoa_view_ setWantsLayer:YES];
497 497
498 gfx::Screen::GetScreenFor(cocoa_view_)->AddObserver(this);
499
498 render_widget_host_->SetView(this); 500 render_widget_host_->SetView(this);
499 } 501 }
500 502
501 RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { 503 RenderWidgetHostViewMac::~RenderWidgetHostViewMac() {
504 gfx::Screen::GetScreenFor(cocoa_view_)->RemoveObserver(this);
505
502 // This is being called from |cocoa_view_|'s destructor, so invalidate the 506 // This is being called from |cocoa_view_|'s destructor, so invalidate the
503 // pointer. 507 // pointer.
504 cocoa_view_ = nil; 508 cocoa_view_ = nil;
505 509
506 UnlockMouse(); 510 UnlockMouse();
507 511
508 // Make sure that the layer doesn't reach into the now-invalid object. 512 // Make sure that the layer doesn't reach into the now-invalid object.
509 DestroyCompositedIOSurfaceAndLayer(); 513 DestroyCompositedIOSurfaceAndLayer();
510 DestroySoftwareLayer(); 514 DestroySoftwareLayer();
511 515
(...skipping 1779 matching lines...) Expand 10 before | Expand all | Expand 10 after
2291 void RenderWidgetHostViewMac::AcceleratedLayerDidDrawFrame(bool succeeded) { 2295 void RenderWidgetHostViewMac::AcceleratedLayerDidDrawFrame(bool succeeded) {
2292 if (!render_widget_host_) 2296 if (!render_widget_host_)
2293 return; 2297 return;
2294 2298
2295 SendPendingLatencyInfoToHost(); 2299 SendPendingLatencyInfoToHost();
2296 SendPendingSwapAck(); 2300 SendPendingSwapAck();
2297 if (!succeeded) 2301 if (!succeeded)
2298 GotAcceleratedCompositingError(); 2302 GotAcceleratedCompositingError();
2299 } 2303 }
2300 2304
2305 ////////////////////////////////////////////////////////////////////////////////
2306 // gfx::DisplayObserver, public:
2307
2308 void RenderWidgetHostViewMac::OnDisplayAdded(const gfx::Display& display) {
2309 }
2310
2311 void RenderWidgetHostViewMac::OnDisplayRemoved(const gfx::Display& display) {
2312 }
2313
2314 void RenderWidgetHostViewMac::OnDisplayMetricsChanged(
2315 const gfx::Display& display, uint32_t metrics) {
2316 gfx::Screen* screen = gfx::Screen::GetScreenFor(cocoa_view_);
2317 if (display.id() != screen->GetDisplayNearestWindow(cocoa_view_).id())
2318 return;
2319
2320 UpdateScreenInfo(cocoa_view_);
2321 }
2322
2301 } // namespace content 2323 } // namespace content
2302 2324
2303 // RenderWidgetHostViewCocoa --------------------------------------------------- 2325 // RenderWidgetHostViewCocoa ---------------------------------------------------
2304 2326
2305 @implementation RenderWidgetHostViewCocoa 2327 @implementation RenderWidgetHostViewCocoa
2306 @synthesize selectedRange = selectedRange_; 2328 @synthesize selectedRange = selectedRange_;
2307 @synthesize suppressNextEscapeKeyUp = suppressNextEscapeKeyUp_; 2329 @synthesize suppressNextEscapeKeyUp = suppressNextEscapeKeyUp_;
2308 @synthesize markedRange = markedRange_; 2330 @synthesize markedRange = markedRange_;
2309 2331
2310 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r { 2332 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r {
(...skipping 1662 matching lines...) Expand 10 before | Expand all | Expand 10 after
3973 3995
3974 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding 3996 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding
3975 // regions that are not draggable. (See ControlRegionView in 3997 // regions that are not draggable. (See ControlRegionView in
3976 // native_app_window_cocoa.mm). This requires the render host view to be 3998 // native_app_window_cocoa.mm). This requires the render host view to be
3977 // draggable by default. 3999 // draggable by default.
3978 - (BOOL)mouseDownCanMoveWindow { 4000 - (BOOL)mouseDownCanMoveWindow {
3979 return YES; 4001 return YES;
3980 } 4002 }
3981 4003
3982 @end 4004 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698