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

Side by Side Diff: ui/gfx/screen_win.cc

Issue 23415002: Implement Screen::GetAllDisplays for windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 7 years, 3 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 | « no previous file | no next file » | 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_win.h" 5 #include "ui/gfx/screen_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include "base/hash.h" 9 #include "base/hash.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 15 matching lines...) Expand all
26 gfx::Display GetDisplay(MONITORINFOEX& monitor_info) { 26 gfx::Display GetDisplay(MONITORINFOEX& monitor_info) {
27 // TODO(oshima): Implement Observer. 27 // TODO(oshima): Implement Observer.
28 int64 id = static_cast<int64>(base::Hash(WideToUTF8(monitor_info.szDevice))); 28 int64 id = static_cast<int64>(base::Hash(WideToUTF8(monitor_info.szDevice)));
29 gfx::Rect bounds = gfx::Rect(monitor_info.rcMonitor); 29 gfx::Rect bounds = gfx::Rect(monitor_info.rcMonitor);
30 gfx::Display display(id, bounds); 30 gfx::Display display(id, bounds);
31 display.set_work_area(gfx::Rect(monitor_info.rcWork)); 31 display.set_work_area(gfx::Rect(monitor_info.rcWork));
32 display.SetScaleAndBounds(ui::win::GetDeviceScaleFactor(), bounds); 32 display.SetScaleAndBounds(ui::win::GetDeviceScaleFactor(), bounds);
33 return display; 33 return display;
34 } 34 }
35 35
36 BOOL CALLBACK EnumMonitorCallback(HMONITOR monitor,
37 HDC hdc,
38 LPRECT rect,
39 LPARAM data) {
40 std::vector<gfx::Display>* all_displays =
41 reinterpret_cast<std::vector<gfx::Display>*>(data);
42 DCHECK(all_displays);
43
44 MONITORINFOEX monitor_info = GetMonitorInfoForMonitor(monitor);
45 gfx::Display display = GetDisplay(monitor_info);
46 all_displays->push_back(display);
47 return TRUE;
48 }
49
36 } // namespace 50 } // namespace
37 51
38 namespace gfx { 52 namespace gfx {
39 53
40 ScreenWin::ScreenWin() { 54 ScreenWin::ScreenWin() {
41 } 55 }
42 56
43 ScreenWin::~ScreenWin() { 57 ScreenWin::~ScreenWin() {
44 } 58 }
45 59
(...skipping 15 matching lines...) Expand all
61 75
62 gfx::NativeWindow ScreenWin::GetWindowAtScreenPoint(const gfx::Point& point) { 76 gfx::NativeWindow ScreenWin::GetWindowAtScreenPoint(const gfx::Point& point) {
63 return GetNativeWindowFromHWND(WindowFromPoint(point.ToPOINT())); 77 return GetNativeWindowFromHWND(WindowFromPoint(point.ToPOINT()));
64 } 78 }
65 79
66 int ScreenWin::GetNumDisplays() const { 80 int ScreenWin::GetNumDisplays() const {
67 return GetSystemMetrics(SM_CMONITORS); 81 return GetSystemMetrics(SM_CMONITORS);
68 } 82 }
69 83
70 std::vector<gfx::Display> ScreenWin::GetAllDisplays() const { 84 std::vector<gfx::Display> ScreenWin::GetAllDisplays() const {
71 NOTIMPLEMENTED(); 85 std::vector<gfx::Display> all_displays;
72 return std::vector<gfx::Display>(1, GetPrimaryDisplay()); 86 EnumDisplayMonitors(NULL, NULL, EnumMonitorCallback,
87 reinterpret_cast<LPARAM>(&all_displays));
88 return all_displays;
73 } 89 }
74 90
75 gfx::Display ScreenWin::GetDisplayNearestWindow(gfx::NativeView window) const { 91 gfx::Display ScreenWin::GetDisplayNearestWindow(gfx::NativeView window) const {
76 HWND window_hwnd = GetHWNDFromNativeView(window); 92 HWND window_hwnd = GetHWNDFromNativeView(window);
77 if (!window_hwnd) { 93 if (!window_hwnd) {
78 // When |window| isn't rooted to a display, we should just return the 94 // When |window| isn't rooted to a display, we should just return the
79 // default display so we get some correct display information like the 95 // default display so we get some correct display information like the
80 // scaling factor. 96 // scaling factor.
81 return GetPrimaryDisplay(); 97 return GetPrimaryDisplay();
82 } 98 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 #endif // USE_AURA 162 #endif // USE_AURA
147 } 163 }
148 164
149 #if !defined(USE_AURA) 165 #if !defined(USE_AURA)
150 Screen* CreateNativeScreen() { 166 Screen* CreateNativeScreen() {
151 return new ScreenWin; 167 return new ScreenWin;
152 } 168 }
153 #endif // !USE_AURA 169 #endif // !USE_AURA
154 170
155 } // namespace gfx 171 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698