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

Unified Diff: ui/gfx/screen_aura.cc

Issue 9960042: Refactor screen/monitor so that gfx::Screen returns monitor object. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 8 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/screen_aura.cc
diff --git a/ui/gfx/screen_aura.cc b/ui/gfx/screen_aura.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5a39715622ab252e5a14440f16fd2a1abc31f6d6
--- /dev/null
+++ b/ui/gfx/screen_aura.cc
@@ -0,0 +1,90 @@
+// Copyright (c) 2012 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 "ui/gfx/screen.h"
+
+#include "base/logging.h"
+#include "ui/gfx/monitor.h"
+#include "ui/gfx/native_widget_types.h"
+#include "ui/gfx/screen_impl.h"
+
+namespace gfx {
+
+// gfx can't depend upon aura, otherwise we have circular dependencies. So,
+// gfx::Screen is pluggable and Desktop plugs in the real implementation.
+namespace {
+ScreenImpl* g_instance_ = NULL;
+
+// TODO(erg): Figure out what to do about the Screen class. For now, I've
+// added default values for when a Screen instance class isn't passed in, but
+// this is the wrong thing.
+void SetDefaultBounds(Monitor* monitor_out) {
+ static Rect* default_bounds = new gfx::Rect(0, 0, 800, 800);
+ monitor_out->set_bounds(*default_bounds);
+ monitor_out->set_work_area(*default_bounds);
+};
+
+}
+
+// static
+void Screen::SetInstance(ScreenImpl* screen) {
+ delete g_instance_;
+ g_instance_ = screen;
+}
+
+// static
+Point Screen::GetCursorScreenPoint() {
+ if (!g_instance_)
Ben Goodger (Google) 2012/04/13 19:57:19 Is this for gfx tests? Can you just provide a stub
oshima 2012/04/13 21:18:41 I think erg added this. Elliot, do we still need t
oshima 2012/04/14 15:23:36 talked to erg and this is no longer necessary. Rem
+ return Point();
+ return g_instance_->GetCursorScreenPoint();
+}
+
+// static
+NativeWindow Screen::GetWindowAtCursorScreenPoint() {
+ if (!g_instance_)
+ return NULL;
+ return g_instance_->GetWindowAtCursorScreenPoint();
+}
+
+// static
+int Screen::GetNumMonitors() {
+ if (!g_instance_)
+ return 1;
+ return g_instance_->GetNumMonitors();
+}
+
+// static
+void Screen::GetMonitorNearestWindow(NativeWindow window,
+ Monitor* monitor_out) {
+ if (!g_instance_)
+ SetDefaultBounds(monitor_out);
+ else
+ g_instance_->GetMonitorNearestWindow(window, monitor_out);
+}
+
+// static
+void Screen::GetMonitorNearestPoint(const Point& point, Monitor* monitor_out) {
+ if (!g_instance_)
+ SetDefaultBounds(monitor_out);
+ else
+ g_instance_->GetMonitorNearestPoint(point, monitor_out);
+}
+
+// static
+void Screen::GetPrimaryMonitor(Monitor* monitor_out) {
+ if (!g_instance_)
+ SetDefaultBounds(monitor_out);
+ else
+ g_instance_->GetPrimaryMonitor(monitor_out);
+}
+
+// static
+void Screen::GetMonitorMatching(const Rect& match_rect, Monitor* monitor_out) {
+ if (!g_instance_)
+ SetDefaultBounds(monitor_out);
+ else
+ g_instance_->GetMonitorNearestPoint(match_rect.CenterPoint(), monitor_out);
+}
+
+} // namespace gfx
« ui/gfx/screen.h ('K') | « ui/gfx/screen_ash.cc ('k') | ui/gfx/screen_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698