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

Unified Diff: ui/gfx/display.cc

Issue 1563183008: Added capability on Windows to get the physical dimensions of your attached monitors. Also added th… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 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 side-by-side diff with in-line comments
Download patch
Index: ui/gfx/display.cc
diff --git a/ui/gfx/display.cc b/ui/gfx/display.cc
index 1777e87e5433822f6769e053a6459a0cd18499dd..7e715512ddc9069f44ba88f688dcc9c0f41f301b 100644
--- a/ui/gfx/display.cc
+++ b/ui/gfx/display.cc
@@ -5,6 +5,7 @@
#include "ui/gfx/display.h"
#include <algorithm>
+#include <vector>
#include "base/command_line.h"
#include "base/logging.h"
@@ -17,6 +18,11 @@
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/switches.h"
+#if defined(OS_WIN)
+#include "ui/gfx/screen_win.h"
+#include "ui/gfx/win/physical_size.h"
+#endif
+
namespace gfx {
namespace {
@@ -195,6 +201,27 @@ bool Display::IsInternal() const {
return is_valid() && (id_ == internal_display_id_);
}
+bool Display::GetPhysicalSize(int* width_mm, int* height_mm) const {
+#if defined(OS_WIN)
+ std::vector<gfx::DisplaySize> display_sizes;
+ gfx::GetPhysicalSizeForDisplays(&display_sizes);
+ for (size_t i = 0; i < display_sizes.size(); ++i) {
scottmg 2016/01/09 01:00:05 for (const auto& display_size : display_sizes) ?
Bret 2016/01/12 00:23:46 Done.
+ const gfx::DisplaySize& display_size = display_sizes[i];
+ int64_t interface_id =
+ ScreenWin::GenerateDisplayId(display_size.display_name);
+ if (interface_id == id_) {
+ *width_mm = display_size.width_mm;
+ *height_mm = display_size.height_mm;
+ return true;
+ }
+ }
+ return false;
+#else
+ // unimplemented
scottmg 2016/01/09 01:00:05 "Unimplemented." or just delete this line, since t
Bret 2016/01/12 00:23:46 Done.
+ NOTREACHED();
+#endif
+}
+
// static
int64_t Display::InternalDisplayId() {
DCHECK_NE(kInvalidDisplayID, internal_display_id_);

Powered by Google App Engine
This is Rietveld 408576698