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

Side by Side Diff: ui/display/mac/screen_mac.mm

Issue 2751833004: Reland "Add display::GetDisplayNearestView" (Closed)
Patch Set: Created 3 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 | « ui/display/ios/screen_ios.mm ('k') | ui/display/screen.h » ('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/display/screen.h" 5 #include "ui/display/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 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 NOTIMPLEMENTED(); 146 NOTIMPLEMENTED();
147 return gfx::NativeWindow(); 147 return gfx::NativeWindow();
148 } 148 }
149 149
150 int GetNumDisplays() const override { return GetAllDisplays().size(); } 150 int GetNumDisplays() const override { return GetAllDisplays().size(); }
151 151
152 const std::vector<Display>& GetAllDisplays() const override { 152 const std::vector<Display>& GetAllDisplays() const override {
153 return displays_; 153 return displays_;
154 } 154 }
155 155
156 Display GetDisplayNearestWindow(gfx::NativeView view) const override { 156 Display GetDisplayNearestWindow(gfx::NativeWindow window) const override {
157 EnsureDisplaysValid(); 157 EnsureDisplaysValid();
158 if (displays_.size() == 1) 158 if (displays_.size() == 1)
159 return displays_[0]; 159 return displays_[0];
160 160
161 NSWindow* window = nil;
162 #if !defined(USE_AURA)
163 if (view)
164 window = [view window];
165 #endif
166 if (!window) 161 if (!window)
167 return GetPrimaryDisplay(); 162 return GetPrimaryDisplay();
168 163
169 // Note the following line calls -[NSWindow 164 // Note the following line calls -[NSWindow
170 // _bestScreenBySpaceAssignmentOrGeometry] which is quite expensive and 165 // _bestScreenBySpaceAssignmentOrGeometry] which is quite expensive and
171 // performs IPC with the window server process. 166 // performs IPC with the window server process.
172 NSScreen* match_screen = [window screen]; 167 NSScreen* match_screen = [window screen];
173 168
174 if (!match_screen) 169 if (!match_screen)
175 return GetPrimaryDisplay(); 170 return GetPrimaryDisplay();
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 // The timer to delay configuring outputs and notifying observers. 317 // The timer to delay configuring outputs and notifying observers.
323 base::Timer configure_timer_; 318 base::Timer configure_timer_;
324 319
325 DisplayChangeNotifier change_notifier_; 320 DisplayChangeNotifier change_notifier_;
326 321
327 DISALLOW_COPY_AND_ASSIGN(ScreenMac); 322 DISALLOW_COPY_AND_ASSIGN(ScreenMac);
328 }; 323 };
329 324
330 } // namespace 325 } // namespace
331 326
327 // static
328 gfx::NativeWindow Screen::GetWindowForView(gfx::NativeView view) {
329 NSWindow* window = nil;
330 #if !defined(USE_AURA)
331 window = [view window];
332 #endif
333 return window;
334 }
335
332 #if !defined(USE_AURA) 336 #if !defined(USE_AURA)
333 Screen* CreateNativeScreen() { 337 Screen* CreateNativeScreen() {
334 return new ScreenMac; 338 return new ScreenMac;
335 } 339 }
336 #endif 340 #endif
337 341
338 } // namespace display 342 } // namespace display
OLDNEW
« no previous file with comments | « ui/display/ios/screen_ios.mm ('k') | ui/display/screen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698