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/gfx/screen.h" | 5 #include "ui/gfx/screen.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 "ui/gfx/display.h" | 10 #include "ui/gfx/display.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 return gfx::Point(pt); | 41 return gfx::Point(pt); |
42 } | 42 } |
43 | 43 |
44 // static | 44 // static |
45 gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() { | 45 gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() { |
46 POINT location; | 46 POINT location; |
47 return GetCursorPos(&location) ? WindowFromPoint(location) : NULL; | 47 return GetCursorPos(&location) ? WindowFromPoint(location) : NULL; |
48 } | 48 } |
49 | 49 |
50 // static | 50 // static |
51 int Screen::GetNumMonitors() { | 51 int Screen::GetNumDisplays() { |
52 return GetSystemMetrics(SM_CMONITORS); | 52 return GetSystemMetrics(SM_CMONITORS); |
53 } | 53 } |
54 | 54 |
55 // static | 55 // static |
56 gfx::Display Screen::GetMonitorNearestWindow(gfx::NativeView window) { | 56 gfx::Display Screen::GetDisplayNearestWindow(gfx::NativeView window) { |
57 MONITORINFO monitor_info; | 57 MONITORINFO monitor_info; |
58 monitor_info.cbSize = sizeof(monitor_info); | 58 monitor_info.cbSize = sizeof(monitor_info); |
59 GetMonitorInfo(MonitorFromWindow(window, MONITOR_DEFAULTTONEAREST), | 59 GetMonitorInfo(MonitorFromWindow(window, MONITOR_DEFAULTTONEAREST), |
60 &monitor_info); | 60 &monitor_info); |
61 return GetDisplay(monitor_info); | 61 return GetDisplay(monitor_info); |
62 } | 62 } |
63 | 63 |
64 // static | 64 // static |
65 gfx::Display Screen::GetMonitorNearestPoint(const gfx::Point& point) { | 65 gfx::Display Screen::GetDisplayNearestPoint(const gfx::Point& point) { |
66 POINT initial_loc = { point.x(), point.y() }; | 66 POINT initial_loc = { point.x(), point.y() }; |
67 HMONITOR monitor = MonitorFromPoint(initial_loc, MONITOR_DEFAULTTONEAREST); | 67 HMONITOR monitor = MonitorFromPoint(initial_loc, MONITOR_DEFAULTTONEAREST); |
68 MONITORINFO mi = {0}; | 68 MONITORINFO mi = {0}; |
69 mi.cbSize = sizeof(mi); | 69 mi.cbSize = sizeof(mi); |
70 if (monitor && GetMonitorInfo(monitor, &mi)) | 70 if (monitor && GetMonitorInfo(monitor, &mi)) |
71 return GetDisplay(mi); | 71 return GetDisplay(mi); |
72 return gfx::Display(); | 72 return gfx::Display(); |
73 } | 73 } |
74 | 74 |
75 // static | 75 // static |
76 gfx::Display Screen::GetPrimaryMonitor() { | 76 gfx::Display Screen::GetPrimaryDisplay() { |
77 MONITORINFO mi = GetMonitorInfoForMonitor( | 77 MONITORINFO mi = GetMonitorInfoForMonitor( |
78 MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY)); | 78 MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY)); |
79 gfx::Display display = GetDisplay(mi); | 79 gfx::Display display = GetDisplay(mi); |
80 DCHECK_EQ(GetSystemMetrics(SM_CXSCREEN), display.size().width()); | 80 DCHECK_EQ(GetSystemMetrics(SM_CXSCREEN), display.size().width()); |
81 DCHECK_EQ(GetSystemMetrics(SM_CYSCREEN), display.size().height()); | 81 DCHECK_EQ(GetSystemMetrics(SM_CYSCREEN), display.size().height()); |
82 return display; | 82 return display; |
83 } | 83 } |
84 | 84 |
85 // static | 85 // static |
86 gfx::Display Screen::GetMonitorMatching(const gfx::Rect& match_rect) { | 86 gfx::Display Screen::GetDisplayMatching(const gfx::Rect& match_rect) { |
87 RECT other_bounds_rect = match_rect.ToRECT(); | 87 RECT other_bounds_rect = match_rect.ToRECT(); |
88 MONITORINFO monitor_info = GetMonitorInfoForMonitor(MonitorFromRect( | 88 MONITORINFO monitor_info = GetMonitorInfoForMonitor(MonitorFromRect( |
89 &other_bounds_rect, MONITOR_DEFAULTTONEAREST)); | 89 &other_bounds_rect, MONITOR_DEFAULTTONEAREST)); |
90 return GetDisplay(monitor_info); | 90 return GetDisplay(monitor_info); |
91 } | 91 } |
92 | 92 |
93 } // namespace gfx | 93 } // namespace gfx |
OLD | NEW |