| 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 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 11 #include "base/hash.h" | 12 #include "base/hash.h" |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/win/win_util.h" | 15 #include "base/win/win_util.h" |
| 15 #include "ui/gfx/display.h" | 16 #include "ui/gfx/display.h" |
| 16 #include "ui/gfx/win/dpi.h" | 17 #include "ui/gfx/win/dpi.h" |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 MONITORINFOEX GetMonitorInfoForMonitor(HMONITOR monitor) { | 21 MONITORINFOEX GetMonitorInfoForMonitor(HMONITOR monitor) { |
| 21 MONITORINFOEX monitor_info; | 22 MONITORINFOEX monitor_info; |
| 22 ZeroMemory(&monitor_info, sizeof(MONITORINFOEX)); | 23 ZeroMemory(&monitor_info, sizeof(MONITORINFOEX)); |
| 23 monitor_info.cbSize = sizeof(monitor_info); | 24 monitor_info.cbSize = sizeof(monitor_info); |
| 24 GetMonitorInfo(monitor, &monitor_info); | 25 GetMonitorInfo(monitor, &monitor_info); |
| 25 return monitor_info; | 26 return monitor_info; |
| 26 } | 27 } |
| 27 | 28 |
| 28 gfx::Display GetDisplay(const MONITORINFOEX& monitor_info) { | 29 gfx::Display GetDisplay(const MONITORINFOEX& monitor_info) { |
| 29 int64 id = static_cast<int64>( | 30 int64_t id = |
| 30 base::Hash(base::WideToUTF8(monitor_info.szDevice))); | 31 static_cast<int64_t>(base::Hash(base::WideToUTF8(monitor_info.szDevice))); |
| 31 gfx::Rect bounds = gfx::Rect(monitor_info.rcMonitor); | 32 gfx::Rect bounds = gfx::Rect(monitor_info.rcMonitor); |
| 32 gfx::Display display(id); | 33 gfx::Display display(id); |
| 33 display.set_bounds(gfx::win::ScreenToDIPRect(bounds)); | 34 display.set_bounds(gfx::win::ScreenToDIPRect(bounds)); |
| 34 display.set_work_area( | 35 display.set_work_area( |
| 35 gfx::win::ScreenToDIPRect(gfx::Rect(monitor_info.rcWork))); | 36 gfx::win::ScreenToDIPRect(gfx::Rect(monitor_info.rcWork))); |
| 36 display.SetScaleAndBounds(gfx::GetDPIScale(), bounds); | 37 display.SetScaleAndBounds(gfx::GetDPIScale(), bounds); |
| 37 | 38 |
| 38 DEVMODE mode; | 39 DEVMODE mode; |
| 39 memset(&mode, 0, sizeof(DEVMODE)); | 40 memset(&mode, 0, sizeof(DEVMODE)); |
| 40 mode.dmSize = sizeof(DEVMODE); | 41 mode.dmSize = sizeof(DEVMODE); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 std::vector<gfx::Display> ScreenWin::GetDisplaysForMonitorInfos( | 207 std::vector<gfx::Display> ScreenWin::GetDisplaysForMonitorInfos( |
| 207 const std::vector<MONITORINFOEX>& monitor_infos) { | 208 const std::vector<MONITORINFOEX>& monitor_infos) { |
| 208 std::vector<gfx::Display> displays; | 209 std::vector<gfx::Display> displays; |
| 209 for (const MONITORINFOEX& monitor_info : monitor_infos) | 210 for (const MONITORINFOEX& monitor_info : monitor_infos) |
| 210 displays.push_back(GetDisplay(monitor_info)); | 211 displays.push_back(GetDisplay(monitor_info)); |
| 211 | 212 |
| 212 return displays; | 213 return displays; |
| 213 } | 214 } |
| 214 | 215 |
| 215 } // namespace gfx | 216 } // namespace gfx |
| OLD | NEW |