OLD | NEW |
---|---|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "views/screen.h" | 5 #include "views/screen.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 namespace views { | 9 namespace views { |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... | |
26 | 26 |
27 // static | 27 // static |
28 gfx::Rect Screen::GetMonitorAreaNearestWindow(gfx::NativeWindow window) { | 28 gfx::Rect Screen::GetMonitorAreaNearestWindow(gfx::NativeWindow window) { |
29 MONITORINFO monitor_info; | 29 MONITORINFO monitor_info; |
30 monitor_info.cbSize = sizeof(monitor_info); | 30 monitor_info.cbSize = sizeof(monitor_info); |
31 GetMonitorInfo(MonitorFromWindow(window, MONITOR_DEFAULTTONEAREST), | 31 GetMonitorInfo(MonitorFromWindow(window, MONITOR_DEFAULTTONEAREST), |
32 &monitor_info); | 32 &monitor_info); |
33 return gfx::Rect(monitor_info.rcMonitor); | 33 return gfx::Rect(monitor_info.rcMonitor); |
34 } | 34 } |
35 | 35 |
36 static gfx::Rect GetMonitorAreaOrWorkAreaNearestPoint(const gfx::Point& point, | |
37 bool work_area) { | |
sky
2011/01/27 00:22:07
align this with ( on previous line.
| |
38 POINT initial_loc = { point.x(), point.y() }; | |
39 HMONITOR monitor = MonitorFromPoint(initial_loc, MONITOR_DEFAULTTONEAREST); | |
40 MONITORINFO mi = {0}; | |
41 mi.cbSize = sizeof(mi); | |
42 if (monitor && GetMonitorInfo(monitor, &mi)) | |
43 return gfx::Rect(work_area ? mi.rcWork : mi.rcMonitor); | |
44 return gfx::Rect(); | |
45 } | |
46 | |
47 // static | |
48 gfx::Rect Screen::GetMonitorWorkAreaNearestPoint(const gfx::Point& point) { | |
49 return GetMonitorAreaOrWorkAreaNearestPoint(point, true); | |
50 } | |
51 | |
36 // static | 52 // static |
37 gfx::Rect Screen::GetMonitorAreaNearestPoint(const gfx::Point& point) { | 53 gfx::Rect Screen::GetMonitorAreaNearestPoint(const gfx::Point& point) { |
38 POINT initial_loc = { point.x(), point.y() }; | 54 return GetMonitorAreaOrWorkAreaNearestPoint(point, false); |
39 HMONITOR monitor = MonitorFromPoint(initial_loc, MONITOR_DEFAULTTONEAREST); | |
40 if (!monitor) | |
41 return gfx::Rect(); | |
42 | |
43 MONITORINFO mi = {0}; | |
44 mi.cbSize = sizeof(mi); | |
45 GetMonitorInfo(monitor, &mi); | |
46 return gfx::Rect(mi.rcMonitor); | |
47 } | 55 } |
48 | 56 |
49 gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() { | 57 gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() { |
50 POINT location; | 58 POINT location; |
51 return GetCursorPos(&location) ? WindowFromPoint(location) : NULL; | 59 return GetCursorPos(&location) ? WindowFromPoint(location) : NULL; |
52 } | 60 } |
53 | 61 |
54 } // namespace | 62 } // namespace |
55 | 63 |
OLD | NEW |