diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-23 00:38:33 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-23 00:38:33 +0000 |
commit | 431552ca5af1f9d2cb09994e1d75e1d7f30cf002 (patch) | |
tree | 545584aa7c60c78021fa18e38c04c20fb248c31d /ash/wm/app_list_controller.cc | |
parent | 1cca163c30823ea0531b9a84ddeb5a136c0927ad (diff) | |
download | chromium_src-431552ca5af1f9d2cb09994e1d75e1d7f30cf002.zip chromium_src-431552ca5af1f9d2cb09994e1d75e1d7f30cf002.tar.gz chromium_src-431552ca5af1f9d2cb09994e1d75e1d7f30cf002.tar.bz2 |
Context menu for multiple launchers
- move the code to create/open context menu from launcher to
root window controller.
- updated methods that access shelf/launcher state to take root window so that menu can specify on which display it is working on.
BUG=145978, 155776
TEST=none
Review URL: https://chromiumcodereview.appspot.com/11198078
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163459 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/wm/app_list_controller.cc')
-rw-r--r-- | ash/wm/app_list_controller.cc | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/ash/wm/app_list_controller.cc b/ash/wm/app_list_controller.cc index f384c44..437ba58 100644 --- a/ash/wm/app_list_controller.cc +++ b/ash/wm/app_list_controller.cc @@ -44,9 +44,11 @@ ui::Layer* GetLayer(views::Widget* widget) { } // Gets arrow location based on shelf alignment. -views::BubbleBorder::ArrowLocation GetBubbleArrowLocation() { +views::BubbleBorder::ArrowLocation GetBubbleArrowLocation( + aura::Window* window) { DCHECK(Shell::HasInstance()); - ShelfAlignment shelf_alignment = Shell::GetInstance()->GetShelfAlignment(); + ShelfAlignment shelf_alignment = Shell::GetInstance()->GetShelfAlignment( + window->GetRootWindow()); switch (shelf_alignment) { case ash::SHELF_ALIGNMENT_BOTTOM: return views::BubbleBorder::BOTTOM_CENTER; @@ -61,9 +63,10 @@ views::BubbleBorder::ArrowLocation GetBubbleArrowLocation() { } // Offset given |rect| towards shelf. -gfx::Rect OffsetTowardsShelf(const gfx::Rect& rect) { +gfx::Rect OffsetTowardsShelf(const gfx::Rect& rect, views::Widget* widget) { DCHECK(Shell::HasInstance()); - ShelfAlignment shelf_alignment = Shell::GetInstance()->GetShelfAlignment(); + ShelfAlignment shelf_alignment = Shell::GetInstance()->GetShelfAlignment( + widget->GetNativeView()->GetRootWindow()); gfx::Rect offseted(rect); switch (shelf_alignment) { case SHELF_ALIGNMENT_BOTTOM: @@ -124,13 +127,16 @@ void AppListController::SetVisible(bool visible) { // will be released with AppListView on close. app_list::AppListView* view = new app_list::AppListView( Shell::GetInstance()->delegate()->CreateAppListViewDelegate()); + // TODO(oshima): support multiple displays. + aura::Window* container = Shell::GetPrimaryRootWindowController()-> + GetContainer(kShellWindowId_AppListContainer); view->InitAsBubble( Shell::GetPrimaryRootWindowController()->GetContainer( kShellWindowId_AppListContainer), pagination_model_.get(), Launcher::ForWindow(GetWindow())->GetAppListButtonView(), gfx::Point(), - GetBubbleArrowLocation()); + GetBubbleArrowLocation(container)); SetView(view); } } @@ -191,9 +197,10 @@ void AppListController::ScheduleAnimation() { gfx::Rect target_bounds; if (is_visible_) { target_bounds = widget->GetWindowBoundsInScreen(); - widget->SetBounds(OffsetTowardsShelf(target_bounds)); + widget->SetBounds(OffsetTowardsShelf(target_bounds, widget)); } else { - target_bounds = OffsetTowardsShelf(widget->GetWindowBoundsInScreen()); + target_bounds = OffsetTowardsShelf(widget->GetWindowBoundsInScreen(), + widget); } ui::ScopedLayerAnimationSettings animation(layer->GetAnimator()); @@ -308,8 +315,10 @@ void AppListController::OnWidgetClosing(views::Widget* widget) { //////////////////////////////////////////////////////////////////////////////// // AppListController, ShellObserver implementation: void AppListController::OnShelfAlignmentChanged() { - if (view_) - view_->SetBubbleArrowLocation(GetBubbleArrowLocation()); + if (view_) { + view_->SetBubbleArrowLocation(GetBubbleArrowLocation( + view_->GetWidget()->GetNativeView())); + } } //////////////////////////////////////////////////////////////////////////////// |