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

Unified 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, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/wm/app_list_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_)
« 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