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 ASH_SCREEN_ASH_H_ | 5 #ifndef ASH_SCREEN_UTIL_H_ |
6 #define ASH_SCREEN_ASH_H_ | 6 #define ASH_SCREEN_UTIL_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/basictypes.h" |
10 #include "base/observer_list.h" | 10 |
11 #include "ui/gfx/screen.h" | 11 namespace aura { |
| 12 class Window; |
| 13 } |
12 | 14 |
13 namespace gfx { | 15 namespace gfx { |
| 16 class Display; |
14 class Rect; | 17 class Rect; |
| 18 class Point; |
15 } | 19 } |
16 | 20 |
17 namespace ash { | 21 namespace ash { |
18 | 22 |
19 // Aura implementation of gfx::Screen. Implemented here to avoid circular | 23 class ASH_EXPORT ScreenUtil { |
20 // dependencies. | |
21 class ASH_EXPORT ScreenAsh : public gfx::Screen { | |
22 public: | 24 public: |
23 ScreenAsh(); | |
24 virtual ~ScreenAsh(); | |
25 | |
26 // Finds the display that contains |point| in screeen coordinates. | 25 // Finds the display that contains |point| in screeen coordinates. |
27 // Returns invalid display if there is no display that can satisfy | 26 // Returns invalid display if there is no display that can satisfy |
28 // the condition. | 27 // the condition. |
29 static gfx::Display FindDisplayContainingPoint(const gfx::Point& point); | 28 static gfx::Display FindDisplayContainingPoint(const gfx::Point& point); |
30 | 29 |
31 // Returns the bounds for maximized windows in parent coordinates. | 30 // Returns the bounds for maximized windows in parent coordinates. |
32 // Maximized windows trigger auto-hiding the shelf. | 31 // Maximized windows trigger auto-hiding the shelf. |
33 static gfx::Rect GetMaximizedWindowBoundsInParent(aura::Window* window); | 32 static gfx::Rect GetMaximizedWindowBoundsInParent(aura::Window* window); |
34 | 33 |
35 // Returns the display bounds in parent coordinates. | 34 // Returns the display bounds in parent coordinates. |
36 static gfx::Rect GetDisplayBoundsInParent(aura::Window* window); | 35 static gfx::Rect GetDisplayBoundsInParent(aura::Window* window); |
37 | 36 |
38 // Returns the display's work area bounds in parent coordinates. | 37 // Returns the display's work area bounds in parent coordinates. |
39 static gfx::Rect GetDisplayWorkAreaBoundsInParent(aura::Window* window); | 38 static gfx::Rect GetDisplayWorkAreaBoundsInParent(aura::Window* window); |
40 | 39 |
| 40 // TODO(oshima): Move following two to wm/coordinate_conversion.h |
41 // Converts |rect| from |window|'s coordinates to the virtual screen | 41 // Converts |rect| from |window|'s coordinates to the virtual screen |
42 // coordinates. | 42 // coordinates. |
43 static gfx::Rect ConvertRectToScreen(aura::Window* window, | 43 static gfx::Rect ConvertRectToScreen(aura::Window* window, |
44 const gfx::Rect& rect); | 44 const gfx::Rect& rect); |
45 | 45 |
46 // Converts |rect| from virtual screen coordinates to the |window|'s | 46 // Converts |rect| from virtual screen coordinates to the |window|'s |
47 // coordinates. | 47 // coordinates. |
48 static gfx::Rect ConvertRectFromScreen(aura::Window* window, | 48 static gfx::Rect ConvertRectFromScreen(aura::Window* window, |
49 const gfx::Rect& rect); | 49 const gfx::Rect& rect); |
50 | 50 |
51 // Returns a gfx::Display object for secondary display. Returns | 51 // Returns a gfx::Display object for secondary display. Returns |
52 // invalid display if there is no secondary display connected. | 52 // invalid display if there is no secondary display connected. |
53 static const gfx::Display& GetSecondaryDisplay(); | 53 static const gfx::Display& GetSecondaryDisplay(); |
54 | 54 |
55 // Returns a gfx::Display object for the specified id. Returns | 55 // Returns a gfx::Display object for the specified id. Returns |
56 // invalid display if no such display is connected. | 56 // invalid display if no such display is connected. |
57 static const gfx::Display& GetDisplayForId(int64 display_id); | 57 static const gfx::Display& GetDisplayForId(int64 display_id); |
58 | 58 |
59 // Notifies observers of display configuration changes. | 59 private: |
60 void NotifyBoundsChanged(const gfx::Display& display); | 60 ScreenUtil() {} |
61 void NotifyDisplayAdded(const gfx::Display& display); | 61 ~ScreenUtil() {} |
62 void NotifyDisplayRemoved(const gfx::Display& display); | |
63 | 62 |
64 protected: | 63 DISALLOW_COPY_AND_ASSIGN(ScreenUtil); |
65 // gfx::Screen overrides: | |
66 virtual bool IsDIPEnabled() OVERRIDE; | |
67 virtual gfx::Point GetCursorScreenPoint() OVERRIDE; | |
68 virtual gfx::NativeWindow GetWindowUnderCursor() OVERRIDE; | |
69 virtual gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) | |
70 OVERRIDE; | |
71 virtual int GetNumDisplays() const OVERRIDE; | |
72 virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE; | |
73 virtual gfx::Display GetDisplayNearestWindow( | |
74 gfx::NativeView view) const OVERRIDE; | |
75 virtual gfx::Display GetDisplayNearestPoint( | |
76 const gfx::Point& point) const OVERRIDE; | |
77 virtual gfx::Display GetDisplayMatching( | |
78 const gfx::Rect& match_rect) const OVERRIDE; | |
79 virtual gfx::Display GetPrimaryDisplay() const OVERRIDE; | |
80 virtual void AddObserver(gfx::DisplayObserver* observer) OVERRIDE; | |
81 virtual void RemoveObserver(gfx::DisplayObserver* observer) OVERRIDE; | |
82 | |
83 private: | |
84 ObserverList<gfx::DisplayObserver> observers_; | |
85 | |
86 DISALLOW_COPY_AND_ASSIGN(ScreenAsh); | |
87 }; | 64 }; |
88 | 65 |
89 } // namespace ash | 66 } // namespace ash |
90 | 67 |
91 #endif // ASH_SCREEN_ASH_H_ | 68 #endif // ASH_SCREEN_UTIL_H_ |
OLD | NEW |