diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-08 22:59:44 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-08 22:59:44 +0000 |
commit | e87687feb9cace286a412def5e199033d3fe4fd1 (patch) | |
tree | 6a3d5241cf94e12110ba642c819516431c489f25 /ui/gfx | |
parent | c750bb202fef68a9521c1ae8e1dec8bd74146be5 (diff) | |
download | chromium_src-e87687feb9cace286a412def5e199033d3fe4fd1.zip chromium_src-e87687feb9cace286a412def5e199033d3fe4fd1.tar.gz chromium_src-e87687feb9cace286a412def5e199033d3fe4fd1.tar.bz2 |
Gets component build to work with aura. As part of this I needed to
break screen_aura in two. Otherwise we end up with a circular
dependency between ui and aura.
BUG=none
TEST=none
R=ben@chromium.org
Review URL: http://codereview.chromium.org/8205018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104662 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx')
-rw-r--r-- | ui/gfx/DEPS | 1 | ||||
-rw-r--r-- | ui/gfx/screen.h | 25 | ||||
-rw-r--r-- | ui/gfx/screen_aura.cc | 41 |
3 files changed, 46 insertions, 21 deletions
diff --git a/ui/gfx/DEPS b/ui/gfx/DEPS index fd66273..548fe15 100644 --- a/ui/gfx/DEPS +++ b/ui/gfx/DEPS @@ -1,5 +1,4 @@ include_rules = [ - "+aura", "+base", "+grit/gfx_resources.h", "+skia", diff --git a/ui/gfx/screen.h b/ui/gfx/screen.h index efecc87..7779fe5 100644 --- a/ui/gfx/screen.h +++ b/ui/gfx/screen.h @@ -17,6 +17,15 @@ namespace gfx { // TODO(erikkay) add more of those methods here class UI_EXPORT Screen { public: + virtual ~Screen() {} + +#if defined(USE_AURA) + // Sets the instance to use. This takes owernship of |screen|, deleting the + // old instance. This is used on aura to avoid circular dependencies between + // ui and aura. + static void SetInstance(Screen* screen); +#endif + static gfx::Point GetCursorScreenPoint(); // Returns the work area of the monitor nearest the specified window. @@ -34,6 +43,22 @@ class UI_EXPORT Screen { // Returns the window under the cursor. static gfx::NativeWindow GetWindowAtCursorScreenPoint(); + + protected: + virtual gfx::Rect GetMonitorWorkAreaNearestWindowImpl( + gfx::NativeView view) = 0; + virtual gfx::Rect GetMonitorAreaNearestWindowImpl( + gfx::NativeView view) = 0; + virtual gfx::Rect GetMonitorWorkAreaNearestPointImpl( + const gfx::Point& point) = 0; + virtual gfx::Rect GetMonitorAreaNearestPointImpl(const gfx::Point& point) = 0; + virtual gfx::NativeWindow GetWindowAtCursorScreenPointImpl() = 0; + +private: +#if defined(USE_AURA) + // The singleton screen instance. Only used on aura. + static Screen* instance_; +#endif }; } // namespace gfx diff --git a/ui/gfx/screen_aura.cc b/ui/gfx/screen_aura.cc index b343f36..db21a92 100644 --- a/ui/gfx/screen_aura.cc +++ b/ui/gfx/screen_aura.cc @@ -9,21 +9,22 @@ #endif #include "base/logging.h" -#include "ui/aura/desktop.h" -#include "ui/aura/window.h" #include "ui/gfx/native_widget_types.h" -namespace { +namespace gfx { -gfx::Rect GetMonitorAreaOrWorkAreaNearestPoint(const gfx::Point& point, - bool work_area) { - // TODO(oshima): Take point/work_area into account. Support multiple monitors. - return gfx::Rect(aura::Desktop::GetInstance()->GetSize()); -} +// gfx can't depend upon aura, otherwise we have circular dependencies. So, +// gfx::Screen is pluggable for aura and Desktop plugs in the real +// implementation. -} // namespace +// static +Screen* Screen::instance_ = NULL; -namespace gfx { +// static +void Screen::SetInstance(Screen* screen) { + delete instance_; + instance_ = screen; +} // static gfx::Point Screen::GetCursorScreenPoint() { @@ -38,31 +39,31 @@ gfx::Point Screen::GetCursorScreenPoint() { // static gfx::Rect Screen::GetMonitorWorkAreaNearestWindow(gfx::NativeWindow window) { - gfx::Rect bounds = GetMonitorAreaNearestWindow(window); - // Emulate that a work area can be smaller than its monitor. - bounds.Inset(10, 10, 10, 10); - return bounds; + DCHECK(instance_); + return instance_->GetMonitorWorkAreaNearestWindowImpl(window); } // static gfx::Rect Screen::GetMonitorAreaNearestWindow(gfx::NativeWindow window) { - // TODO(oshima): Take point/work_area into account. Support multiple monitors. - return gfx::Rect(aura::Desktop::GetInstance()->GetSize()); + DCHECK(instance_); + return instance_->GetMonitorAreaNearestWindowImpl(window); } // static gfx::Rect Screen::GetMonitorWorkAreaNearestPoint(const gfx::Point& point) { - return GetMonitorAreaOrWorkAreaNearestPoint(point, true); + DCHECK(instance_); + return instance_->GetMonitorWorkAreaNearestPointImpl(point); } // static gfx::Rect Screen::GetMonitorAreaNearestPoint(const gfx::Point& point) { - return GetMonitorAreaOrWorkAreaNearestPoint(point, false); + DCHECK(instance_); + return instance_->GetMonitorAreaNearestPointImpl(point); } gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() { - NOTIMPLEMENTED(); - return NULL; + DCHECK(instance_); + return instance_->GetWindowAtCursorScreenPointImpl(); } } // namespace gfx |