Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: ash/app_list/app_list_presenter_delegate.cc

Issue 2908333003: [mus+ash] Removes WmWindow from ash (app_list, frame, metrics, session, system, wallpaper) (Closed)
Patch Set: [mus ash] Removes WmWindow from ash (rebase, nits and cleanup of use of ResizeHandleWindowTargeter) Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.h"
14 #include "ash/shelf/shelf_layout_manager.h" 14 #include "ash/shelf/shelf_layout_manager.h"
15 #include "ash/shelf/shelf_widget.h" 15 #include "ash/shelf/shelf_widget.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"
20 #include "base/command_line.h" 19 #include "base/command_line.h"
21 #include "ui/app_list/app_list_constants.h" 20 #include "ui/app_list/app_list_constants.h"
22 #include "ui/app_list/app_list_features.h" 21 #include "ui/app_list/app_list_features.h"
23 #include "ui/app_list/app_list_switches.h" 22 #include "ui/app_list/app_list_switches.h"
24 #include "ui/app_list/presenter/app_list_presenter_impl.h" 23 #include "ui/app_list/presenter/app_list_presenter_impl.h"
25 #include "ui/app_list/presenter/app_list_view_delegate_factory.h" 24 #include "ui/app_list/presenter/app_list_view_delegate_factory.h"
26 #include "ui/app_list/views/app_list_view.h" 25 #include "ui/app_list/views/app_list_view.h"
27 #include "ui/aura/window.h" 26 #include "ui/aura/window.h"
28 #include "ui/events/event.h" 27 #include "ui/events/event.h"
29 #include "ui/keyboard/keyboard_controller.h" 28 #include "ui/keyboard/keyboard_controller.h"
30 #include "ui/views/widget/widget.h" 29 #include "ui/views/widget/widget.h"
30 #include "ui/wm/core/coordinate_conversion.h"
31 31
32 namespace ash { 32 namespace ash {
33 namespace { 33 namespace {
34 34
35 // Gets the point at the center of the display containing the given |window|. 35 // Gets the point at the center of the display containing the given |window|.
36 // This calculation excludes the virtual keyboard area. If the height of the 36 // This calculation excludes the virtual keyboard area. If the height of the
37 // display area is less than |minimum_height|, its bottom will be extended to 37 // display area is less than |minimum_height|, its bottom will be extended to
38 // that height (so that the app list never starts above the top of the screen). 38 // that height (so that the app list never starts above the top of the screen).
39 gfx::Point GetCenterOfDisplayForWindow(WmWindow* window, int minimum_height) { 39 gfx::Point GetCenterOfDisplayForWindow(aura::Window* window,
40 int minimum_height) {
40 DCHECK(window); 41 DCHECK(window);
41 gfx::Rect bounds = 42 gfx::Rect bounds = ScreenUtil::GetDisplayBoundsWithShelf(window);
42 ScreenUtil::GetDisplayBoundsWithShelf(window->aura_window()); 43 ::wm::ConvertRectToScreen(window->GetRootWindow(), &bounds);
43 bounds = window->GetRootWindow()->ConvertRectToScreen(bounds);
44 44
45 // If the virtual keyboard is active, subtract it from the display bounds, so 45 // If the virtual keyboard is active, subtract it from the display bounds, so
46 // that the app list is centered in the non-keyboard area of the display. 46 // that the app list is centered in the non-keyboard area of the display.
47 // (Note that work_area excludes the keyboard, but it doesn't get updated 47 // (Note that work_area excludes the keyboard, but it doesn't get updated
48 // until after this function is called.) 48 // until after this function is called.)
49 keyboard::KeyboardController* keyboard_controller = 49 keyboard::KeyboardController* keyboard_controller =
50 keyboard::KeyboardController::GetInstance(); 50 keyboard::KeyboardController::GetInstance();
51 if (keyboard_controller && keyboard_controller->keyboard_visible()) 51 if (keyboard_controller && keyboard_controller->keyboard_visible())
52 bounds.Subtract(keyboard_controller->current_keyboard_bounds()); 52 bounds.Subtract(keyboard_controller->current_keyboard_bounds());
53 53
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 = GetRootWindowController(root_window) 98 aura::Window* container = GetRootWindowController(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);
102 102
103 if (!app_list::features::IsFullscreenAppListEnabled()) { 103 if (!app_list::features::IsFullscreenAppListEnabled()) {
104 view->MaybeSetAnchorPoint(GetCenterOfDisplayForWindow( 104 view->MaybeSetAnchorPoint(GetCenterOfDisplayForWindow(
105 WmWindow::Get(root_window), GetMinimumBoundsHeightForAppList(view))); 105 root_window, GetMinimumBoundsHeightForAppList(view)));
106 } 106 }
107 keyboard::KeyboardController* keyboard_controller = 107 keyboard::KeyboardController* keyboard_controller =
108 keyboard::KeyboardController::GetInstance(); 108 keyboard::KeyboardController::GetInstance();
109 if (keyboard_controller) 109 if (keyboard_controller)
110 keyboard_controller->AddObserver(this); 110 keyboard_controller->AddObserver(this);
111 Shell::Get()->AddPreTargetHandler(this); 111 Shell::Get()->AddPreTargetHandler(this);
112 112
113 // By setting us as DnD recipient, the app list knows that we can 113 // By setting us as DnD recipient, the app list knows that we can
114 // handle items. 114 // handle items.
115 Shelf* shelf = Shelf::ForWindow(root_window); 115 Shelf* shelf = Shelf::ForWindow(root_window);
(...skipping 23 matching lines...) Expand all
139 AppListButton* app_list_button = shelf->shelf_widget()->GetAppListButton(); 139 AppListButton* app_list_button = shelf->shelf_widget()->GetAppListButton();
140 if (app_list_button) 140 if (app_list_button)
141 app_list_button->OnAppListDismissed(); 141 app_list_button->OnAppListDismissed();
142 } 142 }
143 143
144 void AppListPresenterDelegate::UpdateBounds() { 144 void AppListPresenterDelegate::UpdateBounds() {
145 if (!view_ || !is_visible_) 145 if (!view_ || !is_visible_)
146 return; 146 return;
147 147
148 view_->UpdateBounds(); 148 view_->UpdateBounds();
149 view_->MaybeSetAnchorPoint(GetCenterOfDisplayForWindow( 149 view_->MaybeSetAnchorPoint(
150 WmWindow::Get(view_->GetWidget()->GetNativeWindow()), 150 GetCenterOfDisplayForWindow(view_->GetWidget()->GetNativeWindow(),
151 GetMinimumBoundsHeightForAppList(view_))); 151 GetMinimumBoundsHeightForAppList(view_)));
152 } 152 }
153 153
154 gfx::Vector2d AppListPresenterDelegate::GetVisibilityAnimationOffset( 154 gfx::Vector2d AppListPresenterDelegate::GetVisibilityAnimationOffset(
155 aura::Window* root_window) { 155 aura::Window* root_window) {
156 DCHECK(Shell::HasInstance()); 156 DCHECK(Shell::HasInstance());
157 157
158 // App list needs to know the new shelf layout in order to calculate its 158 // App list needs to know the new shelf layout in order to calculate its
159 // UI layout when AppListView visibility changes. 159 // UI layout when AppListView visibility changes.
160 Shelf* shelf = Shelf::ForWindow(root_window); 160 Shelf* shelf = Shelf::ForWindow(root_window);
161 shelf->UpdateAutoHideState(); 161 shelf->UpdateAutoHideState();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 void AppListPresenterDelegate::OnKeyboardClosed() {} 230 void AppListPresenterDelegate::OnKeyboardClosed() {}
231 231
232 //////////////////////////////////////////////////////////////////////////////// 232 ////////////////////////////////////////////////////////////////////////////////
233 // AppListPresenterDelegate, ShellObserver implementation: 233 // AppListPresenterDelegate, ShellObserver implementation:
234 void AppListPresenterDelegate::OnOverviewModeStarting() { 234 void AppListPresenterDelegate::OnOverviewModeStarting() {
235 if (is_visible_) 235 if (is_visible_)
236 presenter_->Dismiss(); 236 presenter_->Dismiss();
237 } 237 }
238 238
239 } // namespace ash 239 } // namespace ash
OLDNEW
« no previous file with comments | « ash/app_list/app_list_delegate_impl.cc ('k') | ash/app_list/app_list_presenter_delegate_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698