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" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 gfx::NativeWindow DesktopScreenWin::GetWindowAtCursorScreenPoint() { | 51 gfx::NativeWindow DesktopScreenWin::GetWindowAtCursorScreenPoint() { |
52 POINT location; | 52 POINT location; |
53 gfx::AcceleratedWidget accelerated_widget = | 53 gfx::AcceleratedWidget accelerated_widget = |
54 GetCursorPos(&location) ? WindowFromPoint(location) : NULL; | 54 GetCursorPos(&location) ? WindowFromPoint(location) : NULL; |
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::GetNumDisplays() { |
62 return GetSystemMetrics(SM_CMONITORS); | 62 return GetSystemMetrics(SM_CMONITORS); |
63 } | 63 } |
64 | 64 |
65 gfx::Display DesktopScreenWin::GetMonitorNearestWindow( | 65 gfx::Display DesktopScreenWin::GetDisplayNearestWindow( |
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 GetDisplay(monitor_info); | 74 return GetDisplay(monitor_info); |
75 } | 75 } |
76 | 76 |
77 gfx::Display DesktopScreenWin::GetMonitorNearestPoint( | 77 gfx::Display DesktopScreenWin::GetDisplayNearestPoint( |
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 GetDisplay(mi); | 84 return GetDisplay(mi); |
85 return gfx::Display(); | 85 return gfx::Display(); |
86 } | 86 } |
87 | 87 |
88 gfx::Display DesktopScreenWin::GetPrimaryMonitor() const { | 88 gfx::Display DesktopScreenWin::GetPrimaryDisplay() const { |
89 MONITORINFO mi = GetMonitorInfoForMonitor( | 89 MONITORINFO mi = GetMonitorInfoForMonitor( |
90 MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY)); | 90 MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY)); |
91 gfx::Display display = GetDisplay(mi); | 91 gfx::Display display = GetDisplay(mi); |
92 DCHECK_EQ(GetSystemMetrics(SM_CXSCREEN), display.size().width()); | 92 DCHECK_EQ(GetSystemMetrics(SM_CXSCREEN), display.size().width()); |
93 DCHECK_EQ(GetSystemMetrics(SM_CYSCREEN), display.size().height()); | 93 DCHECK_EQ(GetSystemMetrics(SM_CYSCREEN), display.size().height()); |
94 return display; | 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 |