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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 if (!app_list::features::IsFullscreenAppListEnabled()) { | 106 if (!app_list::features::IsFullscreenAppListEnabled()) { |
107 view->MaybeSetAnchorPoint(GetCenterOfDisplayForWindow( | 107 view->MaybeSetAnchorPoint(GetCenterOfDisplayForWindow( |
108 wm_root_window, GetMinimumBoundsHeightForAppList(view))); | 108 wm_root_window, GetMinimumBoundsHeightForAppList(view))); |
109 } | 109 } |
110 keyboard::KeyboardController* keyboard_controller = | 110 keyboard::KeyboardController* keyboard_controller = |
111 keyboard::KeyboardController::GetInstance(); | 111 keyboard::KeyboardController::GetInstance(); |
112 if (keyboard_controller) | 112 if (keyboard_controller) |
113 keyboard_controller->AddObserver(this); | 113 keyboard_controller->AddObserver(this); |
114 Shell::Get()->AddPreTargetHandler(this); | 114 Shell::Get()->AddPreTargetHandler(this); |
115 WmShelf* shelf = WmShelf::ForWindow(wm_root_window); | 115 WmShelf* shelf = WmShelf::ForWindow(root_window); |
116 shelf->AddObserver(this); | 116 shelf->AddObserver(this); |
117 | 117 |
118 // By setting us as DnD recipient, the app list knows that we can | 118 // By setting us as DnD recipient, the app list knows that we can |
119 // handle items. | 119 // handle items. |
120 view->SetDragAndDropHostOfCurrentAppList( | 120 view->SetDragAndDropHostOfCurrentAppList( |
121 shelf->shelf_widget()->GetDragAndDropHostForAppList()); | 121 shelf->shelf_widget()->GetDragAndDropHostForAppList()); |
122 } | 122 } |
123 | 123 |
124 void AppListPresenterDelegate::OnShown(int64_t display_id) { | 124 void AppListPresenterDelegate::OnShown(int64_t display_id) { |
125 is_visible_ = true; | 125 is_visible_ = true; |
126 // Update applist button status when app list visibility is changed. | 126 // Update applist button status when app list visibility is changed. |
127 WmWindow* root_window = | 127 aura::Window* root_window = |
128 ShellPort::Get()->GetRootWindowForDisplayId(display_id); | 128 ShellPort::Get()->GetRootWindowForDisplayId(display_id)->aura_window(); |
129 AppListButton* app_list_button = | 129 AppListButton* app_list_button = |
130 WmShelf::ForWindow(root_window)->shelf_widget()->GetAppListButton(); | 130 WmShelf::ForWindow(root_window)->shelf_widget()->GetAppListButton(); |
131 if (app_list_button) | 131 if (app_list_button) |
132 app_list_button->OnAppListShown(); | 132 app_list_button->OnAppListShown(); |
133 } | 133 } |
134 | 134 |
135 void AppListPresenterDelegate::OnDismissed() { | 135 void AppListPresenterDelegate::OnDismissed() { |
136 DCHECK(is_visible_); | 136 DCHECK(is_visible_); |
137 DCHECK(view_); | 137 DCHECK(view_); |
138 | 138 |
139 is_visible_ = false; | 139 is_visible_ = false; |
140 | 140 |
141 // Update applist button status when app list visibility is changed. | 141 // Update applist button status when app list visibility is changed. |
142 WmWindow* window = WmWindow::Get(view_->GetWidget()->GetNativeWindow()); | 142 WmShelf* shelf = WmShelf::ForWindow(view_->GetWidget()->GetNativeWindow()); |
143 AppListButton* app_list_button = | 143 AppListButton* app_list_button = shelf->shelf_widget()->GetAppListButton(); |
144 WmShelf::ForWindow(window)->shelf_widget()->GetAppListButton(); | |
145 if (app_list_button) | 144 if (app_list_button) |
146 app_list_button->OnAppListDismissed(); | 145 app_list_button->OnAppListDismissed(); |
147 } | 146 } |
148 | 147 |
149 void AppListPresenterDelegate::UpdateBounds() { | 148 void AppListPresenterDelegate::UpdateBounds() { |
150 if (!view_ || !is_visible_) | 149 if (!view_ || !is_visible_) |
151 return; | 150 return; |
152 | 151 |
153 view_->UpdateBounds(); | 152 view_->UpdateBounds(); |
154 view_->MaybeSetAnchorPoint(GetCenterOfDisplayForWindow( | 153 view_->MaybeSetAnchorPoint(GetCenterOfDisplayForWindow( |
155 WmWindow::Get(view_->GetWidget()->GetNativeWindow()), | 154 WmWindow::Get(view_->GetWidget()->GetNativeWindow()), |
156 GetMinimumBoundsHeightForAppList(view_))); | 155 GetMinimumBoundsHeightForAppList(view_))); |
157 } | 156 } |
158 | 157 |
159 gfx::Vector2d AppListPresenterDelegate::GetVisibilityAnimationOffset( | 158 gfx::Vector2d AppListPresenterDelegate::GetVisibilityAnimationOffset( |
160 aura::Window* root_window) { | 159 aura::Window* root_window) { |
161 DCHECK(Shell::HasInstance()); | 160 DCHECK(Shell::HasInstance()); |
162 | 161 |
163 // 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 |
164 // UI layout when AppListView visibility changes. | 163 // UI layout when AppListView visibility changes. |
165 WmShelf* shelf = WmShelf::ForWindow(WmWindow::Get(root_window)); | 164 WmShelf* shelf = WmShelf::ForWindow(root_window); |
166 shelf->UpdateAutoHideState(); | 165 shelf->UpdateAutoHideState(); |
167 | 166 |
168 switch (shelf->alignment()) { | 167 switch (shelf->alignment()) { |
169 case SHELF_ALIGNMENT_BOTTOM: | 168 case SHELF_ALIGNMENT_BOTTOM: |
170 case SHELF_ALIGNMENT_BOTTOM_LOCKED: | 169 case SHELF_ALIGNMENT_BOTTOM_LOCKED: |
171 return gfx::Vector2d(0, kAnimationOffset); | 170 return gfx::Vector2d(0, kAnimationOffset); |
172 case SHELF_ALIGNMENT_LEFT: | 171 case SHELF_ALIGNMENT_LEFT: |
173 return gfx::Vector2d(-kAnimationOffset, 0); | 172 return gfx::Vector2d(-kAnimationOffset, 0); |
174 case SHELF_ALIGNMENT_RIGHT: | 173 case SHELF_ALIGNMENT_RIGHT: |
175 return gfx::Vector2d(kAnimationOffset, 0); | 174 return gfx::Vector2d(kAnimationOffset, 0); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 } | 241 } |
243 | 242 |
244 //////////////////////////////////////////////////////////////////////////////// | 243 //////////////////////////////////////////////////////////////////////////////// |
245 // AppListPresenterDelegate, WmShelfObserver implementation: | 244 // AppListPresenterDelegate, WmShelfObserver implementation: |
246 | 245 |
247 void AppListPresenterDelegate::OnShelfIconPositionsChanged() { | 246 void AppListPresenterDelegate::OnShelfIconPositionsChanged() { |
248 UpdateBounds(); | 247 UpdateBounds(); |
249 } | 248 } |
250 | 249 |
251 } // namespace ash | 250 } // namespace ash |
OLD | NEW |