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 gfx::Point GetCursorScreenPoint() override { | 99 gfx::Point GetCursorScreenPoint() override { |
95 NSPoint mouseLocation = [NSEvent mouseLocation]; | 100 NSPoint mouseLocation = [NSEvent mouseLocation]; |
96 // Flip coordinates to gfx (0,0 in top-left corner) using primary screen. | 101 // Flip coordinates to gfx (0,0 in top-left corner) using primary screen. |
97 NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; | 102 NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; |
98 mouseLocation.y = NSMaxY([screen frame]) - mouseLocation.y; | 103 mouseLocation.y = NSMaxY([screen frame]) - mouseLocation.y; |
99 return gfx::Point(mouseLocation.x, mouseLocation.y); | 104 return gfx::Point(mouseLocation.x, mouseLocation.y); |
100 } | 105 } |
101 | 106 |
102 gfx::NativeWindow GetWindowUnderCursor() override { | 107 gfx::NativeWindow GetWindowUnderCursor() override { |
103 NOTIMPLEMENTED(); | 108 NOTIMPLEMENTED(); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 | 269 |
265 namespace gfx { | 270 namespace gfx { |
266 | 271 |
267 #if !defined(USE_AURA) | 272 #if !defined(USE_AURA) |
268 Screen* CreateNativeScreen() { | 273 Screen* CreateNativeScreen() { |
269 return new ScreenMac; | 274 return new ScreenMac; |
270 } | 275 } |
271 #endif | 276 #endif |
272 | 277 |
273 } | 278 } |
OLD | NEW |