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

Side by Side Diff: ui/gfx/screen_mac.mm

Issue 667923002: Standardize usage of virtual/override/final in ui/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 | « ui/gfx/render_text_mac.h ('k') | ui/gfx/test/run_all_unittests.cc » ('j') | 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) 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
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 bool IsDIPEnabled() override { 94 bool IsDIPEnabled() override { return true; }
95 return true;
96 }
97 95
98 virtual gfx::Point GetCursorScreenPoint() override { 96 gfx::Point GetCursorScreenPoint() override {
99 NSPoint mouseLocation = [NSEvent mouseLocation]; 97 NSPoint mouseLocation = [NSEvent mouseLocation];
100 // Flip coordinates to gfx (0,0 in top-left corner) using primary screen. 98 // Flip coordinates to gfx (0,0 in top-left corner) using primary screen.
101 NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; 99 NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
102 mouseLocation.y = NSMaxY([screen frame]) - mouseLocation.y; 100 mouseLocation.y = NSMaxY([screen frame]) - mouseLocation.y;
103 return gfx::Point(mouseLocation.x, mouseLocation.y); 101 return gfx::Point(mouseLocation.x, mouseLocation.y);
104 } 102 }
105 103
106 virtual gfx::NativeWindow GetWindowUnderCursor() override { 104 gfx::NativeWindow GetWindowUnderCursor() override {
107 NOTIMPLEMENTED(); 105 NOTIMPLEMENTED();
108 return gfx::NativeWindow(); 106 return gfx::NativeWindow();
109 } 107 }
110 108
111 virtual gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) 109 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override {
112 override {
113 NOTIMPLEMENTED(); 110 NOTIMPLEMENTED();
114 return gfx::NativeWindow(); 111 return gfx::NativeWindow();
115 } 112 }
116 113
117 virtual int GetNumDisplays() const override { 114 int GetNumDisplays() const override { return GetAllDisplays().size(); }
118 return GetAllDisplays().size();
119 115
120 } 116 std::vector<gfx::Display> GetAllDisplays() const override {
121
122 virtual std::vector<gfx::Display> GetAllDisplays() const override {
123 return displays_; 117 return displays_;
124 } 118 }
125 119
126 virtual gfx::Display GetDisplayNearestWindow( 120 gfx::Display GetDisplayNearestWindow(gfx::NativeView view) const override {
127 gfx::NativeView view) const override {
128 NSWindow* window = nil; 121 NSWindow* window = nil;
129 #if !defined(USE_AURA) 122 #if !defined(USE_AURA)
130 if (view) 123 if (view)
131 window = [view window]; 124 window = [view window];
132 #endif 125 #endif
133 if (!window) 126 if (!window)
134 return GetPrimaryDisplay(); 127 return GetPrimaryDisplay();
135 NSScreen* match_screen = [window screen]; 128 NSScreen* match_screen = [window screen];
136 if (!match_screen) 129 if (!match_screen)
137 return GetPrimaryDisplay(); 130 return GetPrimaryDisplay();
138 return GetDisplayForScreen(match_screen); 131 return GetDisplayForScreen(match_screen);
139 } 132 }
140 133
141 virtual gfx::Display GetDisplayNearestPoint( 134 gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const override {
142 const gfx::Point& point) const override {
143 NSPoint ns_point = NSPointFromCGPoint(point.ToCGPoint()); 135 NSPoint ns_point = NSPointFromCGPoint(point.ToCGPoint());
144 136
145 NSArray* screens = [NSScreen screens]; 137 NSArray* screens = [NSScreen screens];
146 NSScreen* primary = [screens objectAtIndex:0]; 138 NSScreen* primary = [screens objectAtIndex:0];
147 ns_point.y = NSMaxY([primary frame]) - ns_point.y; 139 ns_point.y = NSMaxY([primary frame]) - ns_point.y;
148 for (NSScreen* screen in screens) { 140 for (NSScreen* screen in screens) {
149 if (NSMouseInRect(ns_point, [screen frame], NO)) 141 if (NSMouseInRect(ns_point, [screen frame], NO))
150 return GetDisplayForScreen(screen); 142 return GetDisplayForScreen(screen);
151 } 143 }
152 return GetPrimaryDisplay(); 144 return GetPrimaryDisplay();
153 } 145 }
154 146
155 // Returns the display that most closely intersects the provided bounds. 147 // Returns the display that most closely intersects the provided bounds.
156 virtual gfx::Display GetDisplayMatching( 148 gfx::Display GetDisplayMatching(const gfx::Rect& match_rect) const override {
157 const gfx::Rect& match_rect) const override {
158 NSScreen* match_screen = GetMatchingScreen(match_rect); 149 NSScreen* match_screen = GetMatchingScreen(match_rect);
159 return GetDisplayForScreen(match_screen); 150 return GetDisplayForScreen(match_screen);
160 } 151 }
161 152
162 // Returns the primary display. 153 // Returns the primary display.
163 virtual gfx::Display GetPrimaryDisplay() const override { 154 gfx::Display GetPrimaryDisplay() const override {
164 // Primary display is defined as the display with the menubar, 155 // Primary display is defined as the display with the menubar,
165 // which is always at index 0. 156 // which is always at index 0.
166 NSScreen* primary = [[NSScreen screens] objectAtIndex:0]; 157 NSScreen* primary = [[NSScreen screens] objectAtIndex:0];
167 gfx::Display display = GetDisplayForScreen(primary); 158 gfx::Display display = GetDisplayForScreen(primary);
168 return display; 159 return display;
169 } 160 }
170 161
171 virtual void AddObserver(gfx::DisplayObserver* observer) override { 162 void AddObserver(gfx::DisplayObserver* observer) override {
172 change_notifier_.AddObserver(observer); 163 change_notifier_.AddObserver(observer);
173 } 164 }
174 165
175 virtual void RemoveObserver(gfx::DisplayObserver* observer) override { 166 void RemoveObserver(gfx::DisplayObserver* observer) override {
176 change_notifier_.RemoveObserver(observer); 167 change_notifier_.RemoveObserver(observer);
177 } 168 }
178 169
179 static void DisplayReconfigurationCallBack(CGDirectDisplayID display, 170 static void DisplayReconfigurationCallBack(CGDirectDisplayID display,
180 CGDisplayChangeSummaryFlags flags, 171 CGDisplayChangeSummaryFlags flags,
181 void* userInfo) { 172 void* userInfo) {
182 if (flags & kCGDisplayBeginConfigurationFlag) 173 if (flags & kCGDisplayBeginConfigurationFlag)
183 return; 174 return;
184 175
185 static_cast<ScreenMac*>(userInfo)->HandleDisplayReconfiguration(); 176 static_cast<ScreenMac*>(userInfo)->HandleDisplayReconfiguration();
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 266
276 namespace gfx { 267 namespace gfx {
277 268
278 #if !defined(USE_AURA) 269 #if !defined(USE_AURA)
279 Screen* CreateNativeScreen() { 270 Screen* CreateNativeScreen() {
280 return new ScreenMac; 271 return new ScreenMac;
281 } 272 }
282 #endif 273 #endif
283 274
284 } 275 }
OLDNEW
« no previous file with comments | « ui/gfx/render_text_mac.h ('k') | ui/gfx/test/run_all_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698