Chromium Code Reviews| 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..475db60cf0fabbe96bfa31ce807d477fc2df87c7 |
| --- /dev/null |
| +++ b/ui/gfx/screen_aura.cc |
| @@ -0,0 +1,84 @@ |
| +// 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/native_widget_types.h" |
| +#include "ui/gfx/monitor.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* instance_ = NULL; |
|
Ben Goodger (Google)
2012/04/10 16:37:20
g_instance
oshima
2012/04/10 21:31:46
Done.
|
| + |
| +// 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 instance_; |
| + instance_ = screen; |
| +} |
| + |
| +// static |
| +gfx::Point Screen::GetCursorScreenPoint() { |
| + if (!instance_) |
| + return gfx::Point(); |
| + return instance_->GetCursorScreenPoint(); |
| +} |
| + |
| +// static |
| +gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() { |
| + if (!instance_) |
| + return NULL; |
| + return instance_->GetWindowAtCursorScreenPoint(); |
| +} |
| + |
| +// static |
| +int Screen::GetNumMonitors() { |
| + if (!instance_) |
| + return 1; |
| + return instance_->GetNumMonitors(); |
| +} |
| + |
| +// static |
| +const gfx::Monitor* Screen::GetMonitorNearestWindow(gfx::NativeWindow window) { |
| + if (!instance_) |
| + return GetDefaultMonitor(); |
| + return instance_->GetMonitorNearestWindow(window); |
| +} |
| + |
| +// static |
| +const gfx::Monitor* Screen::GetMonitorNearestPoint(const gfx::Point& point) { |
| + if (!instance_) |
| + return GetDefaultMonitor(); |
| + return instance_->GetMonitorNearestPoint(point); |
| +} |
| + |
| +// static |
| +const gfx::Monitor* Screen::GetPrimaryMonitor() { |
| + if (!instance_) |
| + return GetDefaultMonitor(); |
| + return instance_->GetPrimaryMonitor(); |
| +} |
| + |
| +// static |
| +const gfx::Monitor* Screen::GetMonitorMatching(const gfx::Rect& match_rect) { |
| + if (!instance_) |
| + return GetDefaultMonitor(); |
| + return instance_->GetMonitorNearestPoint(match_rect.CenterPoint()); |
| +} |
| + |
| +} // namespace gfx |