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

Unified Diff: ui/gfx/screen_win.cc

Issue 23707010: Implement Display id field in ScreenWin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/screen_win.cc
diff --git a/ui/gfx/screen_win.cc b/ui/gfx/screen_win.cc
index 23dbc9d60fbb865a6124b32d57690bbb41d21ba2..3d0706ddf71c113f1fcc69efc98d679db9dd2314 100644
--- a/ui/gfx/screen_win.cc
+++ b/ui/gfx/screen_win.cc
@@ -6,24 +6,28 @@
#include <windows.h>
+#include "base/hash.h"
#include "base/logging.h"
+#include "base/strings/utf_string_conversions.h"
#include "base/win/win_util.h"
#include "ui/base/win/dpi.h"
#include "ui/gfx/display.h"
namespace {
-MONITORINFO GetMonitorInfoForMonitor(HMONITOR monitor) {
- MONITORINFO monitor_info = { 0 };
+MONITORINFOEX GetMonitorInfoForMonitor(HMONITOR monitor) {
+ MONITORINFOEX monitor_info;
+ ZeroMemory(&monitor_info, sizeof(MONITORINFOEX));
monitor_info.cbSize = sizeof(monitor_info);
base::win::GetMonitorInfoWrapper(monitor, &monitor_info);
return monitor_info;
}
-gfx::Display GetDisplay(MONITORINFO& monitor_info) {
- // TODO(oshima): Implement ID and Observer.
+gfx::Display GetDisplay(MONITORINFOEX& monitor_info) {
+ // TODO(oshima): Implement Observer.
+ int64 id = static_cast<int64>(base::Hash(WideToUTF8(monitor_info.szDevice)));
gfx::Rect bounds = gfx::Rect(monitor_info.rcMonitor);
- gfx::Display display(0, bounds);
+ gfx::Display display(id, bounds);
display.set_work_area(gfx::Rect(monitor_info.rcWork));
display.SetScaleAndBounds(ui::win::GetDeviceScaleFactor(), bounds);
return display;
@@ -73,7 +77,7 @@ gfx::Display ScreenWin::GetDisplayNearestWindow(gfx::NativeView window) const {
return GetPrimaryDisplay();
}
- MONITORINFO monitor_info;
+ MONITORINFOEX monitor_info;
monitor_info.cbSize = sizeof(monitor_info);
base::win::GetMonitorInfoWrapper(
MonitorFromWindow(window_hwnd, MONITOR_DEFAULTTONEAREST), &monitor_info);
@@ -83,7 +87,8 @@ gfx::Display ScreenWin::GetDisplayNearestWindow(gfx::NativeView window) const {
gfx::Display ScreenWin::GetDisplayNearestPoint(const gfx::Point& point) const {
POINT initial_loc = { point.x(), point.y() };
HMONITOR monitor = MonitorFromPoint(initial_loc, MONITOR_DEFAULTTONEAREST);
- MONITORINFO mi = {0};
+ MONITORINFOEX mi;
+ ZeroMemory(&mi, sizeof(MONITORINFOEX));
mi.cbSize = sizeof(mi);
if (monitor && base::win::GetMonitorInfoWrapper(monitor, &mi)) {
return GetDisplay(mi);
@@ -93,13 +98,13 @@ gfx::Display ScreenWin::GetDisplayNearestPoint(const gfx::Point& point) const {
gfx::Display ScreenWin::GetDisplayMatching(const gfx::Rect& match_rect) const {
RECT other_bounds_rect = match_rect.ToRECT();
- MONITORINFO monitor_info = GetMonitorInfoForMonitor(MonitorFromRect(
+ MONITORINFOEX monitor_info = GetMonitorInfoForMonitor(MonitorFromRect(
&other_bounds_rect, MONITOR_DEFAULTTONEAREST));
return GetDisplay(monitor_info);
}
gfx::Display ScreenWin::GetPrimaryDisplay() const {
- MONITORINFO mi = GetMonitorInfoForMonitor(
+ MONITORINFOEX mi = GetMonitorInfoForMonitor(
MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY));
gfx::Display display = GetDisplay(mi);
// TODO(kevers|girard): Test if these checks can be reintroduced for high-DIP
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698