| 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 17 matching lines...) Expand all Loading... |
| 28 } // namespace | 28 } // namespace |
| 29 | 29 |
| 30 namespace gfx { | 30 namespace gfx { |
| 31 | 31 |
| 32 // static | 32 // static |
| 33 bool Screen::IsDIPEnabled() { | 33 bool Screen::IsDIPEnabled() { |
| 34 return false; | 34 return false; |
| 35 } | 35 } |
| 36 | 36 |
| 37 // static | 37 // static |
| 38 gfx::Point Screen::GetCursorScreenPoint() { | 38 gfx::Point Screen::GetCursorScreenPoint(gfx::NativeView context) { |
| 39 POINT pt; | 39 POINT pt; |
| 40 GetCursorPos(&pt); | 40 GetCursorPos(&pt); |
| 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 gfx::NativeView context) { |
| 46 POINT location; | 47 POINT location; |
| 47 return GetCursorPos(&location) ? WindowFromPoint(location) : NULL; | 48 return GetCursorPos(&location) ? WindowFromPoint(location) : NULL; |
| 48 } | 49 } |
| 49 | 50 |
| 50 // static | 51 // static |
| 51 int Screen::GetNumDisplays() { | 52 int Screen::GetNumDisplays(gfx::NativeView context) { |
| 52 return GetSystemMetrics(SM_CMONITORS); | 53 return GetSystemMetrics(SM_CMONITORS); |
| 53 } | 54 } |
| 54 | 55 |
| 55 // static | 56 // static |
| 56 gfx::Display Screen::GetDisplayNearestWindow(gfx::NativeView window) { | 57 gfx::Display Screen::GetDisplayNearestWindow(gfx::NativeView window) { |
| 57 MONITORINFO monitor_info; | 58 MONITORINFO monitor_info; |
| 58 monitor_info.cbSize = sizeof(monitor_info); | 59 monitor_info.cbSize = sizeof(monitor_info); |
| 59 GetMonitorInfo(MonitorFromWindow(window, MONITOR_DEFAULTTONEAREST), | 60 GetMonitorInfo(MonitorFromWindow(window, MONITOR_DEFAULTTONEAREST), |
| 60 &monitor_info); | 61 &monitor_info); |
| 61 return GetDisplay(monitor_info); | 62 return GetDisplay(monitor_info); |
| 62 } | 63 } |
| 63 | 64 |
| 64 // static | 65 // static |
| 65 gfx::Display Screen::GetDisplayNearestPoint(const gfx::Point& point) { | 66 gfx::Display Screen::GetDisplayNearestPoint( |
| 67 gfx::NativeView context, const gfx::Point& point) { |
| 66 POINT initial_loc = { point.x(), point.y() }; | 68 POINT initial_loc = { point.x(), point.y() }; |
| 67 HMONITOR monitor = MonitorFromPoint(initial_loc, MONITOR_DEFAULTTONEAREST); | 69 HMONITOR monitor = MonitorFromPoint(initial_loc, MONITOR_DEFAULTTONEAREST); |
| 68 MONITORINFO mi = {0}; | 70 MONITORINFO mi = {0}; |
| 69 mi.cbSize = sizeof(mi); | 71 mi.cbSize = sizeof(mi); |
| 70 if (monitor && GetMonitorInfo(monitor, &mi)) | 72 if (monitor && GetMonitorInfo(monitor, &mi)) |
| 71 return GetDisplay(mi); | 73 return GetDisplay(mi); |
| 72 return gfx::Display(); | 74 return gfx::Display(); |
| 73 } | 75 } |
| 74 | 76 |
| 75 // static | 77 // static |
| 76 gfx::Display Screen::GetDisplayMatching(const gfx::Rect& match_rect) { | 78 gfx::Display Screen::GetDisplayMatching( |
| 79 gfx::NativeView context, const gfx::Rect& match_rect) { |
| 77 RECT other_bounds_rect = match_rect.ToRECT(); | 80 RECT other_bounds_rect = match_rect.ToRECT(); |
| 78 MONITORINFO monitor_info = GetMonitorInfoForMonitor(MonitorFromRect( | 81 MONITORINFO monitor_info = GetMonitorInfoForMonitor(MonitorFromRect( |
| 79 &other_bounds_rect, MONITOR_DEFAULTTONEAREST)); | 82 &other_bounds_rect, MONITOR_DEFAULTTONEAREST)); |
| 80 return GetDisplay(monitor_info); | 83 return GetDisplay(monitor_info); |
| 81 } | 84 } |
| 82 | 85 |
| 83 // static | 86 // static |
| 84 gfx::Display Screen::GetPrimaryDisplay() { | 87 gfx::Display Screen::GetPrimaryDisplay(gfx::NativeView context) { |
| 85 MONITORINFO mi = GetMonitorInfoForMonitor( | 88 MONITORINFO mi = GetMonitorInfoForMonitor( |
| 86 MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY)); | 89 MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY)); |
| 87 gfx::Display display = GetDisplay(mi); | 90 gfx::Display display = GetDisplay(mi); |
| 88 DCHECK_EQ(GetSystemMetrics(SM_CXSCREEN), display.size().width()); | 91 DCHECK_EQ(GetSystemMetrics(SM_CXSCREEN), display.size().width()); |
| 89 DCHECK_EQ(GetSystemMetrics(SM_CYSCREEN), display.size().height()); | 92 DCHECK_EQ(GetSystemMetrics(SM_CYSCREEN), display.size().height()); |
| 90 return display; | 93 return display; |
| 91 } | 94 } |
| 92 | 95 |
| 93 } // namespace gfx | 96 } // namespace gfx |
| OLD | NEW |