| 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..e871a3f9e86b9921cafcb7d7e62d7819e130425f
|
| --- /dev/null
|
| +++ b/ui/gfx/screen_aura.cc
|
| @@ -0,0 +1,85 @@
|
| +// 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.
|
| +const Monitor* GetDefaultMonitor() {
|
| + static SimpleMonitor* default_monitor =
|
| + new SimpleMonitor(gfx::Rect(0, 0, 800, 800));
|
| + return default_monitor;
|
| +};
|
| +
|
| +}
|
| +
|
| +// static
|
| +void Screen::SetInstance(ScreenImpl* screen) {
|
| + delete g_instance_;
|
| + g_instance_ = screen;
|
| +}
|
| +
|
| +// static
|
| +gfx::Point Screen::GetCursorScreenPoint() {
|
| + if (!g_instance_)
|
| + return gfx::Point();
|
| + return g_instance_->GetCursorScreenPoint();
|
| +}
|
| +
|
| +// static
|
| +gfx::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
|
| +const gfx::Monitor* Screen::GetMonitorNearestWindow(gfx::NativeWindow window) {
|
| + if (!g_instance_)
|
| + return GetDefaultMonitor();
|
| + return g_instance_->GetMonitorNearestWindow(window);
|
| +}
|
| +
|
| +// static
|
| +const gfx::Monitor* Screen::GetMonitorNearestPoint(const gfx::Point& point) {
|
| + if (!g_instance_)
|
| + return GetDefaultMonitor();
|
| + return g_instance_->GetMonitorNearestPoint(point);
|
| +}
|
| +
|
| +// static
|
| +const gfx::Monitor* Screen::GetPrimaryMonitor() {
|
| + if (!g_instance_)
|
| + return GetDefaultMonitor();
|
| + return g_instance_->GetPrimaryMonitor();
|
| +}
|
| +
|
| +// static
|
| +const gfx::Monitor* Screen::GetMonitorMatching(const gfx::Rect& match_rect) {
|
| + if (!g_instance_)
|
| + return GetDefaultMonitor();
|
| + return g_instance_->GetMonitorNearestPoint(match_rect.CenterPoint());
|
| +}
|
| +
|
| +} // namespace gfx
|
|
|