Index: ui/gfx/screen.h |
diff --git a/ui/gfx/screen.h b/ui/gfx/screen.h |
index a451130216815d063dbf266deef258f4339dbebb..a62084368fa3e3b087387c2d073e248c5bff69dd 100644 |
--- a/ui/gfx/screen.h |
+++ b/ui/gfx/screen.h |
@@ -13,77 +13,85 @@ |
namespace gfx { |
+class Monitor; |
+class MonitorObserver; |
+class ScreenImpl; |
+ |
// A utility class for getting various info about screen size, monitors, |
-// cursor position, etc. |
-// TODO(erikkay) add more of those methods here |
+// cursor position, etc. The monitor object returned by Screen's method |
+// is valid only until the next |GetMonitorXXX| method is called. |
+// TODO(oshima): Implment monitor observers on other platforms and |
+// remove above restruction. |
class UI_EXPORT Screen { |
public: |
virtual ~Screen() {} |
-#if defined(USE_ASH) |
+#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); |
+ static void SetInstance(ScreenImpl* screen); |
#endif |
+ static void AddMonitorObserver(MonitorObserver* observer); |
+ static void RemoveMonitorObserver(MonitorObserver* observer); |
+ |
// Returns the current absolute position of the mouse pointer. |
static gfx::Point GetCursorScreenPoint(); |
- // Returns the work area of the monitor nearest the specified window. |
- static gfx::Rect GetMonitorWorkAreaNearestWindow(gfx::NativeView view); |
- |
- // Returns the bounds of the monitor nearest the specified window. |
- static gfx::Rect GetMonitorAreaNearestWindow(gfx::NativeView view); |
+ // Returns the window under the cursor. |
+ static gfx::NativeWindow GetWindowAtCursorScreenPoint(); |
- // Returns the work area of the monitor nearest the specified point. |
- static gfx::Rect GetMonitorWorkAreaNearestPoint(const gfx::Point& point); |
+ // Returns the number of monitors. |
+ // Mirrored displays are excluded; this method is intended to return the |
+ // number of distinct, usable displays. |
+ static int GetNumMonitors(); |
- // Returns the monitor area (not the work area, but the complete bounds) of |
- // the monitor nearest the specified point. |
- static gfx::Rect GetMonitorAreaNearestPoint(const gfx::Point& point); |
+ // Returns the monitor nearest the specified window. See the comment at the |
+ // top regarding the life sycle of |gfx::Monitor| object. |
+ static const gfx::Monitor* GetMonitorNearestWindow(gfx::NativeView view); |
- // Returns the bounds of the work area of the primary monitor. |
- static gfx::Rect GetPrimaryMonitorWorkArea(); |
+ // Returns the the monitor nearest the specified point. See the comment at the |
+ // top regarding the life sycle of |gfx::Monitor| object. |
+ static const gfx::Monitor* GetMonitorNearestPoint(const gfx::Point& point); |
- // Returns the bounds of the primary monitor. |
- static gfx::Rect GetPrimaryMonitorBounds(); |
+ // Returns the bounds of the work area of the primary monitor. See |
+ // the comment at the top regarding the life sycle of |gfx::Monitor| |
+ // object. |
+ static const gfx::Monitor* GetPrimaryMonitor(); |
- // Returns the bounds of the work area of the monitor that most closely |
- // intersects the provided bounds. |
- static gfx::Rect GetMonitorWorkAreaMatching( |
- const gfx::Rect& match_rect); |
+ // Returns the monitor that most closely intersects the provided bounds. See |
+ // the comment at the top regarding the life sycle of |gfx::Monitor| |
+ // object. |
+ static const gfx::Monitor* GetMonitorMatching(const gfx::Rect& match_rect); |
- // Returns the window under the cursor. |
- static gfx::NativeWindow GetWindowAtCursorScreenPoint(); |
+ // Utility functions to get Monitor bounds/WorkArea bounds. |
+ static gfx::Rect GetMonitorAreaNearestWindow(gfx::NativeView view); |
+ static gfx::Rect GetMonitorWorkAreaNearestWindow(gfx::NativeView view); |
+ static gfx::Rect GetMonitorAreaNearestPoint(const gfx::Point& point); |
+ static gfx::Rect GetMonitorWorkAreaNearestPoint(const gfx::Point& point); |
+}; |
- // Returns the dimensions of the primary monitor in pixels. |
- static gfx::Size GetPrimaryMonitorSize(); |
+#if defined(USE_AURA) |
+// A class that provides |gfx::Screen|'s implementation on aura. |
Ben Goodger (Google)
2012/04/10 16:37:20
yes please move to a separate file. note that you
oshima
2012/04/10 21:31:46
Done.
|
+class UI_EXPORT ScreenImpl { |
+ public: |
+ virtual ~ScreenImpl(); |
- // Returns the number of monitors. |
- // Mirrored displays are excluded; this method is intended to return the |
- // number of distinct, usable displays. |
- static int GetNumMonitors(); |
+ virtual gfx::Point GetCursorScreenPoint() = 0; |
+ virtual gfx::NativeWindow GetWindowAtCursorScreenPoint() = 0; |
- protected: |
- virtual gfx::Point GetCursorScreenPointImpl() = 0; |
- virtual gfx::Rect GetMonitorWorkAreaNearestWindowImpl( |
- gfx::NativeView view) = 0; |
- virtual gfx::Rect GetMonitorAreaNearestWindowImpl( |
+ virtual int GetNumMonitors() = 0; |
+ virtual const gfx::Monitor* GetMonitorNearestWindow( |
gfx::NativeView view) = 0; |
- virtual gfx::Rect GetMonitorWorkAreaNearestPointImpl( |
+ virtual const gfx::Monitor* GetMonitorNearestPoint( |
const gfx::Point& point) = 0; |
- virtual gfx::Rect GetMonitorAreaNearestPointImpl(const gfx::Point& point) = 0; |
- virtual gfx::NativeWindow GetWindowAtCursorScreenPointImpl() = 0; |
- virtual gfx::Size GetPrimaryMonitorSizeImpl() = 0; |
- virtual int GetNumMonitorsImpl() = 0; |
+ virtual const gfx::Monitor* GetPrimaryMonitor() = 0; |
-private: |
-#if defined(USE_AURA) |
- // The singleton screen instance. Only used on aura. |
- static Screen* instance_; |
-#endif |
+ virtual void AddMonitorObserver(MonitorObserver* observer) = 0; |
+ virtual void RemoveMonitorObserver(MonitorObserver* observer) = 0; |
}; |
+#endif |
} // namespace gfx |