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

Side by Side Diff: ash/wm/app_list_controller.cc

Issue 250423004: ChromeOS: Avoid overlapping app list with virtual keyboard. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix when overscroll is enabled (added KeyboardControllerObserver). Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « ash/wm/app_list_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/wm/app_list_controller.h" 5 #include "ash/wm/app_list_controller.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/screen_util.h" 9 #include "ash/screen_util.h"
10 #include "ash/shelf/shelf.h" 10 #include "ash/shelf/shelf.h"
11 #include "ash/shelf/shelf_layout_manager.h" 11 #include "ash/shelf/shelf_layout_manager.h"
12 #include "ash/shell.h" 12 #include "ash/shell.h"
13 #include "ash/shell_delegate.h" 13 #include "ash/shell_delegate.h"
14 #include "ash/shell_window_ids.h" 14 #include "ash/shell_window_ids.h"
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "ui/app_list/app_list_constants.h" 16 #include "ui/app_list/app_list_constants.h"
17 #include "ui/app_list/app_list_switches.h" 17 #include "ui/app_list/app_list_switches.h"
18 #include "ui/app_list/pagination_model.h" 18 #include "ui/app_list/pagination_model.h"
19 #include "ui/app_list/views/app_list_view.h" 19 #include "ui/app_list/views/app_list_view.h"
20 #include "ui/aura/client/focus_client.h" 20 #include "ui/aura/client/focus_client.h"
21 #include "ui/aura/window.h" 21 #include "ui/aura/window.h"
22 #include "ui/aura/window_event_dispatcher.h" 22 #include "ui/aura/window_event_dispatcher.h"
23 #include "ui/compositor/layer.h" 23 #include "ui/compositor/layer.h"
24 #include "ui/compositor/scoped_layer_animation_settings.h" 24 #include "ui/compositor/scoped_layer_animation_settings.h"
25 #include "ui/events/event.h" 25 #include "ui/events/event.h"
26 #include "ui/gfx/transform_util.h" 26 #include "ui/gfx/transform_util.h"
27 #include "ui/keyboard/keyboard_controller.h"
27 #include "ui/views/widget/widget.h" 28 #include "ui/views/widget/widget.h"
28 29
29 namespace ash { 30 namespace ash {
30 namespace { 31 namespace {
31 32
32 // Duration for show/hide animation in milliseconds. 33 // Duration for show/hide animation in milliseconds.
33 const int kAnimationDurationMs = 200; 34 const int kAnimationDurationMs = 200;
34 35
35 // Offset in pixels to animation away/towards the shelf. 36 // Offset in pixels to animation away/towards the shelf.
36 const int kAnimationOffset = 8; 37 const int kAnimationOffset = 8;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 0, std::max(kMinimalAnchorPositionOffset - anchor.y(), 0)); 107 0, std::max(kMinimalAnchorPositionOffset - anchor.y(), 0));
107 case SHELF_ALIGNMENT_RIGHT: 108 case SHELF_ALIGNMENT_RIGHT:
108 return gfx::Vector2d( 109 return gfx::Vector2d(
109 0, std::max(kMinimalAnchorPositionOffset - anchor.y(), 0)); 110 0, std::max(kMinimalAnchorPositionOffset - anchor.y(), 0));
110 default: 111 default:
111 NOTREACHED(); 112 NOTREACHED();
112 return gfx::Vector2d(); 113 return gfx::Vector2d();
113 } 114 }
114 } 115 }
115 116
116 // Gets the point at the center of the screen. 117 // Gets the point at the center of the screen, excluding the virtual keyboard.
117 gfx::Point GetScreenCenter() { 118 gfx::Point GetScreenCenter() {
118 return Shell::GetScreen()->GetPrimaryDisplay().bounds().CenterPoint(); 119 gfx::Rect bounds = Shell::GetScreen()->GetPrimaryDisplay().bounds();
oshima 2014/04/30 23:44:28 This always returns the center of primary screen,
Matt Giuca 2014/05/01 05:00:32 Ah, thanks for bringing this to my attention. This
120
121 // If the virtual keyboard is active, subtract it from the display bounds, so
122 // that the app list is centered in the non-keyboard area of the display.
123 // (Note that work_area excludes the keyboard, but it doesn't get updated
124 // until after this function is called.)
125 keyboard::KeyboardController* keyboard_controller =
126 keyboard::KeyboardController::GetInstance();
127 if (keyboard_controller && keyboard_controller->keyboard_visible())
128 bounds.Subtract(keyboard_controller->current_keyboard_bounds());
129
130 return bounds.CenterPoint();
119 } 131 }
120 132
121 } // namespace 133 } // namespace
122 134
123 //////////////////////////////////////////////////////////////////////////////// 135 ////////////////////////////////////////////////////////////////////////////////
124 // AppListController, public: 136 // AppListController, public:
125 137
126 AppListController::AppListController() 138 AppListController::AppListController()
127 : pagination_model_(new app_list::PaginationModel), 139 : pagination_model_(new app_list::PaginationModel),
128 is_visible_(false), 140 is_visible_(false),
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 view_->SetDragAndDropHostOfCurrentAppList(drag_and_drop_host); 238 view_->SetDragAndDropHostOfCurrentAppList(drag_and_drop_host);
227 } 239 }
228 240
229 void AppListController::SetView(app_list::AppListView* view) { 241 void AppListController::SetView(app_list::AppListView* view) {
230 DCHECK(view_ == NULL); 242 DCHECK(view_ == NULL);
231 DCHECK(is_visible_); 243 DCHECK(is_visible_);
232 244
233 view_ = view; 245 view_ = view;
234 views::Widget* widget = view_->GetWidget(); 246 views::Widget* widget = view_->GetWidget();
235 widget->AddObserver(this); 247 widget->AddObserver(this);
248 keyboard::KeyboardController::GetInstance()->AddObserver(this);
oshima 2014/04/30 23:44:28 don't you have to remove the observer later?
Matt Giuca 2014/05/01 05:00:32 Done.
236 Shell::GetInstance()->AddPreTargetHandler(this); 249 Shell::GetInstance()->AddPreTargetHandler(this);
237 Shelf::ForWindow(widget->GetNativeWindow())->AddIconObserver(this); 250 Shelf::ForWindow(widget->GetNativeWindow())->AddIconObserver(this);
238 widget->GetNativeView()->GetRootWindow()->AddObserver(this); 251 widget->GetNativeView()->GetRootWindow()->AddObserver(this);
239 aura::client::GetFocusClient(widget->GetNativeView())->AddObserver(this); 252 aura::client::GetFocusClient(widget->GetNativeView())->AddObserver(this);
240 253
241 view_->ShowWhenReady(); 254 view_->ShowWhenReady();
242 } 255 }
243 256
244 void AppListController::ResetView() { 257 void AppListController::ResetView() {
245 if (!view_) 258 if (!view_)
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 // AppListController, views::WidgetObserver implementation: 383 // AppListController, views::WidgetObserver implementation:
371 384
372 void AppListController::OnWidgetDestroying(views::Widget* widget) { 385 void AppListController::OnWidgetDestroying(views::Widget* widget) {
373 DCHECK(view_->GetWidget() == widget); 386 DCHECK(view_->GetWidget() == widget);
374 if (is_visible_) 387 if (is_visible_)
375 SetVisible(false, widget->GetNativeView()); 388 SetVisible(false, widget->GetNativeView());
376 ResetView(); 389 ResetView();
377 } 390 }
378 391
379 //////////////////////////////////////////////////////////////////////////////// 392 ////////////////////////////////////////////////////////////////////////////////
393 // AppListController, keyboard::KeyboardControllerObserver implementation:
394
395 void AppListController::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) {
396 UpdateBounds();
397 }
398
399 ////////////////////////////////////////////////////////////////////////////////
380 // AppListController, ShellObserver implementation: 400 // AppListController, ShellObserver implementation:
381 void AppListController::OnShelfAlignmentChanged(aura::Window* root_window) { 401 void AppListController::OnShelfAlignmentChanged(aura::Window* root_window) {
382 if (view_) 402 if (view_)
383 view_->SetBubbleArrow(GetBubbleArrow(view_->GetWidget()->GetNativeView())); 403 view_->SetBubbleArrow(GetBubbleArrow(view_->GetWidget()->GetNativeView()));
384 } 404 }
385 405
386 //////////////////////////////////////////////////////////////////////////////// 406 ////////////////////////////////////////////////////////////////////////////////
387 // AppListController, ShelfIconObserver implementation: 407 // AppListController, ShelfIconObserver implementation:
388 408
389 void AppListController::OnShelfIconPositionsChanged() { 409 void AppListController::OnShelfIconPositionsChanged() {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 } else if (should_snap_back_) { 454 } else if (should_snap_back_) {
435 should_snap_back_ = false; 455 should_snap_back_ = false;
436 ui::ScopedLayerAnimationSettings animation(widget_animator); 456 ui::ScopedLayerAnimationSettings animation(widget_animator);
437 animation.SetTransitionDuration(base::TimeDelta::FromMilliseconds( 457 animation.SetTransitionDuration(base::TimeDelta::FromMilliseconds(
438 app_list::kOverscrollPageTransitionDurationMs)); 458 app_list::kOverscrollPageTransitionDurationMs));
439 widget->SetBounds(view_bounds_); 459 widget->SetBounds(view_bounds_);
440 } 460 }
441 } 461 }
442 462
443 } // namespace ash 463 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/app_list_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698