diff options
author | mgiuca@chromium.org <mgiuca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-07 16:38:42 +0000 |
---|---|---|
committer | mgiuca@chromium.org <mgiuca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-07 16:38:42 +0000 |
commit | 958898df48a2e7f25ca6d1784d1b586a7141c082 (patch) | |
tree | 769950d3b5f81738de085cec98ca428546bb823f /ash | |
parent | 9f6988d9fa4baa7f1bab3396304a0417e3b3ba5a (diff) | |
download | chromium_src-958898df48a2e7f25ca6d1784d1b586a7141c082.zip chromium_src-958898df48a2e7f25ca6d1784d1b586a7141c082.tar.gz chromium_src-958898df48a2e7f25ca6d1784d1b586a7141c082.tar.bz2 |
Centered app list appears on the display of the triggering button.
Previously, the centered app list (with --enable-centered-app-list)
always appeared on the primary display. Now, if launched by clicking the
app list button, it is on that button's display. If launched via the
keyboard, it is on the active display.
The centered app list now behaves the same as the normal app list in
this regard.
BUG=368974
TEST=On multi-monitor setup, with --enable-centered-app-list, clicking
the app launcher button should open the app launcher on the same display
where you clicked the button. (Note: Ctrl+Shift+D to simulate two
monitors on the ChromeOS simulator.)
TEST=On multi-monitor setup, with --enable-centered-app-list, pressing
the search key should always open the app launcher on the display that
currently has focus.
Review URL: https://codereview.chromium.org/260883003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@268820 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/wm/app_list_controller.cc | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/ash/wm/app_list_controller.cc b/ash/wm/app_list_controller.cc index 0953db8..4f4cc93 100644 --- a/ash/wm/app_list_controller.cc +++ b/ash/wm/app_list_controller.cc @@ -114,9 +114,11 @@ gfx::Vector2d GetAnchorPositionOffsetToShelf( } } -// Gets the point at the center of the screen, excluding the virtual keyboard. -gfx::Point GetScreenCenter() { - gfx::Rect bounds = Shell::GetScreen()->GetPrimaryDisplay().bounds(); +// Gets the point at the center of the display that a particular view is on. +// This calculation excludes the virtual keyboard area. +gfx::Point GetCenterOfDisplayForView(const views::View* view) { + gfx::Rect bounds = Shell::GetScreen()->GetDisplayNearestWindow( + view->GetWidget()->GetNativeView()).bounds(); // 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. @@ -183,18 +185,21 @@ void AppListController::SetVisible(bool visible, aura::Window* window) { aura::Window* root_window = window->GetRootWindow(); aura::Window* container = GetRootWindowController(root_window)-> GetContainer(kShellWindowId_AppListContainer); + views::View* applist_button = + Shelf::ForWindow(container)->GetAppListButtonView(); is_centered_ = view->ShouldCenterWindow(); if (is_centered_) { - // The experimental app list is centered over the primary display. + // The experimental app list is centered over the display of the app list + // button that was pressed (if triggered via keyboard, this is the display + // with the currently focused window). view->InitAsBubbleAtFixedLocation( NULL, pagination_model_.get(), - GetScreenCenter(), + GetCenterOfDisplayForView(applist_button), views::BubbleBorder::FLOAT, true /* border_accepts_events */); } else { - gfx::Rect applist_button_bounds = Shelf::ForWindow(container)-> - GetAppListButtonView()->GetBoundsInScreen(); + gfx::Rect applist_button_bounds = applist_button->GetBoundsInScreen(); // We need the location of the button within the local screen. applist_button_bounds = ScreenUtil::ConvertRectFromScreen( root_window, @@ -335,7 +340,7 @@ void AppListController::UpdateBounds() { view_->UpdateBounds(); if (is_centered_) - view_->SetAnchorPoint(GetScreenCenter()); + view_->SetAnchorPoint(GetCenterOfDisplayForView(view_)); } //////////////////////////////////////////////////////////////////////////////// |