OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_GFX_SCREEN_H_ | 5 #ifndef UI_GFX_SCREEN_H_ |
6 #define UI_GFX_SCREEN_H_ | 6 #define UI_GFX_SCREEN_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "ui/gfx/native_widget_types.h" | 9 #include "ui/gfx/native_widget_types.h" |
10 #include "ui/gfx/point.h" | 10 #include "ui/gfx/point.h" |
11 #include "ui/gfx/rect.h" | 11 #include "ui/gfx/rect.h" |
12 #include "ui/gfx/size.h" | |
13 | 12 |
14 namespace gfx { | 13 namespace gfx { |
15 | 14 |
15 class Monitor; | |
16 class ScreenImpl; | |
17 | |
16 // A utility class for getting various info about screen size, monitors, | 18 // A utility class for getting various info about screen size, monitors, |
17 // cursor position, etc. | 19 // cursor position, etc. |
18 // TODO(erikkay) add more of those methods here | |
19 class UI_EXPORT Screen { | 20 class UI_EXPORT Screen { |
20 public: | 21 public: |
21 virtual ~Screen() {} | 22 virtual ~Screen() {} |
22 | 23 |
23 #if defined(USE_ASH) | 24 #if defined(USE_AURA) |
24 // Sets the instance to use. This takes owernship of |screen|, deleting the | 25 // Sets the instance to use. This takes owernship of |screen|, deleting the |
25 // old instance. This is used on aura to avoid circular dependencies between | 26 // old instance. This is used on aura to avoid circular dependencies between |
26 // ui and aura. | 27 // ui and aura. |
27 static void SetInstance(Screen* screen); | 28 static void SetInstance(ScreenImpl* screen); |
28 #endif | 29 #endif |
29 | 30 |
30 // Returns the current absolute position of the mouse pointer. | 31 // Returns the current absolute position of the mouse pointer. |
31 static gfx::Point GetCursorScreenPoint(); | 32 static gfx::Point GetCursorScreenPoint(); |
32 | 33 |
33 // Returns the work area of the monitor nearest the specified window. | |
34 static gfx::Rect GetMonitorWorkAreaNearestWindow(gfx::NativeView view); | |
35 | |
36 // Returns the bounds of the monitor nearest the specified window. | |
37 static gfx::Rect GetMonitorAreaNearestWindow(gfx::NativeView view); | |
38 | |
39 // Returns the work area of the monitor nearest the specified point. | |
40 static gfx::Rect GetMonitorWorkAreaNearestPoint(const gfx::Point& point); | |
41 | |
42 // Returns the monitor area (not the work area, but the complete bounds) of | |
43 // the monitor nearest the specified point. | |
44 static gfx::Rect GetMonitorAreaNearestPoint(const gfx::Point& point); | |
45 | |
46 // Returns the bounds of the work area of the primary monitor. | |
47 static gfx::Rect GetPrimaryMonitorWorkArea(); | |
48 | |
49 // Returns the bounds of the primary monitor. | |
50 static gfx::Rect GetPrimaryMonitorBounds(); | |
51 | |
52 // Returns the bounds of the work area of the monitor that most closely | |
53 // intersects the provided bounds. | |
54 static gfx::Rect GetMonitorWorkAreaMatching( | |
55 const gfx::Rect& match_rect); | |
56 | |
57 // Returns the window under the cursor. | 34 // Returns the window under the cursor. |
58 static gfx::NativeWindow GetWindowAtCursorScreenPoint(); | 35 static gfx::NativeWindow GetWindowAtCursorScreenPoint(); |
59 | 36 |
60 // Returns the dimensions of the primary monitor in pixels. | |
61 static gfx::Size GetPrimaryMonitorSize(); | |
62 | |
63 // Returns the number of monitors. | 37 // Returns the number of monitors. |
64 // Mirrored displays are excluded; this method is intended to return the | 38 // Mirrored displays are excluded; this method is intended to return the |
65 // number of distinct, usable displays. | 39 // number of distinct, usable displays. |
66 static int GetNumMonitors(); | 40 static int GetNumMonitors(); |
67 | 41 |
68 protected: | 42 // Returns the monitor nearest the specified window in the |monitor_out| |
69 virtual gfx::Point GetCursorScreenPointImpl() = 0; | 43 // parameter. |
70 virtual gfx::Rect GetMonitorWorkAreaNearestWindowImpl( | 44 static void GetMonitorNearestWindow(gfx::NativeView view, |
71 gfx::NativeView view) = 0; | 45 gfx::Monitor* monitor_out); |
72 virtual gfx::Rect GetMonitorAreaNearestWindowImpl( | |
73 gfx::NativeView view) = 0; | |
74 virtual gfx::Rect GetMonitorWorkAreaNearestPointImpl( | |
75 const gfx::Point& point) = 0; | |
76 virtual gfx::Rect GetMonitorAreaNearestPointImpl(const gfx::Point& point) = 0; | |
77 virtual gfx::NativeWindow GetWindowAtCursorScreenPointImpl() = 0; | |
78 virtual gfx::Size GetPrimaryMonitorSizeImpl() = 0; | |
79 virtual int GetNumMonitorsImpl() = 0; | |
80 | 46 |
81 private: | 47 // Returns the the monitor nearest the specified point in the |monitor_out| |
82 #if defined(USE_AURA) | 48 // parameter. |
83 // The singleton screen instance. Only used on aura. | 49 static void GetMonitorNearestPoint(const gfx::Point& point, |
84 static Screen* instance_; | 50 gfx::Monitor* monitor_out); |
Ben Goodger (Google)
2012/04/13 19:57:19
Now that I've seen all the call sites, I think thi
oshima
2012/04/13 21:18:41
Ok, will do that.
| |
85 #endif | 51 |
52 // Returns the bounds of the work area of the primary monitor in the | |
53 // |monitor_out| parameter. | |
54 static void GetPrimaryMonitor(gfx::Monitor* monitor_out); | |
55 | |
56 // Returns the monitor that most closely intersects the provided bounds | |
57 // in the |monitor_out| parameter. | |
58 static void GetMonitorMatching(const gfx::Rect& match_rect, | |
59 gfx::Monitor* monitor_out); | |
60 | |
61 // Utility functions to get Monitor bounds/WorkArea bounds. | |
62 static gfx::Rect GetMonitorAreaNearestWindow(gfx::NativeView view); | |
63 static gfx::Rect GetMonitorWorkAreaNearestWindow(gfx::NativeView view); | |
64 static gfx::Rect GetMonitorAreaNearestPoint(const gfx::Point& point); | |
65 static gfx::Rect GetMonitorWorkAreaNearestPoint(const gfx::Point& point); | |
66 static gfx::Rect GetPrimaryMonitorBounds(); | |
67 static gfx::Rect GetPrimaryMonitorWorkArea(); | |
86 }; | 68 }; |
87 | 69 |
88 } // namespace gfx | 70 } // namespace gfx |
89 | 71 |
90 #endif // VIEWS_SCREEN_H_ | 72 #endif // VIEWS_SCREEN_H_ |
OLD | NEW |