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 #include "ash/shelf/shelf_layout_manager.h" | 5 #include "ash/shelf/shelf_layout_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <cstring> | 9 #include <cstring> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "ash/accelerators/accelerator_commands.h" | 13 #include "ash/accelerators/accelerator_commands.h" |
14 #include "ash/ash_switches.h" | 14 #include "ash/ash_switches.h" |
| 15 #include "ash/aura/wm_window_aura.h" |
15 #include "ash/common/shell_window_ids.h" | 16 #include "ash/common/shell_window_ids.h" |
16 #include "ash/common/wm/shelf/wm_shelf_util.h" | 17 #include "ash/common/wm/shelf/wm_shelf_util.h" |
17 #include "ash/common/wm/window_state.h" | 18 #include "ash/common/wm/window_state.h" |
18 #include "ash/common/wm/wm_root_window_controller.h" | 19 #include "ash/common/wm_root_window_controller.h" |
19 #include "ash/common/wm/wm_root_window_controller_observer.h" | 20 #include "ash/common/wm_root_window_controller_observer.h" |
20 #include "ash/root_window_controller.h" | 21 #include "ash/root_window_controller.h" |
21 #include "ash/screen_util.h" | 22 #include "ash/screen_util.h" |
22 #include "ash/session/session_state_delegate.h" | 23 #include "ash/session/session_state_delegate.h" |
23 #include "ash/shelf/shelf.h" | 24 #include "ash/shelf/shelf.h" |
24 #include "ash/shelf/shelf_bezel_event_filter.h" | 25 #include "ash/shelf/shelf_bezel_event_filter.h" |
25 #include "ash/shelf/shelf_constants.h" | 26 #include "ash/shelf/shelf_constants.h" |
26 #include "ash/shelf/shelf_delegate.h" | 27 #include "ash/shelf/shelf_delegate.h" |
27 #include "ash/shelf/shelf_layout_manager_observer.h" | 28 #include "ash/shelf/shelf_layout_manager_observer.h" |
28 #include "ash/shelf/shelf_util.h" | 29 #include "ash/shelf/shelf_util.h" |
29 #include "ash/shelf/shelf_widget.h" | 30 #include "ash/shelf/shelf_widget.h" |
30 #include "ash/shell.h" | 31 #include "ash/shell.h" |
31 #include "ash/system/status_area_widget.h" | 32 #include "ash/system/status_area_widget.h" |
32 #include "ash/wm/aura/wm_window_aura.h" | |
33 #include "ash/wm/gestures/shelf_gesture_handler.h" | 33 #include "ash/wm/gestures/shelf_gesture_handler.h" |
34 #include "ash/wm/lock_state_controller.h" | 34 #include "ash/wm/lock_state_controller.h" |
35 #include "ash/wm/mru_window_tracker.h" | 35 #include "ash/wm/mru_window_tracker.h" |
36 #include "ash/wm/window_animations.h" | 36 #include "ash/wm/window_animations.h" |
37 #include "ash/wm/window_state_aura.h" | 37 #include "ash/wm/window_state_aura.h" |
38 #include "ash/wm/window_util.h" | 38 #include "ash/wm/window_util.h" |
39 #include "ash/wm/workspace_controller.h" | 39 #include "ash/wm/workspace_controller.h" |
40 #include "base/auto_reset.h" | 40 #include "base/auto_reset.h" |
41 #include "base/command_line.h" | 41 #include "base/command_line.h" |
42 #include "base/command_line.h" | 42 #include "base/command_line.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 | 184 |
185 // ShelfLayoutManager::RootWindowControllerObserverImpl ------------------------ | 185 // ShelfLayoutManager::RootWindowControllerObserverImpl ------------------------ |
186 | 186 |
187 // NOTE: Some other layout managers also observe for OnShelfAlignmentChanged() | 187 // NOTE: Some other layout managers also observe for OnShelfAlignmentChanged() |
188 // via WmRootWindowControllerObserver instead of via ShellObserver. There are | 188 // via WmRootWindowControllerObserver instead of via ShellObserver. There are |
189 // implicit assumptions that these layout managers run in order. In order to | 189 // implicit assumptions that these layout managers run in order. In order to |
190 // preserve the ordering, OnShelfAlignmentChanged() is implemented here in terms | 190 // preserve the ordering, OnShelfAlignmentChanged() is implemented here in terms |
191 // of a WmRootWindowControllerObserver instead of a ShellObserver. This gives us | 191 // of a WmRootWindowControllerObserver instead of a ShellObserver. This gives us |
192 // a sane ordering (or at least ordering as we've always had it in ash). | 192 // a sane ordering (or at least ordering as we've always had it in ash). |
193 class ShelfLayoutManager::RootWindowControllerObserverImpl | 193 class ShelfLayoutManager::RootWindowControllerObserverImpl |
194 : public wm::WmRootWindowControllerObserver { | 194 : public WmRootWindowControllerObserver { |
195 public: | 195 public: |
196 explicit RootWindowControllerObserverImpl( | 196 explicit RootWindowControllerObserverImpl( |
197 ShelfLayoutManager* shelf_layout_manager) | 197 ShelfLayoutManager* shelf_layout_manager) |
198 : shelf_layout_manager_(shelf_layout_manager) {} | 198 : shelf_layout_manager_(shelf_layout_manager) {} |
199 ~RootWindowControllerObserverImpl() override {} | 199 ~RootWindowControllerObserverImpl() override {} |
200 | 200 |
201 // WmRootWindowControllerObserver: | 201 // WmRootWindowControllerObserver: |
202 void OnShelfAlignmentChanged() override { | 202 void OnShelfAlignmentChanged() override { |
203 shelf_layout_manager_->LayoutShelf(); | 203 shelf_layout_manager_->LayoutShelf(); |
204 } | 204 } |
(...skipping 19 matching lines...) Expand all Loading... |
224 gesture_drag_amount_(0.f), | 224 gesture_drag_amount_(0.f), |
225 gesture_drag_auto_hide_state_(SHELF_AUTO_HIDE_SHOWN), | 225 gesture_drag_auto_hide_state_(SHELF_AUTO_HIDE_SHOWN), |
226 update_shelf_observer_(NULL), | 226 update_shelf_observer_(NULL), |
227 chromevox_panel_height_(0), | 227 chromevox_panel_height_(0), |
228 duration_override_in_ms_(0) { | 228 duration_override_in_ms_(0) { |
229 Shell::GetInstance()->AddShellObserver(this); | 229 Shell::GetInstance()->AddShellObserver(this); |
230 | 230 |
231 if (!Shell::GetInstance()->in_mus()) { | 231 if (!Shell::GetInstance()->in_mus()) { |
232 root_window_controller_observer_.reset( | 232 root_window_controller_observer_.reset( |
233 new RootWindowControllerObserverImpl(this)); | 233 new RootWindowControllerObserverImpl(this)); |
234 wm::WmWindowAura::Get(root_window_) | 234 WmWindowAura::Get(root_window_) |
235 ->GetRootWindowController() | 235 ->GetRootWindowController() |
236 ->AddObserver(root_window_controller_observer_.get()); | 236 ->AddObserver(root_window_controller_observer_.get()); |
237 } | 237 } |
238 Shell::GetInstance()->lock_state_controller()->AddObserver(this); | 238 Shell::GetInstance()->lock_state_controller()->AddObserver(this); |
239 aura::client::GetActivationClient(root_window_)->AddObserver(this); | 239 aura::client::GetActivationClient(root_window_)->AddObserver(this); |
240 Shell::GetInstance()->session_state_delegate()->AddSessionStateObserver(this); | 240 Shell::GetInstance()->session_state_delegate()->AddSessionStateObserver(this); |
241 } | 241 } |
242 | 242 |
243 ShelfLayoutManager::~ShelfLayoutManager() { | 243 ShelfLayoutManager::~ShelfLayoutManager() { |
244 if (update_shelf_observer_) | 244 if (update_shelf_observer_) |
245 update_shelf_observer_->Detach(); | 245 update_shelf_observer_->Detach(); |
246 | 246 |
247 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, | 247 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, |
248 WillDeleteShelfLayoutManager()); | 248 WillDeleteShelfLayoutManager()); |
249 Shell::GetInstance()->RemoveShellObserver(this); | 249 Shell::GetInstance()->RemoveShellObserver(this); |
250 Shell::GetInstance()->lock_state_controller()->RemoveObserver(this); | 250 Shell::GetInstance()->lock_state_controller()->RemoveObserver(this); |
251 Shell::GetInstance()-> | 251 Shell::GetInstance()-> |
252 session_state_delegate()->RemoveSessionStateObserver(this); | 252 session_state_delegate()->RemoveSessionStateObserver(this); |
253 if (root_window_controller_observer_) { | 253 if (root_window_controller_observer_) { |
254 wm::WmWindowAura::Get(root_window_) | 254 WmWindowAura::Get(root_window_) |
255 ->GetRootWindowController() | 255 ->GetRootWindowController() |
256 ->RemoveObserver(root_window_controller_observer_.get()); | 256 ->RemoveObserver(root_window_controller_observer_.get()); |
257 } | 257 } |
258 } | 258 } |
259 | 259 |
260 void ShelfLayoutManager::PrepareForShutdown() { | 260 void ShelfLayoutManager::PrepareForShutdown() { |
261 in_shutdown_ = true; | 261 in_shutdown_ = true; |
262 // Clear all event filters, otherwise sometimes those filters may catch | 262 // Clear all event filters, otherwise sometimes those filters may catch |
263 // synthesized mouse event and cause crashes during the shutdown. | 263 // synthesized mouse event and cause crashes during the shutdown. |
264 set_workspace_controller(NULL); | 264 set_workspace_controller(NULL); |
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 UpdateBoundsAndOpacity(target_bounds, true, NULL); | 1194 UpdateBoundsAndOpacity(target_bounds, true, NULL); |
1195 UpdateVisibilityState(); | 1195 UpdateVisibilityState(); |
1196 } | 1196 } |
1197 | 1197 |
1198 void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() { | 1198 void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() { |
1199 UpdateVisibilityState(); | 1199 UpdateVisibilityState(); |
1200 LayoutShelf(); | 1200 LayoutShelf(); |
1201 } | 1201 } |
1202 | 1202 |
1203 } // namespace ash | 1203 } // namespace ash |
OLD | NEW |