diff options
-rw-r--r-- | ash/accelerators/accelerator_commands.cc | 8 | ||||
-rw-r--r-- | ash/accelerators/accelerator_commands_unittest.cc | 27 | ||||
-rw-r--r-- | ash/accelerators/accelerator_controller.cc | 43 | ||||
-rw-r--r-- | ash/accelerators/accelerator_table.cc | 8 | ||||
-rw-r--r-- | ash/accelerators/accelerator_table.h | 2 | ||||
-rw-r--r-- | ash/ash.gyp | 5 | ||||
-rw-r--r-- | ash/ash_switches.cc | 7 | ||||
-rw-r--r-- | ash/ash_switches.h | 4 | ||||
-rw-r--r-- | ash/extended_desktop_unittest.cc | 52 | ||||
-rw-r--r-- | ash/focus_cycler.cc | 13 | ||||
-rw-r--r-- | ash/focus_cycler_unittest.cc | 9 | ||||
-rw-r--r-- | ash/shell.cc | 4 | ||||
-rw-r--r-- | ash/shell.h | 4 | ||||
-rw-r--r-- | ash/wm/mru_window_tracker.cc | 1 | ||||
-rw-r--r-- | ash/wm/system_gesture_event_filter.cc | 3 | ||||
-rw-r--r-- | ash/wm/window_cycle_controller.cc | 139 | ||||
-rw-r--r-- | ash/wm/window_cycle_controller.h | 82 | ||||
-rw-r--r-- | ash/wm/window_cycle_controller_unittest.cc | 446 | ||||
-rw-r--r-- | ash/wm/window_cycle_list.cc | 85 | ||||
-rw-r--r-- | ash/wm/window_cycle_list.h | 59 | ||||
-rw-r--r-- | chrome/app/generated_resources.grd | 12 | ||||
-rw-r--r-- | chrome/browser/about_flags.cc | 7 |
22 files changed, 54 insertions, 966 deletions
diff --git a/ash/accelerators/accelerator_commands.cc b/ash/accelerators/accelerator_commands.cc index c5bd711..9fbe5eb 100644 --- a/ash/accelerators/accelerator_commands.cc +++ b/ash/accelerators/accelerator_commands.cc @@ -6,7 +6,7 @@ #include "ash/shell.h" #include "ash/shell_delegate.h" -#include "ash/wm/window_cycle_controller.h" +#include "ash/wm/mru_window_tracker.h" #include "ash/wm/window_state.h" #include "ash/wm/window_util.h" #include "ash/wm/wm_event.h" @@ -20,8 +20,10 @@ bool ToggleMinimized() { // Attempt to restore the window that would be cycled through next from // the launcher when there is no active window. if (!window) { - ash::Shell::GetInstance()->window_cycle_controller()-> - HandleCycleWindow(WindowCycleController::FORWARD, false); + MruWindowTracker::WindowList mru_windows( + Shell::GetInstance()->mru_window_tracker()->BuildMruWindowList()); + if (!mru_windows.empty()) + wm::GetWindowState(mru_windows.front())->Activate(); return true; } wm::WindowState* window_state = wm::GetWindowState(window); diff --git a/ash/accelerators/accelerator_commands_unittest.cc b/ash/accelerators/accelerator_commands_unittest.cc index 82f7534..3bc1ece 100644 --- a/ash/accelerators/accelerator_commands_unittest.cc +++ b/ash/accelerators/accelerator_commands_unittest.cc @@ -20,18 +20,31 @@ namespace accelerators { typedef test::AshTestBase AcceleratorCommandsTest; TEST_F(AcceleratorCommandsTest, ToggleMinimized) { - scoped_ptr<aura::Window> window( + scoped_ptr<aura::Window> window1( CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); - wm::WindowState* window_state = wm::GetWindowState(window.get()); - window_state->Activate(); + scoped_ptr<aura::Window> window2( + CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); + wm::WindowState* window_state1 = wm::GetWindowState(window1.get()); + wm::WindowState* window_state2 = wm::GetWindowState(window2.get()); + window_state1->Activate(); + window_state2->Activate(); + + ToggleMinimized(); + EXPECT_TRUE(window_state2->IsMinimized()); + EXPECT_FALSE(window_state2->IsNormalStateType()); + EXPECT_TRUE(window_state1->IsActive()); ToggleMinimized(); - EXPECT_TRUE(window_state->IsMinimized()); - EXPECT_FALSE(window_state->IsNormalStateType()); + EXPECT_TRUE(window_state1->IsMinimized()); + EXPECT_FALSE(window_state1->IsNormalStateType()); + EXPECT_FALSE(window_state1->IsActive()); + // Toggling minimize when there are no active windows should unminimize and + // activate the last active window. ToggleMinimized(); - EXPECT_FALSE(window_state->IsMinimized()); - EXPECT_TRUE(window_state->IsNormalStateType()); + EXPECT_FALSE(window_state1->IsMinimized()); + EXPECT_TRUE(window_state1->IsNormalStateType()); + EXPECT_TRUE(window_state1->IsActive()); } } // namespace accelerators diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc index 5ca4393..7195004 100644 --- a/ash/accelerators/accelerator_controller.cc +++ b/ash/accelerators/accelerator_controller.cc @@ -48,7 +48,6 @@ #include "ash/wm/overview/window_selector_controller.h" #include "ash/wm/partial_screenshot_view.h" #include "ash/wm/power_button_controller.h" -#include "ash/wm/window_cycle_controller.h" #include "ash/wm/window_state.h" #include "ash/wm/window_util.h" #include "ash/wm/wm_event.h" @@ -125,50 +124,26 @@ bool HandleAccessibleFocusCycle(bool reverse) { } bool HandleCycleBackwardMRU(const ui::Accelerator& accelerator) { - Shell* shell = Shell::GetInstance(); - if (accelerator.key_code() == ui::VKEY_TAB) base::RecordAction(base::UserMetricsAction("Accel_PrevWindow_Tab")); - if (switches::UseOverviewMode()) { - shell->window_selector_controller()->HandleCycleWindow( - WindowSelector::BACKWARD); - return true; - } - shell->window_cycle_controller()->HandleCycleWindow( - WindowCycleController::BACKWARD, accelerator.IsAltDown()); + Shell::GetInstance()->window_selector_controller()->HandleCycleWindow( + WindowSelector::BACKWARD); return true; } bool HandleCycleForwardMRU(const ui::Accelerator& accelerator) { - Shell* shell = Shell::GetInstance(); - if (accelerator.key_code() == ui::VKEY_TAB) base::RecordAction(base::UserMetricsAction("Accel_NextWindow_Tab")); - if (switches::UseOverviewMode()) { - shell->window_selector_controller()->HandleCycleWindow( - WindowSelector::FORWARD); - return true; - } - shell->window_cycle_controller()->HandleCycleWindow( - WindowCycleController::FORWARD, accelerator.IsAltDown()); + Shell::GetInstance()->window_selector_controller()->HandleCycleWindow( + WindowSelector::FORWARD); return true; } -bool HandleCycleLinear(const ui::Accelerator& accelerator) { - Shell* shell = Shell::GetInstance(); - - // TODO(jamescook): When overview becomes the default the AcceleratorAction - // should be renamed from CYCLE_LINEAR to TOGGLE_OVERVIEW. - if (switches::UseOverviewMode()) { - base::RecordAction(base::UserMetricsAction("Accel_Overview_F5")); - shell->window_selector_controller()->ToggleOverview(); - return true; - } - if (accelerator.key_code() == ui::VKEY_MEDIA_LAUNCH_APP1) - base::RecordAction(base::UserMetricsAction("Accel_NextWindow_F5")); - shell->window_cycle_controller()->HandleLinearCycleWindow(); +bool ToggleOverview(const ui::Accelerator& accelerator) { + base::RecordAction(base::UserMetricsAction("Accel_Overview_F5")); + Shell::GetInstance()->window_selector_controller()->ToggleOverview(); return true; } @@ -942,8 +917,8 @@ bool AcceleratorController::PerformAction(int action, return HandleCycleBackwardMRU(accelerator); case CYCLE_FORWARD_MRU: return HandleCycleForwardMRU(accelerator); - case CYCLE_LINEAR: - return HandleCycleLinear(accelerator); + case TOGGLE_OVERVIEW: + return ToggleOverview(accelerator); #if defined(OS_CHROMEOS) case ADD_REMOVE_DISPLAY: return HandleAddRemoveDisplay(); diff --git a/ash/accelerators/accelerator_table.cc b/ash/accelerators/accelerator_table.cc index a099dcc..e9fb112 100644 --- a/ash/accelerators/accelerator_table.cc +++ b/ash/accelerators/accelerator_table.cc @@ -37,7 +37,7 @@ const AcceleratorData kAcceleratorData[] = { { true, ui::VKEY_TAB, ui::EF_ALT_DOWN, CYCLE_FORWARD_MRU }, { true, ui::VKEY_TAB, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN, CYCLE_BACKWARD_MRU }, - { true, ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_NONE, CYCLE_LINEAR }, + { true, ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_NONE, TOGGLE_OVERVIEW }, #if defined(OS_CHROMEOS) { true, ui::VKEY_BROWSER_SEARCH, ui::EF_NONE, TOGGLE_APP_LIST }, { true, ui::VKEY_WLAN, ui::EF_NONE, TOGGLE_WIFI }, @@ -356,7 +356,7 @@ const AcceleratorAction kNonrepeatableActions[] = { // TODO(mazda): Add other actions which should not be repeated. CYCLE_BACKWARD_MRU, CYCLE_FORWARD_MRU, - CYCLE_LINEAR, + TOGGLE_OVERVIEW, EXIT, PRINT_UI_HIERARCHIES, // Don't fill the logs if the key is held down. ROTATE_SCREEN, @@ -377,7 +377,7 @@ const AcceleratorAction kActionsAllowedInAppMode[] = { BRIGHTNESS_UP, CYCLE_BACKWARD_MRU, CYCLE_FORWARD_MRU, - CYCLE_LINEAR, + TOGGLE_OVERVIEW, DISABLE_CAPS_LOCK, KEYBOARD_BRIGHTNESS_DOWN, KEYBOARD_BRIGHTNESS_UP, @@ -422,7 +422,7 @@ const AcceleratorAction kActionsNeedingWindow[] = { ACCESSIBLE_FOCUS_PREVIOUS, CYCLE_BACKWARD_MRU, CYCLE_FORWARD_MRU, - CYCLE_LINEAR, + TOGGLE_OVERVIEW, WINDOW_SNAP_LEFT, WINDOW_SNAP_RIGHT, WINDOW_MINIMIZE, diff --git a/ash/accelerators/accelerator_table.h b/ash/accelerators/accelerator_table.h index f34b2df..f6d69de 100644 --- a/ash/accelerators/accelerator_table.h +++ b/ash/accelerators/accelerator_table.h @@ -52,7 +52,6 @@ enum AcceleratorAction { BRIGHTNESS_UP, CYCLE_BACKWARD_MRU, CYCLE_FORWARD_MRU, - CYCLE_LINEAR, DEBUG_TOGGLE_DEVICE_SCALE_FACTOR, DEBUG_TOGGLE_SHOW_DEBUG_BORDERS, DEBUG_TOGGLE_SHOW_FPS_COUNTER, @@ -113,6 +112,7 @@ enum AcceleratorAction { TOGGLE_DESKTOP_BACKGROUND_MODE, TOGGLE_FULLSCREEN, TOGGLE_MAXIMIZED, + TOGGLE_OVERVIEW, TOGGLE_ROOT_WINDOW_FULL_SCREEN, TOGGLE_SPOKEN_FEEDBACK, TOGGLE_TOUCH_VIEW_TESTING, diff --git a/ash/ash.gyp b/ash/ash.gyp index d7282b7..0591a4f 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -606,10 +606,6 @@ 'wm/video_detector.h', 'wm/window_animations.cc', 'wm/window_animations.h', - 'wm/window_cycle_controller.cc', - 'wm/window_cycle_controller.h', - 'wm/window_cycle_list.cc', - 'wm/window_cycle_list.h', 'wm/window_positioner.cc', 'wm/window_positioner.h', 'wm/window_state.cc', @@ -964,7 +960,6 @@ 'wm/user_activity_detector_unittest.cc', 'wm/video_detector_unittest.cc', 'wm/window_animations_unittest.cc', - 'wm/window_cycle_controller_unittest.cc', 'wm/window_manager_unittest.cc', 'wm/window_modality_controller_unittest.cc', 'wm/window_positioner_unittest.cc', diff --git a/ash/ash_switches.cc b/ash/ash_switches.cc index da289bb..4375264 100644 --- a/ash/ash_switches.cc +++ b/ash/ash_switches.cc @@ -53,9 +53,6 @@ const char kAshDisableAudioDeviceMenu[] = // Disable ability to dock windows at the desktop edge. const char kAshDisableDockedWindows[] = "ash-disable-docked-windows"; -// Disables overview mode for window switching. -const char kAshDisableOverviewMode[] = "ash-disable-overview-mode"; - // Use alternate visual style for the caption buttons (minimize, maximize, // restore, close). The alternate style: // - Adds a dedicated button for minimize. @@ -148,10 +145,6 @@ bool UseImmersiveFullscreenForAllWindows() { kAshEnableImmersiveFullscreenForBrowserOnly); } -bool UseOverviewMode() { - return !CommandLine::ForCurrentProcess()->HasSwitch(kAshDisableOverviewMode); -} - bool UseDockedWindows() { return !CommandLine::ForCurrentProcess()->HasSwitch(kAshDisableDockedWindows); } diff --git a/ash/ash_switches.h b/ash/ash_switches.h index 1aceb0d..198d436 100644 --- a/ash/ash_switches.h +++ b/ash/ash_switches.h @@ -31,7 +31,6 @@ ASH_EXPORT extern const char kAshDisableAudioDeviceMenu[]; #endif ASH_EXPORT extern const char kAshDisableDockedWindows[]; -ASH_EXPORT extern const char kAshDisableOverviewMode[]; ASH_EXPORT extern const char kAshEnableAlternateFrameCaptionButtonStyle[]; ASH_EXPORT extern const char kAshEnableBrightnessControl[]; ASH_EXPORT extern const char kAshEnableImmersiveFullscreenForAllWindows[]; @@ -67,9 +66,6 @@ ASH_EXPORT bool UseDragOffShelf(); // immersive fullscreen via <F4>. ASH_EXPORT bool UseImmersiveFullscreenForAllWindows(); -// Returns true if overview mode should be activated for window switching. -ASH_EXPORT bool UseOverviewMode(); - // Returns true if docked windows feature is enabled. ASH_EXPORT bool UseDockedWindows(); diff --git a/ash/extended_desktop_unittest.cc b/ash/extended_desktop_unittest.cc index dbab079..d0f3f2c 100644 --- a/ash/extended_desktop_unittest.cc +++ b/ash/extended_desktop_unittest.cc @@ -11,7 +11,6 @@ #include "ash/system/tray/system_tray.h" #include "ash/test/ash_test_base.h" #include "ash/wm/coordinate_conversion.h" -#include "ash/wm/window_cycle_controller.h" #include "ash/wm/window_properties.h" #include "ash/wm/window_util.h" #include "base/strings/string_util.h" @@ -284,57 +283,6 @@ TEST_F(ExtendedDesktopTest, TestCursorLocation) { EXPECT_FALSE(root_window1_test_api.ContainsMouse()); } -TEST_F(ExtendedDesktopTest, CycleWindows) { - if (!SupportsMultipleDisplays()) - return; - - UpdateDisplay("700x500,500x500"); - aura::Window::Windows root_windows = Shell::GetAllRootWindows(); - - WindowCycleController* controller = - Shell::GetInstance()->window_cycle_controller(); - - views::Widget* d1_w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); - EXPECT_EQ(root_windows[0], d1_w1->GetNativeView()->GetRootWindow()); - views::Widget* d2_w1 = CreateTestWidget(gfx::Rect(800, 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. - views::Widget* d1_w2 = CreateTestWidget(gfx::Rect(10, 200, 100, 100)); - EXPECT_EQ(root_windows[0], d1_w2->GetNativeView()->GetRootWindow()); - views::Widget* d2_w2 = CreateTestWidget(gfx::Rect(800, 200, 100, 100)); - EXPECT_EQ(root_windows[1], d2_w2->GetNativeView()->GetRootWindow()); - - controller->HandleCycleWindow(WindowCycleController::FORWARD, true); - EXPECT_TRUE(wm::IsActiveWindow(d1_w2->GetNativeView())); - controller->HandleCycleWindow(WindowCycleController::FORWARD, true); - EXPECT_TRUE(wm::IsActiveWindow(d2_w1->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(d2_w1->GetNativeView())); - controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); - EXPECT_TRUE(wm::IsActiveWindow(d1_w2->GetNativeView())); - controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); - EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView())); -} - TEST_F(ExtendedDesktopTest, GetRootWindowAt) { if (!SupportsMultipleDisplays()) return; diff --git a/ash/focus_cycler.cc b/ash/focus_cycler.cc index c83db87..efd958c 100644 --- a/ash/focus_cycler.cc +++ b/ash/focus_cycler.cc @@ -6,7 +6,7 @@ #include "ash/shell.h" #include "ash/wm/mru_window_tracker.h" -#include "ash/wm/window_cycle_controller.h" +#include "ash/wm/window_state.h" #include "ash/wm/window_util.h" #include "ui/aura/client/activation_client.h" #include "ui/aura/window.h" @@ -77,13 +77,12 @@ void FocusCycler::RotateFocus(Direction direction) { if (index == browser_index) { // Activate the most recently active browser window. - ash::Shell::GetInstance()->window_cycle_controller()->HandleCycleWindow( - WindowCycleController::FORWARD, false); - - // Rotate pane focus within that window. - aura::Window* window = ash::wm::GetActiveWindow(); - if (!window) + MruWindowTracker::WindowList mru_windows( + Shell::GetInstance()->mru_window_tracker()->BuildMruWindowList()); + if (mru_windows.empty()) break; + aura::Window* window = mru_windows.front(); + wm::GetWindowState(window)->Activate(); views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window); if (!widget) break; diff --git a/ash/focus_cycler_unittest.cc b/ash/focus_cycler_unittest.cc index 66be1ed..5b25d96 100644 --- a/ash/focus_cycler_unittest.cc +++ b/ash/focus_cycler_unittest.cc @@ -252,13 +252,16 @@ TEST_F(FocusCyclerTest, CycleFocusNoBrowser) { EXPECT_TRUE(tray()->GetWidget()->IsActive()); } +// Tests that focus cycles from the active browser to the status area and back. TEST_F(FocusCyclerTest, Shelf_CycleFocusForward) { ASSERT_TRUE(CreateTray()); InstallFocusCycleOnShelf(); shelf_widget()->Hide(); - // Create a single test window. + // Create two test windows. scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0)); + scoped_ptr<Window> window1(CreateTestWindowInShellWithId(1)); + wm::ActivateWindow(window1.get()); wm::ActivateWindow(window0.get()); EXPECT_TRUE(wm::IsActiveWindow(window0.get())); @@ -269,6 +272,10 @@ TEST_F(FocusCyclerTest, Shelf_CycleFocusForward) { // Cycle focus to the browser. focus_cycler()->RotateFocus(FocusCycler::FORWARD); EXPECT_TRUE(wm::IsActiveWindow(window0.get())); + + // Cycle focus to the status area. + focus_cycler()->RotateFocus(FocusCycler::FORWARD); + EXPECT_TRUE(tray()->GetWidget()->IsActive()); } TEST_F(FocusCyclerTest, Shelf_CycleFocusBackwardInvisible) { diff --git a/ash/shell.cc b/ash/shell.cc index 08ae512..94f4fed 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -74,7 +74,6 @@ #include "ash/wm/user_activity_detector.h" #include "ash/wm/video_detector.h" #include "ash/wm/window_animations.h" -#include "ash/wm/window_cycle_controller.h" #include "ash/wm/window_positioner.h" #include "ash/wm/window_properties.h" #include "ash/wm/window_util.h" @@ -691,7 +690,6 @@ Shell::~Shell() { resize_shadow_controller_.reset(); window_selector_controller_.reset(); - window_cycle_controller_.reset(); mru_window_tracker_.reset(); // |shelf_window_watcher_| has a weak pointer to |shelf_Model_| @@ -924,7 +922,6 @@ void Shell::Init() { high_contrast_controller_.reset(new HighContrastController); video_detector_.reset(new VideoDetector); - window_cycle_controller_.reset(new WindowCycleController()); window_selector_controller_.reset(new WindowSelectorController()); tooltip_controller_.reset( @@ -1033,7 +1030,6 @@ void Shell::InitRootWindow(aura::Window* root_window) { DCHECK(activation_client_); DCHECK(visibility_controller_.get()); DCHECK(drag_drop_controller_.get()); - DCHECK(window_cycle_controller_.get()); aura::client::SetFocusClient(root_window, focus_client_.get()); input_method_filter_->SetInputMethodPropertyInRootWindow(root_window); diff --git a/ash/shell.h b/ash/shell.h index 49fbda9..2334fcf 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -363,9 +363,6 @@ class ASH_EXPORT Shell VideoDetector* video_detector() { return video_detector_.get(); } - WindowCycleController* window_cycle_controller() { - return window_cycle_controller_.get(); - } WindowSelectorController* window_selector_controller() { return window_selector_controller_.get(); } @@ -650,7 +647,6 @@ class ASH_EXPORT Shell scoped_ptr<MruWindowTracker> mru_window_tracker_; scoped_ptr<UserActivityDetector> user_activity_detector_; scoped_ptr<VideoDetector> video_detector_; - scoped_ptr<WindowCycleController> window_cycle_controller_; scoped_ptr<WindowSelectorController> window_selector_controller_; scoped_ptr<internal::FocusCycler> focus_cycler_; scoped_ptr<DisplayController> display_controller_; diff --git a/ash/wm/mru_window_tracker.cc b/ash/wm/mru_window_tracker.cc index c0fe9eb..8e211b3 100644 --- a/ash/wm/mru_window_tracker.cc +++ b/ash/wm/mru_window_tracker.cc @@ -10,7 +10,6 @@ #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/switchable_windows.h" -#include "ash/wm/window_cycle_list.h" #include "ash/wm/window_state.h" #include "ash/wm/window_util.h" #include "ash/wm/workspace_controller.h" diff --git a/ash/wm/system_gesture_event_filter.cc b/ash/wm/system_gesture_event_filter.cc index 2e7dbf3..1c31832 100644 --- a/ash/wm/system_gesture_event_filter.cc +++ b/ash/wm/system_gesture_event_filter.cc @@ -23,9 +23,8 @@ namespace internal { SystemGestureEventFilter::SystemGestureEventFilter() : long_press_affordance_(new LongPressAffordanceHandler), + overview_gesture_handler_(new OverviewGestureHandler), shelf_gesture_handler_(new ShelfGestureHandler()) { - if (switches::UseOverviewMode()) - overview_gesture_handler_.reset(new OverviewGestureHandler); } SystemGestureEventFilter::~SystemGestureEventFilter() { diff --git a/ash/wm/window_cycle_controller.cc b/ash/wm/window_cycle_controller.cc deleted file mode 100644 index 5f76133..0000000 --- a/ash/wm/window_cycle_controller.cc +++ /dev/null @@ -1,139 +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/wm/window_cycle_controller.h" - -#include <algorithm> - -#include "ash/session_state_delegate.h" -#include "ash/shell.h" -#include "ash/shell_window_ids.h" -#include "ash/wm/mru_window_tracker.h" -#include "ash/wm/window_cycle_list.h" -#include "ash/wm/window_util.h" -#include "ash/wm/workspace_controller.h" -#include "ui/aura/window_event_dispatcher.h" -#include "ui/events/event.h" -#include "ui/events/event_handler.h" - -namespace ash { - -namespace { - -// Filter to watch for the termination of a keyboard gesture to cycle through -// multiple windows. -class WindowCycleEventFilter : public ui::EventHandler { - public: - WindowCycleEventFilter(); - virtual ~WindowCycleEventFilter(); - - // Overridden from ui::EventHandler: - virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE; - private: - DISALLOW_COPY_AND_ASSIGN(WindowCycleEventFilter); -}; - -// Watch for all keyboard events by filtering the root window. -WindowCycleEventFilter::WindowCycleEventFilter() { -} - -WindowCycleEventFilter::~WindowCycleEventFilter() { -} - -void WindowCycleEventFilter::OnKeyEvent(ui::KeyEvent* event) { - // Views uses VKEY_MENU for both left and right Alt keys. - if (event->key_code() == ui::VKEY_MENU && - event->type() == ui::ET_KEY_RELEASED) { - Shell::GetInstance()->window_cycle_controller()->AltKeyReleased(); - // Warning: |this| will be deleted from here on. - } -} - -} // namespace - -////////////////////////////////////////////////////////////////////////////// -// WindowCycleController, public: - -WindowCycleController::WindowCycleController() { -} - -WindowCycleController::~WindowCycleController() { - StopCycling(); -} - -// static -bool WindowCycleController::CanCycle() { - // Don't allow window cycling if the screen is locked or a modal dialog is - // open. - return !Shell::GetInstance()->session_state_delegate()->IsScreenLocked() && - !Shell::GetInstance()->IsSystemModalWindowOpen(); -} - -void WindowCycleController::HandleCycleWindow(Direction direction, - bool is_alt_down) { - if (!CanCycle()) - return; - - if (is_alt_down) { - if (!IsCycling()) { - // This is the start of an alt-tab cycle through multiple windows, so - // listen for the alt key being released to stop cycling. - StartCycling(); - Step(direction); - InstallEventFilter(); - } else { - // We're in the middle of an alt-tab cycle, just step forward. - Step(direction); - } - } else { - // This is a simple, single-step window cycle. - StartCycling(); - Step(direction); - StopCycling(); - } -} - -void WindowCycleController::HandleLinearCycleWindow() { - if (!CanCycle() || IsCycling()) - return; - - // Use the reversed list of windows to prevent a 2-cycle of the most recent - // windows occurring. - WindowCycleList cycle_list(MruWindowTracker::BuildWindowList(true)); - cycle_list.Step(WindowCycleList::FORWARD); -} - -void WindowCycleController::AltKeyReleased() { - StopCycling(); -} - -////////////////////////////////////////////////////////////////////////////// -// WindowCycleController, private: - -void WindowCycleController::StartCycling() { - windows_.reset(new WindowCycleList(ash::Shell::GetInstance()-> - mru_window_tracker()->BuildMruWindowList())); -} - -void WindowCycleController::Step(Direction direction) { - DCHECK(windows_.get()); - windows_->Step(direction == FORWARD ? WindowCycleList::FORWARD : - WindowCycleList::BACKWARD); -} - -void WindowCycleController::StopCycling() { - windows_.reset(); - // Remove our key event filter. - if (event_handler_) { - Shell::GetInstance()->RemovePreTargetHandler(event_handler_.get()); - event_handler_.reset(); - } -} - -void WindowCycleController::InstallEventFilter() { - event_handler_.reset(new WindowCycleEventFilter()); - Shell::GetInstance()->AddPreTargetHandler(event_handler_.get()); -} - -} // namespace ash diff --git a/ash/wm/window_cycle_controller.h b/ash/wm/window_cycle_controller.h deleted file mode 100644 index 12822c0..0000000 --- a/ash/wm/window_cycle_controller.h +++ /dev/null @@ -1,82 +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. - -#ifndef ASH_WM_WINDOW_CYCLE_CONTROLLER_H_ -#define ASH_WM_WINDOW_CYCLE_CONTROLLER_H_ - -#include "ash/ash_export.h" -#include "base/basictypes.h" -#include "base/memory/scoped_ptr.h" - -namespace ui { -class EventHandler; -} - -namespace ash { - -class WindowCycleList; - -// Controls cycling through windows with the keyboard, for example, via alt-tab. -// Windows are sorted primarily by most recently used, and then by screen order. -// We activate windows as you cycle through them, so the order on the screen -// may change during the gesture, but the most recently used list isn't updated -// until the cycling ends. Thus we maintain the state of the windows -// at the beginning of the gesture so you can cycle through in a consistent -// order. -class ASH_EXPORT WindowCycleController { - public: - enum Direction { - FORWARD, - BACKWARD - }; - WindowCycleController(); - virtual ~WindowCycleController(); - - // Returns true if cycling through windows is enabled. This is false at - // certain times, such as when the lock screen is visible. - static bool CanCycle(); - - // Cycles between windows in the given |direction|. If |is_alt_down| then - // interprets this call as the start of a multi-step cycle sequence and - // installs a key filter to watch for alt being released. - void HandleCycleWindow(Direction direction, bool is_alt_down); - - // Cycles between windows without maintaining a multi-step cycle sequence - // (see above). - void HandleLinearCycleWindow(); - - // Informs the controller that the Alt key has been released and it can - // terminate the existing multi-step cycle. - void AltKeyReleased(); - - // Returns true if we are in the middle of a window cycling gesture. - bool IsCycling() const { return windows_.get() != NULL; } - - // Returns the WindowCycleList. Really only useful for testing. - const WindowCycleList* windows() const { return windows_.get(); } - - private: - // Call to start cycling windows. You must call StopCycling() when done. - void StartCycling(); - - // Cycles to the next or previous window based on |direction|. - void Step(Direction direction); - - // Installs an event filter to watch for release of the alt key. - void InstallEventFilter(); - - // Stops the current window cycle and cleans up the event filter. - void StopCycling(); - - scoped_ptr<WindowCycleList> windows_; - - // Event handler to watch for release of alt key. - scoped_ptr<ui::EventHandler> event_handler_; - - DISALLOW_COPY_AND_ASSIGN(WindowCycleController); -}; - -} // namespace ash - -#endif // ASH_WM_WINDOW_CYCLE_CONTROLLER_H_ diff --git a/ash/wm/window_cycle_controller_unittest.cc b/ash/wm/window_cycle_controller_unittest.cc deleted file mode 100644 index 902853a..0000000 --- a/ash/wm/window_cycle_controller_unittest.cc +++ /dev/null @@ -1,446 +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/wm/window_cycle_controller.h" - -#include <algorithm> - -#include "ash/session_state_delegate.h" -#include "ash/shell.h" -#include "ash/shell_window_ids.h" -#include "ash/test/ash_test_base.h" -#include "ash/test/test_shell_delegate.h" -#include "ash/wm/window_cycle_list.h" -#include "ash/wm/window_state.h" -#include "ash/wm/window_util.h" -#include "base/memory/scoped_ptr.h" -#include "ui/aura/client/aura_constants.h" -#include "ui/aura/client/screen_position_client.h" -#include "ui/aura/env.h" -#include "ui/aura/test/test_windows.h" -#include "ui/aura/window.h" -#include "ui/aura/window_event_dispatcher.h" -#include "ui/gfx/rect.h" -#include "ui/gfx/screen.h" - -namespace ash { - -namespace { - -using aura::test::CreateTestWindowWithId; -using aura::test::TestWindowDelegate; -using aura::Window; - -typedef test::AshTestBase WindowCycleControllerTest; - -TEST_F(WindowCycleControllerTest, HandleCycleWindowBaseCases) { - WindowCycleController* controller = - Shell::GetInstance()->window_cycle_controller(); - - // Cycling doesn't crash if there are no windows. - controller->HandleCycleWindow(WindowCycleController::FORWARD, false); - - // Create a single test window. - scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0)); - wm::ActivateWindow(window0.get()); - EXPECT_TRUE(wm::IsActiveWindow(window0.get())); - - // Cycling works for a single window, even though nothing changes. - controller->HandleCycleWindow(WindowCycleController::FORWARD, false); - EXPECT_TRUE(wm::IsActiveWindow(window0.get())); -} - -// Verifies if there is only one window and it isn't active that cycling -// activates it. -TEST_F(WindowCycleControllerTest, SingleWindowNotActive) { - WindowCycleController* controller = - Shell::GetInstance()->window_cycle_controller(); - - // Create a single test window. - scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0)); - wm::ActivateWindow(window0.get()); - EXPECT_TRUE(wm::IsActiveWindow(window0.get())); - - // Rotate focus, this should move focus to another window that isn't part of - // the default container. - Shell::GetInstance()->RotateFocus(Shell::FORWARD); - EXPECT_FALSE(wm::IsActiveWindow(window0.get())); - - // Cycling should activate the window. - controller->HandleCycleWindow(WindowCycleController::FORWARD, false); - EXPECT_TRUE(wm::IsActiveWindow(window0.get())); -} - -TEST_F(WindowCycleControllerTest, HandleCycleWindow) { - WindowCycleController* controller = - Shell::GetInstance()->window_cycle_controller(); - - // Set up several windows to use to test cycling. Create them in reverse - // order so they are stacked 0 over 1 over 2. - scoped_ptr<Window> window2(CreateTestWindowInShellWithId(2)); - scoped_ptr<Window> window1(CreateTestWindowInShellWithId(1)); - scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0)); - wm::ActivateWindow(window0.get()); - - // Simulate pressing and releasing Alt-tab. - EXPECT_TRUE(wm::IsActiveWindow(window0.get())); - controller->HandleCycleWindow(WindowCycleController::FORWARD, true); - - // Window lists should return the topmost window in front. - ASSERT_TRUE(controller->windows()); - ASSERT_EQ(3u, controller->windows()->windows().size()); - ASSERT_EQ(window0.get(), controller->windows()->windows()[0]); - ASSERT_EQ(window1.get(), controller->windows()->windows()[1]); - ASSERT_EQ(window2.get(), controller->windows()->windows()[2]); - - controller->AltKeyReleased(); - EXPECT_TRUE(wm::IsActiveWindow(window1.get())); - - // Pressing and releasing Alt-tab again should cycle back to the most- - // recently-used window in the current child order. - controller->HandleCycleWindow(WindowCycleController::FORWARD, true); - controller->AltKeyReleased(); - EXPECT_TRUE(wm::IsActiveWindow(window0.get())); - - // Pressing Alt-tab multiple times without releasing Alt should cycle through - // all the windows and wrap around. - controller->HandleCycleWindow(WindowCycleController::FORWARD, true); - EXPECT_TRUE(controller->IsCycling()); - EXPECT_TRUE(wm::IsActiveWindow(window1.get())); - - controller->HandleCycleWindow(WindowCycleController::FORWARD, true); - EXPECT_TRUE(controller->IsCycling()); - EXPECT_TRUE(wm::IsActiveWindow(window2.get())); - - controller->HandleCycleWindow(WindowCycleController::FORWARD, true); - EXPECT_TRUE(controller->IsCycling()); - EXPECT_TRUE(wm::IsActiveWindow(window0.get())); - - controller->AltKeyReleased(); - EXPECT_FALSE(controller->IsCycling()); - EXPECT_TRUE(wm::IsActiveWindow(window0.get())); - - // Reset our stacking order. - wm::ActivateWindow(window2.get()); - wm::ActivateWindow(window1.get()); - wm::ActivateWindow(window0.get()); - - // Likewise we can cycle backwards through all the windows. - controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); - EXPECT_TRUE(wm::IsActiveWindow(window2.get())); - controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); - EXPECT_TRUE(wm::IsActiveWindow(window1.get())); - controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); - EXPECT_TRUE(wm::IsActiveWindow(window0.get())); - controller->AltKeyReleased(); - EXPECT_TRUE(wm::IsActiveWindow(window0.get())); - - // Passing false for is_alt_down does not start a cycle gesture. - controller->HandleCycleWindow(WindowCycleController::FORWARD, false); - EXPECT_FALSE(controller->IsCycling()); - EXPECT_TRUE(wm::IsActiveWindow(window1.get())); - - controller->HandleCycleWindow(WindowCycleController::FORWARD, false); - EXPECT_FALSE(controller->IsCycling()); - EXPECT_TRUE(wm::IsActiveWindow(window0.get())); - - // When the screen is locked, cycling window does not take effect. - Shell::GetInstance()->session_state_delegate()->LockScreen(); - EXPECT_TRUE(wm::IsActiveWindow(window0.get())); - controller->HandleCycleWindow(WindowCycleController::FORWARD, false); - EXPECT_TRUE(wm::IsActiveWindow(window0.get())); - controller->HandleCycleWindow(WindowCycleController::BACKWARD, false); - EXPECT_TRUE(wm::IsActiveWindow(window0.get())); - - Shell::GetInstance()->session_state_delegate()->UnlockScreen(); - EXPECT_TRUE(wm::IsActiveWindow(window0.get())); - controller->HandleCycleWindow(WindowCycleController::FORWARD, false); - EXPECT_TRUE(wm::IsActiveWindow(window1.get())); - controller->HandleCycleWindow(WindowCycleController::FORWARD, false); - EXPECT_TRUE(wm::IsActiveWindow(window0.get())); - - // When a modal window is active, cycling window does not take effect. - aura::Window* modal_container = - ash::Shell::GetContainer( - Shell::GetPrimaryRootWindow(), - internal::kShellWindowId_SystemModalContainer); - scoped_ptr<Window> modal_window( - CreateTestWindowWithId(-2, modal_container)); - modal_window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); - wm::ActivateWindow(modal_window.get()); - EXPECT_TRUE(wm::IsActiveWindow(modal_window.get())); - controller->HandleCycleWindow(WindowCycleController::FORWARD, false); - EXPECT_TRUE(wm::IsActiveWindow(modal_window.get())); - EXPECT_FALSE(wm::IsActiveWindow(window0.get())); - EXPECT_FALSE(wm::IsActiveWindow(window1.get())); - EXPECT_FALSE(wm::IsActiveWindow(window2.get())); - controller->HandleCycleWindow(WindowCycleController::BACKWARD, false); - EXPECT_TRUE(wm::IsActiveWindow(modal_window.get())); - EXPECT_FALSE(wm::IsActiveWindow(window0.get())); - EXPECT_FALSE(wm::IsActiveWindow(window1.get())); - EXPECT_FALSE(wm::IsActiveWindow(window2.get())); -} - -// Cycles between a maximized and normal window. -TEST_F(WindowCycleControllerTest, MaximizedWindow) { - // Create a couple of test windows. - scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0)); - scoped_ptr<Window> window1(CreateTestWindowInShellWithId(1)); - wm::WindowState* window1_state = wm::GetWindowState(window1.get()); - window1_state->Maximize(); - window1_state->Activate(); - EXPECT_TRUE(window1_state->IsActive()); - - // Rotate focus, this should move focus to window0. - WindowCycleController* controller = - Shell::GetInstance()->window_cycle_controller(); - controller->HandleCycleWindow(WindowCycleController::FORWARD, false); - EXPECT_TRUE(wm::GetWindowState(window0.get())->IsActive()); - - // One more time. - controller->HandleCycleWindow(WindowCycleController::FORWARD, false); - EXPECT_TRUE(window1_state->IsActive()); -} - -// Cycles to a minimized window. -TEST_F(WindowCycleControllerTest, Minimized) { - // Create a couple of test windows. - scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0)); - scoped_ptr<Window> window1(CreateTestWindowInShellWithId(1)); - wm::WindowState* window0_state = wm::GetWindowState(window0.get()); - wm::WindowState* window1_state = wm::GetWindowState(window1.get()); - - window1_state->Minimize(); - window0_state->Activate(); - EXPECT_TRUE(window0_state->IsActive()); - - // Rotate focus, this should move focus to window1 and unminimize it. - WindowCycleController* controller = - Shell::GetInstance()->window_cycle_controller(); - controller->HandleCycleWindow(WindowCycleController::FORWARD, false); - EXPECT_FALSE(window1_state->IsMinimized()); - EXPECT_TRUE(window1_state->IsActive()); - - // One more time back to w0. - controller->HandleCycleWindow(WindowCycleController::FORWARD, false); - EXPECT_TRUE(window0_state->IsActive()); -} - -TEST_F(WindowCycleControllerTest, AlwaysOnTopWindow) { - WindowCycleController* controller = - Shell::GetInstance()->window_cycle_controller(); - - // Set up several windows to use to test cycling. - scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0)); - scoped_ptr<Window> window1(CreateTestWindowInShellWithId(1)); - - Window* top_container = - Shell::GetContainer( - Shell::GetPrimaryRootWindow(), - internal::kShellWindowId_AlwaysOnTopContainer); - scoped_ptr<Window> window2(CreateTestWindowWithId(2, top_container)); - wm::ActivateWindow(window0.get()); - - // Simulate pressing and releasing Alt-tab. - EXPECT_TRUE(wm::IsActiveWindow(window0.get())); - controller->HandleCycleWindow(WindowCycleController::FORWARD, true); - - // Window lists should return the topmost window in front. - ASSERT_TRUE(controller->windows()); - ASSERT_EQ(3u, controller->windows()->windows().size()); - EXPECT_EQ(window0.get(), controller->windows()->windows()[0]); - EXPECT_EQ(window2.get(), controller->windows()->windows()[1]); - EXPECT_EQ(window1.get(), controller->windows()->windows()[2]); - - controller->AltKeyReleased(); - EXPECT_TRUE(wm::IsActiveWindow(window2.get())); - - controller->HandleCycleWindow(WindowCycleController::FORWARD, true); - EXPECT_TRUE(wm::IsActiveWindow(window0.get())); - - controller->AltKeyReleased(); - - controller->HandleCycleWindow(WindowCycleController::FORWARD, true); - EXPECT_TRUE(wm::IsActiveWindow(window2.get())); - - controller->HandleCycleWindow(WindowCycleController::FORWARD, true); - EXPECT_TRUE(wm::IsActiveWindow(window1.get())); - - controller->HandleCycleWindow(WindowCycleController::FORWARD, true); - EXPECT_TRUE(wm::IsActiveWindow(window0.get())); -} - -TEST_F(WindowCycleControllerTest, AlwaysOnTopMultiWindow) { - WindowCycleController* controller = - Shell::GetInstance()->window_cycle_controller(); - - // Set up several windows to use to test cycling. - scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0)); - scoped_ptr<Window> window1(CreateTestWindowInShellWithId(1)); - - Window* top_container = - Shell::GetContainer( - Shell::GetPrimaryRootWindow(), - internal::kShellWindowId_AlwaysOnTopContainer); - scoped_ptr<Window> window2(CreateTestWindowWithId(2, top_container)); - scoped_ptr<Window> window3(CreateTestWindowWithId(3, top_container)); - wm::ActivateWindow(window0.get()); - - // Simulate pressing and releasing Alt-tab. - EXPECT_TRUE(wm::IsActiveWindow(window0.get())); - controller->HandleCycleWindow(WindowCycleController::FORWARD, true); - - // Window lists should return the topmost window in front. - ASSERT_TRUE(controller->windows()); - ASSERT_EQ(4u, controller->windows()->windows().size()); - EXPECT_EQ(window0.get(), controller->windows()->windows()[0]); - EXPECT_EQ(window3.get(), controller->windows()->windows()[1]); - EXPECT_EQ(window2.get(), controller->windows()->windows()[2]); - EXPECT_EQ(window1.get(), controller->windows()->windows()[3]); - - controller->AltKeyReleased(); - EXPECT_TRUE(wm::IsActiveWindow(window3.get())); - - controller->HandleCycleWindow(WindowCycleController::FORWARD, true); - EXPECT_TRUE(wm::IsActiveWindow(window0.get())); - - controller->AltKeyReleased(); - - controller->HandleCycleWindow(WindowCycleController::FORWARD, true); - EXPECT_TRUE(wm::IsActiveWindow(window3.get())); - - controller->HandleCycleWindow(WindowCycleController::FORWARD, true); - EXPECT_TRUE(wm::IsActiveWindow(window2.get())); - - controller->HandleCycleWindow(WindowCycleController::FORWARD, true); - EXPECT_TRUE(wm::IsActiveWindow(window1.get())); - - controller->HandleCycleWindow(WindowCycleController::FORWARD, true); - EXPECT_TRUE(wm::IsActiveWindow(window0.get())); -} - -TEST_F(WindowCycleControllerTest, AlwaysOnTopMultipleRootWindows) { - if (!SupportsMultipleDisplays()) - return; - - // Set up a second root window - UpdateDisplay("1000x600,600x400"); - aura::Window::Windows root_windows = Shell::GetAllRootWindows(); - ASSERT_EQ(2U, root_windows.size()); - - WindowCycleController* controller = - Shell::GetInstance()->window_cycle_controller(); - - Shell::GetInstance()->set_target_root_window(root_windows[0]); - - // Create two windows in the primary root. - scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0)); - EXPECT_EQ(root_windows[0], window0->GetRootWindow()); - Window* top_container0 = - Shell::GetContainer( - root_windows[0], - internal::kShellWindowId_AlwaysOnTopContainer); - scoped_ptr<Window> window1(CreateTestWindowWithId(1, top_container0)); - EXPECT_EQ(root_windows[0], window1->GetRootWindow()); - - // And two on the secondary root. - Shell::GetInstance()->set_target_root_window(root_windows[1]); - scoped_ptr<Window> window2(CreateTestWindowInShellWithId(2)); - EXPECT_EQ(root_windows[1], window2->GetRootWindow()); - - Window* top_container1 = - Shell::GetContainer( - root_windows[1], - internal::kShellWindowId_AlwaysOnTopContainer); - scoped_ptr<Window> window3(CreateTestWindowWithId(3, top_container1)); - EXPECT_EQ(root_windows[1], window3->GetRootWindow()); - - // Move the active root window to the secondary. - Shell::GetInstance()->set_target_root_window(root_windows[1]); - - wm::ActivateWindow(window2.get()); - - EXPECT_EQ(root_windows[0], window0->GetRootWindow()); - EXPECT_EQ(root_windows[0], window1->GetRootWindow()); - EXPECT_EQ(root_windows[1], window2->GetRootWindow()); - EXPECT_EQ(root_windows[1], window3->GetRootWindow()); - - // Simulate pressing and releasing Alt-tab. - EXPECT_TRUE(wm::IsActiveWindow(window2.get())); - controller->HandleCycleWindow(WindowCycleController::FORWARD, true); - - // Window lists should return the topmost window in front. - ASSERT_TRUE(controller->windows()); - ASSERT_EQ(4u, controller->windows()->windows().size()); - EXPECT_EQ(window2.get(), controller->windows()->windows()[0]); - EXPECT_EQ(window3.get(), controller->windows()->windows()[1]); - EXPECT_EQ(window1.get(), controller->windows()->windows()[2]); - EXPECT_EQ(window0.get(), controller->windows()->windows()[3]); - - controller->AltKeyReleased(); - EXPECT_TRUE(wm::IsActiveWindow(window3.get())); - - controller->HandleCycleWindow(WindowCycleController::FORWARD, true); - EXPECT_TRUE(wm::IsActiveWindow(window2.get())); - - controller->AltKeyReleased(); - - controller->HandleCycleWindow(WindowCycleController::FORWARD, true); - EXPECT_TRUE(wm::IsActiveWindow(window3.get())); - - controller->HandleCycleWindow(WindowCycleController::FORWARD, true); - EXPECT_TRUE(wm::IsActiveWindow(window1.get())); - - controller->HandleCycleWindow(WindowCycleController::FORWARD, true); - EXPECT_TRUE(wm::IsActiveWindow(window0.get())); - - controller->HandleCycleWindow(WindowCycleController::FORWARD, true); - EXPECT_TRUE(wm::IsActiveWindow(window2.get())); -} - -TEST_F(WindowCycleControllerTest, MostRecentlyUsed) { - WindowCycleController* controller = - Shell::GetInstance()->window_cycle_controller(); - - // Set up several windows to use to test cycling. - scoped_ptr<Window> window0(CreateTestWindowInShellWithId(0)); - scoped_ptr<Window> window1(CreateTestWindowInShellWithId(1)); - scoped_ptr<Window> window2(CreateTestWindowInShellWithId(2)); - - wm::ActivateWindow(window0.get()); - - // Simulate pressing and releasing Alt-tab. - EXPECT_TRUE(wm::IsActiveWindow(window0.get())); - controller->HandleCycleWindow(WindowCycleController::FORWARD, true); - - // Window lists should return the topmost window in front. - ASSERT_TRUE(controller->windows()); - ASSERT_EQ(3u, controller->windows()->windows().size()); - EXPECT_EQ(window0.get(), controller->windows()->windows()[0]); - EXPECT_EQ(window2.get(), controller->windows()->windows()[1]); - EXPECT_EQ(window1.get(), controller->windows()->windows()[2]); - - controller->HandleCycleWindow(WindowCycleController::FORWARD, true); - controller->AltKeyReleased(); - EXPECT_TRUE(wm::IsActiveWindow(window1.get())); - - - controller->HandleCycleWindow(WindowCycleController::FORWARD, true); - EXPECT_TRUE(wm::IsActiveWindow(window0.get())); - - controller->AltKeyReleased(); - - controller->HandleCycleWindow(WindowCycleController::FORWARD, true); - EXPECT_TRUE(wm::IsActiveWindow(window1.get())); - - controller->HandleCycleWindow(WindowCycleController::FORWARD, true); - EXPECT_TRUE(wm::IsActiveWindow(window2.get())); - - controller->HandleCycleWindow(WindowCycleController::FORWARD, true); - EXPECT_TRUE(wm::IsActiveWindow(window0.get())); -} - -} // namespace - -} // namespace ash diff --git a/ash/wm/window_cycle_list.cc b/ash/wm/window_cycle_list.cc deleted file mode 100644 index 58f1313..0000000 --- a/ash/wm/window_cycle_list.cc +++ /dev/null @@ -1,85 +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/wm/window_cycle_list.h" - -#include "ash/shell.h" -#include "ash/wm/mru_window_tracker.h" -#include "ash/wm/window_util.h" -#include "ui/aura/window.h" -#include "ui/wm/core/window_animations.h" - -namespace ash { - -WindowCycleList::WindowCycleList(const WindowList& windows) - : windows_(windows), - current_index_(-1) { - ash::Shell::GetInstance()->mru_window_tracker()->SetIgnoreActivations(true); - // Locate the currently active window in the list to use as our start point. - aura::Window* active_window = wm::GetActiveWindow(); - - // The active window may not be in the cycle list, which is expected if there - // are additional modal windows on the screen. - current_index_ = GetWindowIndex(active_window); - - for (WindowList::const_iterator i = windows_.begin(); i != windows_.end(); - ++i) { - (*i)->AddObserver(this); - } -} - -WindowCycleList::~WindowCycleList() { - ash::Shell::GetInstance()->mru_window_tracker()->SetIgnoreActivations(false); - for (WindowList::const_iterator i = windows_.begin(); i != windows_.end(); - ++i) { - (*i)->RemoveObserver(this); - } -} - -void WindowCycleList::Step(Direction direction) { - if (windows_.empty()) - return; - - if (current_index_ == -1) { - // We weren't able to find our active window in the shell delegate's - // provided window list. Just switch to the first (or last) one. - current_index_ = (direction == FORWARD ? 0 : windows_.size() - 1); - } else { - // When there is only one window, we should give a feedback to user. - if (windows_.size() == 1) { - AnimateWindow(windows_[0], - views::corewm::WINDOW_ANIMATION_TYPE_BOUNCE); - return; - } - // We're in a valid cycle, so step forward or backward. - current_index_ += (direction == FORWARD ? 1 : -1); - } - // Wrap to window list size. - current_index_ = (current_index_ + windows_.size()) % windows_.size(); - DCHECK(windows_[current_index_]); - // Make sure the next window is visible. - windows_[current_index_]->Show(); - wm::ActivateWindow(windows_[current_index_]); -} - -int WindowCycleList::GetWindowIndex(aura::Window* window) { - WindowList::const_iterator it = - std::find(windows_.begin(), windows_.end(), window); - if (it == windows_.end()) - return -1; // Not found. - return it - windows_.begin(); -} - -void WindowCycleList::OnWindowDestroyed(aura::Window* window) { - WindowList::iterator i = std::find(windows_.begin(), windows_.end(), window); - DCHECK(i != windows_.end()); - int removed_index = static_cast<int>(i - windows_.begin()); - windows_.erase(i); - if (current_index_ > removed_index) - current_index_--; - else if (current_index_ == static_cast<int>(windows_.size())) - current_index_--; -} - -} // namespace ash diff --git a/ash/wm/window_cycle_list.h b/ash/wm/window_cycle_list.h deleted file mode 100644 index 6e0c759..0000000 --- a/ash/wm/window_cycle_list.h +++ /dev/null @@ -1,59 +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. - -#ifndef ASH_WM_WINDOW_CYCLE_LIST_H_ -#define ASH_WM_WINDOW_CYCLE_LIST_H_ - -#include <vector> - -#include "ash/ash_export.h" -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "ui/aura/window_observer.h" - -namespace ash { - -// Tracks a set of Windows that can be stepped through. This class is used by -// the WindowCycleController. -class ASH_EXPORT WindowCycleList : public aura::WindowObserver { - public: - typedef std::vector<aura::Window*> WindowList; - - enum Direction { - FORWARD, - BACKWARD - }; - - explicit WindowCycleList(const WindowList& windows); - virtual ~WindowCycleList(); - - bool empty() const { return windows_.empty(); } - - // Cycles to the next or previous window based on |direction|. - void Step(Direction direction); - - const WindowList& windows() const { return windows_; } - - private: - // Returns the index of |window| in |windows_| or -1 if it isn't there. - int GetWindowIndex(aura::Window* window); - - // aura::WindowObserver overrides: - virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; - - // List of weak pointers to windows to use while cycling with the keyboard. - // List is built when the user initiates the gesture (e.g. hits alt-tab the - // first time) and is emptied when the gesture is complete (e.g. releases the - // alt key). - WindowList windows_; - - // Current position in the |windows_| list or -1 if we're not cycling. - int current_index_; - - DISALLOW_COPY_AND_ASSIGN(WindowCycleList); -}; - -} // namespace ash - -#endif // ASH_WM_WINDOW_CYCLE_LIST_H_ diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 9c4e01a..4edc8820 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -5992,18 +5992,6 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_OVERSCROLL_HISTORY_NAVIGATION_SIMPLE_UI" desc="Description for the simple UI for history navigation from horizontal overscroll."> Simple </message> - <message name="IDS_FLAGS_OVERVIEW_MODE_NAME" desc="Title for the flag to enable window overview mode."> - Enable overview mode. - </message> - <message name="IDS_FLAGS_OVERVIEW_MODE_DESCRIPTION" desc="Description for the flag to enable window overview mode."> - Enable overview mode, activated by pushing the switch window button. - </message> - <message name="IDS_FLAGS_DISABLE_OVERVIEW_MODE_NAME" desc="Title for the flag to disable window overview mode."> - Disable overview mode. - </message> - <message name="IDS_FLAGS_DISABLE_OVERVIEW_MODE_DESCRIPTION" desc="Description for the flag to disable window overview mode."> - Disable overview mode, activated by pushing the switch window button. - </message> <message name="IDS_FLAGS_SCROLL_END_EFFECT_NAME" desc="Title for the flag for scroll end effect from vertical overscroll."> Scroll end effect </message> diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index b1f19f2..d2ece63 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -1029,13 +1029,6 @@ const Experiment kExperiments[] = { SINGLE_VALUE_TYPE(switches::kDisableMinimizeOnSecondLauncherItemClick) }, { - "disable-overview-mode", - IDS_FLAGS_DISABLE_OVERVIEW_MODE_NAME, - IDS_FLAGS_DISABLE_OVERVIEW_MODE_DESCRIPTION, - kOsCrOS, - SINGLE_VALUE_TYPE(ash::switches::kAshDisableOverviewMode) - }, - { "show-touch-hud", IDS_FLAGS_SHOW_TOUCH_HUD_NAME, IDS_FLAGS_SHOW_TOUCH_HUD_DESCRIPTION, |