Chromium Code Reviews| Index: ash/wm/app_list_controller.cc |
| diff --git a/ash/wm/app_list_controller.cc b/ash/wm/app_list_controller.cc |
| index 4f24ed46dce65b68b99a331fc15f442a050d0c9b..561b852fe46f5b25a7f24f7f84451f007e7aa76b 100644 |
| --- a/ash/wm/app_list_controller.cc |
| +++ b/ash/wm/app_list_controller.cc |
| @@ -24,6 +24,7 @@ |
| #include "ui/compositor/scoped_layer_animation_settings.h" |
| #include "ui/events/event.h" |
| #include "ui/gfx/transform_util.h" |
| +#include "ui/keyboard/keyboard_controller.h" |
| #include "ui/views/widget/widget.h" |
| namespace ash { |
| @@ -113,9 +114,20 @@ gfx::Vector2d GetAnchorPositionOffsetToShelf( |
| } |
| } |
| -// Gets the point at the center of the screen. |
| +// Gets the point at the center of the screen, excluding the virtual keyboard. |
| gfx::Point GetScreenCenter() { |
| - return Shell::GetScreen()->GetPrimaryDisplay().bounds().CenterPoint(); |
| + 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
|
| + |
| + // If the virtual keyboard is active, subtract it from the display bounds, so |
| + // that the app list is centered in the non-keyboard area of the display. |
| + // (Note that work_area excludes the keyboard, but it doesn't get updated |
| + // until after this function is called.) |
| + keyboard::KeyboardController* keyboard_controller = |
| + keyboard::KeyboardController::GetInstance(); |
| + if (keyboard_controller && keyboard_controller->keyboard_visible()) |
| + bounds.Subtract(keyboard_controller->current_keyboard_bounds()); |
| + |
| + return bounds.CenterPoint(); |
| } |
| } // namespace |
| @@ -233,6 +245,7 @@ void AppListController::SetView(app_list::AppListView* view) { |
| view_ = view; |
| views::Widget* widget = view_->GetWidget(); |
| widget->AddObserver(this); |
| + 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.
|
| Shell::GetInstance()->AddPreTargetHandler(this); |
| Shelf::ForWindow(widget->GetNativeWindow())->AddIconObserver(this); |
| widget->GetNativeView()->GetRootWindow()->AddObserver(this); |
| @@ -377,6 +390,13 @@ void AppListController::OnWidgetDestroying(views::Widget* widget) { |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| +// AppListController, keyboard::KeyboardControllerObserver implementation: |
| + |
| +void AppListController::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) { |
| + UpdateBounds(); |
| +} |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| // AppListController, ShellObserver implementation: |
| void AppListController::OnShelfAlignmentChanged(aura::Window* root_window) { |
| if (view_) |