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/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" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 // UI layout when AppListView visibility changes. | 91 // UI layout when AppListView visibility changes. |
| 92 Shell::GetPrimaryRootWindowController() | 92 Shell::GetPrimaryRootWindowController() |
| 93 ->GetShelfLayoutManager() | 93 ->GetShelfLayoutManager() |
| 94 ->UpdateAutoHideState(); | 94 ->UpdateAutoHideState(); |
| 95 view_ = view; | 95 view_ = view; |
| 96 aura::Window* root_window = | 96 aura::Window* root_window = |
| 97 ShellPort::Get()->GetRootWindowForDisplayId(display_id); | 97 ShellPort::Get()->GetRootWindowForDisplayId(display_id); |
| 98 aura::Window* container = RootWindowController::ForWindow(root_window) | 98 aura::Window* container = RootWindowController::ForWindow(root_window) |
| 99 ->GetContainer(kShellWindowId_AppListContainer); | 99 ->GetContainer(kShellWindowId_AppListContainer); |
| 100 | 100 |
| 101 view->Initialize(container, current_apps_page); | 101 view->Initialize(container, current_apps_page, IsMaximizeModeActive(), |
| 102 IsSideShelf(root_window)); | |
|
vadimt
2017/06/13 18:14:10
Would it be too expensive to calculate root_window
newcomer
2017/06/13 18:51:45
Done.
| |
| 102 | 103 |
| 103 if (!app_list::features::IsFullscreenAppListEnabled()) { | 104 if (!app_list::features::IsFullscreenAppListEnabled()) { |
| 104 view->MaybeSetAnchorPoint(GetCenterOfDisplayForWindow( | 105 view->MaybeSetAnchorPoint(GetCenterOfDisplayForWindow( |
| 105 root_window, GetMinimumBoundsHeightForAppList(view))); | 106 root_window, GetMinimumBoundsHeightForAppList(view))); |
| 106 } | 107 } |
| 107 keyboard::KeyboardController* keyboard_controller = | 108 keyboard::KeyboardController* keyboard_controller = |
| 108 keyboard::KeyboardController::GetInstance(); | 109 keyboard::KeyboardController::GetInstance(); |
| 109 if (keyboard_controller) | 110 if (keyboard_controller) |
| 110 keyboard_controller->AddObserver(this); | 111 keyboard_controller->AddObserver(this); |
| 111 Shell::Get()->AddPreTargetHandler(this); | 112 Shell::Get()->AddPreTargetHandler(this); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 return gfx::Vector2d(0, kAnimationOffset); | 160 return gfx::Vector2d(0, kAnimationOffset); |
| 160 case SHELF_ALIGNMENT_LEFT: | 161 case SHELF_ALIGNMENT_LEFT: |
| 161 return gfx::Vector2d(-kAnimationOffset, 0); | 162 return gfx::Vector2d(-kAnimationOffset, 0); |
| 162 case SHELF_ALIGNMENT_RIGHT: | 163 case SHELF_ALIGNMENT_RIGHT: |
| 163 return gfx::Vector2d(kAnimationOffset, 0); | 164 return gfx::Vector2d(kAnimationOffset, 0); |
| 164 } | 165 } |
| 165 NOTREACHED(); | 166 NOTREACHED(); |
| 166 return gfx::Vector2d(); | 167 return gfx::Vector2d(); |
| 167 } | 168 } |
| 168 | 169 |
| 170 bool AppListPresenterDelegate::IsMaximizeModeActive() { | |
| 171 MaximizeModeController* maximize_mode_controller = | |
| 172 Shell::Get()->maximize_mode_controller(); | |
| 173 return maximize_mode_controller && | |
|
vadimt
2017/06/13 18:14:10
Can it realistically be null?
newcomer
2017/06/13 18:51:45
I copied that function from https://cs.chromium.or
| |
| 174 maximize_mode_controller->IsMaximizeModeWindowManagerEnabled(); | |
| 175 } | |
| 176 | |
| 177 bool AppListPresenterDelegate::IsSideShelf(aura::Window* root_window) { | |
| 178 Shelf* shelf = Shelf::ForWindow(root_window); | |
| 179 switch (shelf->alignment()) { | |
| 180 case SHELF_ALIGNMENT_BOTTOM: | |
| 181 case SHELF_ALIGNMENT_BOTTOM_LOCKED: | |
| 182 return false; | |
| 183 case SHELF_ALIGNMENT_LEFT: | |
| 184 case SHELF_ALIGNMENT_RIGHT: | |
| 185 return true; | |
| 186 } | |
| 187 } | |
| 188 | |
| 169 //////////////////////////////////////////////////////////////////////////////// | 189 //////////////////////////////////////////////////////////////////////////////// |
| 170 // AppListPresenterDelegate, private: | 190 // AppListPresenterDelegate, private: |
| 171 | 191 |
| 172 void AppListPresenterDelegate::ProcessLocatedEvent(ui::LocatedEvent* event) { | 192 void AppListPresenterDelegate::ProcessLocatedEvent(ui::LocatedEvent* event) { |
| 173 if (!view_ || !is_visible_) | 193 if (!view_ || !is_visible_) |
| 174 return; | 194 return; |
| 175 | 195 |
| 176 // If the event happened on a menu, then the event should not close the app | 196 // If the event happened on a menu, then the event should not close the app |
| 177 // list. | 197 // list. |
| 178 aura::Window* target = static_cast<aura::Window*>(event->target()); | 198 aura::Window* target = static_cast<aura::Window*>(event->target()); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 | 242 |
| 223 void AppListPresenterDelegate::OnKeyboardClosed() {} | 243 void AppListPresenterDelegate::OnKeyboardClosed() {} |
| 224 | 244 |
| 225 //////////////////////////////////////////////////////////////////////////////// | 245 //////////////////////////////////////////////////////////////////////////////// |
| 226 // AppListPresenterDelegate, ShellObserver implementation: | 246 // AppListPresenterDelegate, ShellObserver implementation: |
| 227 void AppListPresenterDelegate::OnOverviewModeStarting() { | 247 void AppListPresenterDelegate::OnOverviewModeStarting() { |
| 228 if (is_visible_) | 248 if (is_visible_) |
| 229 presenter_->Dismiss(); | 249 presenter_->Dismiss(); |
| 230 } | 250 } |
| 231 | 251 |
| 252 void AppListPresenterDelegate::OnMaximizeModeStarted() { | |
| 253 if (!app_list::features::IsFullscreenAppListEnabled()) | |
| 254 return; | |
| 255 | |
| 256 view_->OnMaximizeModeChanged(true); | |
| 257 } | |
| 258 | |
| 259 void AppListPresenterDelegate::OnMaximizeModeEnded() { | |
| 260 if (!app_list::features::IsFullscreenAppListEnabled()) | |
| 261 return; | |
| 262 | |
| 263 view_->OnMaximizeModeChanged(false); | |
| 264 } | |
| 265 | |
| 232 } // namespace ash | 266 } // namespace ash |
| OLD | NEW |