Chromium Code Reviews| 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 <vector> | 9 #include <vector> | 
| 10 | 10 | 
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 #include "ash/shell.h" | 21 #include "ash/shell.h" | 
| 22 #include "ash/shell_port.h" | 22 #include "ash/shell_port.h" | 
| 23 #include "ash/system/status_area_widget.h" | 23 #include "ash/system/status_area_widget.h" | 
| 24 #include "ash/wm/fullscreen_window_finder.h" | 24 #include "ash/wm/fullscreen_window_finder.h" | 
| 25 #include "ash/wm/mru_window_tracker.h" | 25 #include "ash/wm/mru_window_tracker.h" | 
| 26 #include "ash/wm/screen_pinning_controller.h" | 26 #include "ash/wm/screen_pinning_controller.h" | 
| 27 #include "ash/wm/window_state.h" | 27 #include "ash/wm/window_state.h" | 
| 28 #include "base/auto_reset.h" | 28 #include "base/auto_reset.h" | 
| 29 #include "base/command_line.h" | 29 #include "base/command_line.h" | 
| 30 #include "base/i18n/rtl.h" | 30 #include "base/i18n/rtl.h" | 
| 31 #include "ui/app_list/app_list_features.h" | |
| 31 #include "ui/base/ui_base_switches.h" | 32 #include "ui/base/ui_base_switches.h" | 
| 32 #include "ui/compositor/layer.h" | 33 #include "ui/compositor/layer.h" | 
| 33 #include "ui/compositor/layer_animation_observer.h" | 34 #include "ui/compositor/layer_animation_observer.h" | 
| 34 #include "ui/compositor/layer_animator.h" | 35 #include "ui/compositor/layer_animator.h" | 
| 35 #include "ui/compositor/scoped_layer_animation_settings.h" | 36 #include "ui/compositor/scoped_layer_animation_settings.h" | 
| 36 #include "ui/display/display.h" | 37 #include "ui/display/display.h" | 
| 37 #include "ui/display/screen.h" | 38 #include "ui/display/screen.h" | 
| 38 #include "ui/events/event.h" | 39 #include "ui/events/event.h" | 
| 39 #include "ui/events/event_handler.h" | 40 #include "ui/events/event_handler.h" | 
| 40 #include "ui/keyboard/keyboard_controller.h" | 41 #include "ui/keyboard/keyboard_controller.h" | 
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 ShelfLayoutManager::~ShelfLayoutManager() { | 167 ShelfLayoutManager::~ShelfLayoutManager() { | 
| 167 if (update_shelf_observer_) | 168 if (update_shelf_observer_) | 
| 168 update_shelf_observer_->Detach(); | 169 update_shelf_observer_->Detach(); | 
| 169 | 170 | 
| 170 for (auto& observer : observers_) | 171 for (auto& observer : observers_) | 
| 171 observer.WillDeleteShelfLayoutManager(); | 172 observer.WillDeleteShelfLayoutManager(); | 
| 172 Shell::Get()->RemoveShellObserver(this); | 173 Shell::Get()->RemoveShellObserver(this); | 
| 173 ShellPort::Get()->RemoveLockStateObserver(this); | 174 ShellPort::Get()->RemoveLockStateObserver(this); | 
| 174 } | 175 } | 
| 175 | 176 | 
| 177 void ShelfLayoutManager::OnAppListIsActive() { | |
| 178 MaybeUpdateShelfBackground(AnimationChangeType::IMMEDIATE); | |
| 179 } | |
| 180 | |
| 176 void ShelfLayoutManager::PrepareForShutdown() { | 181 void ShelfLayoutManager::PrepareForShutdown() { | 
| 177 in_shutdown_ = true; | 182 in_shutdown_ = true; | 
| 178 // Stop observing changes to avoid updating a partially destructed shelf. | 183 // Stop observing changes to avoid updating a partially destructed shelf. | 
| 179 Shell::Get()->activation_client()->RemoveObserver(this); | 184 Shell::Get()->activation_client()->RemoveObserver(this); | 
| 180 } | 185 } | 
| 181 | 186 | 
| 182 bool ShelfLayoutManager::IsVisible() const { | 187 bool ShelfLayoutManager::IsVisible() const { | 
| 183 // status_area_widget() may be nullptr during the shutdown. | 188 // status_area_widget() may be nullptr during the shutdown. | 
| 184 return shelf_widget_->status_area_widget() && | 189 return shelf_widget_->status_area_widget() && | 
| 185 shelf_widget_->status_area_widget()->IsVisible() && | 190 shelf_widget_->status_area_widget()->IsVisible() && | 
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 418 } | 423 } | 
| 419 | 424 | 
| 420 void ShelfLayoutManager::OnVirtualKeyboardStateChanged( | 425 void ShelfLayoutManager::OnVirtualKeyboardStateChanged( | 
| 421 bool activated, | 426 bool activated, | 
| 422 aura::Window* root_window) { | 427 aura::Window* root_window) { | 
| 423 UpdateKeyboardObserverFromStateChanged( | 428 UpdateKeyboardObserverFromStateChanged( | 
| 424 activated, root_window, shelf_widget_->GetNativeWindow()->GetRootWindow(), | 429 activated, root_window, shelf_widget_->GetNativeWindow()->GetRootWindow(), | 
| 425 &keyboard_observer_); | 430 &keyboard_observer_); | 
| 426 } | 431 } | 
| 427 | 432 | 
| 433 void ShelfLayoutManager::OnAppListVisibilityChanged(bool shown, | |
| 434 aura::Window* root_window) { | |
| 435 if (shelf_widget() == Shelf::ForWindow(root_window)->shelf_widget()) { | |
| 
 
xiyuan
2017/06/06 16:50:18
nit: reverse and bail out early
if (shelf_widget(
 
newcomer
2017/06/06 17:12:56
Done.
 
msw
2017/06/06 17:56:31
nit: if (shelf_ == Shelf::ForWindow(root_window))
 
newcomer
2017/06/06 23:26:27
Done.
 
 | |
| 436 app_list_is_being_shown = shown; | |
| 437 if (app_list::features::IsFullscreenAppListEnabled()) | |
| 438 MaybeUpdateShelfBackground(AnimationChangeType::IMMEDIATE); | |
| 439 } | |
| 440 } | |
| 441 | |
| 428 void ShelfLayoutManager::OnWindowActivated(ActivationReason reason, | 442 void ShelfLayoutManager::OnWindowActivated(ActivationReason reason, | 
| 429 aura::Window* gained_active, | 443 aura::Window* gained_active, | 
| 430 aura::Window* lost_active) { | 444 aura::Window* lost_active) { | 
| 431 UpdateAutoHideStateNow(); | 445 UpdateAutoHideStateNow(); | 
| 432 } | 446 } | 
| 433 | 447 | 
| 434 void ShelfLayoutManager::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) { | 448 void ShelfLayoutManager::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) { | 
| 435 bool keyboard_is_about_to_hide = false; | 449 bool keyboard_is_about_to_hide = false; | 
| 436 if (new_bounds.IsEmpty() && !keyboard_bounds_.IsEmpty()) | 450 if (new_bounds.IsEmpty() && !keyboard_bounds_.IsEmpty()) | 
| 437 keyboard_is_about_to_hide = true; | 451 keyboard_is_about_to_hide = true; | 
| (...skipping 23 matching lines...) Expand all Loading... | |
| 461 } | 475 } | 
| 462 | 476 | 
| 463 ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const { | 477 ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const { | 
| 464 if (state_.pre_lock_screen_animation_active) | 478 if (state_.pre_lock_screen_animation_active) | 
| 465 return SHELF_BACKGROUND_DEFAULT; | 479 return SHELF_BACKGROUND_DEFAULT; | 
| 466 | 480 | 
| 467 // Handle all non active screen states, including OOBE and pre-login. | 481 // Handle all non active screen states, including OOBE and pre-login. | 
| 468 if (state_.session_state != session_manager::SessionState::ACTIVE) | 482 if (state_.session_state != session_manager::SessionState::ACTIVE) | 
| 469 return SHELF_BACKGROUND_OVERLAP; | 483 return SHELF_BACKGROUND_OVERLAP; | 
| 470 | 484 | 
| 485 // If the app list is active, hide the shelf background to prevent overlap. | |
| 486 if (app_list_is_being_shown && | |
| 487 app_list::features::IsFullscreenAppListEnabled()) | |
| 488 return SHELF_BACKGROUND_DEFAULT; | |
| 489 | |
| 471 if (state_.visibility_state != SHELF_AUTO_HIDE && | 490 if (state_.visibility_state != SHELF_AUTO_HIDE && | 
| 472 state_.window_state == wm::WORKSPACE_WINDOW_STATE_MAXIMIZED) { | 491 state_.window_state == wm::WORKSPACE_WINDOW_STATE_MAXIMIZED) { | 
| 473 return SHELF_BACKGROUND_MAXIMIZED; | 492 return SHELF_BACKGROUND_MAXIMIZED; | 
| 474 } | 493 } | 
| 475 | 494 | 
| 476 if (gesture_drag_status_ == GESTURE_DRAG_IN_PROGRESS || | 495 if (gesture_drag_status_ == GESTURE_DRAG_IN_PROGRESS || | 
| 477 window_overlaps_shelf_ || state_.visibility_state == SHELF_AUTO_HIDE) { | 496 window_overlaps_shelf_ || state_.visibility_state == SHELF_AUTO_HIDE) { | 
| 478 return SHELF_BACKGROUND_OVERLAP; | 497 return SHELF_BACKGROUND_OVERLAP; | 
| 479 } | 498 } | 
| 480 | 499 | 
| (...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1153 gesture_drag_status_ = GESTURE_DRAG_NONE; | 1172 gesture_drag_status_ = GESTURE_DRAG_NONE; | 
| 1154 } | 1173 } | 
| 1155 | 1174 | 
| 1156 void ShelfLayoutManager::CancelGestureDrag() { | 1175 void ShelfLayoutManager::CancelGestureDrag() { | 
| 1157 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS; | 1176 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS; | 
| 1158 UpdateVisibilityState(); | 1177 UpdateVisibilityState(); | 
| 1159 gesture_drag_status_ = GESTURE_DRAG_NONE; | 1178 gesture_drag_status_ = GESTURE_DRAG_NONE; | 
| 1160 } | 1179 } | 
| 1161 | 1180 | 
| 1162 } // namespace ash | 1181 } // namespace ash | 
| OLD | NEW |