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

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

Issue 137353002: Remove GetMonitorInfoWrapper, which is no longer needed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 6 years, 11 months 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 | « content/browser/renderer_host/render_widget_host_view_win.cc ('k') | ui/gfx/win/hwnd_util.cc » ('j') | 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) 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_win.h" 5 #include "ui/gfx/screen_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include "base/hash.h" 9 #include "base/hash.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/win/win_util.h" 12 #include "base/win/win_util.h"
13 #include "ui/gfx/display.h" 13 #include "ui/gfx/display.h"
14 #include "ui/gfx/win/dpi.h" 14 #include "ui/gfx/win/dpi.h"
15 15
16 namespace { 16 namespace {
17 17
18 MONITORINFOEX GetMonitorInfoForMonitor(HMONITOR monitor) { 18 MONITORINFOEX GetMonitorInfoForMonitor(HMONITOR monitor) {
19 MONITORINFOEX monitor_info; 19 MONITORINFOEX monitor_info;
20 ZeroMemory(&monitor_info, sizeof(MONITORINFOEX)); 20 ZeroMemory(&monitor_info, sizeof(MONITORINFOEX));
21 monitor_info.cbSize = sizeof(monitor_info); 21 monitor_info.cbSize = sizeof(monitor_info);
22 base::win::GetMonitorInfoWrapper(monitor, &monitor_info); 22 GetMonitorInfo(monitor, &monitor_info);
23 return monitor_info; 23 return monitor_info;
24 } 24 }
25 25
26 gfx::Display GetDisplay(MONITORINFOEX& monitor_info) { 26 gfx::Display GetDisplay(MONITORINFOEX& monitor_info) {
27 // TODO(oshima): Implement Observer. 27 // TODO(oshima): Implement Observer.
28 int64 id = static_cast<int64>( 28 int64 id = static_cast<int64>(
29 base::Hash(base::WideToUTF8(monitor_info.szDevice))); 29 base::Hash(base::WideToUTF8(monitor_info.szDevice)));
30 gfx::Rect bounds = gfx::Rect(monitor_info.rcMonitor); 30 gfx::Rect bounds = gfx::Rect(monitor_info.rcMonitor);
31 gfx::Display display(id, bounds); 31 gfx::Display display(id, bounds);
32 display.set_work_area(gfx::Rect(monitor_info.rcWork)); 32 display.set_work_area(gfx::Rect(monitor_info.rcWork));
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 HWND window_hwnd = GetHWNDFromNativeView(window); 93 HWND window_hwnd = GetHWNDFromNativeView(window);
94 if (!window_hwnd) { 94 if (!window_hwnd) {
95 // When |window| isn't rooted to a display, we should just return the 95 // When |window| isn't rooted to a display, we should just return the
96 // default display so we get some correct display information like the 96 // default display so we get some correct display information like the
97 // scaling factor. 97 // scaling factor.
98 return GetPrimaryDisplay(); 98 return GetPrimaryDisplay();
99 } 99 }
100 100
101 MONITORINFOEX monitor_info; 101 MONITORINFOEX monitor_info;
102 monitor_info.cbSize = sizeof(monitor_info); 102 monitor_info.cbSize = sizeof(monitor_info);
103 base::win::GetMonitorInfoWrapper( 103 GetMonitorInfo(MonitorFromWindow(window_hwnd, MONITOR_DEFAULTTONEAREST),
104 MonitorFromWindow(window_hwnd, MONITOR_DEFAULTTONEAREST), &monitor_info); 104 &monitor_info);
105 return GetDisplay(monitor_info); 105 return GetDisplay(monitor_info);
106 } 106 }
107 107
108 gfx::Display ScreenWin::GetDisplayNearestPoint(const gfx::Point& point) const { 108 gfx::Display ScreenWin::GetDisplayNearestPoint(const gfx::Point& point) const {
109 POINT initial_loc = { point.x(), point.y() }; 109 POINT initial_loc = { point.x(), point.y() };
110 HMONITOR monitor = MonitorFromPoint(initial_loc, MONITOR_DEFAULTTONEAREST); 110 HMONITOR monitor = MonitorFromPoint(initial_loc, MONITOR_DEFAULTTONEAREST);
111 MONITORINFOEX mi; 111 MONITORINFOEX mi;
112 ZeroMemory(&mi, sizeof(MONITORINFOEX)); 112 ZeroMemory(&mi, sizeof(MONITORINFOEX));
113 mi.cbSize = sizeof(mi); 113 mi.cbSize = sizeof(mi);
114 if (monitor && base::win::GetMonitorInfoWrapper(monitor, &mi)) { 114 if (monitor && GetMonitorInfo(monitor, &mi)) {
115 return GetDisplay(mi); 115 return GetDisplay(mi);
116 } 116 }
117 return gfx::Display(); 117 return gfx::Display();
118 } 118 }
119 119
120 gfx::Display ScreenWin::GetDisplayMatching(const gfx::Rect& match_rect) const { 120 gfx::Display ScreenWin::GetDisplayMatching(const gfx::Rect& match_rect) const {
121 RECT other_bounds_rect = match_rect.ToRECT(); 121 RECT other_bounds_rect = match_rect.ToRECT();
122 MONITORINFOEX monitor_info = GetMonitorInfoForMonitor(MonitorFromRect( 122 MONITORINFOEX monitor_info = GetMonitorInfoForMonitor(MonitorFromRect(
123 &other_bounds_rect, MONITOR_DEFAULTTONEAREST)); 123 &other_bounds_rect, MONITOR_DEFAULTTONEAREST));
124 return GetDisplay(monitor_info); 124 return GetDisplay(monitor_info);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 #endif // USE_AURA 163 #endif // USE_AURA
164 } 164 }
165 165
166 #if !defined(USE_AURA) 166 #if !defined(USE_AURA)
167 Screen* CreateNativeScreen() { 167 Screen* CreateNativeScreen() {
168 return new ScreenWin; 168 return new ScreenWin;
169 } 169 }
170 #endif // !USE_AURA 170 #endif // !USE_AURA
171 171
172 } // namespace gfx 172 } // namespace gfx
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_win.cc ('k') | ui/gfx/win/hwnd_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698