summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-23 00:38:33 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-23 00:38:33 +0000
commit431552ca5af1f9d2cb09994e1d75e1d7f30cf002 (patch)
tree545584aa7c60c78021fa18e38c04c20fb248c31d /ash
parent1cca163c30823ea0531b9a84ddeb5a136c0927ad (diff)
downloadchromium_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')
-rw-r--r--ash/ash.gyp10
-rw-r--r--ash/launcher/launcher_alignment_menu.cc21
-rw-r--r--ash/launcher/launcher_alignment_menu.h8
-rw-r--r--ash/launcher/launcher_context_menu.cc73
-rw-r--r--ash/launcher/launcher_context_menu_unittest.cc54
-rw-r--r--ash/launcher/launcher_delegate.h17
-rw-r--r--ash/launcher/launcher_view.cc13
-rw-r--r--ash/launcher/launcher_view_unittest.cc6
-rw-r--r--ash/root_window_controller.cc38
-rw-r--r--ash/root_window_controller.h14
-rw-r--r--ash/root_window_controller_unittest.cc5
-rw-r--r--ash/screen_ash_unittest.cc3
-rw-r--r--ash/shell.cc46
-rw-r--r--ash/shell.h25
-rw-r--r--ash/shell/context_menu.cc65
-rw-r--r--ash/shell/context_menu.h (renamed from ash/launcher/launcher_context_menu.h)36
-rw-r--r--ash/shell/launcher_delegate_impl.cc8
-rw-r--r--ash/shell/launcher_delegate_impl.h4
-rw-r--r--ash/shell/shell_delegate_impl.cc5
-rw-r--r--ash/shell/shell_delegate_impl.h2
-rw-r--r--ash/shell_delegate.h8
-rw-r--r--ash/shell_unittest.cc36
-rw-r--r--ash/test/test_launcher_delegate.cc7
-rw-r--r--ash/test/test_launcher_delegate.h4
-rw-r--r--ash/test/test_shell_delegate.cc4
-rw-r--r--ash/test/test_shell_delegate.h1
-rw-r--r--ash/wm/app_list_controller.cc27
-rw-r--r--ash/wm/shelf_layout_manager_unittest.cc12
-rw-r--r--ash/wm/workspace/workspace_window_resizer_unittest.cc4
29 files changed, 328 insertions, 228 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index d7e48fc..b6dbee16 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -107,8 +107,6 @@
'launcher/launcher_alignment_menu.h',
'launcher/launcher_button.cc',
'launcher/launcher_button.h',
- 'launcher/launcher_context_menu.cc',
- 'launcher/launcher_context_menu.h',
'launcher/launcher_delegate.h',
'launcher/launcher_icon_observer.h',
'launcher/launcher_model.cc',
@@ -465,6 +463,7 @@
'target_name': 'ash_unittests',
'type': 'executable',
'dependencies': [
+ 'ash_strings.gyp:ash_strings',
'../base/base.gyp:base',
'../base/base.gyp:test_support_base',
'../chrome/chrome_resources.gyp:packed_resources',
@@ -507,7 +506,6 @@
'drag_drop/drag_drop_tracker_unittest.cc',
'extended_desktop_unittest.cc',
'focus_cycler_unittest.cc',
- 'launcher/launcher_context_menu_unittest.cc',
'launcher/launcher_model_unittest.cc',
'launcher/launcher_navigator_unittest.cc',
'launcher/launcher_tooltip_manager_unittest.cc',
@@ -519,10 +517,13 @@
'shell_unittest.cc',
'shell/app_list.cc',
'shell/bubble.cc',
+ 'shell/context_menu.cc',
+ 'shell/context_menu.h',
'shell/launcher_delegate_impl.cc',
'shell/lock_view.cc',
'shell/panel_window.cc',
'shell/shell_delegate_impl.cc',
+ 'shell/shell_delegate_impl.h',
'shell/toplevel_window.cc',
'shell/widgets.cc',
'shell/window_type_launcher.cc',
@@ -598,6 +599,7 @@
'target_name': 'ash_shell',
'type': 'executable',
'dependencies': [
+ 'ash_strings.gyp:ash_strings',
'../base/base.gyp:base',
'../base/base.gyp:base_i18n',
'../chrome/chrome_resources.gyp:packed_resources',
@@ -627,6 +629,8 @@
'shell/content_client/shell_content_browser_client.h',
'shell/content_client/shell_main_delegate.cc',
'shell/content_client/shell_main_delegate.h',
+ 'shell/context_menu.cc',
+ 'shell/context_menu.h',
'shell/example_factory.h',
'shell/launcher_delegate_impl.cc',
'shell/launcher_delegate_impl.h',
diff --git a/ash/launcher/launcher_alignment_menu.cc b/ash/launcher/launcher_alignment_menu.cc
index 5bdaee4..304c239c 100644
--- a/ash/launcher/launcher_alignment_menu.cc
+++ b/ash/launcher/launcher_alignment_menu.cc
@@ -11,7 +11,11 @@
namespace ash {
-LauncherAlignmentMenu::LauncherAlignmentMenu() : ui::SimpleMenuModel(NULL) {
+LauncherAlignmentMenu::LauncherAlignmentMenu(
+ aura::RootWindow* root)
+ : ui::SimpleMenuModel(NULL),
+ root_window_(root) {
+ DCHECK(root_window_);
int align_group_id = 1;
set_delegate(this);
AddRadioItemWithStringId(MENU_ALIGN_LEFT,
@@ -31,13 +35,13 @@ LauncherAlignmentMenu::~LauncherAlignmentMenu() {
bool LauncherAlignmentMenu::IsCommandIdChecked(int command_id) const {
switch (command_id) {
case MENU_ALIGN_LEFT:
- return ash::Shell::GetInstance()->GetShelfAlignment() ==
+ return Shell::GetInstance()->GetShelfAlignment(root_window_) ==
SHELF_ALIGNMENT_LEFT;
case MENU_ALIGN_BOTTOM:
- return ash::Shell::GetInstance()->GetShelfAlignment() ==
+ return Shell::GetInstance()->GetShelfAlignment(root_window_) ==
SHELF_ALIGNMENT_BOTTOM;
case MENU_ALIGN_RIGHT:
- return ash::Shell::GetInstance()->GetShelfAlignment() ==
+ return Shell::GetInstance()->GetShelfAlignment(root_window_) ==
SHELF_ALIGNMENT_RIGHT;
default:
return false;
@@ -57,13 +61,16 @@ bool LauncherAlignmentMenu::GetAcceleratorForCommandId(
void LauncherAlignmentMenu::ExecuteCommand(int command_id) {
switch (static_cast<MenuItem>(command_id)) {
case MENU_ALIGN_LEFT:
- ash::Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_LEFT);
+ Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_LEFT,
+ root_window_);
break;
case MENU_ALIGN_BOTTOM:
- ash::Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_BOTTOM);
+ Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_BOTTOM,
+ root_window_);
break;
case MENU_ALIGN_RIGHT:
- ash::Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_RIGHT);
+ Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_RIGHT,
+ root_window_);
break;
}
}
diff --git a/ash/launcher/launcher_alignment_menu.h b/ash/launcher/launcher_alignment_menu.h
index 8ba8a96..25311d4 100644
--- a/ash/launcher/launcher_alignment_menu.h
+++ b/ash/launcher/launcher_alignment_menu.h
@@ -9,13 +9,17 @@
#include "base/basictypes.h"
#include "ui/base/models/simple_menu_model.h"
+namespace aura {
+class RootWindow;
+}
+
namespace ash {
// Submenu for choosing the alignment of the launcher.
class ASH_EXPORT LauncherAlignmentMenu : public ui::SimpleMenuModel,
public ui::SimpleMenuModel::Delegate {
public:
- LauncherAlignmentMenu();
+ explicit LauncherAlignmentMenu(aura::RootWindow* root);
virtual ~LauncherAlignmentMenu();
// ui::SimpleMenuModel::Delegate overrides:
@@ -34,6 +38,8 @@ class ASH_EXPORT LauncherAlignmentMenu : public ui::SimpleMenuModel,
MENU_ALIGN_BOTTOM,
};
+ aura::RootWindow* root_window_;
+
DISALLOW_COPY_AND_ASSIGN(LauncherAlignmentMenu);
};
diff --git a/ash/launcher/launcher_context_menu.cc b/ash/launcher/launcher_context_menu.cc
deleted file mode 100644
index f2ea498..0000000
--- a/ash/launcher/launcher_context_menu.cc
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ash/launcher/launcher_context_menu.h"
-
-#include "ash/root_window_controller.h"
-#include "ash/shell.h"
-#include "ash/wm/shelf_types.h"
-#include "grit/ash_strings.h"
-#include "ui/base/l10n/l10n_util.h"
-
-namespace ash {
-
-LauncherContextMenu::LauncherContextMenu() : ui::SimpleMenuModel(NULL) {
- set_delegate(this);
- AddCheckItemWithStringId(MENU_AUTO_HIDE, GetAutoHideResourceStringId());
- AddSubMenuWithStringId(MENU_ALIGNMENT_MENU,
- IDS_AURA_LAUNCHER_CONTEXT_MENU_POSITION,
- &alignment_menu_);
-}
-
-LauncherContextMenu::~LauncherContextMenu() {
-}
-
-// static
-bool LauncherContextMenu::IsAutoHideMenuHideChecked() {
- return ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS ==
- Shell::GetInstance()->GetShelfAutoHideBehavior();
-}
-
-// static
-ShelfAutoHideBehavior LauncherContextMenu::GetToggledAutoHideBehavior() {
- return IsAutoHideMenuHideChecked() ? ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER :
- ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
-}
-
-// static
-int LauncherContextMenu::GetAutoHideResourceStringId() {
- return IDS_AURA_LAUNCHER_CONTEXT_MENU_AUTO_HIDE;
-}
-
-bool LauncherContextMenu::IsCommandIdChecked(int command_id) const {
- switch (command_id) {
- case MENU_AUTO_HIDE:
- return IsAutoHideMenuHideChecked();
- default:
- return false;
- }
-}
-
-bool LauncherContextMenu::IsCommandIdEnabled(int command_id) const {
- return true;
-}
-
-bool LauncherContextMenu::GetAcceleratorForCommandId(
- int command_id,
- ui::Accelerator* accelerator) {
- return false;
-}
-
-void LauncherContextMenu::ExecuteCommand(int command_id) {
- switch (static_cast<MenuItem>(command_id)) {
- case MENU_AUTO_HIDE:
- ash::Shell::GetInstance()->SetShelfAutoHideBehavior(
- GetToggledAutoHideBehavior());
- break;
- case MENU_ALIGNMENT_MENU:
- break;
- }
-}
-
-} // namespace ash
diff --git a/ash/launcher/launcher_context_menu_unittest.cc b/ash/launcher/launcher_context_menu_unittest.cc
deleted file mode 100644
index 0fc9318..0000000
--- a/ash/launcher/launcher_context_menu_unittest.cc
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ash/launcher/launcher_context_menu.h"
-
-#include "ash/shell.h"
-#include "ash/test/ash_test_base.h"
-#include "ash/wm/property_util.h"
-#include "ash/wm/window_util.h"
-#include "ui/aura/client/aura_constants.h"
-#include "ui/aura/window.h"
-#include "ui/base/ui_base_types.h"
-#include "ui/compositor/layer.h"
-
-namespace ash {
-
-typedef test::AshTestBase LauncherContextMenuTest;
-
-// Various assertions around IsAutoHideMenuHideChecked() and
-// ToggleAutoHideMenu().
-TEST_F(LauncherContextMenuTest, ToggleAutoHide) {
- scoped_ptr<aura::Window> window(new aura::Window(NULL));
- window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
- window->SetType(aura::client::WINDOW_TYPE_NORMAL);
- window->Init(ui::LAYER_TEXTURED);
- window->SetParent(NULL);
- window->Show();
- wm::ActivateWindow(window.get());
-
- Shell* shell = Shell::GetInstance();
- shell->SetShelfAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
- EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
- shell->GetShelfAutoHideBehavior());
- EXPECT_TRUE(LauncherContextMenu::IsAutoHideMenuHideChecked());
- shell->SetShelfAutoHideBehavior(
- LauncherContextMenu::GetToggledAutoHideBehavior());
- EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER,
- shell->GetShelfAutoHideBehavior());
-
- window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
- EXPECT_FALSE(LauncherContextMenu::IsAutoHideMenuHideChecked());
- shell->SetShelfAutoHideBehavior(
- LauncherContextMenu::GetToggledAutoHideBehavior());
- EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
- shell->GetShelfAutoHideBehavior());
- EXPECT_TRUE(LauncherContextMenu::IsAutoHideMenuHideChecked());
- shell->SetShelfAutoHideBehavior(
- LauncherContextMenu::GetToggledAutoHideBehavior());
- EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER,
- shell->GetShelfAutoHideBehavior());
-}
-
-} // namespace ash
diff --git a/ash/launcher/launcher_delegate.h b/ash/launcher/launcher_delegate.h
index 95b4485..e3eb140 100644
--- a/ash/launcher/launcher_delegate.h
+++ b/ash/launcher/launcher_delegate.h
@@ -9,6 +9,10 @@
#include "ash/launcher/launcher_types.h"
#include "base/string16.h"
+namespace aura {
+class RootWindow;
+}
+
namespace ui {
class MenuModel;
}
@@ -37,14 +41,11 @@ class ASH_EXPORT LauncherDelegate {
// Returns the title to display for the specified launcher item.
virtual string16 GetTitle(const LauncherItem& item) = 0;
- // Returns the context menumodel for the specified item. Return NULL if there
- // should be no context menu. The caller takes ownership of the returned
- // model.
- virtual ui::MenuModel* CreateContextMenu(const LauncherItem& item) = 0;
-
- // Returns the context menumodel for the launcher. Return NULL if there should
- // be no context menu. The caller takes ownership of the returned model.
- virtual ui::MenuModel* CreateContextMenuForLauncher() = 0;
+ // Returns the context menumodel for the specified item on
+ // |root_window|. Return NULL if there should be no context
+ // menu. The caller takes ownership of the returned model.
+ virtual ui::MenuModel* CreateContextMenu(const LauncherItem& item,
+ aura::RootWindow* root_window) = 0;
// Returns the id of the item associated with the specified window, or 0 if
// there isn't one.
diff --git a/ash/launcher/launcher_view.cc b/ash/launcher/launcher_view.cc
index 64676ec..a3c2fe7 100644
--- a/ash/launcher/launcher_view.cc
+++ b/ash/launcher/launcher_view.cc
@@ -21,6 +21,7 @@
#include "base/memory/scoped_ptr.h"
#include "grit/ash_strings.h"
#include "grit/ash_resources.h"
+#include "ui/aura/window.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/base/resource/resource_bundle.h"
@@ -34,6 +35,7 @@
#include "ui/views/focus/focus_search.h"
#include "ui/views/view_model.h"
#include "ui/views/view_model_utils.h"
+#include "ui/views/widget/widget.h"
using ui::Animation;
using views::View;
@@ -1040,10 +1042,13 @@ void LauncherView::ShowContextMenuForView(views::View* source,
view_index = -1;
}
#if !defined(OS_MACOSX)
- scoped_ptr<ui::MenuModel> menu_model(
- view_index == -1 ?
- delegate_->CreateContextMenuForLauncher() :
- delegate_->CreateContextMenu(model_->items()[view_index]));
+ if (view_index == -1) {
+ Shell::GetInstance()->ShowContextMenu(point);
+ return;
+ }
+ scoped_ptr<ui::MenuModel> menu_model(delegate_->CreateContextMenu(
+ model_->items()[view_index],
+ source->GetWidget()->GetNativeView()->GetRootWindow()));
if (!menu_model.get())
return;
AutoReset<LauncherID> reseter(
diff --git a/ash/launcher/launcher_view_unittest.cc b/ash/launcher/launcher_view_unittest.cc
index 5e1e3c0..fdb062f 100644
--- a/ash/launcher/launcher_view_unittest.cc
+++ b/ash/launcher/launcher_view_unittest.cc
@@ -154,10 +154,8 @@ class MockLauncherDelegate : public ash::LauncherDelegate {
return string16();
}
virtual ui::MenuModel* CreateContextMenu(
- const ash::LauncherItem& item) OVERRIDE {
- return NULL;
- }
- virtual ui::MenuModel* CreateContextMenuForLauncher() OVERRIDE {
+ const ash::LauncherItem& item,
+ aura::RootWindow* root_window) OVERRIDE {
return NULL;
}
virtual ash::LauncherID GetIDByWindow(aura::Window* window) OVERRIDE {
diff --git a/ash/root_window_controller.cc b/ash/root_window_controller.cc
index 9bcdf76..b0d29a0 100644
--- a/ash/root_window_controller.cc
+++ b/ash/root_window_controller.cc
@@ -40,8 +40,13 @@
#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
#include "ui/aura/window_tracker.h"
+#include "ui/base/models/menu_model.h"
#include "ui/gfx/display.h"
#include "ui/gfx/screen.h"
+#include "ui/views/controls/menu/menu_model_adapter.h"
+#include "ui/views/controls/menu/menu_runner.h"
+#include "ui/views/view_model.h"
+#include "ui/views/view_model_utils.h"
namespace ash {
namespace {
@@ -404,6 +409,28 @@ void RootWindowController::MoveWindowsTo(aura::RootWindow* dst) {
}
}
+void RootWindowController::ShowContextMenu(
+ const gfx::Point& location_in_screen) {
+ aura::RootWindow* target = Shell::IsLauncherPerDisplayEnabled() ?
+ root_window() : Shell::GetPrimaryRootWindow();
+ DCHECK(Shell::GetInstance()->delegate());
+ scoped_ptr<ui::MenuModel> menu_model(
+ Shell::GetInstance()->delegate()->CreateContextMenu(target));
+
+ views::MenuModelAdapter menu_model_adapter(menu_model.get());
+ views::MenuRunner menu_runner(menu_model_adapter.CreateMenu());
+ views::Widget* widget =
+ root_window_->GetProperty(kDesktopController)->widget();
+
+ if (menu_runner.RunMenuAt(
+ widget, NULL, gfx::Rect(location_in_screen, gfx::Size()),
+ views::MenuItemView::TOPLEFT, views::MenuRunner::CONTEXT_MENU) ==
+ views::MenuRunner::MENU_DELETED)
+ return;
+
+ Shell::GetInstance()->UpdateShelfVisibility();
+}
+
void RootWindowController::UpdateShelfVisibility() {
shelf_->UpdateVisibilityState();
}
@@ -425,6 +452,17 @@ ShelfAlignment RootWindowController::GetShelfAlignment() {
return shelf_->alignment();
}
+bool RootWindowController::IsShelfAutoHideMenuHideChecked() {
+ return GetShelfAutoHideBehavior() == ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
+}
+
+ShelfAutoHideBehavior
+RootWindowController::GetToggledShelfAutoHideBehavior() {
+ return IsShelfAutoHideMenuHideChecked() ?
+ ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER :
+ ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
+}
+
////////////////////////////////////////////////////////////////////////////////
// RootWindowController, private:
diff --git a/ash/root_window_controller.h b/ash/root_window_controller.h
index 170c0c2..e264b3c 100644
--- a/ash/root_window_controller.h
+++ b/ash/root_window_controller.h
@@ -13,6 +13,10 @@
class SkBitmap;
+namespace gfx {
+class Point;
+}
+
namespace aura {
class EventFilter;
class RootWindow;
@@ -73,6 +77,10 @@ class ASH_EXPORT RootWindowController {
return status_area_widget_;
}
+ // Shows context menu at the |location_in_screen|. This uses
+ // |ShellDelegate::CreateContextMenu| to define the content of the menu.
+ void ShowContextMenu(const gfx::Point& location_in_screen);
+
// Returns the layout-manager for the appropriate modal-container. If the
// window is inside the lockscreen modal container, then the layout manager
// for that is returned. Otherwise the layout manager for the default modal
@@ -135,7 +143,11 @@ class ASH_EXPORT RootWindowController {
bool SetShelfAlignment(ShelfAlignment alignment);
ShelfAlignment GetShelfAlignment();
-private:
+ // Get the shelf's auto hide status.
+ bool IsShelfAutoHideMenuHideChecked();
+ ShelfAutoHideBehavior GetToggledShelfAutoHideBehavior();
+
+ private:
// Creates each of the special window containers that holds windows of various
// types in the shell UI.
void CreateContainersInRootWindow(aura::RootWindow* root_window);
diff --git a/ash/root_window_controller_unittest.cc b/ash/root_window_controller_unittest.cc
index 67adc4a..e7ff230 100644
--- a/ash/root_window_controller_unittest.cc
+++ b/ash/root_window_controller_unittest.cc
@@ -97,8 +97,9 @@ typedef test::AshTestBase RootWindowControllerTest;
TEST_F(RootWindowControllerTest, MoveWindows_Basic) {
UpdateDisplay("600x600,500x500");
Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
- ash::Shell::GetInstance()->SetShelfAutoHideBehavior(
- ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ internal::RootWindowController* controller =
+ Shell::GetPrimaryRootWindowController();
+ controller->SetShelfAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
views::Widget* normal = CreateTestWidget(gfx::Rect(650, 10, 100, 100));
EXPECT_EQ(root_windows[1], normal->GetNativeView()->GetRootWindow());
diff --git a/ash/screen_ash_unittest.cc b/ash/screen_ash_unittest.cc
index 229ae11..0fc71a6 100644
--- a/ash/screen_ash_unittest.cc
+++ b/ash/screen_ash_unittest.cc
@@ -5,6 +5,7 @@
#include "ash/screen_ash.h"
#include "ash/display/display_controller.h"
+#include "ash/root_window_controller.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
#include "ash/wm/window_util.h"
@@ -22,7 +23,7 @@ typedef test::AshTestBase ScreenAshTest;
#if !defined(OS_WIN)
TEST_F(ScreenAshTest, Bounds) {
UpdateDisplay("600x600,500x500");
- Shell::GetInstance()->SetShelfAutoHideBehavior(
+ Shell::GetPrimaryRootWindowController()->SetShelfAutoHideBehavior(
ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
views::Widget* primary =
diff --git a/ash/shell.cc b/ash/shell.cc
index 56a2fea..6d4432f 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -20,7 +20,6 @@
#include "ash/drag_drop/drag_drop_controller.h"
#include "ash/focus_cycler.h"
#include "ash/high_contrast/high_contrast_controller.h"
-#include "ash/launcher/launcher.h"
#include "ash/magnifier/magnification_controller.h"
#include "ash/root_window_controller.h"
#include "ash/screen_ash.h"
@@ -511,16 +510,17 @@ void Shell::RemoveEnvEventFilter(aura::EventFilter* filter) {
aura::Env::GetInstance()->RemovePreTargetHandler(filter);
}
-void Shell::ShowContextMenu(const gfx::Point& location) {
+void Shell::ShowContextMenu(const gfx::Point& location_in_screen) {
// No context menus if user have not logged in.
if (!delegate_.get() || !delegate_->IsUserLoggedIn())
return;
// No context menus when screen is locked.
if (IsScreenLocked())
return;
+
aura::RootWindow* root =
- wm::GetRootWindowMatching(gfx::Rect(location, gfx::Size()));
- Launcher::ForWindow(root)->ShowContextMenu(location);
+ wm::GetRootWindowMatching(gfx::Rect(location_in_screen, gfx::Size()));
+ GetRootWindowController(root)->ShowContextMenu(location_in_screen);
}
void Shell::ToggleAppList() {
@@ -621,26 +621,42 @@ void Shell::RemoveShellObserver(ShellObserver* observer) {
}
void Shell::UpdateShelfVisibility() {
- // TODO(oshima): Update all root windows.
- GetPrimaryRootWindowController()->UpdateShelfVisibility();
+ RootWindowControllerList controllers = GetAllRootWindowControllers();
+ for (RootWindowControllerList::iterator iter = controllers.begin();
+ iter != controllers.end(); ++iter)
+ if ((*iter)->shelf())
+ (*iter)->UpdateShelfVisibility();
}
-void Shell::SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior) {
- GetPrimaryRootWindowController()->SetShelfAutoHideBehavior(behavior);
+void Shell::SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior,
+ aura::RootWindow* root_window) {
+ GetRootWindowController(root_window)->SetShelfAutoHideBehavior(behavior);
}
-ShelfAutoHideBehavior Shell::GetShelfAutoHideBehavior() const {
- return GetPrimaryRootWindowController()->GetShelfAutoHideBehavior();
+ShelfAutoHideBehavior Shell::GetShelfAutoHideBehavior(
+ aura::RootWindow* root_window) const {
+ return GetRootWindowController(root_window)->GetShelfAutoHideBehavior();
}
-void Shell::SetShelfAlignment(ShelfAlignment alignment) {
- if (GetPrimaryRootWindowController()->SetShelfAlignment(alignment)) {
+bool Shell::IsShelfAutoHideMenuHideChecked(aura::RootWindow* root_window) {
+ return GetRootWindowController(root_window)->GetShelfAutoHideBehavior() ==
+ ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
+}
+
+ShelfAutoHideBehavior Shell::GetToggledShelfAutoHideBehavior(
+ aura::RootWindow* root_window) {
+ return GetRootWindowController(root_window)->
+ GetToggledShelfAutoHideBehavior();
+}
+
+void Shell::SetShelfAlignment(ShelfAlignment alignment,
+ aura::RootWindow* root_window) {
+ if (GetRootWindowController(root_window)->SetShelfAlignment(alignment))
FOR_EACH_OBSERVER(ShellObserver, observers_, OnShelfAlignmentChanged());
- }
}
-ShelfAlignment Shell::GetShelfAlignment() {
- return GetPrimaryRootWindowController()->GetShelfAlignment();
+ShelfAlignment Shell::GetShelfAlignment(aura::RootWindow* root_window) {
+ return GetRootWindowController(root_window)->GetShelfAlignment();
}
void Shell::SetDimming(bool should_dim) {
diff --git a/ash/shell.h b/ash/shell.h
index 05dc2b8..0a29535 100644
--- a/ash/shell.h
+++ b/ash/shell.h
@@ -198,8 +198,8 @@ class ASH_EXPORT Shell : internal::SystemModalContainerEventFilterDelegate{
void RemoveEnvEventFilter(aura::EventFilter* filter);
// Shows the context menu for the background and launcher at
- // |location| (in screen coordinates).
- void ShowContextMenu(const gfx::Point& location);
+ // |location_in_screen| (in screen coordinates).
+ void ShowContextMenu(const gfx::Point& location_in_screen);
// Toggles app list.
void ToggleAppList();
@@ -330,12 +330,23 @@ class ASH_EXPORT Shell : internal::SystemModalContainerEventFilterDelegate{
// Force the shelf to query for it's current visibility state.
void UpdateShelfVisibility();
- // Sets/gets the shelf auto-hide behavior.
- void SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior);
- ShelfAutoHideBehavior GetShelfAutoHideBehavior() const;
+ // TODO(oshima): Define an interface to access shelf/launcher
+ // state, or just use Launcher.
- void SetShelfAlignment(ShelfAlignment alignment);
- ShelfAlignment GetShelfAlignment();
+ // Sets/gets the shelf auto-hide behavior on |root_window|.
+ void SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior,
+ aura::RootWindow* root_window);
+ ShelfAutoHideBehavior GetShelfAutoHideBehavior(
+ aura::RootWindow* root_window) const;
+
+ bool IsShelfAutoHideMenuHideChecked(aura::RootWindow* root);
+ ShelfAutoHideBehavior GetToggledShelfAutoHideBehavior(
+ aura::RootWindow* root_window);
+
+ // Sets/gets shelf's alignment on |root_window|.
+ void SetShelfAlignment(ShelfAlignment alignment,
+ aura::RootWindow* root_window);
+ ShelfAlignment GetShelfAlignment(aura::RootWindow* root_window);
// Dims or undims the screen.
void SetDimming(bool should_dim);
diff --git a/ash/shell/context_menu.cc b/ash/shell/context_menu.cc
new file mode 100644
index 0000000..fe23f20
--- /dev/null
+++ b/ash/shell/context_menu.cc
@@ -0,0 +1,65 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/shell/context_menu.h"
+
+#include "ash/launcher/launcher.h"
+#include "ash/root_window_controller.h"
+#include "ash/shell.h"
+#include "ash/wm/shelf_types.h"
+#include "grit/ash_strings.h"
+#include "ui/base/l10n/l10n_util.h"
+
+namespace ash {
+namespace shell {
+
+ContextMenu::ContextMenu(aura::RootWindow* root)
+ : ui::SimpleMenuModel(NULL),
+ root_window_(root),
+ alignment_menu_(root) {
+ DCHECK(root_window_);
+ set_delegate(this);
+ AddCheckItemWithStringId(MENU_AUTO_HIDE,
+ IDS_AURA_LAUNCHER_CONTEXT_MENU_AUTO_HIDE);
+ AddSubMenuWithStringId(MENU_ALIGNMENT_MENU,
+ IDS_AURA_LAUNCHER_CONTEXT_MENU_POSITION,
+ &alignment_menu_);
+}
+
+ContextMenu::~ContextMenu() {
+}
+
+bool ContextMenu::IsCommandIdChecked(int command_id) const {
+ switch (command_id) {
+ case MENU_AUTO_HIDE:
+ return Shell::GetInstance()->IsShelfAutoHideMenuHideChecked(root_window_);
+ default:
+ return false;
+ }
+}
+
+bool ContextMenu::IsCommandIdEnabled(int command_id) const {
+ return true;
+}
+
+bool ContextMenu::GetAcceleratorForCommandId(
+ int command_id,
+ ui::Accelerator* accelerator) {
+ return false;
+}
+
+void ContextMenu::ExecuteCommand(int command_id) {
+ switch (static_cast<MenuItem>(command_id)) {
+ case MENU_AUTO_HIDE:
+ Shell::GetInstance()->SetShelfAutoHideBehavior(
+ Shell::GetInstance()->GetToggledShelfAutoHideBehavior(root_window_),
+ root_window_);
+ break;
+ case MENU_ALIGNMENT_MENU:
+ break;
+ }
+}
+
+} // namespace shell
+} // namespace ash
diff --git a/ash/launcher/launcher_context_menu.h b/ash/shell/context_menu.h
index 41b52be..d98820e0 100644
--- a/ash/launcher/launcher_context_menu.h
+++ b/ash/shell/context_menu.h
@@ -2,32 +2,27 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ASH_WM_LAUNCHER_LAUNCHER_CONTEXT_MENU_H_
-#define ASH_WM_LAUNCHER_LAUNCHER_CONTEXT_MENU_H_
+#ifndef ASH_WM_SHELL_CONTEXT_MENU_H_
+#define ASH_WM_SHELL_CONTEXT_MENU_H_
-#include "ash/ash_export.h"
#include "ash/launcher/launcher_alignment_menu.h"
#include "ash/wm/shelf_types.h"
#include "base/basictypes.h"
#include "ui/base/models/simple_menu_model.h"
+namespace aura {
+class RootWindow;
+}
+
namespace ash {
+namespace shell {
-// Context menu for the launcher.
-class ASH_EXPORT LauncherContextMenu : public ui::SimpleMenuModel,
- public ui::SimpleMenuModel::Delegate {
+// Context menu for the ash_shell.
+class ContextMenu : public ui::SimpleMenuModel,
+ public ui::SimpleMenuModel::Delegate {
public:
- LauncherContextMenu();
- virtual ~LauncherContextMenu();
-
- // Returns true if the auto-hide menu item is checked.
- static bool IsAutoHideMenuHideChecked();
-
- // Returns the toggled state of the auto-hide behavior.
- static ShelfAutoHideBehavior GetToggledAutoHideBehavior();
-
- // Returns the resource id for the auto-hide menu.
- static int GetAutoHideResourceStringId();
+ explicit ContextMenu(aura::RootWindow* root);
+ virtual ~ContextMenu();
// ui::SimpleMenuModel::Delegate overrides:
virtual bool IsCommandIdChecked(int command_id) const OVERRIDE;
@@ -43,11 +38,14 @@ class ASH_EXPORT LauncherContextMenu : public ui::SimpleMenuModel,
MENU_ALIGNMENT_MENU,
};
+ aura::RootWindow* root_window_;
+
LauncherAlignmentMenu alignment_menu_;
- DISALLOW_COPY_AND_ASSIGN(LauncherContextMenu);
+ DISALLOW_COPY_AND_ASSIGN(ContextMenu);
};
+} // namespace shell
} // namespace ash
-#endif // ASH_WM_LAUNCHER_LAUNCHER_CONTEXT_MENU_H_
+#endif // ASH_WM_SHELL_CONTEXT_MENU_H_
diff --git a/ash/shell/launcher_delegate_impl.cc b/ash/shell/launcher_delegate_impl.cc
index 418c632..9cf4ca6 100644
--- a/ash/shell/launcher_delegate_impl.cc
+++ b/ash/shell/launcher_delegate_impl.cc
@@ -4,7 +4,6 @@
#include "ash/shell/launcher_delegate_impl.h"
-#include "ash/launcher/launcher_context_menu.h"
#include "ash/shell/toplevel_window.h"
#include "ash/shell/window_watcher.h"
#include "ash/wm/window_util.h"
@@ -45,14 +44,11 @@ string16 LauncherDelegateImpl::GetTitle(const ash::LauncherItem& item) {
}
ui::MenuModel* LauncherDelegateImpl::CreateContextMenu(
- const ash::LauncherItem& item) {
+ const ash::LauncherItem& item,
+ aura::RootWindow* root_window) {
return NULL;
}
-ui::MenuModel* LauncherDelegateImpl::CreateContextMenuForLauncher() {
- return new LauncherContextMenu;
-}
-
ash::LauncherID LauncherDelegateImpl::GetIDByWindow(aura::Window* window) {
return watcher_->GetIDByWindow(window);
}
diff --git a/ash/shell/launcher_delegate_impl.h b/ash/shell/launcher_delegate_impl.h
index 18440ef..978ddaf 100644
--- a/ash/shell/launcher_delegate_impl.h
+++ b/ash/shell/launcher_delegate_impl.h
@@ -31,8 +31,8 @@ class LauncherDelegateImpl : public ash::LauncherDelegate {
virtual int GetBrowserShortcutResourceId() OVERRIDE;
virtual string16 GetTitle(const ash::LauncherItem& item) OVERRIDE;
virtual ui::MenuModel* CreateContextMenu(
- const ash::LauncherItem& item) OVERRIDE;
- virtual ui::MenuModel* CreateContextMenuForLauncher() OVERRIDE;
+ const ash::LauncherItem& item,
+ aura::RootWindow* root) OVERRIDE;
virtual ash::LauncherID GetIDByWindow(aura::Window* window) OVERRIDE;
virtual bool IsDraggable(const ash::LauncherItem& item) OVERRIDE;
diff --git a/ash/shell/shell_delegate_impl.cc b/ash/shell/shell_delegate_impl.cc
index 93cad7f..8873565 100644
--- a/ash/shell/shell_delegate_impl.cc
+++ b/ash/shell/shell_delegate_impl.cc
@@ -7,6 +7,7 @@
#include "ash/caps_lock_delegate_stub.h"
#include "ash/shell/example_factory.h"
#include "ash/shell/launcher_delegate_impl.h"
+#include "ash/shell/context_menu.h"
#include "ash/shell/toplevel_window.h"
#include "ash/shell_window_ids.h"
#include "ash/wm/window_util.h"
@@ -169,5 +170,9 @@ double ShellDelegateImpl::GetSavedScreenMagnifierScale() {
return std::numeric_limits<double>::min();
}
+ui::MenuModel* ShellDelegateImpl::CreateContextMenu(aura::RootWindow* root) {
+ return new ContextMenu(root);
+}
+
} // namespace shell
} // namespace ash
diff --git a/ash/shell/shell_delegate_impl.h b/ash/shell/shell_delegate_impl.h
index f8c3b0d..ff9360b19 100644
--- a/ash/shell/shell_delegate_impl.h
+++ b/ash/shell/shell_delegate_impl.h
@@ -58,6 +58,8 @@ class ShellDelegateImpl : public ash::ShellDelegate {
virtual string16 GetTimeRemainingString(base::TimeDelta delta) OVERRIDE;
virtual void SaveScreenMagnifierScale(double scale) OVERRIDE;
virtual double GetSavedScreenMagnifierScale() OVERRIDE;
+ virtual ui::MenuModel* CreateContextMenu(
+ aura::RootWindow* root_window) OVERRIDE;
private:
// Used to update Launcher. Owned by main.
diff --git a/ash/shell_delegate.h b/ash/shell_delegate.h
index afef3a9..d1cde49 100644
--- a/ash/shell_delegate.h
+++ b/ash/shell_delegate.h
@@ -18,12 +18,17 @@ class AppListViewDelegate;
}
namespace aura {
+class RootWindow;
class Window;
namespace client {
class UserActionClient;
}
}
+namespace ui {
+class MenuModel;
+}
+
namespace views {
class Widget;
}
@@ -172,6 +177,9 @@ class ASH_EXPORT ShellDelegate {
// Gets a saved value of the zoom scale of full screen magnifier. If a value
// is not saved, return a negative value.
virtual double GetSavedScreenMagnifierScale() = 0;
+
+ // Creates a menu model of the context for the |root_window|.
+ virtual ui::MenuModel* CreateContextMenu(aura::RootWindow* root_window) = 0;
};
} // namespace ash
diff --git a/ash/shell_unittest.cc b/ash/shell_unittest.cc
index d939cdb..d9f1eb5 100644
--- a/ash/shell_unittest.cc
+++ b/ash/shell_unittest.cc
@@ -16,6 +16,7 @@
#include "ash/test/ash_test_base.h"
#include "ash/wm/root_window_layout_manager.h"
#include "ash/wm/shelf_layout_manager.h"
+#include "ash/wm/window_util.h"
#include "base/utf_string_conversions.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/root_window.h"
@@ -391,6 +392,41 @@ TEST_F(ShellTest, SystemBackgroundBehindDesktopBackground) {
"system background and desktop background need to have a common parent";
}
+// Various assertions around IsAutoHideMenuHideChecked() and
+// ToggleAutoHideMenu().
+TEST_F(ShellTest, ToggleAutoHide) {
+ scoped_ptr<aura::Window> window(new aura::Window(NULL));
+ window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
+ window->SetType(aura::client::WINDOW_TYPE_NORMAL);
+ window->Init(ui::LAYER_TEXTURED);
+ window->SetParent(NULL);
+ window->Show();
+ wm::ActivateWindow(window.get());
+
+ internal::RootWindowController* controller =
+ Shell::GetPrimaryRootWindowController();
+ controller->SetShelfAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
+ controller->GetShelfAutoHideBehavior());
+ EXPECT_TRUE(controller->IsShelfAutoHideMenuHideChecked());
+ controller->SetShelfAutoHideBehavior(
+ controller->GetToggledShelfAutoHideBehavior());
+ EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER,
+ controller->GetShelfAutoHideBehavior());
+
+ window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
+ EXPECT_FALSE(controller->IsShelfAutoHideMenuHideChecked());
+ controller->SetShelfAutoHideBehavior(
+ controller->GetToggledShelfAutoHideBehavior());
+ EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
+ controller->GetShelfAutoHideBehavior());
+ EXPECT_TRUE(controller->IsShelfAutoHideMenuHideChecked());
+ controller->SetShelfAutoHideBehavior(
+ controller->GetToggledShelfAutoHideBehavior());
+ EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER,
+ controller->GetShelfAutoHideBehavior());
+}
+
// This verifies WindowObservers are removed when a window is destroyed after
// the Shell is destroyed. This scenario (aura::Windows being deleted after the
// Shell) occurs if someone is holding a reference to an unparented Window, as
diff --git a/ash/test/test_launcher_delegate.cc b/ash/test/test_launcher_delegate.cc
index 323c422..e708e49 100644
--- a/ash/test/test_launcher_delegate.cc
+++ b/ash/test/test_launcher_delegate.cc
@@ -78,11 +78,8 @@ string16 TestLauncherDelegate::GetTitle(const ash::LauncherItem& item) {
}
ui::MenuModel* TestLauncherDelegate::CreateContextMenu(
- const ash::LauncherItem& item) {
- return NULL;
-}
-
-ui::MenuModel* TestLauncherDelegate::CreateContextMenuForLauncher() {
+ const ash::LauncherItem& item,
+ aura::RootWindow* root) {
return NULL;
}
diff --git a/ash/test/test_launcher_delegate.h b/ash/test/test_launcher_delegate.h
index 981b16b4..38140fa 100644
--- a/ash/test/test_launcher_delegate.h
+++ b/ash/test/test_launcher_delegate.h
@@ -40,8 +40,8 @@ class TestLauncherDelegate : public LauncherDelegate,
int event_flags) OVERRIDE;
virtual int GetBrowserShortcutResourceId() OVERRIDE;
virtual string16 GetTitle(const LauncherItem& item) OVERRIDE;
- virtual ui::MenuModel* CreateContextMenu(const LauncherItem& item) OVERRIDE;
- virtual ui::MenuModel* CreateContextMenuForLauncher() OVERRIDE;
+ virtual ui::MenuModel* CreateContextMenu(const LauncherItem& item,
+ aura::RootWindow* root) OVERRIDE;
virtual ash::LauncherID GetIDByWindow(aura::Window* window) OVERRIDE;
virtual bool IsDraggable(const ash::LauncherItem& item) OVERRIDE;
diff --git a/ash/test/test_shell_delegate.cc b/ash/test/test_shell_delegate.cc
index 4614f10..28b09b3 100644
--- a/ash/test/test_shell_delegate.cc
+++ b/ash/test/test_shell_delegate.cc
@@ -152,6 +152,10 @@ string16 TestShellDelegate::GetTimeRemainingString(base::TimeDelta delta) {
void TestShellDelegate::SaveScreenMagnifierScale(double scale) {
}
+ui::MenuModel* TestShellDelegate::CreateContextMenu(aura::RootWindow* root) {
+ return NULL;
+}
+
double TestShellDelegate::GetSavedScreenMagnifierScale() {
return std::numeric_limits<double>::min();
}
diff --git a/ash/test/test_shell_delegate.h b/ash/test/test_shell_delegate.h
index 8c196c9..989dbe1 100644
--- a/ash/test/test_shell_delegate.h
+++ b/ash/test/test_shell_delegate.h
@@ -54,6 +54,7 @@ class TestShellDelegate : public ShellDelegate {
virtual string16 GetTimeRemainingString(base::TimeDelta delta) OVERRIDE;
virtual void SaveScreenMagnifierScale(double scale) OVERRIDE;
virtual double GetSavedScreenMagnifierScale() OVERRIDE;
+ virtual ui::MenuModel* CreateContextMenu(aura::RootWindow* root) OVERRIDE;
int num_exit_requests() const { return num_exit_requests_; }
private:
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()));
+ }
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/ash/wm/shelf_layout_manager_unittest.cc b/ash/wm/shelf_layout_manager_unittest.cc
index dff6dc5..6b2ab39 100644
--- a/ash/wm/shelf_layout_manager_unittest.cc
+++ b/ash/wm/shelf_layout_manager_unittest.cc
@@ -511,9 +511,11 @@ TEST_F(ShelfLayoutManagerTest, VisibleWhenStatusOrLauncherFocused) {
// state,and toggling app list won't change shelf visibility state.
TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfVisibleState) {
Shell* shell = Shell::GetInstance();
+ internal::RootWindowController* controller =
+ Shell::GetPrimaryRootWindowController();
ShelfLayoutManager* shelf = shelf_layout_manager();
shelf->LayoutShelf();
- shell->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
+ controller->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
// Create a normal unmaximized windowm shelf should be visible.
aura::Window* window = CreateTestWindow();
@@ -539,8 +541,10 @@ TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfVisibleState) {
TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) {
Shell* shell = Shell::GetInstance();
ShelfLayoutManager* shelf = shelf_layout_manager();
+ internal::RootWindowController* controller =
+ Shell::GetPrimaryRootWindowController();
shelf->LayoutShelf();
- shell->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ controller->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
// Create a window and show it in maximized state.
aura::Window* window = CreateTestWindow();
@@ -660,7 +664,9 @@ TEST_F(ShelfLayoutManagerTest, SetAlignment) {
TEST_F(ShelfLayoutManagerTest, GestureDrag) {
ShelfLayoutManager* shelf = GetShelfLayoutManager();
- shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
+ internal::RootWindowController* controller =
+ Shell::GetPrimaryRootWindowController();
+ controller->SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
shelf->LayoutShelf();
views::Widget* widget = new views::Widget;
diff --git a/ash/wm/workspace/workspace_window_resizer_unittest.cc b/ash/wm/workspace/workspace_window_resizer_unittest.cc
index 75aad47..f625df7 100644
--- a/ash/wm/workspace/workspace_window_resizer_unittest.cc
+++ b/ash/wm/workspace/workspace_window_resizer_unittest.cc
@@ -917,8 +917,8 @@ TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideBottomWorkArea) {
// Verifies snapping to edges works.
TEST_F(WorkspaceWindowResizerTest, SnapToEdge) {
- Shell::GetInstance()->SetShelfAutoHideBehavior(
- SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
+ Shell::GetPrimaryRootWindowController()->
+ SetShelfAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
window_->SetBounds(gfx::Rect(96, 112, 320, 160));
scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
window_.get(), gfx::Point(), HTCAPTION, empty_windows()));