OLD | NEW |
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 "ui/gfx/screen.h" | 5 #include "ui/gfx/screen.h" |
6 | 6 |
7 #import <ApplicationServices/ApplicationServices.h> | 7 #import <ApplicationServices/ApplicationServices.h> |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 class ScreenMac : public gfx::Screen { | 85 class ScreenMac : public gfx::Screen { |
86 public: | 86 public: |
87 ScreenMac() { | 87 ScreenMac() { |
88 displays_ = BuildDisplaysFromQuartz(); | 88 displays_ = BuildDisplaysFromQuartz(); |
89 | 89 |
90 CGDisplayRegisterReconfigurationCallback( | 90 CGDisplayRegisterReconfigurationCallback( |
91 ScreenMac::DisplayReconfigurationCallBack, this); | 91 ScreenMac::DisplayReconfigurationCallBack, this); |
92 } | 92 } |
93 | 93 |
| 94 virtual ~ScreenMac() { |
| 95 CGDisplayRemoveReconfigurationCallback( |
| 96 ScreenMac::DisplayReconfigurationCallBack, this); |
| 97 } |
| 98 |
94 virtual bool IsDIPEnabled() OVERRIDE { | 99 virtual bool IsDIPEnabled() OVERRIDE { |
95 return true; | 100 return true; |
96 } | 101 } |
97 | 102 |
98 virtual gfx::Point GetCursorScreenPoint() OVERRIDE { | 103 virtual gfx::Point GetCursorScreenPoint() OVERRIDE { |
99 NSPoint mouseLocation = [NSEvent mouseLocation]; | 104 NSPoint mouseLocation = [NSEvent mouseLocation]; |
100 // Flip coordinates to gfx (0,0 in top-left corner) using primary screen. | 105 // Flip coordinates to gfx (0,0 in top-left corner) using primary screen. |
101 NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; | 106 NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; |
102 mouseLocation.y = NSMaxY([screen frame]) - mouseLocation.y; | 107 mouseLocation.y = NSMaxY([screen frame]) - mouseLocation.y; |
103 return gfx::Point(mouseLocation.x, mouseLocation.y); | 108 return gfx::Point(mouseLocation.x, mouseLocation.y); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 | 280 |
276 namespace gfx { | 281 namespace gfx { |
277 | 282 |
278 #if !defined(USE_AURA) | 283 #if !defined(USE_AURA) |
279 Screen* CreateNativeScreen() { | 284 Screen* CreateNativeScreen() { |
280 return new ScreenMac; | 285 return new ScreenMac; |
281 } | 286 } |
282 #endif | 287 #endif |
283 | 288 |
284 } | 289 } |
OLD | NEW |