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

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

Issue 2688413007: Add display::GetDisplayNearestView (Closed)
Patch Set: WindowForView 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
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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::NativeView view) const override {
157 return GetDisplayNearestView(view);
158 }
159
160 Display GetDisplayNearestView(gfx::NativeView view) const override {
157 EnsureDisplaysValid(); 161 EnsureDisplaysValid();
158 if (displays_.size() == 1) 162 if (displays_.size() == 1)
159 return displays_[0]; 163 return displays_[0];
160 164
161 NSWindow* window = nil; 165 NSWindow* window = nil;
162 #if !defined(USE_AURA) 166 #if !defined(USE_AURA)
163 if (view) 167 if (view)
164 window = [view window]; 168 window = [view window];
165 #endif 169 #endif
166 if (!window) 170 if (!window)
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 // The timer to delay configuring outputs and notifying observers. 326 // The timer to delay configuring outputs and notifying observers.
323 base::Timer configure_timer_; 327 base::Timer configure_timer_;
324 328
325 DisplayChangeNotifier change_notifier_; 329 DisplayChangeNotifier change_notifier_;
326 330
327 DISALLOW_COPY_AND_ASSIGN(ScreenMac); 331 DISALLOW_COPY_AND_ASSIGN(ScreenMac);
328 }; 332 };
329 333
330 } // namespace 334 } // namespace
331 335
336 // static
337 gfx::NativeWindow Screen::WindowForView(gfx::NativeView view) {
338 return [view window];
339 }
340
332 #if !defined(USE_AURA) 341 #if !defined(USE_AURA)
333 Screen* CreateNativeScreen() { 342 Screen* CreateNativeScreen() {
334 return new ScreenMac; 343 return new ScreenMac;
335 } 344 }
336 #endif 345 #endif
337 346
338 } // namespace display 347 } // namespace display
OLDNEW
« no previous file with comments | « ui/display/ios/screen_ios.mm ('k') | ui/display/screen.h » ('j') | ui/display/screen.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698