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

Unified Diff: ui/gfx/screen_win.cc

Issue 11030017: Add context to gfx::Screen calls in support of simultaneous desktop+ash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix new addition Created 8 years, 2 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 | « ui/gfx/screen_unittest.cc ('k') | ui/ui.gyp » ('j') | 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 47583608d7531ee4c3f8785a382a6d398cb77b44..58844ac9466bd53a7542f776c20a95b62f80432c 100644
--- a/ui/gfx/screen_win.cc
+++ b/ui/gfx/screen_win.cc
@@ -25,69 +25,73 @@ gfx::Display GetDisplay(MONITORINFO& monitor_info) {
return display;
}
+class ScreenWin : public gfx::Screen {
+ public:
+ ScreenWin() {}
+
+ bool IsDIPEnabled() OVERRIDE {
+ return false;
+ }
+
+ gfx::Point GetCursorScreenPoint() OVERRIDE {
+ POINT pt;
+ GetCursorPos(&pt);
+ return gfx::Point(pt);
+ }
+
+ gfx::NativeWindow GetWindowAtCursorScreenPoint() OVERRIDE {
+ POINT location;
+ return GetCursorPos(&location) ? WindowFromPoint(location) : NULL;
+ }
+
+ int GetNumDisplays() OVERRIDE {
+ return GetSystemMetrics(SM_CMONITORS);
+ }
+
+ gfx::Display GetDisplayNearestWindow(gfx::NativeView window) const OVERRIDE {
+ MONITORINFO monitor_info;
+ monitor_info.cbSize = sizeof(monitor_info);
+ GetMonitorInfo(MonitorFromWindow(window, MONITOR_DEFAULTTONEAREST),
+ &monitor_info);
+ return GetDisplay(monitor_info);
+ }
+
+ gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const OVERRIDE {
+ POINT initial_loc = { point.x(), point.y() };
+ HMONITOR monitor = MonitorFromPoint(initial_loc, MONITOR_DEFAULTTONEAREST);
+ MONITORINFO mi = {0};
+ mi.cbSize = sizeof(mi);
+ if (monitor && GetMonitorInfo(monitor, &mi))
+ return GetDisplay(mi);
+ return gfx::Display();
+ }
+
+ gfx::Display GetDisplayMatching(const gfx::Rect& match_rect) const OVERRIDE {
+ RECT other_bounds_rect = match_rect.ToRECT();
+ MONITORINFO monitor_info = GetMonitorInfoForMonitor(MonitorFromRect(
+ &other_bounds_rect, MONITOR_DEFAULTTONEAREST));
+ return GetDisplay(monitor_info);
+ }
+
+ gfx::Display GetPrimaryDisplay() const OVERRIDE {
+ MONITORINFO mi = GetMonitorInfoForMonitor(
+ MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY));
+ gfx::Display display = GetDisplay(mi);
+ DCHECK_EQ(GetSystemMetrics(SM_CXSCREEN), display.size().width());
+ DCHECK_EQ(GetSystemMetrics(SM_CYSCREEN), display.size().height());
+ return display;
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ScreenWin);
+};
+
} // namespace
namespace gfx {
-// static
-bool Screen::IsDIPEnabled() {
- return false;
-}
-
-// static
-gfx::Point Screen::GetCursorScreenPoint() {
- POINT pt;
- GetCursorPos(&pt);
- return gfx::Point(pt);
-}
-
-// static
-gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() {
- POINT location;
- return GetCursorPos(&location) ? WindowFromPoint(location) : NULL;
-}
-
-// static
-int Screen::GetNumDisplays() {
- return GetSystemMetrics(SM_CMONITORS);
-}
-
-// static
-gfx::Display Screen::GetDisplayNearestWindow(gfx::NativeView window) {
- MONITORINFO monitor_info;
- monitor_info.cbSize = sizeof(monitor_info);
- GetMonitorInfo(MonitorFromWindow(window, MONITOR_DEFAULTTONEAREST),
- &monitor_info);
- return GetDisplay(monitor_info);
-}
-
-// static
-gfx::Display Screen::GetDisplayNearestPoint(const gfx::Point& point) {
- POINT initial_loc = { point.x(), point.y() };
- HMONITOR monitor = MonitorFromPoint(initial_loc, MONITOR_DEFAULTTONEAREST);
- MONITORINFO mi = {0};
- mi.cbSize = sizeof(mi);
- if (monitor && GetMonitorInfo(monitor, &mi))
- return GetDisplay(mi);
- return gfx::Display();
-}
-
-// static
-gfx::Display Screen::GetDisplayMatching(const gfx::Rect& match_rect) {
- RECT other_bounds_rect = match_rect.ToRECT();
- MONITORINFO monitor_info = GetMonitorInfoForMonitor(MonitorFromRect(
- &other_bounds_rect, MONITOR_DEFAULTTONEAREST));
- return GetDisplay(monitor_info);
-}
-
-// static
-gfx::Display Screen::GetPrimaryDisplay() {
- MONITORINFO mi = GetMonitorInfoForMonitor(
- MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY));
- gfx::Display display = GetDisplay(mi);
- DCHECK_EQ(GetSystemMetrics(SM_CXSCREEN), display.size().width());
- DCHECK_EQ(GetSystemMetrics(SM_CYSCREEN), display.size().height());
- return display;
+Screen* CreateNativeScreen() {
+ return new ScreenWin;
}
} // namespace gfx
« no previous file with comments | « ui/gfx/screen_unittest.cc ('k') | ui/ui.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698