Chromium Code Reviews| 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_win.h" | 5 #include "ui/gfx/screen_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/hash.h" | 12 #include "base/hash.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/win/win_util.h" | 15 #include "base/win/win_util.h" |
| 16 #include "ui/gfx/display.h" | 16 #include "ui/gfx/display.h" |
| 17 #include "ui/gfx/win/dpi.h" | 17 #include "ui/gfx/win/dpi.h" |
| 18 #include "ui/gfx/win/physical_size.h" | |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 MONITORINFOEX GetMonitorInfoForMonitor(HMONITOR monitor) { | 22 MONITORINFOEX GetMonitorInfoForMonitor(HMONITOR monitor) { |
| 22 MONITORINFOEX monitor_info; | 23 MONITORINFOEX monitor_info; |
| 23 ZeroMemory(&monitor_info, sizeof(MONITORINFOEX)); | 24 ZeroMemory(&monitor_info, sizeof(MONITORINFOEX)); |
| 24 monitor_info.cbSize = sizeof(monitor_info); | 25 monitor_info.cbSize = sizeof(monitor_info); |
| 25 GetMonitorInfo(monitor, &monitor_info); | 26 GetMonitorInfo(monitor, &monitor_info); |
| 26 return monitor_info; | 27 return monitor_info; |
| 27 } | 28 } |
| 28 | 29 |
| 30 int64_t GenerateDisplayId(const std::string& str) { | |
|
sky
2016/01/14 15:36:58
Is this change still needed?
Bret
2016/01/14 21:46:45
I missed that. Reverted.
| |
| 31 return static_cast<int64_t>(base::Hash(str)); | |
| 32 } | |
| 33 | |
| 29 gfx::Display GetDisplay(const MONITORINFOEX& monitor_info) { | 34 gfx::Display GetDisplay(const MONITORINFOEX& monitor_info) { |
| 30 int64_t id = | 35 int64_t id = GenerateDisplayId(base::WideToUTF8(monitor_info.szDevice)); |
| 31 static_cast<int64_t>(base::Hash(base::WideToUTF8(monitor_info.szDevice))); | |
| 32 gfx::Rect bounds = gfx::Rect(monitor_info.rcMonitor); | 36 gfx::Rect bounds = gfx::Rect(monitor_info.rcMonitor); |
| 33 gfx::Display display(id); | 37 gfx::Display display(id); |
| 34 display.set_bounds(gfx::win::ScreenToDIPRect(bounds)); | 38 display.set_bounds(gfx::win::ScreenToDIPRect(bounds)); |
| 35 display.set_work_area( | 39 display.set_work_area( |
| 36 gfx::win::ScreenToDIPRect(gfx::Rect(monitor_info.rcWork))); | 40 gfx::win::ScreenToDIPRect(gfx::Rect(monitor_info.rcWork))); |
| 37 display.SetScaleAndBounds(gfx::GetDPIScale(), bounds); | 41 display.SetScaleAndBounds(gfx::GetDPIScale(), bounds); |
| 38 | 42 |
| 39 DEVMODE mode; | 43 DEVMODE mode; |
| 40 memset(&mode, 0, sizeof(DEVMODE)); | 44 memset(&mode, 0, sizeof(DEVMODE)); |
| 41 mode.dmSize = sizeof(DEVMODE); | 45 mode.dmSize = sizeof(DEVMODE); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 std::vector<gfx::Display> ScreenWin::GetDisplaysForMonitorInfos( | 211 std::vector<gfx::Display> ScreenWin::GetDisplaysForMonitorInfos( |
| 208 const std::vector<MONITORINFOEX>& monitor_infos) { | 212 const std::vector<MONITORINFOEX>& monitor_infos) { |
| 209 std::vector<gfx::Display> displays; | 213 std::vector<gfx::Display> displays; |
| 210 for (const MONITORINFOEX& monitor_info : monitor_infos) | 214 for (const MONITORINFOEX& monitor_info : monitor_infos) |
| 211 displays.push_back(GetDisplay(monitor_info)); | 215 displays.push_back(GetDisplay(monitor_info)); |
| 212 | 216 |
| 213 return displays; | 217 return displays; |
| 214 } | 218 } |
| 215 | 219 |
| 216 } // namespace gfx | 220 } // namespace gfx |
| OLD | NEW |