summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-22 06:20:27 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-22 06:20:27 +0000
commit0f81f44b1dc0b8244bad4847e45d5cea65b2016d (patch)
tree672d3bf75d5a80a9cbf317d38653bc3114fe59aa
parentb0b6ffa3a5a812484fab30229b47d9762c452d5e (diff)
downloadchromium_src-0f81f44b1dc0b8244bad4847e45d5cea65b2016d.zip
chromium_src-0f81f44b1dc0b8244bad4847e45d5cea65b2016d.tar.gz
chromium_src-0f81f44b1dc0b8244bad4847e45d5cea65b2016d.tar.bz2
Cycle through windows across root windows
This also fixed the issue where AshTestBase wasn't showing the host window. BUG=123160 TEST=ExtendedDesktopTest.CycyleWindow Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=143492 Review URL: https://chromiumcodereview.appspot.com/10649005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143546 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/extended_desktop_unittest.cc59
-rw-r--r--ash/wm/window_cycle_controller.cc21
-rw-r--r--ash/wm/window_cycle_controller.h7
3 files changed, 78 insertions, 9 deletions
diff --git a/ash/extended_desktop_unittest.cc b/ash/extended_desktop_unittest.cc
index 5bccab6..eb69c3b 100644
--- a/ash/extended_desktop_unittest.cc
+++ b/ash/extended_desktop_unittest.cc
@@ -5,6 +5,7 @@
#include "ash/monitor/monitor_controller.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
+#include "ash/wm/window_cycle_controller.h"
#include "ash/wm/window_util.h"
#include "ui/aura/client/activation_client.h"
#include "ui/aura/client/capture_client.h"
@@ -24,6 +25,7 @@ views::Widget* CreateTestWidget(const gfx::Rect& bounds) {
params.bounds = bounds;
views::Widget* widget = new views::Widget;
widget->Init(params);
+ widget->Show();
return widget;
}
@@ -95,14 +97,12 @@ TEST_F(ExtendedDesktopTest, Activation) {
views::Widget* widget_on_2nd = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
EXPECT_EQ(root_windows[1], widget_on_2nd->GetNativeView()->GetRootWindow());
- widget_on_2nd->Show();
// Move the active root window back to the primary.
Shell::GetInstance()->set_active_root_window(root_windows[0]);
views::Widget* widget_on_1st = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
EXPECT_EQ(root_windows[0], widget_on_1st->GetNativeView()->GetRootWindow());
- widget_on_1st->Show();
aura::test::EventGenerator generator_1st(root_windows[0]);
aura::test::EventGenerator generator_2nd(root_windows[1]);
@@ -129,7 +129,6 @@ TEST_F(ExtendedDesktopTest, SystemModal) {
Shell::GetInstance()->set_active_root_window(root_windows[0]);
views::Widget* widget_on_1st = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
- widget_on_1st->Show();
EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView()));
EXPECT_EQ(root_windows[0], Shell::GetActiveRootWindow());
@@ -176,4 +175,58 @@ TEST_F(ExtendedDesktopTest, TestCursor) {
EXPECT_EQ(ui::kCursorCopy, root_windows[1]->last_cursor().native_type());
}
+TEST_F(ExtendedDesktopTest, CycleWindows) {
+ UpdateMonitor("0+0-1000x600,1001+0-600x400");
+ Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
+ WindowCycleController* controller =
+ Shell::GetInstance()->window_cycle_controller();
+
+ // Switch active windows between root windows.
+ Shell::GetInstance()->set_active_root_window(root_windows[0]);
+ views::Widget* d1_w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
+ EXPECT_EQ(root_windows[0], d1_w1->GetNativeView()->GetRootWindow());
+
+ Shell::GetInstance()->set_active_root_window(root_windows[1]);
+ views::Widget* d2_w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
+ EXPECT_EQ(root_windows[1], d2_w1->GetNativeView()->GetRootWindow());
+ EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView()));
+
+ controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
+ EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView()));
+ controller->HandleCycleWindow(WindowCycleController::FORWARD, false);
+ EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView()));
+ controller->HandleCycleWindow(WindowCycleController::BACKWARD, false);
+ EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView()));
+ controller->HandleCycleWindow(WindowCycleController::BACKWARD, false);
+ EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView()));
+
+ // Cycle through all windows across root windows.
+ Shell::GetInstance()->set_active_root_window(root_windows[0]);
+ views::Widget* d1_w2 = CreateTestWidget(gfx::Rect(100, 100, 100, 100));
+ EXPECT_EQ(root_windows[0], d1_w2->GetNativeView()->GetRootWindow());
+
+ Shell::GetInstance()->set_active_root_window(root_windows[1]);
+ views::Widget* d2_w2 = CreateTestWidget(gfx::Rect(100, 100, 100, 100));
+ EXPECT_EQ(root_windows[1], d2_w2->GetNativeView()->GetRootWindow());
+
+ controller->HandleCycleWindow(WindowCycleController::FORWARD, true);
+ EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView()));
+ controller->HandleCycleWindow(WindowCycleController::FORWARD, true);
+ EXPECT_TRUE(wm::IsActiveWindow(d1_w2->GetNativeView()));
+ controller->HandleCycleWindow(WindowCycleController::FORWARD, true);
+ EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView()));
+ controller->HandleCycleWindow(WindowCycleController::FORWARD, true);
+ EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView()));
+
+ // Backwards
+ controller->HandleCycleWindow(WindowCycleController::BACKWARD, true);
+ EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView()));
+ controller->HandleCycleWindow(WindowCycleController::BACKWARD, true);
+ EXPECT_TRUE(wm::IsActiveWindow(d1_w2->GetNativeView()));
+ controller->HandleCycleWindow(WindowCycleController::BACKWARD, true);
+ EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView()));
+ controller->HandleCycleWindow(WindowCycleController::BACKWARD, true);
+ EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView()));
+}
+
} // namespace ash
diff --git a/ash/wm/window_cycle_controller.cc b/ash/wm/window_cycle_controller.cc
index 0345c4b..f48ee76 100644
--- a/ash/wm/window_cycle_controller.cc
+++ b/ash/wm/window_cycle_controller.cc
@@ -127,12 +127,27 @@ void WindowCycleController::AltKeyReleased() {
// static
std::vector<aura::Window*> WindowCycleController::BuildWindowList() {
- // TODO(oshima): Figure out how this should work with multiple root
- // windows. Just use active root window for now.
+ WindowCycleList::WindowList windows;
+ Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
+
+ for (Shell::RootWindowList::const_iterator iter = root_windows.begin();
+ iter != root_windows.end(); ++iter) {
+ if (*iter == Shell::GetActiveRootWindow())
+ continue;
+ aura::Window* default_container = Shell::GetContainer(
+ *iter, internal::kShellWindowId_DefaultContainer);
+ WindowCycleList::WindowList children = default_container->children();
+ windows.insert(windows.end(), children.begin(), children.end());
+ }
+ // Add windows in the active root windows last so that the topmost window
+ // in the active root window becomes the front of the list.
aura::Window* default_container = Shell::GetContainer(
Shell::GetActiveRootWindow(),
internal::kShellWindowId_DefaultContainer);
- WindowCycleList::WindowList windows = default_container->children();
+
+ WindowCycleList::WindowList children = default_container->children();
+ windows.insert(windows.end(), children.begin(), children.end());
+
// Removes unfocusable windows.
WindowCycleList::WindowList::iterator last =
std::remove_if(
diff --git a/ash/wm/window_cycle_controller.h b/ash/wm/window_cycle_controller.h
index 301a6ab..dfc43fa 100644
--- a/ash/wm/window_cycle_controller.h
+++ b/ash/wm/window_cycle_controller.h
@@ -54,9 +54,10 @@ class ASH_EXPORT WindowCycleController {
// Returns the WindowCycleList. Really only useful for testing.
const WindowCycleList* windows() const { return windows_.get(); }
- // Returns the set of windows to cycle through. This method creates the vector
- // based on the current set of windows. As a result it is not necessarily the
- // same as the set of windows being iterated over.
+ // Returns the set of windows to cycle through. This method creates
+ // the vector based on the current set of windows across all valid root
+ // windows. As a result it is not necessarily the same as the set of
+ // windows being iterated over.
static std::vector<aura::Window*> BuildWindowList();
private: