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_DISPLAY_MULTI_DISPLAY_MANAGER_H_ | 5 #ifndef ASH_DISPLAY_DISPLAY_MANAGER_H_ |
6 #define ASH_DISPLAY_MULTI_DISPLAY_MANAGER_H_ | 6 #define ASH_DISPLAY_DISPLAY_MANAGER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "ash/ash_export.h" | 11 #include "ash/ash_export.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "ui/aura/display_manager.h" | |
15 #include "ui/aura/root_window_observer.h" | 14 #include "ui/aura/root_window_observer.h" |
16 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
17 | 16 |
18 namespace gfx { | 17 namespace gfx { |
19 class Display; | 18 class Display; |
20 class Insets; | 19 class Insets; |
21 class Rect; | 20 class Rect; |
22 } | 21 } |
23 | 22 |
24 namespace ash { | 23 namespace ash { |
25 class AcceleratorControllerTest; | 24 class AcceleratorControllerTest; |
26 namespace test { | 25 namespace test { |
27 class MultiDisplayManagerTestApi; | 26 class DisplayManagerTestApi; |
28 class SystemGestureEventFilterTest; | 27 class SystemGestureEventFilterTest; |
29 } | 28 } |
30 namespace internal { | 29 namespace internal { |
31 | 30 |
32 // MultiDisplayManager maintains the current display configurations, | 31 // DisplayManager maintains the current display configurations, |
33 // and notifies observers when configuration changes. | 32 // and notifies observers when configuration changes. |
34 // This is exported for unittest. | 33 // This is exported for unittest. |
35 // | 34 // |
36 // TODO(oshima): gfx::Screen needs to return translated coordinates | 35 // TODO(oshima): gfx::Screen needs to return translated coordinates |
37 // if the root window is translated. crbug.com/119268. | 36 // if the root window is translated. crbug.com/119268. |
38 class ASH_EXPORT MultiDisplayManager : public aura::DisplayManager, | 37 class ASH_EXPORT DisplayManager : public aura::RootWindowObserver { |
39 public aura::RootWindowObserver { | |
40 public: | 38 public: |
41 MultiDisplayManager(); | 39 DisplayManager(); |
42 virtual ~MultiDisplayManager(); | 40 virtual ~DisplayManager(); |
43 | 41 |
44 // Used to emulate display change when run in a desktop environment instead | 42 // Used to emulate display change when run in a desktop environment instead |
45 // of on a device. | 43 // of on a device. |
46 static void CycleDisplay(); | 44 static void CycleDisplay(); |
47 static void ToggleDisplayScale(); | 45 static void ToggleDisplayScale(); |
48 | 46 |
49 // When set to true, the MultiMonitorManager calls OnDisplayBoundsChanged | 47 // When set to true, the MonitorManager calls OnDisplayBoundsChanged |
50 // even if the display's bounds didn't change. Used to swap primary | 48 // even if the display's bounds didn't change. Used to swap primary |
51 // display. | 49 // display. |
52 void set_force_bounds_changed(bool force_bounds_changed) { | 50 void set_force_bounds_changed(bool force_bounds_changed) { |
53 force_bounds_changed_ = force_bounds_changed; | 51 force_bounds_changed_ = force_bounds_changed; |
54 } | 52 } |
55 | 53 |
56 // True if the given |display| is currently connected. | 54 // True if the given |display| is currently connected. |
57 bool IsActiveDisplay(const gfx::Display& display) const; | 55 bool IsActiveDisplay(const gfx::Display& display) const; |
58 | 56 |
59 // True if there is an internal display. | 57 // True if there is an internal display. |
60 bool HasInternalDisplay() const; | 58 bool HasInternalDisplay() const; |
61 | 59 |
62 bool IsInternalDisplayId(int64 id) const; | 60 bool IsInternalDisplayId(int64 id) const; |
63 | 61 |
64 bool UpdateWorkAreaOfDisplayNearestWindow(const aura::Window* window, | 62 bool UpdateWorkAreaOfDisplayNearestWindow(const aura::Window* window, |
65 const gfx::Insets& insets); | 63 const gfx::Insets& insets); |
66 | 64 |
67 // Returns display for given |id|; | 65 // Returns display for given |id|; |
68 const gfx::Display& GetDisplayForId(int64 id) const; | 66 const gfx::Display& GetDisplayForId(int64 id) const; |
69 | 67 |
70 // Finds the display that contains |point| in screeen coordinates. | 68 // Finds the display that contains |point| in screeen coordinates. |
71 // Returns invalid display if there is no display that can satisfy | 69 // Returns invalid display if there is no display that can satisfy |
72 // the condition. | 70 // the condition. |
73 const gfx::Display& FindDisplayContainingPoint( | 71 const gfx::Display& FindDisplayContainingPoint( |
74 const gfx::Point& point_in_screen) const; | 72 const gfx::Point& point_in_screen) const; |
75 | 73 |
76 // Registers the overscan insets for the display of the specified ID. Note | 74 // Rjegisters the overscan insets for the display of the specified ID. Note |
ananta
2012/11/09 18:39:51
Registers
oshima
2012/11/09 18:53:49
Done.
| |
77 // that the insets size should be specified in DIP size. It also triggers the | 75 // that the insets size should be specified in DIP size. It also triggers the |
78 // display's bounds change. | 76 // display's bounds change. |
79 void SetOverscanInsets(int64 display_id, const gfx::Insets& insets_in_dip); | 77 void SetOverscanInsets(int64 display_id, const gfx::Insets& insets_in_dip); |
80 | 78 |
81 // Returns the current overscan insets for the specified |display_id|. | 79 // Returns the current overscan insets for the specified |display_id|. |
82 // Returns an empty insets (0, 0, 0, 0) if no insets are specified for | 80 // Returns an empty insets (0, 0, 0, 0) if no insets are specified for |
83 // the display. | 81 // the display. |
84 gfx::Insets GetOverscanInsets(int64 display_id) const; | 82 gfx::Insets GetOverscanInsets(int64 display_id) const; |
85 | 83 |
86 // DisplayManager overrides: | 84 // Called when display configuration has changed. The new display |
87 virtual void OnNativeDisplaysChanged( | 85 // configurations is passed as a vector of Display object, which |
88 const std::vector<gfx::Display>& displays) OVERRIDE; | 86 // contains each display's new infomration. |
89 virtual aura::RootWindow* CreateRootWindowForDisplay( | 87 void OnNativeDisplaysChanged(const std::vector<gfx::Display>& displays); |
90 const gfx::Display& display) OVERRIDE; | |
91 virtual gfx::Display* GetDisplayAt(size_t index) OVERRIDE; | |
92 | 88 |
93 virtual size_t GetNumDisplays() const OVERRIDE; | 89 // Create a root window for given |display|. |
94 virtual const gfx::Display& GetDisplayNearestPoint( | 90 aura::RootWindow* CreateRootWindowForDisplay(const gfx::Display& display); |
95 const gfx::Point& point) const OVERRIDE; | 91 |
96 virtual const gfx::Display& GetDisplayNearestWindow( | 92 // Obsoleted: Do not use in new code. |
97 const aura::Window* window) const OVERRIDE; | 93 // Returns the display at |index|. The display at 0 is |
98 virtual const gfx::Display& GetDisplayMatching( | 94 // no longer considered "primary". |
99 const gfx::Rect& match_rect)const OVERRIDE; | 95 gfx::Display* GetDisplayAt(size_t index); |
100 virtual std::string GetDisplayNameFor(const gfx::Display& display) OVERRIDE; | 96 |
97 size_t GetNumDisplays() const; | |
98 | |
99 // Returns the display object nearest given |window|. | |
100 const gfx::Display& GetDisplayNearestPoint( | |
101 const gfx::Point& point) const; | |
102 | |
103 // Returns the display object nearest given |point|. | |
104 const gfx::Display& GetDisplayNearestWindow( | |
105 const aura::Window* window) const; | |
106 | |
107 // Returns the display that most closely intersects |match_rect|. | |
108 const gfx::Display& GetDisplayMatching( | |
109 const gfx::Rect& match_rect)const; | |
110 | |
111 // Returns the human-readable name for the display specified by |display|. | |
112 std::string GetDisplayNameFor(const gfx::Display& display); | |
101 | 113 |
102 // RootWindowObserver overrides: | 114 // RootWindowObserver overrides: |
103 virtual void OnRootWindowResized(const aura::RootWindow* root, | 115 virtual void OnRootWindowResized(const aura::RootWindow* root, |
104 const gfx::Size& new_size) OVERRIDE; | 116 const gfx::Size& new_size) OVERRIDE; |
105 | 117 |
106 private: | 118 private: |
107 FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, ConvertPoint); | 119 FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, ConvertPoint); |
108 FRIEND_TEST_ALL_PREFIXES(MultiDisplayManagerTest, TestNativeDisplaysChanged); | 120 FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, TestNativeDisplaysChanged); |
109 FRIEND_TEST_ALL_PREFIXES(MultiDisplayManagerTest, | 121 FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, |
110 NativeDisplaysChangedAfterPrimaryChange); | 122 NativeDisplaysChangedAfterPrimaryChange); |
111 friend class ash::AcceleratorControllerTest; | 123 friend class ash::AcceleratorControllerTest; |
112 friend class test::MultiDisplayManagerTestApi; | 124 friend class test::DisplayManagerTestApi; |
113 friend class MultiDisplayManagerTest; | 125 friend class DisplayManagerTest; |
114 friend class test::SystemGestureEventFilterTest; | 126 friend class test::SystemGestureEventFilterTest; |
115 | 127 |
116 typedef std::vector<gfx::Display> DisplayList; | 128 typedef std::vector<gfx::Display> DisplayList; |
117 | 129 |
118 void Init(); | 130 void Init(); |
119 void CycleDisplayImpl(); | 131 void CycleDisplayImpl(); |
120 void ScaleDisplayImpl(); | 132 void ScaleDisplayImpl(); |
121 | 133 |
122 gfx::Display& FindDisplayForRootWindow(const aura::RootWindow* root); | 134 gfx::Display& FindDisplayForRootWindow(const aura::RootWindow* root); |
123 gfx::Display& FindDisplayForId(int64 id); | 135 gfx::Display& FindDisplayForId(int64 id); |
(...skipping 27 matching lines...) Expand all Loading... | |
151 scoped_ptr<gfx::Display> internal_display_; | 163 scoped_ptr<gfx::Display> internal_display_; |
152 | 164 |
153 bool force_bounds_changed_; | 165 bool force_bounds_changed_; |
154 | 166 |
155 // The mapping from the display ID to its overscan insets. | 167 // The mapping from the display ID to its overscan insets. |
156 std::map<int64, gfx::Insets> overscan_mapping_; | 168 std::map<int64, gfx::Insets> overscan_mapping_; |
157 | 169 |
158 // The cached display's name for the display ID. | 170 // The cached display's name for the display ID. |
159 std::map<int64, std::string> display_names_; | 171 std::map<int64, std::string> display_names_; |
160 | 172 |
161 DISALLOW_COPY_AND_ASSIGN(MultiDisplayManager); | 173 DISALLOW_COPY_AND_ASSIGN(DisplayManager); |
162 }; | 174 }; |
163 | 175 |
164 extern const aura::WindowProperty<int64>* const kDisplayIdKey; | 176 extern const aura::WindowProperty<int64>* const kDisplayIdKey; |
165 | 177 |
166 } // namespace internal | 178 } // namespace internal |
167 } // namespace ash | 179 } // namespace ash |
168 | 180 |
169 #endif // ASH_DISPLAY_MULTI_DISPLAY_MANAGER_H_ | 181 #endif // ASH_DISPLAY_DISPLAY_MANAGER_H_ |
OLD | NEW |