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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // UI layout when AppListView visibility changes. | 92 // UI layout when AppListView visibility changes. |
93 ash::Shell::GetPrimaryRootWindowController() | 93 ash::Shell::GetPrimaryRootWindowController() |
94 ->GetShelfLayoutManager() | 94 ->GetShelfLayoutManager() |
95 ->UpdateAutoHideState(); | 95 ->UpdateAutoHideState(); |
96 view_ = view; | 96 view_ = view; |
97 WmWindow* wm_root_window = | 97 WmWindow* wm_root_window = |
98 ShellPort::Get()->GetRootWindowForDisplayId(display_id); | 98 ShellPort::Get()->GetRootWindowForDisplayId(display_id); |
99 aura::Window* root_window = wm_root_window->aura_window(); | 99 aura::Window* root_window = wm_root_window->aura_window(); |
100 aura::Window* container = GetRootWindowController(root_window) | 100 aura::Window* container = GetRootWindowController(root_window) |
101 ->GetContainer(kShellWindowId_AppListContainer); | 101 ->GetContainer(kShellWindowId_AppListContainer); |
102 view->InitAsBubble(container, current_apps_page); | |
103 // The app list is centered over the display. | |
104 view->SetAnchorPoint(GetCenterOfDisplayForWindow( | |
105 wm_root_window, GetMinimumBoundsHeightForAppList(view))); | |
106 | 102 |
| 103 view->Initialize(container, current_apps_page); |
| 104 |
| 105 if (!app_list::switches::IsFullscreenAppListEnabled()) { |
| 106 view->MaybeSetAnchorPoint(GetCenterOfDisplayForWindow( |
| 107 wm_root_window, GetMinimumBoundsHeightForAppList(view))); |
| 108 } |
107 keyboard::KeyboardController* keyboard_controller = | 109 keyboard::KeyboardController* keyboard_controller = |
108 keyboard::KeyboardController::GetInstance(); | 110 keyboard::KeyboardController::GetInstance(); |
109 if (keyboard_controller) | 111 if (keyboard_controller) |
110 keyboard_controller->AddObserver(this); | 112 keyboard_controller->AddObserver(this); |
111 Shell::Get()->AddPreTargetHandler(this); | 113 Shell::Get()->AddPreTargetHandler(this); |
112 WmShelf* shelf = WmShelf::ForWindow(wm_root_window); | 114 WmShelf* shelf = WmShelf::ForWindow(wm_root_window); |
113 shelf->AddObserver(this); | 115 shelf->AddObserver(this); |
114 | 116 |
115 // 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 |
116 // handle items. | 118 // handle items. |
(...skipping 24 matching lines...) Expand all Loading... |
141 WmShelf::ForWindow(window)->shelf_widget()->GetAppListButton(); | 143 WmShelf::ForWindow(window)->shelf_widget()->GetAppListButton(); |
142 if (app_list_button) | 144 if (app_list_button) |
143 app_list_button->OnAppListDismissed(); | 145 app_list_button->OnAppListDismissed(); |
144 } | 146 } |
145 | 147 |
146 void AppListPresenterDelegate::UpdateBounds() { | 148 void AppListPresenterDelegate::UpdateBounds() { |
147 if (!view_ || !is_visible_) | 149 if (!view_ || !is_visible_) |
148 return; | 150 return; |
149 | 151 |
150 view_->UpdateBounds(); | 152 view_->UpdateBounds(); |
151 view_->SetAnchorPoint(GetCenterOfDisplayForWindow( | 153 view_->MaybeSetAnchorPoint(GetCenterOfDisplayForWindow( |
152 WmWindow::Get(view_->GetWidget()->GetNativeWindow()), | 154 WmWindow::Get(view_->GetWidget()->GetNativeWindow()), |
153 GetMinimumBoundsHeightForAppList(view_))); | 155 GetMinimumBoundsHeightForAppList(view_))); |
154 } | 156 } |
155 | 157 |
156 gfx::Vector2d AppListPresenterDelegate::GetVisibilityAnimationOffset( | 158 gfx::Vector2d AppListPresenterDelegate::GetVisibilityAnimationOffset( |
157 aura::Window* root_window) { | 159 aura::Window* root_window) { |
158 DCHECK(Shell::HasInstance()); | 160 DCHECK(Shell::HasInstance()); |
159 | 161 |
160 // App list needs to know the new shelf layout in order to calculate its | 162 // App list needs to know the new shelf layout in order to calculate its |
161 // UI layout when AppListView visibility changes. | 163 // UI layout when AppListView visibility changes. |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 } | 241 } |
240 | 242 |
241 //////////////////////////////////////////////////////////////////////////////// | 243 //////////////////////////////////////////////////////////////////////////////// |
242 // AppListPresenterDelegate, WmShelfObserver implementation: | 244 // AppListPresenterDelegate, WmShelfObserver implementation: |
243 | 245 |
244 void AppListPresenterDelegate::OnShelfIconPositionsChanged() { | 246 void AppListPresenterDelegate::OnShelfIconPositionsChanged() { |
245 UpdateBounds(); | 247 UpdateBounds(); |
246 } | 248 } |
247 | 249 |
248 } // namespace ash | 250 } // namespace ash |
OLD | NEW |