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

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

Issue 659883002: Enable hidpi on Linux, refactor a bit on Windows to share Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: resource bundle loading Created 6 years, 2 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
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/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 GetMonitorInfo(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 int64 id = static_cast<int64>( 27 int64 id = static_cast<int64>(
28 base::Hash(base::WideToUTF8(monitor_info.szDevice))); 28 base::Hash(base::WideToUTF8(monitor_info.szDevice)));
29 gfx::Rect bounds = gfx::Rect(monitor_info.rcMonitor); 29 gfx::Rect bounds = gfx::Rect(monitor_info.rcMonitor);
30 gfx::Display display(id, bounds); 30 gfx::Display display(id, bounds);
31 display.set_work_area(gfx::Rect(monitor_info.rcWork)); 31 display.set_work_area(gfx::Rect(monitor_info.rcWork));
32 display.SetScaleAndBounds(gfx::win::GetDeviceScaleFactor(), bounds); 32 display.SetScaleAndBounds(gfx::GetDeviceScaleFactor(), bounds);
33 33
34 DEVMODE mode; 34 DEVMODE mode;
35 memset(&mode, 0, sizeof(DEVMODE)); 35 memset(&mode, 0, sizeof(DEVMODE));
36 mode.dmSize = sizeof(DEVMODE); 36 mode.dmSize = sizeof(DEVMODE);
37 mode.dmDriverExtra = 0; 37 mode.dmDriverExtra = 0;
38 if (EnumDisplaySettings(monitor_info.szDevice, 38 if (EnumDisplaySettings(monitor_info.szDevice,
39 ENUM_CURRENT_SETTINGS, 39 ENUM_CURRENT_SETTINGS,
40 &mode)) { 40 &mode)) {
41 switch (mode.dmDisplayOrientation) { 41 switch (mode.dmDisplayOrientation) {
42 case DMDO_DEFAULT: 42 case DMDO_DEFAULT:
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 } 94 }
95 95
96 bool ScreenWin::IsDIPEnabled() { 96 bool ScreenWin::IsDIPEnabled() {
97 return IsInHighDPIMode(); 97 return IsInHighDPIMode();
98 } 98 }
99 99
100 gfx::Point ScreenWin::GetCursorScreenPoint() { 100 gfx::Point ScreenWin::GetCursorScreenPoint() {
101 POINT pt; 101 POINT pt;
102 GetCursorPos(&pt); 102 GetCursorPos(&pt);
103 gfx::Point cursor_pos_pixels(pt); 103 gfx::Point cursor_pos_pixels(pt);
104 return gfx::win::ScreenToDIPPoint(cursor_pos_pixels); 104 return gfx::ScreenToDIPPoint(cursor_pos_pixels);
105 } 105 }
106 106
107 gfx::NativeWindow ScreenWin::GetWindowUnderCursor() { 107 gfx::NativeWindow ScreenWin::GetWindowUnderCursor() {
108 POINT cursor_loc; 108 POINT cursor_loc;
109 HWND hwnd = GetCursorPos(&cursor_loc) ? WindowFromPoint(cursor_loc) : NULL; 109 HWND hwnd = GetCursorPos(&cursor_loc) ? WindowFromPoint(cursor_loc) : NULL;
110 return GetNativeWindowFromHWND(hwnd); 110 return GetNativeWindowFromHWND(hwnd);
111 } 111 }
112 112
113 gfx::NativeWindow ScreenWin::GetWindowAtScreenPoint(const gfx::Point& point) { 113 gfx::NativeWindow ScreenWin::GetWindowAtScreenPoint(const gfx::Point& point) {
114 gfx::Point point_in_pixels = gfx::win::DIPToScreenPoint(point); 114 gfx::Point point_in_pixels = gfx::DIPToScreenPoint(point);
115 return GetNativeWindowFromHWND(WindowFromPoint(point_in_pixels.ToPOINT())); 115 return GetNativeWindowFromHWND(WindowFromPoint(point_in_pixels.ToPOINT()));
116 } 116 }
117 117
118 int ScreenWin::GetNumDisplays() const { 118 int ScreenWin::GetNumDisplays() const {
119 return GetSystemMetrics(SM_CMONITORS); 119 return GetSystemMetrics(SM_CMONITORS);
120 } 120 }
121 121
122 std::vector<gfx::Display> ScreenWin::GetAllDisplays() const { 122 std::vector<gfx::Display> ScreenWin::GetAllDisplays() const {
123 return displays_; 123 return displays_;
124 } 124 }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 NOTREACHED(); 196 NOTREACHED();
197 return NULL; 197 return NULL;
198 } 198 }
199 199
200 NativeWindow ScreenWin::GetNativeWindowFromHWND(HWND hwnd) const { 200 NativeWindow ScreenWin::GetNativeWindowFromHWND(HWND hwnd) const {
201 NOTREACHED(); 201 NOTREACHED();
202 return NULL; 202 return NULL;
203 } 203 }
204 204
205 } // namespace gfx 205 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698