OLD | NEW |
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/aura/desktop/desktop_screen_win.h" | 5 #include "ui/aura/desktop/desktop_screen_win.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/aura/desktop/desktop_screen.h" | 8 #include "ui/aura/desktop/desktop_screen.h" |
9 #include "ui/aura/root_window.h" | 9 #include "ui/aura/root_window.h" |
10 #include "ui/aura/root_window_host.h" | 10 #include "ui/aura/root_window_host.h" |
11 #include "ui/gfx/monitor.h" | 11 #include "ui/gfx/display.h" |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 MONITORINFO GetMonitorInfoForMonitor(HMONITOR monitor) { | 15 MONITORINFO GetMonitorInfoForMonitor(HMONITOR monitor) { |
16 MONITORINFO monitor_info = { 0 }; | 16 MONITORINFO monitor_info = { 0 }; |
17 monitor_info.cbSize = sizeof(monitor_info); | 17 monitor_info.cbSize = sizeof(monitor_info); |
18 GetMonitorInfo(monitor, &monitor_info); | 18 GetMonitorInfo(monitor, &monitor_info); |
19 return monitor_info; | 19 return monitor_info; |
20 } | 20 } |
21 | 21 |
22 gfx::Monitor GetMonitor(MONITORINFO& monitor_info) { | 22 gfx::Display GetDisplay(MONITORINFO& monitor_info) { |
23 // TODO(oshima): Implement ID and Observer. | 23 // TODO(oshima): Implement ID and Observer. |
24 gfx::Monitor monitor(0, gfx::Rect(monitor_info.rcMonitor)); | 24 gfx::Display display(0, gfx::Rect(monitor_info.rcMonitor)); |
25 monitor.set_work_area(gfx::Rect(monitor_info.rcWork)); | 25 display.set_work_area(gfx::Rect(monitor_info.rcWork)); |
26 return monitor; | 26 return display; |
27 } | 27 } |
28 | 28 |
29 } // namespace | 29 } // namespace |
30 | 30 |
31 namespace aura { | 31 namespace aura { |
32 | 32 |
33 //////////////////////////////////////////////////////////////////////////////// | 33 //////////////////////////////////////////////////////////////////////////////// |
34 // DesktopScreenWin, public: | 34 // DesktopScreenWin, public: |
35 | 35 |
36 DesktopScreenWin::DesktopScreenWin() { | 36 DesktopScreenWin::DesktopScreenWin() { |
(...skipping 18 matching lines...) Expand all Loading... |
55 RootWindowHost* host = NULL; | 55 RootWindowHost* host = NULL; |
56 if (::IsWindow(accelerated_widget)) | 56 if (::IsWindow(accelerated_widget)) |
57 host = RootWindowHost::GetForAcceleratedWidget(accelerated_widget); | 57 host = RootWindowHost::GetForAcceleratedWidget(accelerated_widget); |
58 return host ? host->GetRootWindow() : NULL; | 58 return host ? host->GetRootWindow() : NULL; |
59 } | 59 } |
60 | 60 |
61 int DesktopScreenWin::GetNumMonitors() { | 61 int DesktopScreenWin::GetNumMonitors() { |
62 return GetSystemMetrics(SM_CMONITORS); | 62 return GetSystemMetrics(SM_CMONITORS); |
63 } | 63 } |
64 | 64 |
65 gfx::Monitor DesktopScreenWin::GetMonitorNearestWindow( | 65 gfx::Display DesktopScreenWin::GetMonitorNearestWindow( |
66 gfx::NativeView window) const { | 66 gfx::NativeView window) const { |
67 gfx::AcceleratedWidget accelerated_window = | 67 gfx::AcceleratedWidget accelerated_window = |
68 window->GetRootWindow()->GetAcceleratedWidget(); | 68 window->GetRootWindow()->GetAcceleratedWidget(); |
69 MONITORINFO monitor_info; | 69 MONITORINFO monitor_info; |
70 monitor_info.cbSize = sizeof(monitor_info); | 70 monitor_info.cbSize = sizeof(monitor_info); |
71 GetMonitorInfo(MonitorFromWindow(accelerated_window, | 71 GetMonitorInfo(MonitorFromWindow(accelerated_window, |
72 MONITOR_DEFAULTTONEAREST), | 72 MONITOR_DEFAULTTONEAREST), |
73 &monitor_info); | 73 &monitor_info); |
74 return GetMonitor(monitor_info); | 74 return GetDisplay(monitor_info); |
75 } | 75 } |
76 | 76 |
77 gfx::Monitor DesktopScreenWin::GetMonitorNearestPoint( | 77 gfx::Display DesktopScreenWin::GetMonitorNearestPoint( |
78 const gfx::Point& point) const { | 78 const gfx::Point& point) const { |
79 POINT initial_loc = { point.x(), point.y() }; | 79 POINT initial_loc = { point.x(), point.y() }; |
80 HMONITOR monitor = MonitorFromPoint(initial_loc, MONITOR_DEFAULTTONEAREST); | 80 HMONITOR monitor = MonitorFromPoint(initial_loc, MONITOR_DEFAULTTONEAREST); |
81 MONITORINFO mi = {0}; | 81 MONITORINFO mi = {0}; |
82 mi.cbSize = sizeof(mi); | 82 mi.cbSize = sizeof(mi); |
83 if (monitor && GetMonitorInfo(monitor, &mi)) | 83 if (monitor && GetMonitorInfo(monitor, &mi)) |
84 return GetMonitor(mi); | 84 return GetDisplay(mi); |
85 return gfx::Monitor(); | 85 return gfx::Display(); |
86 } | 86 } |
87 | 87 |
88 gfx::Monitor DesktopScreenWin::GetPrimaryMonitor() const { | 88 gfx::Display DesktopScreenWin::GetPrimaryMonitor() const { |
89 MONITORINFO mi = GetMonitorInfoForMonitor( | 89 MONITORINFO mi = GetMonitorInfoForMonitor( |
90 MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY)); | 90 MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY)); |
91 gfx::Monitor monitor = GetMonitor(mi); | 91 gfx::Display display = GetDisplay(mi); |
92 DCHECK_EQ(GetSystemMetrics(SM_CXSCREEN), monitor.size().width()); | 92 DCHECK_EQ(GetSystemMetrics(SM_CXSCREEN), display.size().width()); |
93 DCHECK_EQ(GetSystemMetrics(SM_CYSCREEN), monitor.size().height()); | 93 DCHECK_EQ(GetSystemMetrics(SM_CYSCREEN), display.size().height()); |
94 return monitor; | 94 return display; |
95 } | 95 } |
96 | 96 |
97 //////////////////////////////////////////////////////////////////////////////// | 97 //////////////////////////////////////////////////////////////////////////////// |
98 | 98 |
99 gfx::ScreenImpl* CreateDesktopScreen() { | 99 gfx::ScreenImpl* CreateDesktopScreen() { |
100 return new DesktopScreenWin; | 100 return new DesktopScreenWin; |
101 } | 101 } |
102 | 102 |
103 } // namespace aura | 103 } // namespace aura |
OLD | NEW |