Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Side by Side Diff: ash/common/shelf/shelf_layout_manager.cc

Issue 2736753005: Converts WmActivationObserver to aura::client::ActivationChangeObserver (Closed)
Patch Set: cleanup Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/common/shelf/shelf_layout_manager.h" 5 #include "ash/common/shelf/shelf_layout_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <vector> 9 #include <vector>
10 10
11 #include "ash/animation/animation_change_type.h" 11 #include "ash/animation/animation_change_type.h"
12 #include "ash/common/session/session_controller.h" 12 #include "ash/common/session/session_controller.h"
13 #include "ash/common/session/session_state_delegate.h" 13 #include "ash/common/session/session_state_delegate.h"
14 #include "ash/common/shelf/shelf_constants.h" 14 #include "ash/common/shelf/shelf_constants.h"
15 #include "ash/common/shelf/shelf_layout_manager_observer.h" 15 #include "ash/common/shelf/shelf_layout_manager_observer.h"
16 #include "ash/common/shelf/shelf_widget.h" 16 #include "ash/common/shelf/shelf_widget.h"
17 #include "ash/common/shelf/wm_shelf.h" 17 #include "ash/common/shelf/wm_shelf.h"
18 #include "ash/common/system/status_area_widget.h" 18 #include "ash/common/system/status_area_widget.h"
19 #include "ash/common/wm/fullscreen_window_finder.h" 19 #include "ash/common/wm/fullscreen_window_finder.h"
20 #include "ash/common/wm/mru_window_tracker.h" 20 #include "ash/common/wm/mru_window_tracker.h"
21 #include "ash/common/wm/window_state.h" 21 #include "ash/common/wm/window_state.h"
22 #include "ash/common/wm/wm_screen_util.h" 22 #include "ash/common/wm/wm_screen_util.h"
23 #include "ash/common/wm_shell.h" 23 #include "ash/common/wm_shell.h"
24 #include "ash/common/wm_window.h" 24 #include "ash/common/wm_window.h"
25 #include "ash/public/cpp/shell_window_ids.h" 25 #include "ash/public/cpp/shell_window_ids.h"
26 #include "ash/root_window_controller.h" 26 #include "ash/root_window_controller.h"
27 #include "ash/shell.h"
27 #include "base/auto_reset.h" 28 #include "base/auto_reset.h"
28 #include "base/command_line.h" 29 #include "base/command_line.h"
29 #include "base/i18n/rtl.h" 30 #include "base/i18n/rtl.h"
30 #include "ui/base/ui_base_switches.h" 31 #include "ui/base/ui_base_switches.h"
31 #include "ui/compositor/layer.h" 32 #include "ui/compositor/layer.h"
32 #include "ui/compositor/layer_animation_observer.h" 33 #include "ui/compositor/layer_animation_observer.h"
33 #include "ui/compositor/layer_animator.h" 34 #include "ui/compositor/layer_animator.h"
34 #include "ui/compositor/scoped_layer_animation_settings.h" 35 #include "ui/compositor/scoped_layer_animation_settings.h"
35 #include "ui/display/display.h" 36 #include "ui/display/display.h"
36 #include "ui/display/screen.h" 37 #include "ui/display/screen.h"
37 #include "ui/events/event.h" 38 #include "ui/events/event.h"
38 #include "ui/events/event_handler.h" 39 #include "ui/events/event_handler.h"
39 #include "ui/keyboard/keyboard_controller.h" 40 #include "ui/keyboard/keyboard_controller.h"
40 #include "ui/keyboard/keyboard_util.h" 41 #include "ui/keyboard/keyboard_util.h"
41 #include "ui/views/border.h" 42 #include "ui/views/border.h"
42 #include "ui/views/widget/widget.h" 43 #include "ui/views/widget/widget.h"
44 #include "ui/wm/public/activation_client.h"
43 45
44 namespace ash { 46 namespace ash {
45 namespace { 47 namespace {
46 48
47 // Delay before showing the shelf. This is after the mouse stops moving. 49 // Delay before showing the shelf. This is after the mouse stops moving.
48 const int kAutoHideDelayMS = 200; 50 const int kAutoHideDelayMS = 200;
49 51
50 // Duration of the animation to show or hide the shelf. 52 // Duration of the animation to show or hide the shelf.
51 const int kAnimationDurationMS = 200; 53 const int kAnimationDurationMS = 200;
52 54
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 gesture_drag_amount_(0.f), 151 gesture_drag_amount_(0.f),
150 gesture_drag_auto_hide_state_(SHELF_AUTO_HIDE_SHOWN), 152 gesture_drag_auto_hide_state_(SHELF_AUTO_HIDE_SHOWN),
151 update_shelf_observer_(NULL), 153 update_shelf_observer_(NULL),
152 chromevox_panel_height_(0), 154 chromevox_panel_height_(0),
153 duration_override_in_ms_(0), 155 duration_override_in_ms_(0),
154 shelf_background_type_(SHELF_BACKGROUND_OVERLAP) { 156 shelf_background_type_(SHELF_BACKGROUND_OVERLAP) {
155 DCHECK(shelf_widget_); 157 DCHECK(shelf_widget_);
156 DCHECK(wm_shelf_); 158 DCHECK(wm_shelf_);
157 WmShell::Get()->AddShellObserver(this); 159 WmShell::Get()->AddShellObserver(this);
158 WmShell::Get()->AddLockStateObserver(this); 160 WmShell::Get()->AddLockStateObserver(this);
159 WmShell::Get()->AddActivationObserver(this); 161 Shell::GetInstance()->activation_client()->AddObserver(this);
160 WmShell::Get()->session_controller()->AddSessionStateObserver(this); 162 WmShell::Get()->session_controller()->AddSessionStateObserver(this);
161 state_.session_state = 163 state_.session_state =
162 WmShell::Get()->session_controller()->GetSessionState(); 164 WmShell::Get()->session_controller()->GetSessionState();
163 } 165 }
164 166
165 ShelfLayoutManager::~ShelfLayoutManager() { 167 ShelfLayoutManager::~ShelfLayoutManager() {
166 if (update_shelf_observer_) 168 if (update_shelf_observer_)
167 update_shelf_observer_->Detach(); 169 update_shelf_observer_->Detach();
168 170
169 for (auto& observer : observers_) 171 for (auto& observer : observers_)
170 observer.WillDeleteShelfLayoutManager(); 172 observer.WillDeleteShelfLayoutManager();
171 WmShell::Get()->RemoveShellObserver(this); 173 WmShell::Get()->RemoveShellObserver(this);
172 WmShell::Get()->RemoveLockStateObserver(this); 174 WmShell::Get()->RemoveLockStateObserver(this);
173 WmShell::Get()->session_controller()->RemoveSessionStateObserver(this); 175 WmShell::Get()->session_controller()->RemoveSessionStateObserver(this);
174 } 176 }
175 177
176 void ShelfLayoutManager::PrepareForShutdown() { 178 void ShelfLayoutManager::PrepareForShutdown() {
177 in_shutdown_ = true; 179 in_shutdown_ = true;
178 // Stop observing changes to avoid updating a partially destructed shelf. 180 // Stop observing changes to avoid updating a partially destructed shelf.
179 WmShell::Get()->RemoveActivationObserver(this); 181 Shell::GetInstance()->activation_client()->RemoveObserver(this);
180 } 182 }
181 183
182 bool ShelfLayoutManager::IsVisible() const { 184 bool ShelfLayoutManager::IsVisible() const {
183 // status_area_widget() may be NULL during the shutdown. 185 // status_area_widget() may be NULL during the shutdown.
184 return shelf_widget_->status_area_widget() && 186 return shelf_widget_->status_area_widget() &&
185 shelf_widget_->status_area_widget()->IsVisible() && 187 shelf_widget_->status_area_widget()->IsVisible() &&
186 (state_.visibility_state == SHELF_VISIBLE || 188 (state_.visibility_state == SHELF_VISIBLE ||
187 (state_.visibility_state == SHELF_AUTO_HIDE && 189 (state_.visibility_state == SHELF_AUTO_HIDE &&
188 state_.auto_hide_state == SHELF_AUTO_HIDE_SHOWN)); 190 state_.auto_hide_state == SHELF_AUTO_HIDE_SHOWN));
189 } 191 }
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 void ShelfLayoutManager::OnShelfAutoHideBehaviorChanged(WmWindow* root_window) { 398 void ShelfLayoutManager::OnShelfAutoHideBehaviorChanged(WmWindow* root_window) {
397 UpdateVisibilityState(); 399 UpdateVisibilityState();
398 } 400 }
399 401
400 void ShelfLayoutManager::OnPinnedStateChanged(WmWindow* pinned_window) { 402 void ShelfLayoutManager::OnPinnedStateChanged(WmWindow* pinned_window) {
401 // Shelf needs to be hidden on entering to pinned mode, or restored 403 // Shelf needs to be hidden on entering to pinned mode, or restored
402 // on exiting from pinned mode. 404 // on exiting from pinned mode.
403 UpdateVisibilityState(); 405 UpdateVisibilityState();
404 } 406 }
405 407
406 void ShelfLayoutManager::OnWindowActivated(WmWindow* gained_active, 408 void ShelfLayoutManager::OnWindowActivated(ActivationReason reason,
407 WmWindow* lost_active) { 409 aura::Window* gained_active,
410 aura::Window* lost_active) {
408 UpdateAutoHideStateNow(); 411 UpdateAutoHideStateNow();
409 } 412 }
410 413
411 void ShelfLayoutManager::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) { 414 void ShelfLayoutManager::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) {
412 bool keyboard_is_about_to_hide = false; 415 bool keyboard_is_about_to_hide = false;
413 if (new_bounds.IsEmpty() && !keyboard_bounds_.IsEmpty()) 416 if (new_bounds.IsEmpty() && !keyboard_bounds_.IsEmpty())
414 keyboard_is_about_to_hide = true; 417 keyboard_is_about_to_hide = true;
415 // If new window behavior flag enabled and in non-sticky mode, do not change 418 // If new window behavior flag enabled and in non-sticky mode, do not change
416 // the work area. 419 // the work area.
417 bool change_work_area = 420 bool change_work_area =
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 gesture_drag_status_ = GESTURE_DRAG_NONE; 1137 gesture_drag_status_ = GESTURE_DRAG_NONE;
1135 } 1138 }
1136 1139
1137 void ShelfLayoutManager::CancelGestureDrag() { 1140 void ShelfLayoutManager::CancelGestureDrag() {
1138 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS; 1141 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS;
1139 UpdateVisibilityState(); 1142 UpdateVisibilityState();
1140 gesture_drag_status_ = GESTURE_DRAG_NONE; 1143 gesture_drag_status_ = GESTURE_DRAG_NONE;
1141 } 1144 }
1142 1145
1143 } // namespace ash 1146 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698