summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-25 00:39:35 +0000
committerderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-25 00:39:35 +0000
commit6b7d954ff37811b45fac57e34418ff1c169b6ef8 (patch)
treef9b48972f6343d85508e1277bc9c524d7cb222a2
parented5c8219cf7da9a89d3da219c09f777ac3998ba9 (diff)
downloadchromium_src-6b7d954ff37811b45fac57e34418ff1c169b6ef8.zip
chromium_src-6b7d954ff37811b45fac57e34418ff1c169b6ef8.tar.gz
chromium_src-6b7d954ff37811b45fac57e34418ff1c169b6ef8.tar.bz2
Move DisplayUtils methods into gfx::Screen.
These methods are currently just used by metrics. I moved them from base into the browser a while back, but I think it makes the most sense for them to live in gfx::Screen. I'm also relocating the tests to ui_unittest and making them work on Aura. BUG=99711,100341 TEST=ran ui_unittest Review URL: http://codereview.chromium.org/8382019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107027 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/metrics/display_utils.h24
-rw-r--r--chrome/browser/metrics/display_utils_aura.cc23
-rw-r--r--chrome/browser/metrics/display_utils_gtk.cc28
-rw-r--r--chrome/browser/metrics/display_utils_mac.cc51
-rw-r--r--chrome/browser/metrics/display_utils_unittest.cc32
-rw-r--r--chrome/browser/metrics/display_utils_win.cc21
-rw-r--r--chrome/browser/metrics/metrics_log.cc12
-rw-r--r--chrome/chrome_browser.gypi5
-rw-r--r--chrome/chrome_tests.gypi1
-rw-r--r--ui/aura/screen_aura.cc8
-rw-r--r--ui/aura/screen_aura.h2
-rw-r--r--ui/gfx/screen.h12
-rw-r--r--ui/gfx/screen_aura.cc16
-rw-r--r--ui/gfx/screen_gtk.cc15
-rw-r--r--ui/gfx/screen_mac.mm43
-rw-r--r--ui/gfx/screen_unittest.cc45
-rw-r--r--ui/gfx/screen_win.cc12
-rw-r--r--ui/ui_unittests.gypi6
18 files changed, 158 insertions, 198 deletions
diff --git a/chrome/browser/metrics/display_utils.h b/chrome/browser/metrics/display_utils.h
deleted file mode 100644
index c512148..0000000
--- a/chrome/browser/metrics/display_utils.h
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_METRICS_DISPLAY_UTILS_H_
-#define CHROME_BROWSER_METRICS_DISPLAY_UTILS_H_
-#pragma once
-
-#include "base/basictypes.h"
-
-class DisplayUtils {
- public:
- // Returns the pixel dimensions of the primary display via the
- // width and height parameters.
- static void GetPrimaryDisplayDimensions(int* width, int* height);
-
- // Returns the number of displays.
- static int GetDisplayCount();
-
- private:
- DISALLOW_COPY_AND_ASSIGN(DisplayUtils);
-};
-
-#endif // CHROME_BROWSER_METRICS_DISPLAY_UTILS_H_
diff --git a/chrome/browser/metrics/display_utils_aura.cc b/chrome/browser/metrics/display_utils_aura.cc
deleted file mode 100644
index 791c973..0000000
--- a/chrome/browser/metrics/display_utils_aura.cc
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/metrics/display_utils.h"
-
-#include "content/browser/browser_thread.h"
-#include "ui/gfx/screen.h"
-
-// static
-void DisplayUtils::GetPrimaryDisplayDimensions(int* width, int* height) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- gfx::Rect bounds =
- gfx::Screen::GetMonitorAreaNearestPoint(gfx::Point());
- *width = bounds.width();
- *height = bounds.height();
-}
-
-// static
-int DisplayUtils::GetDisplayCount() {
- NOTIMPLEMENTED();
- return 1;
-}
diff --git a/chrome/browser/metrics/display_utils_gtk.cc b/chrome/browser/metrics/display_utils_gtk.cc
deleted file mode 100644
index e3f5667..0000000
--- a/chrome/browser/metrics/display_utils_gtk.cc
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/metrics/display_utils.h"
-
-#include <gdk/gdk.h>
-
-#include "content/browser/browser_thread.h"
-
-// static
-void DisplayUtils::GetPrimaryDisplayDimensions(int* width, int* height) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- GdkScreen* screen = gdk_screen_get_default();
- if (width)
- *width = gdk_screen_get_width(screen);
- if (height)
- *height = gdk_screen_get_height(screen);
-}
-
-// static
-int DisplayUtils::GetDisplayCount() {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- // This query is kinda bogus for Linux -- do we want number of X screens?
- // The number of monitors Xinerama has? We'll just use whatever GDK uses.
- GdkScreen* screen = gdk_screen_get_default();
- return gdk_screen_get_n_monitors(screen);
-}
diff --git a/chrome/browser/metrics/display_utils_mac.cc b/chrome/browser/metrics/display_utils_mac.cc
deleted file mode 100644
index dd0fd30..0000000
--- a/chrome/browser/metrics/display_utils_mac.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/metrics/display_utils.h"
-
-#include <ApplicationServices/ApplicationServices.h>
-
-// static
-void DisplayUtils::GetPrimaryDisplayDimensions(int* width, int* height) {
- CGDirectDisplayID main_display = CGMainDisplayID();
- if (width)
- *width = CGDisplayPixelsWide(main_display);
- if (height)
- *height = CGDisplayPixelsHigh(main_display);
-}
-
-// static
-int DisplayUtils::GetDisplayCount() {
- // Don't just return the number of online displays. It includes displays
- // that mirror other displays, which are not desired in the count. It's
- // tempting to use the count returned by CGGetActiveDisplayList, but active
- // displays exclude sleeping displays, and those are desired in the count.
-
- // It would be ridiculous to have this many displays connected, but
- // CGDirectDisplayID is just an integer, so supporting up to this many
- // doesn't hurt.
- CGDirectDisplayID online_displays[128];
- CGDisplayCount online_display_count = 0;
- if (CGGetOnlineDisplayList(arraysize(online_displays),
- online_displays,
- &online_display_count) != kCGErrorSuccess) {
- // 1 is a reasonable assumption.
- return 1;
- }
-
- int display_count = 0;
- for (CGDisplayCount online_display_index = 0;
- online_display_index < online_display_count;
- ++online_display_index) {
- CGDirectDisplayID online_display = online_displays[online_display_index];
- if (CGDisplayMirrorsDisplay(online_display) == kCGNullDirectDisplay) {
- // If this display doesn't mirror any other, include it in the count.
- // The primary display in a mirrored set will be counted, but those that
- // mirror it will not be.
- ++display_count;
- }
- }
-
- return display_count;
-}
diff --git a/chrome/browser/metrics/display_utils_unittest.cc b/chrome/browser/metrics/display_utils_unittest.cc
deleted file mode 100644
index 40ebc4c..0000000
--- a/chrome/browser/metrics/display_utils_unittest.cc
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/message_loop.h"
-#include "chrome/browser/metrics/display_utils.h"
-#include "content/browser/browser_thread.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-// Crashes on Linux Aura, probably because we need to initialize a Screen
-// object. See http://crbug.com/100341
-#if defined(USE_AURA) && !defined(OS_WIN)
-#define MAYBE_GetPrimaryDisplayDimensions DISABLED_GetPrimaryDisplayDimensions
-#else
-#define MAYBE_GetPrimaryDisplayDimensions GetPrimaryDisplayDimensions
-#endif
-TEST(DisplayUtilsTest, MAYBE_GetPrimaryDisplayDimensions) {
- MessageLoop message_loop;
- BrowserThread ui_thread(BrowserThread::UI, &message_loop);
- int width = 0, height = 0;
- // We aren't actually testing that it's correct, just that it's sane.
- DisplayUtils::GetPrimaryDisplayDimensions(&width, &height);
- EXPECT_GE(width, 10);
- EXPECT_GE(height, 10);
-}
-
-TEST(DisplayUtilsTest, GetDisplayCount) {
- MessageLoop message_loop;
- BrowserThread ui_thread(BrowserThread::UI, &message_loop);
- // We aren't actually testing that it's correct, just that it's sane.
- EXPECT_GE(DisplayUtils::GetDisplayCount(), 1);
-}
diff --git a/chrome/browser/metrics/display_utils_win.cc b/chrome/browser/metrics/display_utils_win.cc
deleted file mode 100644
index 5b459c8..0000000
--- a/chrome/browser/metrics/display_utils_win.cc
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/metrics/display_utils.h"
-
-#include <windows.h>
-
-// static
-void DisplayUtils::GetPrimaryDisplayDimensions(int* width, int* height) {
- if (width)
- *width = GetSystemMetrics(SM_CXSCREEN);
-
- if (height)
- *height = GetSystemMetrics(SM_CYSCREEN);
-}
-
-// static
-int DisplayUtils::GetDisplayCount() {
- return GetSystemMetrics(SM_CMONITORS);
-}
diff --git a/chrome/browser/metrics/metrics_log.cc b/chrome/browser/metrics/metrics_log.cc
index d0bffb0..4526893 100644
--- a/chrome/browser/metrics/metrics_log.cc
+++ b/chrome/browser/metrics/metrics_log.cc
@@ -19,7 +19,6 @@
#include "chrome/browser/autocomplete/autocomplete.h"
#include "chrome/browser/autocomplete/autocomplete_match.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/metrics/display_utils.h"
#include "chrome/browser/plugin_prefs.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile_manager.h"
@@ -28,6 +27,7 @@
#include "chrome/common/pref_names.h"
#include "content/browser/gpu/gpu_data_manager.h"
#include "googleurl/src/gurl.h"
+#include "ui/gfx/screen.h"
#include "webkit/plugins/webplugininfo.h"
#define OPEN_ELEMENT_FOR_SCOPE(name) ScopedElement scoped_element(this, name)
@@ -358,12 +358,10 @@ void MetricsLog::RecordEnvironment(
{
OPEN_ELEMENT_FOR_SCOPE("display");
- int width = 0;
- int height = 0;
- DisplayUtils::GetPrimaryDisplayDimensions(&width, &height);
- WriteIntAttribute("xsize", width);
- WriteIntAttribute("ysize", height);
- WriteIntAttribute("screens", DisplayUtils::GetDisplayCount());
+ const gfx::Size display_size = gfx::Screen::GetPrimaryMonitorSize();
+ WriteIntAttribute("xsize", display_size.width());
+ WriteIntAttribute("ysize", display_size.height());
+ WriteIntAttribute("screens", gfx::Screen::GetNumMonitors());
}
{
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index ffb1340..9bec609 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1531,10 +1531,6 @@
'browser/memory_details_win.cc',
'browser/memory_purger.cc',
'browser/memory_purger.h',
- 'browser/metrics/display_utils_aura.cc',
- 'browser/metrics/display_utils_gtk.cc',
- 'browser/metrics/display_utils_mac.cc',
- 'browser/metrics/display_utils_win.cc',
'browser/metrics/field_trial_synchronizer.cc',
'browser/metrics/field_trial_synchronizer.h',
'browser/metrics/histogram_synchronizer.cc',
@@ -4310,7 +4306,6 @@
'browser/importer/nss_decryptor_system_nss.cc',
'browser/importer/nss_decryptor_system_nss.h',
'browser/jankometer.cc',
- 'browser/metrics/display_utils_posix.cc',
'browser/password_manager/login_database_posix.cc',
'browser/ui/browser_list_stub.cc',
'browser/ui/crypto_module_password_dialog_nss.cc',
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 07f9aff..3c403b9 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1368,7 +1368,6 @@
'browser/language_usage_metrics_unittest.cc',
'browser/mac/keystone_glue_unittest.mm',
'browser/media/media_internals_unittest.cc',
- 'browser/metrics/display_utils_unittest.cc',
'browser/metrics/metrics_log_unittest.cc',
'browser/metrics/metrics_log_serializer_unittest.cc',
'browser/metrics/metrics_response_unittest.cc',
diff --git a/ui/aura/screen_aura.cc b/ui/aura/screen_aura.cc
index 16d1367..c8d64ca 100644
--- a/ui/aura/screen_aura.cc
+++ b/ui/aura/screen_aura.cc
@@ -55,4 +55,12 @@ gfx::Rect ScreenAura::GetWorkAreaBounds() {
return bounds;
}
+gfx::Size ScreenAura::GetPrimaryMonitorSizeImpl() {
+ return GetMonitorWorkAreaNearestPoint(gfx::Point()).size();
+}
+
+int ScreenAura::GetNumMonitorsImpl() {
+ return 1;
+}
+
} // namespace aura
diff --git a/ui/aura/screen_aura.h b/ui/aura/screen_aura.h
index 5ebacf8..b2a9f4c 100644
--- a/ui/aura/screen_aura.h
+++ b/ui/aura/screen_aura.h
@@ -35,6 +35,8 @@ class AURA_EXPORT ScreenAura : public gfx::Screen {
virtual gfx::Rect GetMonitorAreaNearestPointImpl(
const gfx::Point& point) OVERRIDE;
virtual gfx::NativeWindow GetWindowAtCursorScreenPointImpl() OVERRIDE;
+ virtual gfx::Size GetPrimaryMonitorSizeImpl() OVERRIDE;
+ virtual int GetNumMonitorsImpl() OVERRIDE;
private:
// We currently support only one monitor. These two methods return the bounds
diff --git a/ui/gfx/screen.h b/ui/gfx/screen.h
index 0c712d47..45a15ad 100644
--- a/ui/gfx/screen.h
+++ b/ui/gfx/screen.h
@@ -9,6 +9,7 @@
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/point.h"
#include "ui/gfx/rect.h"
+#include "ui/gfx/size.h"
namespace gfx {
@@ -26,6 +27,7 @@ class UI_EXPORT Screen {
static void SetInstance(Screen* screen);
#endif
+ // Returns the current absolute position of the mouse pointer.
static gfx::Point GetCursorScreenPoint();
// Returns the work area of the monitor nearest the specified window.
@@ -44,6 +46,14 @@ class UI_EXPORT Screen {
// Returns the window under the cursor.
static gfx::NativeWindow GetWindowAtCursorScreenPoint();
+ // Returns the dimensions of the primary monitor in pixels.
+ static gfx::Size GetPrimaryMonitorSize();
+
+ // Returns the number of monitors.
+ // Mirrored displays are excluded; this method is intended to return the
+ // number of distinct, usable displays.
+ static int GetNumMonitors();
+
protected:
virtual gfx::Point GetCursorScreenPointImpl() = 0;
virtual gfx::Rect GetMonitorWorkAreaNearestWindowImpl(
@@ -54,6 +64,8 @@ class UI_EXPORT Screen {
const gfx::Point& point) = 0;
virtual gfx::Rect GetMonitorAreaNearestPointImpl(const gfx::Point& point) = 0;
virtual gfx::NativeWindow GetWindowAtCursorScreenPointImpl() = 0;
+ virtual gfx::Size GetPrimaryMonitorSizeImpl() = 0;
+ virtual int GetNumMonitorsImpl() = 0;
private:
#if defined(USE_AURA)
diff --git a/ui/gfx/screen_aura.cc b/ui/gfx/screen_aura.cc
index 097fe8c..0093af6 100644
--- a/ui/gfx/screen_aura.cc
+++ b/ui/gfx/screen_aura.cc
@@ -24,38 +24,42 @@ void Screen::SetInstance(Screen* screen) {
// static
gfx::Point Screen::GetCursorScreenPoint() {
- DCHECK(instance_);
return instance_->GetCursorScreenPointImpl();
}
// static
gfx::Rect Screen::GetMonitorWorkAreaNearestWindow(gfx::NativeWindow window) {
- DCHECK(instance_);
return instance_->GetMonitorWorkAreaNearestWindowImpl(window);
}
// static
gfx::Rect Screen::GetMonitorAreaNearestWindow(gfx::NativeWindow window) {
- DCHECK(instance_);
return instance_->GetMonitorAreaNearestWindowImpl(window);
}
// static
gfx::Rect Screen::GetMonitorWorkAreaNearestPoint(const gfx::Point& point) {
- DCHECK(instance_);
return instance_->GetMonitorWorkAreaNearestPointImpl(point);
}
// static
gfx::Rect Screen::GetMonitorAreaNearestPoint(const gfx::Point& point) {
- DCHECK(instance_);
return instance_->GetMonitorAreaNearestPointImpl(point);
}
// static
gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() {
- DCHECK(instance_);
return instance_->GetWindowAtCursorScreenPointImpl();
}
+// static
+gfx::Size Screen::GetPrimaryMonitorSize() {
+ return instance_->GetPrimaryMonitorSizeImpl();
+}
+
+// static
+int Screen::GetNumMonitors() {
+ return instance_->GetNumMonitorsImpl();
+}
+
} // namespace gfx
diff --git a/ui/gfx/screen_gtk.cc b/ui/gfx/screen_gtk.cc
index 81904e1..42799b7 100644
--- a/ui/gfx/screen_gtk.cc
+++ b/ui/gfx/screen_gtk.cc
@@ -63,6 +63,7 @@ gfx::Rect Screen::GetMonitorAreaNearestPoint(const gfx::Point& point) {
return gfx::Rect(bounds);
}
+// static
gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() {
GdkWindow* window = gdk_window_at_pointer(NULL, NULL);
if (!window)
@@ -77,4 +78,18 @@ gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() {
return GTK_IS_WINDOW(widget) ? GTK_WINDOW(widget) : NULL;
}
+// static
+gfx::Size Screen::GetPrimaryMonitorSize() {
+ GdkScreen* screen = gdk_screen_get_default();
+ return gfx::Size(gdk_screen_get_width(screen), gdk_screen_get_height(screen));
+}
+
+// static
+int Screen::GetNumMonitors() {
+ // This query is kinda bogus for Linux -- do we want number of X screens?
+ // The number of monitors Xinerama has? We'll just use whatever GDK uses.
+ GdkScreen* screen = gdk_screen_get_default();
+ return gdk_screen_get_n_monitors(screen);
+}
+
} // namespace gfx
diff --git a/ui/gfx/screen_mac.mm b/ui/gfx/screen_mac.mm
index b38344a..6bf0992 100644
--- a/ui/gfx/screen_mac.mm
+++ b/ui/gfx/screen_mac.mm
@@ -4,6 +4,7 @@
#include "ui/gfx/screen.h"
+#import <ApplicationServices/ApplicationServices.h>
#import <Cocoa/Cocoa.h>
namespace gfx {
@@ -17,4 +18,46 @@ gfx::Point Screen::GetCursorScreenPoint() {
return gfx::Point(mouseLocation.x, mouseLocation.y);
}
+// static
+gfx::Size Screen::GetPrimaryMonitorSize() {
+ CGDirectDisplayID main_display = CGMainDisplayID();
+ return gfx::Size(CGDisplayPixelsWide(main_display),
+ CGDisplayPixelsHigh(main_display));
+}
+
+// static
+int Screen::GetNumMonitors() {
+ // Don't just return the number of online displays. It includes displays
+ // that mirror other displays, which are not desired in the count. It's
+ // tempting to use the count returned by CGGetActiveDisplayList, but active
+ // displays exclude sleeping displays, and those are desired in the count.
+
+ // It would be ridiculous to have this many displays connected, but
+ // CGDirectDisplayID is just an integer, so supporting up to this many
+ // doesn't hurt.
+ CGDirectDisplayID online_displays[128];
+ CGDisplayCount online_display_count = 0;
+ if (CGGetOnlineDisplayList(arraysize(online_displays),
+ online_displays,
+ &online_display_count) != kCGErrorSuccess) {
+ // 1 is a reasonable assumption.
+ return 1;
+ }
+
+ int display_count = 0;
+ for (CGDisplayCount online_display_index = 0;
+ online_display_index < online_display_count;
+ ++online_display_index) {
+ CGDirectDisplayID online_display = online_displays[online_display_index];
+ if (CGDisplayMirrorsDisplay(online_display) == kCGNullDirectDisplay) {
+ // If this display doesn't mirror any other, include it in the count.
+ // The primary display in a mirrored set will be counted, but those that
+ // mirror it will not be.
+ ++display_count;
+ }
+ }
+
+ return display_count;
+}
+
} // namespace gfx
diff --git a/ui/gfx/screen_unittest.cc b/ui/gfx/screen_unittest.cc
new file mode 100644
index 0000000..4b1a572
--- /dev/null
+++ b/ui/gfx/screen_unittest.cc
@@ -0,0 +1,45 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gfx/screen.h"
+
+#if defined(USE_AURA)
+#include "base/message_loop.h"
+#include "ui/aura/desktop.h"
+#endif
+
+namespace {
+
+#if defined(USE_AURA)
+class ScreenTest : public testing::Test {
+ public:
+ ScreenTest() {
+ aura::Desktop::GetInstance()->ShowDesktop();
+ }
+
+ virtual ~ScreenTest() {
+ aura::Desktop::GetInstance()->DeleteInstanceForTesting();
+ }
+
+ private:
+ MessageLoopForUI message_loop_;
+};
+#else
+typedef testing::Test ScreenTest;
+#endif
+
+TEST_F(ScreenTest, GetPrimaryMonitorSize) {
+ // We aren't actually testing that it's correct, just that it's sane.
+ const gfx::Size size = gfx::Screen::GetPrimaryMonitorSize();
+ EXPECT_GE(size.width(), 1);
+ EXPECT_GE(size.height(), 1);
+}
+
+TEST_F(ScreenTest, GetNumMonitors) {
+ // We aren't actually testing that it's correct, just that it's sane.
+ EXPECT_GE(gfx::Screen::GetNumMonitors(), 1);
+}
+
+} // namespace
diff --git a/ui/gfx/screen_win.cc b/ui/gfx/screen_win.cc
index 530cebe..2873b72 100644
--- a/ui/gfx/screen_win.cc
+++ b/ui/gfx/screen_win.cc
@@ -54,9 +54,21 @@ gfx::Rect Screen::GetMonitorAreaNearestPoint(const gfx::Point& point) {
return GetMonitorAreaOrWorkAreaNearestPoint(point, false);
}
+// static
gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() {
POINT location;
return GetCursorPos(&location) ? WindowFromPoint(location) : NULL;
}
+// static
+gfx::Size Screen::GetPrimaryMonitorSize() {
+ return gfx::Size(GetSystemMetrics(SM_CXSCREEN),
+ GetSystemMetrics(SM_CYSCREEN));
+}
+
+// static
+int Screen::GetNumMonitors() {
+ return GetSystemMetrics(SM_CMONITORS);
+}
+
} // namespace gfx
diff --git a/ui/ui_unittests.gypi b/ui/ui_unittests.gypi
index 5b57fb3..a550de2 100644
--- a/ui/ui_unittests.gypi
+++ b/ui/ui_unittests.gypi
@@ -78,6 +78,7 @@
'gfx/insets_unittest.cc',
'gfx/rect_unittest.cc',
'gfx/run_all_unittests.cc',
+ 'gfx/screen_unittest.cc',
'gfx/skbitmap_operations_unittest.cc',
'gfx/skia_util_unittest.cc',
'gfx/test_suite.cc',
@@ -176,6 +177,11 @@
'base/clipboard/clipboard_unittest.cc',
],
}],
+ ['use_aura==1', {
+ 'dependencies': [
+ 'aura/aura.gyp:aura',
+ ],
+ }],
],
},
],