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

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: 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/logging.h" 9 #include "base/logging.h"
10 #include "base/win/win_util.h" 10 #include "base/win/win_util.h"
11 #include "ui/base/win/dpi.h" 11 #include "ui/base/win/dpi.h"
12 #include "ui/gfx/display.h" 12 #include "ui/gfx/display.h"
13 13
14 namespace { 14 namespace {
15 15
16 MONITORINFO GetMonitorInfoForMonitor(HMONITOR monitor) { 16 MONITORINFO GetMonitorInfoForMonitor(HMONITOR monitor) {
17 MONITORINFO monitor_info = { 0 }; 17 MONITORINFO monitor_info = { 0 };
18 monitor_info.cbSize = sizeof(monitor_info); 18 monitor_info.cbSize = sizeof(monitor_info);
19 base::win::GetMonitorInfoWrapper(monitor, &monitor_info); 19 base::win::GetMonitorInfoWrapper(monitor, &monitor_info);
20 return monitor_info; 20 return monitor_info;
21 } 21 }
22 22
23 gfx::Display GetDisplay(MONITORINFO& monitor_info) { 23 gfx::Display GetDisplay(MONITORINFO& monitor_info) {
24 // TODO(oshima): Implement ID and Observer. 24 // TODO(oshima): Implement ID and Observer.
Haojian Wu 2013/08/25 07:49:58 oshima@, Do you have any idea about the display |i
oshima 2013/08/26 18:33:12 Can you take deviceID and generate hash using base
Haojian Wu 2013/08/30 13:52:16 I have separated a new CL to finish this. see http
25 gfx::Rect bounds = gfx::Rect(monitor_info.rcMonitor); 25 gfx::Rect bounds = gfx::Rect(monitor_info.rcMonitor);
26 gfx::Display display(0, bounds); 26 gfx::Display display(0, bounds);
27 display.set_work_area(gfx::Rect(monitor_info.rcWork)); 27 display.set_work_area(gfx::Rect(monitor_info.rcWork));
28 display.SetScaleAndBounds(ui::win::GetDeviceScaleFactor(), bounds); 28 display.SetScaleAndBounds(ui::win::GetDeviceScaleFactor(), bounds);
29 return display; 29 return display;
30 } 30 }
31 31
32 BOOL CALLBACK EnumMonitorCallback(HMONITOR monitor,
33 HDC hdc,
34 LPRECT rect,
35 LPARAM data) {
36 std::vector<gfx::Display>* all_displays =
37 reinterpret_cast<std::vector<gfx::Display>*>(data);
38 DCHECK(all_displays);
39
40 MONITORINFO monitor_info = GetMonitorInfoForMonitor(monitor);
41 gfx::Display display = GetDisplay(monitor_info);
42 all_displays->push_back(display);
43 return TRUE;
44 }
45
32 } // namespace 46 } // namespace
33 47
34 namespace gfx { 48 namespace gfx {
35 49
36 ScreenWin::ScreenWin() { 50 ScreenWin::ScreenWin() {
37 } 51 }
38 52
39 ScreenWin::~ScreenWin() { 53 ScreenWin::~ScreenWin() {
40 } 54 }
41 55
(...skipping 11 matching lines...) Expand all
53 POINT location; 67 POINT location;
54 HWND window_hwnd = GetCursorPos(&location) ? WindowFromPoint(location) : NULL; 68 HWND window_hwnd = GetCursorPos(&location) ? WindowFromPoint(location) : NULL;
55 return GetNativeWindowFromHWND(window_hwnd); 69 return GetNativeWindowFromHWND(window_hwnd);
56 } 70 }
57 71
58 int ScreenWin::GetNumDisplays() const { 72 int ScreenWin::GetNumDisplays() const {
59 return GetSystemMetrics(SM_CMONITORS); 73 return GetSystemMetrics(SM_CMONITORS);
60 } 74 }
61 75
62 std::vector<gfx::Display> ScreenWin::GetAllDisplays() const { 76 std::vector<gfx::Display> ScreenWin::GetAllDisplays() const {
63 NOTIMPLEMENTED(); 77 std::vector<gfx::Display> all_displays;
64 return std::vector<gfx::Display>(1, GetPrimaryDisplay()); 78 EnumDisplayMonitors(NULL, NULL, EnumMonitorCallback,
79 reinterpret_cast<LPARAM>(&all_displays));
80 return all_displays;
65 } 81 }
66 82
67 gfx::Display ScreenWin::GetDisplayNearestWindow(gfx::NativeView window) const { 83 gfx::Display ScreenWin::GetDisplayNearestWindow(gfx::NativeView window) const {
68 HWND window_hwnd = GetHWNDFromNativeView(window); 84 HWND window_hwnd = GetHWNDFromNativeView(window);
69 if (!window_hwnd) { 85 if (!window_hwnd) {
70 // When |window| isn't rooted to a display, we should just return the 86 // When |window| isn't rooted to a display, we should just return the
71 // default display so we get some correct display information like the 87 // default display so we get some correct display information like the
72 // scaling factor. 88 // scaling factor.
73 return GetPrimaryDisplay(); 89 return GetPrimaryDisplay();
74 } 90 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 #endif // USE_AURA 153 #endif // USE_AURA
138 } 154 }
139 155
140 #if !defined(USE_AURA) 156 #if !defined(USE_AURA)
141 Screen* CreateNativeScreen() { 157 Screen* CreateNativeScreen() {
142 return new ScreenWin; 158 return new ScreenWin;
143 } 159 }
144 #endif // !USE_AURA 160 #endif // !USE_AURA
145 161
146 } // namespace gfx 162 } // 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