Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: ui/gfx/screen_win.cc

Issue 8549008: Extract MonitorInfoProvider from WindowSizer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add docs Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gfx/screen_mac.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 namespace {
10
11 MONITORINFO GetMonitorInfoForMonitor(HMONITOR monitor) {
12 MONITORINFO monitor_info = { 0 };
13 monitor_info.cbSize = sizeof(monitor_info);
14 GetMonitorInfo(monitor, &monitor_info);
15 return monitor_info;
16 }
17
18 } // namespace
19
9 namespace gfx { 20 namespace gfx {
10 21
11 // static 22 // static
12 gfx::Point Screen::GetCursorScreenPoint() { 23 gfx::Point Screen::GetCursorScreenPoint() {
13 POINT pt; 24 POINT pt;
14 GetCursorPos(&pt); 25 GetCursorPos(&pt);
15 return gfx::Point(pt); 26 return gfx::Point(pt);
16 } 27 }
17 28
18 // static 29 // static
(...skipping 29 matching lines...) Expand all
48 gfx::Rect Screen::GetMonitorWorkAreaNearestPoint(const gfx::Point& point) { 59 gfx::Rect Screen::GetMonitorWorkAreaNearestPoint(const gfx::Point& point) {
49 return GetMonitorAreaOrWorkAreaNearestPoint(point, true); 60 return GetMonitorAreaOrWorkAreaNearestPoint(point, true);
50 } 61 }
51 62
52 // static 63 // static
53 gfx::Rect Screen::GetMonitorAreaNearestPoint(const gfx::Point& point) { 64 gfx::Rect Screen::GetMonitorAreaNearestPoint(const gfx::Point& point) {
54 return GetMonitorAreaOrWorkAreaNearestPoint(point, false); 65 return GetMonitorAreaOrWorkAreaNearestPoint(point, false);
55 } 66 }
56 67
57 // static 68 // static
69 gfx::Rect Screen::GetPrimaryMonitorWorkArea() {
70 return gfx::Rect(GetMonitorInfoForMonitor(MonitorFromWindow(NULL,
71 MONITOR_DEFAULTTOPRIMARY)).rcWork);
72 }
73
74 // static
75 gfx::Rect Screen::GetPrimaryMonitorBounds() {
76 return gfx::Rect(GetMonitorInfoForMonitor(MonitorFromWindow(NULL,
77 MONITOR_DEFAULTTOPRIMARY)).rcMonitor);
78 }
79
80 // static
81 gfx::Rect Screen::GetMonitorWorkAreaMatching(const gfx::Rect& match_rect) {
82 RECT other_bounds_rect = match_rect.ToRECT();
83 MONITORINFO monitor_info = GetMonitorInfoForMonitor(MonitorFromRect(
84 &other_bounds_rect, MONITOR_DEFAULTTONEAREST));
85 return gfx::Rect(monitor_info.rcWork);
86 }
87
88 // static
58 gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() { 89 gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() {
59 POINT location; 90 POINT location;
60 return GetCursorPos(&location) ? WindowFromPoint(location) : NULL; 91 return GetCursorPos(&location) ? WindowFromPoint(location) : NULL;
61 } 92 }
62 93
63 // static 94 // static
64 gfx::Size Screen::GetPrimaryMonitorSize() { 95 gfx::Size Screen::GetPrimaryMonitorSize() {
65 return gfx::Size(GetSystemMetrics(SM_CXSCREEN), 96 return gfx::Size(GetSystemMetrics(SM_CXSCREEN),
66 GetSystemMetrics(SM_CYSCREEN)); 97 GetSystemMetrics(SM_CYSCREEN));
67 } 98 }
68 99
69 // static 100 // static
70 int Screen::GetNumMonitors() { 101 int Screen::GetNumMonitors() {
71 return GetSystemMetrics(SM_CMONITORS); 102 return GetSystemMetrics(SM_CMONITORS);
72 } 103 }
73 104
74 } // namespace gfx 105 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/screen_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698