| 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/app_list/app_list_presenter_delegate.h" | 5 #include "ash/app_list/app_list_presenter_delegate.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/public/cpp/shelf_types.h" | 8 #include "ash/public/cpp/shelf_types.h" |
| 9 #include "ash/public/cpp/shell_window_ids.h" | 9 #include "ash/public/cpp/shell_window_ids.h" |
| 10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
| 11 #include "ash/screen_util.h" | 11 #include "ash/screen_util.h" |
| 12 #include "ash/shelf/app_list_button.h" | 12 #include "ash/shelf/app_list_button.h" |
| 13 #include "ash/shelf/shelf.h" |
| 13 #include "ash/shelf/shelf_layout_manager.h" | 14 #include "ash/shelf/shelf_layout_manager.h" |
| 14 #include "ash/shelf/shelf_widget.h" | 15 #include "ash/shelf/shelf_widget.h" |
| 15 #include "ash/shelf/wm_shelf.h" | |
| 16 #include "ash/shell.h" | 16 #include "ash/shell.h" |
| 17 #include "ash/shell_port.h" | 17 #include "ash/shell_port.h" |
| 18 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 18 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
| 19 #include "ash/wm_window.h" | 19 #include "ash/wm_window.h" |
| 20 #include "base/command_line.h" | 20 #include "base/command_line.h" |
| 21 #include "ui/app_list/app_list_constants.h" | 21 #include "ui/app_list/app_list_constants.h" |
| 22 #include "ui/app_list/app_list_features.h" | 22 #include "ui/app_list/app_list_features.h" |
| 23 #include "ui/app_list/app_list_switches.h" | 23 #include "ui/app_list/app_list_switches.h" |
| 24 #include "ui/app_list/presenter/app_list_presenter_impl.h" | 24 #include "ui/app_list/presenter/app_list_presenter_impl.h" |
| 25 #include "ui/app_list/presenter/app_list_view_delegate_factory.h" | 25 #include "ui/app_list/presenter/app_list_view_delegate_factory.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 104 |
| 105 if (!app_list::features::IsFullscreenAppListEnabled()) { | 105 if (!app_list::features::IsFullscreenAppListEnabled()) { |
| 106 view->MaybeSetAnchorPoint(GetCenterOfDisplayForWindow( | 106 view->MaybeSetAnchorPoint(GetCenterOfDisplayForWindow( |
| 107 WmWindow::Get(root_window), GetMinimumBoundsHeightForAppList(view))); | 107 WmWindow::Get(root_window), GetMinimumBoundsHeightForAppList(view))); |
| 108 } | 108 } |
| 109 keyboard::KeyboardController* keyboard_controller = | 109 keyboard::KeyboardController* keyboard_controller = |
| 110 keyboard::KeyboardController::GetInstance(); | 110 keyboard::KeyboardController::GetInstance(); |
| 111 if (keyboard_controller) | 111 if (keyboard_controller) |
| 112 keyboard_controller->AddObserver(this); | 112 keyboard_controller->AddObserver(this); |
| 113 Shell::Get()->AddPreTargetHandler(this); | 113 Shell::Get()->AddPreTargetHandler(this); |
| 114 WmShelf* shelf = WmShelf::ForWindow(root_window); | 114 Shelf* shelf = Shelf::ForWindow(root_window); |
| 115 shelf->AddObserver(this); | 115 shelf->AddObserver(this); |
| 116 | 116 |
| 117 // By setting us as DnD recipient, the app list knows that we can | 117 // By setting us as DnD recipient, the app list knows that we can |
| 118 // handle items. | 118 // handle items. |
| 119 view->SetDragAndDropHostOfCurrentAppList( | 119 view->SetDragAndDropHostOfCurrentAppList( |
| 120 shelf->shelf_widget()->GetDragAndDropHostForAppList()); | 120 shelf->shelf_widget()->GetDragAndDropHostForAppList()); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void AppListPresenterDelegate::OnShown(int64_t display_id) { | 123 void AppListPresenterDelegate::OnShown(int64_t display_id) { |
| 124 is_visible_ = true; | 124 is_visible_ = true; |
| 125 // Update applist button status when app list visibility is changed. | 125 // Update applist button status when app list visibility is changed. |
| 126 aura::Window* root_window = | 126 aura::Window* root_window = |
| 127 ShellPort::Get()->GetRootWindowForDisplayId(display_id); | 127 ShellPort::Get()->GetRootWindowForDisplayId(display_id); |
| 128 AppListButton* app_list_button = | 128 AppListButton* app_list_button = |
| 129 WmShelf::ForWindow(root_window)->shelf_widget()->GetAppListButton(); | 129 Shelf::ForWindow(root_window)->shelf_widget()->GetAppListButton(); |
| 130 if (app_list_button) | 130 if (app_list_button) |
| 131 app_list_button->OnAppListShown(); | 131 app_list_button->OnAppListShown(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void AppListPresenterDelegate::OnDismissed() { | 134 void AppListPresenterDelegate::OnDismissed() { |
| 135 DCHECK(is_visible_); | 135 DCHECK(is_visible_); |
| 136 DCHECK(view_); | 136 DCHECK(view_); |
| 137 | 137 |
| 138 is_visible_ = false; | 138 is_visible_ = false; |
| 139 | 139 |
| 140 // Update applist button status when app list visibility is changed. | 140 // Update applist button status when app list visibility is changed. |
| 141 WmShelf* shelf = WmShelf::ForWindow(view_->GetWidget()->GetNativeWindow()); | 141 Shelf* shelf = Shelf::ForWindow(view_->GetWidget()->GetNativeWindow()); |
| 142 AppListButton* app_list_button = shelf->shelf_widget()->GetAppListButton(); | 142 AppListButton* app_list_button = shelf->shelf_widget()->GetAppListButton(); |
| 143 if (app_list_button) | 143 if (app_list_button) |
| 144 app_list_button->OnAppListDismissed(); | 144 app_list_button->OnAppListDismissed(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 void AppListPresenterDelegate::UpdateBounds() { | 147 void AppListPresenterDelegate::UpdateBounds() { |
| 148 if (!view_ || !is_visible_) | 148 if (!view_ || !is_visible_) |
| 149 return; | 149 return; |
| 150 | 150 |
| 151 view_->UpdateBounds(); | 151 view_->UpdateBounds(); |
| 152 view_->MaybeSetAnchorPoint(GetCenterOfDisplayForWindow( | 152 view_->MaybeSetAnchorPoint(GetCenterOfDisplayForWindow( |
| 153 WmWindow::Get(view_->GetWidget()->GetNativeWindow()), | 153 WmWindow::Get(view_->GetWidget()->GetNativeWindow()), |
| 154 GetMinimumBoundsHeightForAppList(view_))); | 154 GetMinimumBoundsHeightForAppList(view_))); |
| 155 } | 155 } |
| 156 | 156 |
| 157 gfx::Vector2d AppListPresenterDelegate::GetVisibilityAnimationOffset( | 157 gfx::Vector2d AppListPresenterDelegate::GetVisibilityAnimationOffset( |
| 158 aura::Window* root_window) { | 158 aura::Window* root_window) { |
| 159 DCHECK(Shell::HasInstance()); | 159 DCHECK(Shell::HasInstance()); |
| 160 | 160 |
| 161 // App list needs to know the new shelf layout in order to calculate its | 161 // App list needs to know the new shelf layout in order to calculate its |
| 162 // UI layout when AppListView visibility changes. | 162 // UI layout when AppListView visibility changes. |
| 163 WmShelf* shelf = WmShelf::ForWindow(root_window); | 163 Shelf* shelf = Shelf::ForWindow(root_window); |
| 164 shelf->UpdateAutoHideState(); | 164 shelf->UpdateAutoHideState(); |
| 165 | 165 |
| 166 switch (shelf->alignment()) { | 166 switch (shelf->alignment()) { |
| 167 case SHELF_ALIGNMENT_BOTTOM: | 167 case SHELF_ALIGNMENT_BOTTOM: |
| 168 case SHELF_ALIGNMENT_BOTTOM_LOCKED: | 168 case SHELF_ALIGNMENT_BOTTOM_LOCKED: |
| 169 return gfx::Vector2d(0, kAnimationOffset); | 169 return gfx::Vector2d(0, kAnimationOffset); |
| 170 case SHELF_ALIGNMENT_LEFT: | 170 case SHELF_ALIGNMENT_LEFT: |
| 171 return gfx::Vector2d(-kAnimationOffset, 0); | 171 return gfx::Vector2d(-kAnimationOffset, 0); |
| 172 case SHELF_ALIGNMENT_RIGHT: | 172 case SHELF_ALIGNMENT_RIGHT: |
| 173 return gfx::Vector2d(kAnimationOffset, 0); | 173 return gfx::Vector2d(kAnimationOffset, 0); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 void AppListPresenterDelegate::OnKeyboardClosed() {} | 233 void AppListPresenterDelegate::OnKeyboardClosed() {} |
| 234 | 234 |
| 235 //////////////////////////////////////////////////////////////////////////////// | 235 //////////////////////////////////////////////////////////////////////////////// |
| 236 // AppListPresenterDelegate, ShellObserver implementation: | 236 // AppListPresenterDelegate, ShellObserver implementation: |
| 237 void AppListPresenterDelegate::OnOverviewModeStarting() { | 237 void AppListPresenterDelegate::OnOverviewModeStarting() { |
| 238 if (is_visible_) | 238 if (is_visible_) |
| 239 presenter_->Dismiss(); | 239 presenter_->Dismiss(); |
| 240 } | 240 } |
| 241 | 241 |
| 242 //////////////////////////////////////////////////////////////////////////////// | 242 //////////////////////////////////////////////////////////////////////////////// |
| 243 // AppListPresenterDelegate, WmShelfObserver implementation: | 243 // AppListPresenterDelegate, ShelfObserver implementation: |
| 244 | 244 |
| 245 void AppListPresenterDelegate::OnShelfIconPositionsChanged() { | 245 void AppListPresenterDelegate::OnShelfIconPositionsChanged() { |
| 246 UpdateBounds(); | 246 UpdateBounds(); |
| 247 } | 247 } |
| 248 | 248 |
| 249 } // namespace ash | 249 } // namespace ash |
| OLD | NEW |