summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-17 17:27:28 +0000
committerjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-17 17:27:28 +0000
commit6416a9a9c8f50dc9368123478147a0e4b9c7951f (patch)
tree5b1b7c6dd4a74c9c2b9284d37d3faf10f5e468fd /ash
parentec7b271972848c075878d14fe07f29197ebec6d6 (diff)
downloadchromium_src-6416a9a9c8f50dc9368123478147a0e4b9c7951f.zip
chromium_src-6416a9a9c8f50dc9368123478147a0e4b9c7951f.tar.gz
chromium_src-6416a9a9c8f50dc9368123478147a0e4b9c7951f.tar.bz2
Aura: ShellDelegate GetCycleWindowList can request order by activity
alicet@ is working on window switching animations for compact mode. We're finding that while most-recently-used cycling works pretty well for normal mode it's pretty confusing for compact mode, since you can't see an overview of the windows. This patch allows the window cycler controller to choose between most-recently-used and traditional linear order while we're sorting out which works better. BUG=none TEST=aura_shell_unittests WindowCycleControllerTest Review URL: https://chromiumcodereview.appspot.com/9112044 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117908 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/shell/shell_main.cc3
-rw-r--r--ash/shell_delegate.h13
-rw-r--r--ash/test/test_shell_delegate.cc3
-rw-r--r--ash/test/test_shell_delegate.h3
-rw-r--r--ash/wm/window_cycle_controller.cc10
-rw-r--r--ash/wm/window_cycle_controller_unittest.cc8
6 files changed, 27 insertions, 13 deletions
diff --git a/ash/shell/shell_main.cc b/ash/shell/shell_main.cc
index a002c5e..2276fb5 100644
--- a/ash/shell/shell_main.cc
+++ b/ash/shell/shell_main.cc
@@ -65,7 +65,8 @@ class ShellDelegateImpl : public ash::ShellDelegate {
return ash::shell::CreateAppListViewDelegate();
}
- std::vector<aura::Window*> GetCycleWindowList() const OVERRIDE {
+ std::vector<aura::Window*> GetCycleWindowList(
+ CycleOrder order) const OVERRIDE {
aura::Window* default_container = ash::Shell::GetInstance()->GetContainer(
ash::internal::kShellWindowId_DefaultContainer);
std::vector<aura::Window*> windows = default_container->children();
diff --git a/ash/shell_delegate.h b/ash/shell_delegate.h
index 0bb1ce6..0f39756 100644
--- a/ash/shell_delegate.h
+++ b/ash/shell_delegate.h
@@ -32,6 +32,11 @@ struct LauncherItem;
// Delegate of the Shell.
class ASH_EXPORT ShellDelegate {
public:
+ enum CycleOrder {
+ ORDER_MRU, // Most recently used
+ ORDER_LINEAR
+ };
+
// The Shell owns the delegate.
virtual ~ShellDelegate() {}
@@ -50,10 +55,12 @@ class ASH_EXPORT ShellDelegate {
virtual AppListViewDelegate* CreateAppListViewDelegate() = 0;
// Returns a list of windows to cycle with keyboard shortcuts (e.g. alt-tab
- // or the window switching key). Windows should be in most-recently-used
- // order with the currently active window at the front of the list. The list
+ // or the window switching key). If |order_by_activity| is true then windows
+ // are returned in most-recently-used order with the currently active window
+ // at the front of the list. Otherwise any order may be returned. The list
// does not contain NULL pointers.
- virtual std::vector<aura::Window*> GetCycleWindowList() const = 0;
+ virtual std::vector<aura::Window*> GetCycleWindowList(
+ CycleOrder order) const = 0;
// Invoked when the user clicks on a window entry in the launcher.
virtual void LauncherItemClicked(const LauncherItem& item) = 0;
diff --git a/ash/test/test_shell_delegate.cc b/ash/test/test_shell_delegate.cc
index 92c36d7..c8e1e1e 100644
--- a/ash/test/test_shell_delegate.cc
+++ b/ash/test/test_shell_delegate.cc
@@ -33,7 +33,8 @@ AppListViewDelegate* TestShellDelegate::CreateAppListViewDelegate() {
return NULL;
}
-std::vector<aura::Window*> TestShellDelegate::GetCycleWindowList() const {
+std::vector<aura::Window*> TestShellDelegate::GetCycleWindowList(
+ CycleOrder order) const {
// We just use the Shell's default container of windows, so tests can be
// written with the usual CreateTestWindowWithId() calls. But window cycling
// expects the topmost window at the front of the list, so reverse the order.
diff --git a/ash/test/test_shell_delegate.h b/ash/test/test_shell_delegate.h
index 50cd72d..b81b086 100644
--- a/ash/test/test_shell_delegate.h
+++ b/ash/test/test_shell_delegate.h
@@ -22,7 +22,8 @@ class TestShellDelegate : public ShellDelegate {
virtual views::Widget* CreateStatusArea() OVERRIDE;
virtual void BuildAppListModel(AppListModel* model) OVERRIDE;
virtual AppListViewDelegate* CreateAppListViewDelegate() OVERRIDE;
- virtual std::vector<aura::Window*> GetCycleWindowList() const OVERRIDE;
+ virtual std::vector<aura::Window*> GetCycleWindowList(
+ CycleOrder order) const OVERRIDE;
virtual void LauncherItemClicked(const LauncherItem& item) OVERRIDE;
virtual bool ConfigureLauncherItem(LauncherItem* item) OVERRIDE;
};
diff --git a/ash/wm/window_cycle_controller.cc b/ash/wm/window_cycle_controller.cc
index ab827b0..7a578ed 100644
--- a/ash/wm/window_cycle_controller.cc
+++ b/ash/wm/window_cycle_controller.cc
@@ -108,10 +108,12 @@ void WindowCycleController::AltKeyReleased() {
// WindowCycleController, private:
void WindowCycleController::StartCycling() {
- // Our delegate will provide a list of windows to use for cycling, in an
- // order that makes sense for that application.
- ShellDelegate* shell_delegate = ash::Shell::GetInstance()->delegate();
- windows_ = shell_delegate->GetCycleWindowList();
+ // Most-recently-used cycling is confusing in compact window mode because
+ // you can't see all the windows.
+ windows_ = ash::Shell::GetInstance()->delegate()->GetCycleWindowList(
+ Shell::GetInstance()->IsWindowModeCompact() ?
+ ShellDelegate::ORDER_LINEAR :
+ ShellDelegate::ORDER_MRU);
// Locate the currently active window in the list to use as our start point.
aura::Window* active_window = GetActiveWindow();
diff --git a/ash/wm/window_cycle_controller_unittest.cc b/ash/wm/window_cycle_controller_unittest.cc
index a747884..0a2681d 100644
--- a/ash/wm/window_cycle_controller_unittest.cc
+++ b/ash/wm/window_cycle_controller_unittest.cc
@@ -36,7 +36,9 @@ TEST_F(WindowCycleControllerTest, HandleCycleWindowBaseCases) {
Shell::GetInstance()->window_cycle_controller();
// Cycling doesn't crash if there are no windows.
- EXPECT_TRUE(Shell::GetInstance()->delegate()->GetCycleWindowList().empty());
+ std::vector<Window*> windows = Shell::GetInstance()->delegate()->
+ GetCycleWindowList(ShellDelegate::ORDER_MRU);
+ EXPECT_TRUE(windows.empty());
controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
// Create a single test window.
@@ -67,8 +69,8 @@ TEST_F(WindowCycleControllerTest, HandleCycleWindow) {
ActivateWindow(window0.get());
// Window lists should return the topmost window in front.
- std::vector<Window*> windows =
- Shell::GetInstance()->delegate()->GetCycleWindowList();
+ std::vector<Window*> windows = Shell::GetInstance()->delegate()->
+ GetCycleWindowList(ShellDelegate::ORDER_MRU);
ASSERT_EQ(3u, windows.size());
ASSERT_EQ(window0.get(), windows[0]);
ASSERT_EQ(window1.get(), windows[1]);