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_DISPLAY_CONTROLLER_H_ | 5 #ifndef ASH_DISPLAY_DISPLAY_CONTROLLER_H_ |
6 #define ASH_DISPLAY_DISPLAY_CONTROLLER_H_ | 6 #define ASH_DISPLAY_DISPLAY_CONTROLLER_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <map> | 10 #include <map> |
9 #include <vector> | 11 #include <vector> |
10 | 12 |
11 #include "ash/ash_export.h" | 13 #include "ash/ash_export.h" |
12 #include "ash/display/display_manager.h" | 14 #include "ash/display/display_manager.h" |
13 #include "base/basictypes.h" | |
14 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
15 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
| 17 #include "base/macros.h" |
16 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
17 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
18 #include "base/observer_list.h" | 20 #include "base/observer_list.h" |
19 #include "base/time/time.h" | 21 #include "base/time/time.h" |
20 #include "ui/aura/window.h" | 22 #include "ui/aura/window.h" |
21 #include "ui/aura/window_tree_host_observer.h" | 23 #include "ui/aura/window_tree_host_observer.h" |
22 #include "ui/base/ime/input_method.h" | 24 #include "ui/base/ime/input_method.h" |
23 #include "ui/base/ime/input_method_delegate.h" | 25 #include "ui/base/ime/input_method_delegate.h" |
24 #include "ui/gfx/display_observer.h" | 26 #include "ui/gfx/display_observer.h" |
25 #include "ui/gfx/geometry/point.h" | 27 #include "ui/gfx/geometry/point.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 }; | 84 }; |
83 | 85 |
84 WindowTreeHostManager(); | 86 WindowTreeHostManager(); |
85 ~WindowTreeHostManager() override; | 87 ~WindowTreeHostManager() override; |
86 | 88 |
87 void Start(); | 89 void Start(); |
88 void Shutdown(); | 90 void Shutdown(); |
89 | 91 |
90 // Returns primary display's ID. | 92 // Returns primary display's ID. |
91 // TODO(oshima): Move this out from WindowTreeHostManager; | 93 // TODO(oshima): Move this out from WindowTreeHostManager; |
92 static int64 GetPrimaryDisplayId(); | 94 static int64_t GetPrimaryDisplayId(); |
93 | 95 |
94 CursorWindowController* cursor_window_controller() { | 96 CursorWindowController* cursor_window_controller() { |
95 return cursor_window_controller_.get(); | 97 return cursor_window_controller_.get(); |
96 } | 98 } |
97 | 99 |
98 MirrorWindowController* mirror_window_controller() { | 100 MirrorWindowController* mirror_window_controller() { |
99 return mirror_window_controller_.get(); | 101 return mirror_window_controller_.get(); |
100 } | 102 } |
101 | 103 |
102 // Create a WindowTreeHost for the primary display. This replaces | 104 // Create a WindowTreeHost for the primary display. This replaces |
103 // |initial_bounds| in |init_params|. | 105 // |initial_bounds| in |init_params|. |
104 void CreatePrimaryHost(const AshWindowTreeHostInitParams& init_params); | 106 void CreatePrimaryHost(const AshWindowTreeHostInitParams& init_params); |
105 | 107 |
106 // Initializes all WindowTreeHosts. | 108 // Initializes all WindowTreeHosts. |
107 void InitHosts(); | 109 void InitHosts(); |
108 | 110 |
109 // Add/Remove observers. | 111 // Add/Remove observers. |
110 void AddObserver(Observer* observer); | 112 void AddObserver(Observer* observer); |
111 void RemoveObserver(Observer* observer); | 113 void RemoveObserver(Observer* observer); |
112 | 114 |
113 // Returns the root window for primary display. | 115 // Returns the root window for primary display. |
114 aura::Window* GetPrimaryRootWindow(); | 116 aura::Window* GetPrimaryRootWindow(); |
115 | 117 |
116 // Returns the root window for |display_id|. | 118 // Returns the root window for |display_id|. |
117 aura::Window* GetRootWindowForDisplayId(int64 id); | 119 aura::Window* GetRootWindowForDisplayId(int64_t id); |
118 | 120 |
119 // Returns AshWTH for given display |id|. Call results in CHECK failure | 121 // Returns AshWTH for given display |id|. Call results in CHECK failure |
120 // if the WTH does not exist. | 122 // if the WTH does not exist. |
121 AshWindowTreeHost* GetAshWindowTreeHostForDisplayId(int64 id); | 123 AshWindowTreeHost* GetAshWindowTreeHostForDisplayId(int64_t id); |
122 | 124 |
123 // Toggle mirror mode. | 125 // Toggle mirror mode. |
124 void ToggleMirrorMode(); | 126 void ToggleMirrorMode(); |
125 | 127 |
126 // Swap primary and secondary display. | 128 // Swap primary and secondary display. |
127 void SwapPrimaryDisplay(); | 129 void SwapPrimaryDisplay(); |
128 | 130 |
129 // Sets the ID of the primary display. If the display is not connected, it | 131 // Sets the ID of the primary display. If the display is not connected, it |
130 // will switch the primary display when connected. | 132 // will switch the primary display when connected. |
131 void SetPrimaryDisplayId(int64 id); | 133 void SetPrimaryDisplayId(int64_t id); |
132 | 134 |
133 // Sets primary display. This re-assigns the current root | 135 // Sets primary display. This re-assigns the current root |
134 // window to given |display|. | 136 // window to given |display|. |
135 void SetPrimaryDisplay(const gfx::Display& display); | 137 void SetPrimaryDisplay(const gfx::Display& display); |
136 | 138 |
137 // Closes all child windows in the all root windows. | 139 // Closes all child windows in the all root windows. |
138 void CloseChildWindows(); | 140 void CloseChildWindows(); |
139 | 141 |
140 // Returns all root windows. In non extended desktop mode, this | 142 // Returns all root windows. In non extended desktop mode, this |
141 // returns the primary root window only. | 143 // returns the primary root window only. |
142 aura::Window::Windows GetAllRootWindows(); | 144 aura::Window::Windows GetAllRootWindows(); |
143 | 145 |
144 // Returns all oot window controllers. In non extended desktop | 146 // Returns all oot window controllers. In non extended desktop |
145 // mode, this return a RootWindowController for the primary root window only. | 147 // mode, this return a RootWindowController for the primary root window only. |
146 std::vector<RootWindowController*> GetAllRootWindowControllers(); | 148 std::vector<RootWindowController*> GetAllRootWindowControllers(); |
147 | 149 |
148 // Gets/Sets/Clears the overscan insets for the specified |display_id|. See | 150 // Gets/Sets/Clears the overscan insets for the specified |display_id|. See |
149 // display_manager.h for the details. | 151 // display_manager.h for the details. |
150 gfx::Insets GetOverscanInsets(int64 display_id) const; | 152 gfx::Insets GetOverscanInsets(int64_t display_id) const; |
151 void SetOverscanInsets(int64 display_id, const gfx::Insets& insets_in_dip); | 153 void SetOverscanInsets(int64_t display_id, const gfx::Insets& insets_in_dip); |
152 | 154 |
153 // Checks if the mouse pointer is on one of displays, and moves to | 155 // Checks if the mouse pointer is on one of displays, and moves to |
154 // the center of the nearest display if it's outside of all displays. | 156 // the center of the nearest display if it's outside of all displays. |
155 void UpdateMouseLocationAfterDisplayChange(); | 157 void UpdateMouseLocationAfterDisplayChange(); |
156 | 158 |
157 // Sets the work area's |insets| to the display assigned to |window|. | 159 // Sets the work area's |insets| to the display assigned to |window|. |
158 bool UpdateWorkAreaOfDisplayNearestWindow(const aura::Window* window, | 160 bool UpdateWorkAreaOfDisplayNearestWindow(const aura::Window* window, |
159 const gfx::Insets& insets); | 161 const gfx::Insets& insets); |
160 | 162 |
161 ui::InputMethod* input_method() { return input_method_.get(); } | 163 ui::InputMethod* input_method() { return input_method_.get(); } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 204 |
203 // Delete the AsWindowTreeHost. This does not remove the entry from | 205 // Delete the AsWindowTreeHost. This does not remove the entry from |
204 // |window_tree_hosts_|. Caller has to explicitly remove it. | 206 // |window_tree_hosts_|. Caller has to explicitly remove it. |
205 void DeleteHost(AshWindowTreeHost* host_to_delete); | 207 void DeleteHost(AshWindowTreeHost* host_to_delete); |
206 | 208 |
207 class DisplayChangeLimiter { | 209 class DisplayChangeLimiter { |
208 public: | 210 public: |
209 DisplayChangeLimiter(); | 211 DisplayChangeLimiter(); |
210 | 212 |
211 // Sets how long the throttling should last. | 213 // Sets how long the throttling should last. |
212 void SetThrottleTimeout(int64 throttle_ms); | 214 void SetThrottleTimeout(int64_t throttle_ms); |
213 | 215 |
214 bool IsThrottled() const; | 216 bool IsThrottled() const; |
215 | 217 |
216 private: | 218 private: |
217 // The time when the throttling ends. | 219 // The time when the throttling ends. |
218 base::Time throttle_timeout_; | 220 base::Time throttle_timeout_; |
219 | 221 |
220 DISALLOW_COPY_AND_ASSIGN(DisplayChangeLimiter); | 222 DISALLOW_COPY_AND_ASSIGN(DisplayChangeLimiter); |
221 }; | 223 }; |
222 | 224 |
223 // The limiter to throttle how fast a user can | 225 // The limiter to throttle how fast a user can |
224 // change the display configuration. | 226 // change the display configuration. |
225 scoped_ptr<DisplayChangeLimiter> limiter_; | 227 scoped_ptr<DisplayChangeLimiter> limiter_; |
226 | 228 |
227 typedef std::map<int64, AshWindowTreeHost*> WindowTreeHostMap; | 229 typedef std::map<int64_t, AshWindowTreeHost*> WindowTreeHostMap; |
228 // The mapping from display ID to its window tree host. | 230 // The mapping from display ID to its window tree host. |
229 WindowTreeHostMap window_tree_hosts_; | 231 WindowTreeHostMap window_tree_hosts_; |
230 | 232 |
231 base::ObserverList<Observer, true> observers_; | 233 base::ObserverList<Observer, true> observers_; |
232 | 234 |
233 // Store the primary window tree host temporarily while replacing | 235 // Store the primary window tree host temporarily while replacing |
234 // display. | 236 // display. |
235 AshWindowTreeHost* primary_tree_host_for_replace_; | 237 AshWindowTreeHost* primary_tree_host_for_replace_; |
236 | 238 |
237 scoped_ptr<FocusActivationStore> focus_activation_store_; | 239 scoped_ptr<FocusActivationStore> focus_activation_store_; |
238 | 240 |
239 scoped_ptr<CursorWindowController> cursor_window_controller_; | 241 scoped_ptr<CursorWindowController> cursor_window_controller_; |
240 scoped_ptr<MirrorWindowController> mirror_window_controller_; | 242 scoped_ptr<MirrorWindowController> mirror_window_controller_; |
241 | 243 |
242 scoped_ptr<ui::InputMethod> input_method_; | 244 scoped_ptr<ui::InputMethod> input_method_; |
243 scoped_ptr<InputMethodEventHandler> input_method_event_handler_; | 245 scoped_ptr<InputMethodEventHandler> input_method_event_handler_; |
244 | 246 |
245 // Stores the current cursor location (in native coordinates and screen | 247 // Stores the current cursor location (in native coordinates and screen |
246 // coordinates respectively). The locations are used to restore the cursor | 248 // coordinates respectively). The locations are used to restore the cursor |
247 // location when the display configuration changes and to determine whether | 249 // location when the display configuration changes and to determine whether |
248 // the mouse should be moved after a display configuration change. | 250 // the mouse should be moved after a display configuration change. |
249 gfx::Point cursor_location_in_native_coords_for_restore_; | 251 gfx::Point cursor_location_in_native_coords_for_restore_; |
250 gfx::Point cursor_location_in_screen_coords_for_restore_; | 252 gfx::Point cursor_location_in_screen_coords_for_restore_; |
251 | 253 |
252 // Stores the cursor's display. The id is used to determine whether the mouse | 254 // Stores the cursor's display. The id is used to determine whether the mouse |
253 // should be moved after a display configuration change. | 255 // should be moved after a display configuration change. |
254 int64 cursor_display_id_for_restore_; | 256 int64_t cursor_display_id_for_restore_; |
255 | 257 |
256 base::WeakPtrFactory<WindowTreeHostManager> weak_ptr_factory_; | 258 base::WeakPtrFactory<WindowTreeHostManager> weak_ptr_factory_; |
257 | 259 |
258 DISALLOW_COPY_AND_ASSIGN(WindowTreeHostManager); | 260 DISALLOW_COPY_AND_ASSIGN(WindowTreeHostManager); |
259 }; | 261 }; |
260 | 262 |
261 } // namespace ash | 263 } // namespace ash |
262 | 264 |
263 #endif // ASH_DISPLAY_DISPLAY_CONTROLLER_H_ | 265 #endif // ASH_DISPLAY_DISPLAY_CONTROLLER_H_ |
OLD | NEW |