diff options
author | mtomasz@chromium.org <mtomasz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-06 04:19:55 +0000 |
---|---|---|
committer | mtomasz@chromium.org <mtomasz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-06 04:19:55 +0000 |
commit | 92337391a0ab28a38a77b20eb9d4d046dc961c86 (patch) | |
tree | 6f59ae8db91ba5f0620b34cfbb9a1b8ee8ce28d4 /ash | |
parent | f1c722e9adac7ffa3f3198c04ab43d3f1d039dd4 (diff) | |
download | chromium_src-92337391a0ab28a38a77b20eb9d4d046dc961c86.zip chromium_src-92337391a0ab28a38a77b20eb9d4d046dc961c86.tar.gz chromium_src-92337391a0ab28a38a77b20eb9d4d046dc961c86.tar.bz2 |
Fixed nonrepeative accelerators.
This patch fixes broken alt+(shift)+tab accelerator handling. In some situations pressing this accelerator did not invoke switching windows. This patch fixes that issue and significantly simplifies nonrepeative accelerators handling. Moreover, from now adding new nonrepeative accelerators will be very easy.
TEST=Open more than two windows, press alt+tab, release alt first then release tab. Press alt+tab again.
BUG=158213
Review URL: https://chromiumcodereview.appspot.com/11344008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166139 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/accelerators/accelerator_controller.cc | 96 | ||||
-rw-r--r-- | ash/accelerators/accelerator_controller.h | 44 | ||||
-rw-r--r-- | ash/accelerators/accelerator_controller_unittest.cc | 361 | ||||
-rw-r--r-- | ash/accelerators/accelerator_dispatcher.cc | 5 | ||||
-rw-r--r-- | ash/accelerators/accelerator_dispatcher.h | 3 | ||||
-rw-r--r-- | ash/accelerators/accelerator_filter.cc | 5 | ||||
-rw-r--r-- | ash/accelerators/accelerator_table.cc | 52 | ||||
-rw-r--r-- | ash/accelerators/accelerator_table.h | 21 | ||||
-rw-r--r-- | ash/wm/gestures/bezel_gesture_handler.cc | 9 | ||||
-rw-r--r-- | ash/wm/system_gesture_event_filter.cc | 7 |
10 files changed, 335 insertions, 268 deletions
diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc index be53ee6..b27a4eab 100644 --- a/ash/accelerators/accelerator_controller.cc +++ b/ash/accelerators/accelerator_controller.cc @@ -339,15 +339,28 @@ bool HandlePrintWindowHierarchy() { } // namespace //////////////////////////////////////////////////////////////////////////////// +// AcceleratorControllerContext, public: + +AcceleratorControllerContext::AcceleratorControllerContext() + : repeated_(false), + previous_event_type_(ui::ET_UNKNOWN) { +} + +void AcceleratorControllerContext::UpdateContext( + const ui::Accelerator& accelerator) { + const ui::Accelerator previous_accelerator = current_accelerator_; + current_accelerator_ = accelerator; + + // Compute contextual information. + repeated_ = previous_accelerator == current_accelerator_; + previous_event_type_ = previous_accelerator.type(); +} + +//////////////////////////////////////////////////////////////////////////////// // AcceleratorController, public: AcceleratorController::AcceleratorController() - : accelerator_manager_(new ui::AcceleratorManager), - toggle_maximized_suppressed_(false), - cycle_backward_linear_suppressed_(false), - cycle_forward_linear_suppressed_(false), - cycle_backward_mru_suppressed_(false), - cycle_forward_mru_suppressed_(false) { + : accelerator_manager_(new ui::AcceleratorManager) { Init(); } @@ -367,6 +380,8 @@ void AcceleratorController::Init() { actions_allowed_at_modal_window_.insert(kActionsAllowedAtModalWindow[i]); for (size_t i = 0; i < kReservedActionsLength; ++i) reserved_actions_.insert(kReservedActions[i]); + for (size_t i = 0; i < kNonrepeatableActionsLength; ++i) + nonrepeatable_actions_.insert(kNonrepeatableActions[i]); RegisterAccelerators(kAcceleratorData, kAcceleratorDataLength); @@ -448,63 +463,44 @@ bool AcceleratorController::PerformAction(int action, return true; } const ui::KeyboardCode key_code = accelerator.key_code(); - - const ui::AcceleratorManagerContext& context = - accelerator_manager_->GetContext(); - const ui::EventType last_event_type = context.GetLastEventType(); + // PerformAction() is performed from gesture controllers and passes + // empty Accelerator() instance as the second argument. Such events + // should never be suspended. + const bool gesture_event = key_code == ui::VKEY_UNKNOWN; + + // Ignore accelerators invoked as repeated (while holding a key for a long + // time, if their handling is nonrepeatable. + if (nonrepeatable_actions_.find(action) != nonrepeatable_actions_.end() && + context_.repeated() && !gesture_event) { + return true; + } + // Type of the previous accelerator. Used by NEXT_IME and DISABLE_CAPS_LOCK. + const ui::EventType previous_event_type = context_.previous_event_type(); // You *MUST* return true when some action is performed. Otherwise, this // function might be called *twice*, via BrowserView::PreHandleKeyboardEvent // and BrowserView::HandleKeyboardEvent, for a single accelerator press. switch (action) { - case CYCLE_BACKWARD_MRU_PRESSED: - if (cycle_backward_mru_suppressed_) - return true; - // Temporarily disable the feature until crbug.com/158213 is fixed. - // TODO(mtomasz): Reenable the feature. - // cycle_backward_mru_suppressed_ = true; + case CYCLE_BACKWARD_MRU: if (key_code == ui::VKEY_TAB && shell->delegate()) shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_PREVWINDOW_TAB); return HandleCycleWindowMRU(WindowCycleController::BACKWARD, accelerator.IsAltDown()); - case CYCLE_BACKWARD_MRU_RELEASED: - cycle_backward_mru_suppressed_ = false; - return true; - case CYCLE_FORWARD_MRU_PRESSED: - if (cycle_forward_mru_suppressed_) - return true; - // Temporarily disable the feature until crbug.com/158213 is fixed. - // TODO(mtomasz): Reenable the feature. - // cycle_forward_mru_suppressed_ = true; + case CYCLE_FORWARD_MRU: if (key_code == ui::VKEY_TAB && shell->delegate()) shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_NEXTWINDOW_TAB); return HandleCycleWindowMRU(WindowCycleController::FORWARD, accelerator.IsAltDown()); - case CYCLE_FORWARD_MRU_RELEASED: - cycle_forward_mru_suppressed_ = false; - return true; - case CYCLE_BACKWARD_LINEAR_PRESSED: - if (cycle_backward_linear_suppressed_) - return true; - cycle_backward_linear_suppressed_ = true; + case CYCLE_BACKWARD_LINEAR: if (key_code == ui::VKEY_F5 && shell->delegate()) shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_PREVWINDOW_F5); HandleCycleWindowLinear(CYCLE_BACKWARD); return true; - case CYCLE_BACKWARD_LINEAR_RELEASED: - cycle_backward_linear_suppressed_ = false; - return true; - case CYCLE_FORWARD_LINEAR_PRESSED: - if (cycle_forward_linear_suppressed_) - return true; - cycle_forward_linear_suppressed_ = true; + case CYCLE_FORWARD_LINEAR: if (key_code == ui::VKEY_F5 && shell->delegate()) shell->delegate()->RecordUserMetricsAction(UMA_ACCEL_NEXTWINDOW_F5); HandleCycleWindowLinear(CYCLE_FORWARD); return true; - case CYCLE_FORWARD_LINEAR_RELEASED: - cycle_forward_linear_suppressed_ = false; - return true; #if defined(OS_CHROMEOS) case CYCLE_DISPLAY_MODE: HandleCycleDisplayMode(); @@ -570,7 +566,7 @@ bool AcceleratorController::PerformAction(int action, return true; case DISABLE_CAPS_LOCK: // See: case NEXT_IME. - if (last_event_type == ui::ET_KEY_RELEASED) { + if (previous_event_type == ui::ET_KEY_RELEASED) { // We totally ignore this accelerator. return false; } @@ -646,8 +642,9 @@ bool AcceleratorController::PerformAction(int action, // ET_KEY_RELEASED accelerator for Chrome OS (see ash/accelerators/ // accelerator_controller.cc) when Shift+Alt+Tab is pressed and then Tab // is released. - if (last_event_type == ui::ET_KEY_RELEASED) { + if (previous_event_type == ui::ET_KEY_RELEASED) { // We totally ignore this accelerator. + // TODO(mazda): Fix crbug.com/158217 return false; } if (ime_control_delegate_.get()) @@ -735,12 +732,7 @@ bool AcceleratorController::PerformAction(int action, } break; } - case TOGGLE_MAXIMIZED_PRESSED: { - // We do not want to toggle maximization on the acceleration key - // repeating. - if (toggle_maximized_suppressed_) - return true; - toggle_maximized_suppressed_ = true; + case TOGGLE_MAXIMIZED: { if (key_code == ui::VKEY_F4 && shell->delegate()) { shell->delegate()->RecordUserMetricsAction( UMA_ACCEL_MAXIMIZE_RESTORE_F4); @@ -748,10 +740,6 @@ bool AcceleratorController::PerformAction(int action, shell->delegate()->ToggleMaximized(); return true; } - case TOGGLE_MAXIMIZED_RELEASED: { - toggle_maximized_suppressed_ = false; - return true; - } case WINDOW_POSITION_CENTER: { aura::Window* window = wm::GetActiveWindow(); if (window) { diff --git a/ash/accelerators/accelerator_controller.h b/ash/accelerators/accelerator_controller.h index 6528a67..dd099ee 100644 --- a/ash/accelerators/accelerator_controller.h +++ b/ash/accelerators/accelerator_controller.h @@ -28,6 +28,33 @@ class KeyboardBrightnessControlDelegate; class ScreenshotDelegate; class VolumeControlDelegate; +// Stores information about accelerator context, eg. previous accelerator +// or if the current accelerator is repeated or not. +class ASH_EXPORT AcceleratorControllerContext { + public: + AcceleratorControllerContext(); + ~AcceleratorControllerContext() {} + + // Updates context - determines if the accelerator is repeated, as well as + // event type of the previous accelerator. + void UpdateContext(const ui::Accelerator& accelerator); + + ui::EventType previous_event_type() const { return previous_event_type_; } + bool repeated() const { return repeated_; } + + private: + ui::Accelerator current_accelerator_; + + // If the current accelerator was repeated. + bool repeated_; + + // Event type of the previous accelerator. Used for NEXT_IME and + // DISABLE_CAPS_LOCK accelerator actions. + ui::EventType previous_event_type_; + + DISALLOW_COPY_AND_ASSIGN(AcceleratorControllerContext); +}; + // AcceleratorController provides functions for registering or unregistering // global keyboard accelerators, which are handled earlier than any windows. It // also implements several handlers as an accelerator target. @@ -83,6 +110,11 @@ class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget { return brightness_control_delegate_.get(); } + // Provides access to an object holding contextual information. + AcceleratorControllerContext* context() { + return &context_; + } + private: FRIEND_TEST_ALL_PREFIXES(AcceleratorControllerTest, GlobalAccelerators); @@ -111,6 +143,9 @@ class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget { keyboard_brightness_control_delegate_; scoped_ptr<ScreenshotDelegate> screenshot_delegate_; + // Contextual information, eg. if the current accelerator is repeated. + AcceleratorControllerContext context_; + // A map from accelerators to the AcceleratorAction values, which are used in // the implementation. std::map<ui::Accelerator, int> accelerators_; @@ -123,13 +158,8 @@ class ASH_EXPORT AcceleratorController : public ui::AcceleratorTarget { std::set<int> actions_allowed_at_modal_window_; // Reserved actions. See accelerator_table.h for details. std::set<int> reserved_actions_; - - // Used to suppress accelerator handling on key repeat. - bool toggle_maximized_suppressed_; - bool cycle_backward_linear_suppressed_; - bool cycle_forward_linear_suppressed_; - bool cycle_backward_mru_suppressed_; - bool cycle_forward_mru_suppressed_; + // Actions which will not be repeated while holding the accelerator key. + std::set<int> nonrepeatable_actions_; DISALLOW_COPY_AND_ASSIGN(AcceleratorController); }; diff --git a/ash/accelerators/accelerator_controller_unittest.cc b/ash/accelerators/accelerator_controller_unittest.cc index 15b17d9..69977c3 100644 --- a/ash/accelerators/accelerator_controller_unittest.cc +++ b/ash/accelerators/accelerator_controller_unittest.cc @@ -320,6 +320,7 @@ class AcceleratorControllerTest : public test::AshTestBase { } static AcceleratorController* GetController(); + static bool ProcessWithContext(const ui::Accelerator& accelerator); private: DISALLOW_COPY_AND_ASSIGN(AcceleratorControllerTest); @@ -329,13 +330,20 @@ AcceleratorController* AcceleratorControllerTest::GetController() { return Shell::GetInstance()->accelerator_controller(); } +bool AcceleratorControllerTest::ProcessWithContext( + const ui::Accelerator& accelerator) { + AcceleratorController* controller = GetController(); + controller->context()->UpdateContext(accelerator); + return controller->Process(accelerator); +} + TEST_F(AcceleratorControllerTest, Register) { const ui::Accelerator accelerator_a(ui::VKEY_A, ui::EF_NONE); TestTarget target; GetController()->Register(accelerator_a, &target); // The registered accelerator is processed. - EXPECT_TRUE(GetController()->Process(accelerator_a)); + EXPECT_TRUE(ProcessWithContext(accelerator_a)); EXPECT_EQ(1, target.accelerator_pressed_count()); } @@ -348,7 +356,7 @@ TEST_F(AcceleratorControllerTest, RegisterMultipleTarget) { // If multiple targets are registered with the same accelerator, the target // registered later processes the accelerator. - EXPECT_TRUE(GetController()->Process(accelerator_a)); + EXPECT_TRUE(ProcessWithContext(accelerator_a)); EXPECT_EQ(0, target1.accelerator_pressed_count()); EXPECT_EQ(1, target2.accelerator_pressed_count()); } @@ -363,13 +371,13 @@ TEST_F(AcceleratorControllerTest, Unregister) { // Unregistering a different accelerator does not affect the other // accelerator. GetController()->Unregister(accelerator_b, &target); - EXPECT_TRUE(GetController()->Process(accelerator_a)); + EXPECT_TRUE(ProcessWithContext(accelerator_a)); EXPECT_EQ(1, target.accelerator_pressed_count()); // The unregistered accelerator is no longer processed. target.set_accelerator_pressed_count(0); GetController()->Unregister(accelerator_a, &target); - EXPECT_FALSE(GetController()->Process(accelerator_a)); + EXPECT_FALSE(ProcessWithContext(accelerator_a)); EXPECT_EQ(0, target.accelerator_pressed_count()); } @@ -385,12 +393,12 @@ TEST_F(AcceleratorControllerTest, UnregisterAll) { GetController()->UnregisterAll(&target1); // All the accelerators registered for |target1| are no longer processed. - EXPECT_FALSE(GetController()->Process(accelerator_a)); - EXPECT_FALSE(GetController()->Process(accelerator_b)); + EXPECT_FALSE(ProcessWithContext(accelerator_a)); + EXPECT_FALSE(ProcessWithContext(accelerator_b)); EXPECT_EQ(0, target1.accelerator_pressed_count()); // UnregisterAll with a different target does not affect the other target. - EXPECT_TRUE(GetController()->Process(accelerator_c)); + EXPECT_TRUE(ProcessWithContext(accelerator_c)); EXPECT_EQ(1, target2.accelerator_pressed_count()); } @@ -400,12 +408,12 @@ TEST_F(AcceleratorControllerTest, Process) { GetController()->Register(accelerator_a, &target1); // The registered accelerator is processed. - EXPECT_TRUE(GetController()->Process(accelerator_a)); + EXPECT_TRUE(ProcessWithContext(accelerator_a)); EXPECT_EQ(1, target1.accelerator_pressed_count()); // The non-registered accelerator is not processed. const ui::Accelerator accelerator_b(ui::VKEY_B, ui::EF_NONE); - EXPECT_FALSE(GetController()->Process(accelerator_b)); + EXPECT_FALSE(ProcessWithContext(accelerator_b)); } TEST_F(AcceleratorControllerTest, IsRegistered) { @@ -449,33 +457,23 @@ TEST_F(AcceleratorControllerTest, WindowSnap) { { gfx::Rect normal_bounds = window->bounds(); - GetController()->PerformAction(TOGGLE_MAXIMIZED_RELEASED, dummy); - GetController()->PerformAction(TOGGLE_MAXIMIZED_PRESSED, dummy); + GetController()->PerformAction(TOGGLE_MAXIMIZED, dummy); EXPECT_TRUE(wm::IsWindowMaximized(window.get())); EXPECT_NE(normal_bounds.ToString(), window->bounds().ToString()); - GetController()->PerformAction(TOGGLE_MAXIMIZED_PRESSED, dummy); - EXPECT_TRUE(wm::IsWindowMaximized(window.get())); - EXPECT_NE(normal_bounds.ToString(), window->bounds().ToString()); - - GetController()->PerformAction(TOGGLE_MAXIMIZED_RELEASED, dummy); - GetController()->PerformAction(TOGGLE_MAXIMIZED_PRESSED, dummy); + GetController()->PerformAction(TOGGLE_MAXIMIZED, dummy); EXPECT_FALSE(wm::IsWindowMaximized(window.get())); EXPECT_EQ(normal_bounds.ToString(), window->bounds().ToString()); - GetController()->PerformAction(TOGGLE_MAXIMIZED_RELEASED, dummy); - GetController()->PerformAction(TOGGLE_MAXIMIZED_PRESSED, dummy); + GetController()->PerformAction(TOGGLE_MAXIMIZED, dummy); GetController()->PerformAction(WINDOW_SNAP_LEFT, dummy); EXPECT_FALSE(wm::IsWindowMaximized(window.get())); - GetController()->PerformAction(TOGGLE_MAXIMIZED_RELEASED, dummy); - GetController()->PerformAction(TOGGLE_MAXIMIZED_PRESSED, dummy); + GetController()->PerformAction(TOGGLE_MAXIMIZED, dummy); GetController()->PerformAction(WINDOW_SNAP_RIGHT, dummy); EXPECT_FALSE(wm::IsWindowMaximized(window.get())); - GetController()->PerformAction(TOGGLE_MAXIMIZED_RELEASED, dummy); - GetController()->PerformAction(TOGGLE_MAXIMIZED_PRESSED, dummy); - GetController()->PerformAction(TOGGLE_MAXIMIZED_RELEASED, dummy); + GetController()->PerformAction(TOGGLE_MAXIMIZED, dummy); EXPECT_TRUE(wm::IsWindowMaximized(window.get())); GetController()->PerformAction(WINDOW_MINIMIZE, dummy); EXPECT_FALSE(wm::IsWindowMaximized(window.get())); @@ -489,6 +487,61 @@ TEST_F(AcceleratorControllerTest, WindowSnap) { } } +TEST_F(AcceleratorControllerTest, ControllerContext) { + ui::Accelerator accelerator_a(ui::VKEY_A, ui::EF_NONE); + ui::Accelerator accelerator_a2(ui::VKEY_A, ui::EF_NONE); + ui::Accelerator accelerator_b(ui::VKEY_B, ui::EF_NONE); + + accelerator_a.set_type(ui::ET_KEY_PRESSED); + accelerator_a2.set_type(ui::ET_KEY_RELEASED); + accelerator_b.set_type(ui::ET_KEY_PRESSED); + + EXPECT_FALSE(GetController()->context()->repeated()); + EXPECT_EQ(ui::ET_UNKNOWN, GetController()->context()->previous_event_type()); + + GetController()->context()->UpdateContext(accelerator_a); + EXPECT_FALSE(GetController()->context()->repeated()); + EXPECT_EQ(ui::ET_KEY_PRESSED, + GetController()->context()->previous_event_type()); + + GetController()->context()->UpdateContext(accelerator_a2); + EXPECT_FALSE(GetController()->context()->repeated()); + EXPECT_EQ(ui::ET_KEY_PRESSED, + GetController()->context()->previous_event_type()); + + GetController()->context()->UpdateContext(accelerator_a2); + EXPECT_TRUE(GetController()->context()->repeated()); + EXPECT_EQ(ui::ET_KEY_RELEASED, + GetController()->context()->previous_event_type()); + + GetController()->context()->UpdateContext(accelerator_b); + EXPECT_FALSE(GetController()->context()->repeated()); + EXPECT_EQ(ui::ET_KEY_RELEASED, + GetController()->context()->previous_event_type()); +} + +TEST_F(AcceleratorControllerTest, SuppressToggleMaximized) { + scoped_ptr<aura::Window> window( + aura::test::CreateTestWindowWithBounds(gfx::Rect(5, 5, 20, 20), NULL)); + wm::ActivateWindow(window.get()); + const ui::Accelerator accelerator(ui::VKEY_A, ui::EF_NONE); + const ui::Accelerator empty_accelerator; + + // Toggling not suppressed. + GetController()->context()->UpdateContext(accelerator); + GetController()->PerformAction(TOGGLE_MAXIMIZED, accelerator); + EXPECT_TRUE(wm::IsWindowMaximized(window.get())); + + // The same accelerator - toggling suppressed. + GetController()->context()->UpdateContext(accelerator); + GetController()->PerformAction(TOGGLE_MAXIMIZED, accelerator); + EXPECT_TRUE(wm::IsWindowMaximized(window.get())); + + // Suppressed but not for gesture events. + GetController()->PerformAction(TOGGLE_MAXIMIZED, empty_accelerator); + EXPECT_FALSE(wm::IsWindowMaximized(window.get())); +} + #if defined(OS_WIN) || defined(USE_X11) TEST_F(AcceleratorControllerTest, ProcessOnce) { ui::Accelerator accelerator_a(ui::VKEY_A, ui::EF_NONE); @@ -539,39 +592,39 @@ TEST_F(AcceleratorControllerTest, ProcessOnce) { TEST_F(AcceleratorControllerTest, GlobalAccelerators) { // CycleBackward - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_TAB, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN))); // CycleForward - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_TAB, ui::EF_ALT_DOWN))); #if defined(OS_CHROMEOS) // CycleBackward - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_F5, ui::EF_SHIFT_DOWN))); // CycleForward - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_F5, ui::EF_NONE))); // Take screenshot / partial screenshot // True should always be returned regardless of the existence of the delegate. { - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_F5, ui::EF_CONTROL_DOWN))); - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_PRINT, ui::EF_NONE))); - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_F5, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); DummyScreenshotDelegate* delegate = new DummyScreenshotDelegate; GetController()->SetScreenshotDelegate( scoped_ptr<ScreenshotDelegate>(delegate).Pass()); EXPECT_EQ(0, delegate->handle_take_screenshot_count()); - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_F5, ui::EF_CONTROL_DOWN))); EXPECT_EQ(1, delegate->handle_take_screenshot_count()); - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_PRINT, ui::EF_NONE))); EXPECT_EQ(2, delegate->handle_take_screenshot_count()); - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_F5, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); EXPECT_EQ(2, delegate->handle_take_screenshot_count()); } @@ -579,10 +632,10 @@ TEST_F(AcceleratorControllerTest, GlobalAccelerators) { // ToggleAppList { EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); EXPECT_TRUE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); } @@ -590,10 +643,10 @@ TEST_F(AcceleratorControllerTest, GlobalAccelerators) { { ShellDelegate* delegate = ash::Shell::GetInstance()->delegate(); delegate->ToggleSpokenFeedback(); - EXPECT_FALSE(GetController()->Process( + EXPECT_FALSE(ProcessWithContext( ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); delegate->ToggleSpokenFeedback(); - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); } // DisableCapsLock @@ -602,49 +655,49 @@ TEST_F(AcceleratorControllerTest, GlobalAccelerators) { delegate->SetCapsLockEnabled(true); EXPECT_TRUE(delegate->IsCapsLockEnabled()); // Handled only on key release. - EXPECT_FALSE(GetController()->Process( + EXPECT_FALSE(ProcessWithContext( ui::Accelerator(ui::VKEY_LSHIFT, ui::EF_NONE))); EXPECT_TRUE(delegate->IsCapsLockEnabled()); - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ReleaseAccelerator(ui::VKEY_SHIFT, ui::EF_NONE))); EXPECT_FALSE(delegate->IsCapsLockEnabled()); delegate->SetCapsLockEnabled(true); - EXPECT_FALSE(GetController()->Process( + EXPECT_FALSE(ProcessWithContext( ui::Accelerator(ui::VKEY_RSHIFT, ui::EF_NONE))); EXPECT_TRUE(delegate->IsCapsLockEnabled()); - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ReleaseAccelerator(ui::VKEY_LSHIFT, ui::EF_NONE))); EXPECT_FALSE(delegate->IsCapsLockEnabled()); delegate->SetCapsLockEnabled(true); - EXPECT_FALSE(GetController()->Process( + EXPECT_FALSE(ProcessWithContext( ui::Accelerator(ui::VKEY_SHIFT, ui::EF_NONE))); EXPECT_TRUE(delegate->IsCapsLockEnabled()); - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ReleaseAccelerator(ui::VKEY_RSHIFT, ui::EF_NONE))); EXPECT_FALSE(delegate->IsCapsLockEnabled()); // Do not handle when a shift pressed with other keys. delegate->SetCapsLockEnabled(true); - EXPECT_FALSE(GetController()->Process( + EXPECT_FALSE(ProcessWithContext( ui::Accelerator(ui::VKEY_A, ui::EF_SHIFT_DOWN))); EXPECT_TRUE(delegate->IsCapsLockEnabled()); - EXPECT_FALSE(GetController()->Process( + EXPECT_FALSE(ProcessWithContext( ReleaseAccelerator(ui::VKEY_A, ui::EF_SHIFT_DOWN))); EXPECT_TRUE(delegate->IsCapsLockEnabled()); // Do not consume shift keyup when caps lock is off. delegate->SetCapsLockEnabled(false); - EXPECT_FALSE(GetController()->Process( + EXPECT_FALSE(ProcessWithContext( ui::Accelerator(ui::VKEY_LSHIFT, ui::EF_NONE))); - EXPECT_FALSE(GetController()->Process( + EXPECT_FALSE(ProcessWithContext( ReleaseAccelerator(ui::VKEY_LSHIFT, ui::EF_NONE))); - EXPECT_FALSE(GetController()->Process( + EXPECT_FALSE(ProcessWithContext( ui::Accelerator(ui::VKEY_RSHIFT, ui::EF_NONE))); - EXPECT_FALSE(GetController()->Process( + EXPECT_FALSE(ProcessWithContext( ReleaseAccelerator(ui::VKEY_RSHIFT, ui::EF_NONE))); - EXPECT_FALSE(GetController()->Process( + EXPECT_FALSE(ProcessWithContext( ui::Accelerator(ui::VKEY_SHIFT, ui::EF_NONE))); - EXPECT_FALSE(GetController()->Process( + EXPECT_FALSE(ProcessWithContext( ReleaseAccelerator(ui::VKEY_SHIFT, ui::EF_NONE))); } // ToggleCapsLock @@ -652,10 +705,10 @@ TEST_F(AcceleratorControllerTest, GlobalAccelerators) { CapsLockDelegate* delegate = Shell::GetInstance()->caps_lock_delegate(); delegate->SetCapsLockEnabled(true); EXPECT_TRUE(delegate->IsCapsLockEnabled()); - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_LWIN, ui::EF_ALT_DOWN))); EXPECT_FALSE(delegate->IsCapsLockEnabled()); - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_LWIN, ui::EF_ALT_DOWN))); EXPECT_TRUE(delegate->IsCapsLockEnabled()); } @@ -665,23 +718,23 @@ TEST_F(AcceleratorControllerTest, GlobalAccelerators) { const ui::Accelerator f9(ui::VKEY_F9, ui::EF_NONE); const ui::Accelerator f10(ui::VKEY_F10, ui::EF_NONE); { - EXPECT_TRUE(GetController()->Process(f8)); - EXPECT_TRUE(GetController()->Process(f9)); - EXPECT_TRUE(GetController()->Process(f10)); + EXPECT_TRUE(ProcessWithContext(f8)); + EXPECT_TRUE(ProcessWithContext(f9)); + EXPECT_TRUE(ProcessWithContext(f10)); DummyVolumeControlDelegate* delegate = new DummyVolumeControlDelegate(false); ash::Shell::GetInstance()->tray_delegate()->SetVolumeControlDelegate( scoped_ptr<VolumeControlDelegate>(delegate).Pass()); EXPECT_EQ(0, delegate->handle_volume_mute_count()); - EXPECT_FALSE(GetController()->Process(f8)); + EXPECT_FALSE(ProcessWithContext(f8)); EXPECT_EQ(1, delegate->handle_volume_mute_count()); EXPECT_EQ(f8, delegate->last_accelerator()); EXPECT_EQ(0, delegate->handle_volume_down_count()); - EXPECT_FALSE(GetController()->Process(f9)); + EXPECT_FALSE(ProcessWithContext(f9)); EXPECT_EQ(1, delegate->handle_volume_down_count()); EXPECT_EQ(f9, delegate->last_accelerator()); EXPECT_EQ(0, delegate->handle_volume_up_count()); - EXPECT_FALSE(GetController()->Process(f10)); + EXPECT_FALSE(ProcessWithContext(f10)); EXPECT_EQ(1, delegate->handle_volume_up_count()); EXPECT_EQ(f10, delegate->last_accelerator()); } @@ -690,15 +743,15 @@ TEST_F(AcceleratorControllerTest, GlobalAccelerators) { ash::Shell::GetInstance()->tray_delegate()->SetVolumeControlDelegate( scoped_ptr<VolumeControlDelegate>(delegate).Pass()); EXPECT_EQ(0, delegate->handle_volume_mute_count()); - EXPECT_TRUE(GetController()->Process(f8)); + EXPECT_TRUE(ProcessWithContext(f8)); EXPECT_EQ(1, delegate->handle_volume_mute_count()); EXPECT_EQ(f8, delegate->last_accelerator()); EXPECT_EQ(0, delegate->handle_volume_down_count()); - EXPECT_TRUE(GetController()->Process(f9)); + EXPECT_TRUE(ProcessWithContext(f9)); EXPECT_EQ(1, delegate->handle_volume_down_count()); EXPECT_EQ(f9, delegate->last_accelerator()); EXPECT_EQ(0, delegate->handle_volume_up_count()); - EXPECT_TRUE(GetController()->Process(f10)); + EXPECT_TRUE(ProcessWithContext(f10)); EXPECT_EQ(1, delegate->handle_volume_up_count()); EXPECT_EQ(f10, delegate->last_accelerator()); } @@ -712,15 +765,15 @@ TEST_F(AcceleratorControllerTest, GlobalAccelerators) { ash::Shell::GetInstance()->tray_delegate()->SetVolumeControlDelegate( scoped_ptr<VolumeControlDelegate>(delegate).Pass()); EXPECT_EQ(0, delegate->handle_volume_mute_count()); - EXPECT_FALSE(GetController()->Process(volume_mute)); + EXPECT_FALSE(ProcessWithContext(volume_mute)); EXPECT_EQ(1, delegate->handle_volume_mute_count()); EXPECT_EQ(volume_mute, delegate->last_accelerator()); EXPECT_EQ(0, delegate->handle_volume_down_count()); - EXPECT_FALSE(GetController()->Process(volume_down)); + EXPECT_FALSE(ProcessWithContext(volume_down)); EXPECT_EQ(1, delegate->handle_volume_down_count()); EXPECT_EQ(volume_down, delegate->last_accelerator()); EXPECT_EQ(0, delegate->handle_volume_up_count()); - EXPECT_FALSE(GetController()->Process(volume_up)); + EXPECT_FALSE(ProcessWithContext(volume_up)); EXPECT_EQ(1, delegate->handle_volume_up_count()); EXPECT_EQ(volume_up, delegate->last_accelerator()); } @@ -729,15 +782,15 @@ TEST_F(AcceleratorControllerTest, GlobalAccelerators) { ash::Shell::GetInstance()->tray_delegate()->SetVolumeControlDelegate( scoped_ptr<VolumeControlDelegate>(delegate).Pass()); EXPECT_EQ(0, delegate->handle_volume_mute_count()); - EXPECT_TRUE(GetController()->Process(volume_mute)); + EXPECT_TRUE(ProcessWithContext(volume_mute)); EXPECT_EQ(1, delegate->handle_volume_mute_count()); EXPECT_EQ(volume_mute, delegate->last_accelerator()); EXPECT_EQ(0, delegate->handle_volume_down_count()); - EXPECT_TRUE(GetController()->Process(volume_down)); + EXPECT_TRUE(ProcessWithContext(volume_down)); EXPECT_EQ(1, delegate->handle_volume_down_count()); EXPECT_EQ(volume_down, delegate->last_accelerator()); EXPECT_EQ(0, delegate->handle_volume_up_count()); - EXPECT_TRUE(GetController()->Process(volume_up)); + EXPECT_TRUE(ProcessWithContext(volume_up)); EXPECT_EQ(1, delegate->handle_volume_up_count()); EXPECT_EQ(volume_up, delegate->last_accelerator()); } @@ -746,30 +799,30 @@ TEST_F(AcceleratorControllerTest, GlobalAccelerators) { const ui::Accelerator f6(ui::VKEY_F6, ui::EF_NONE); const ui::Accelerator f7(ui::VKEY_F7, ui::EF_NONE); { - EXPECT_FALSE(GetController()->Process(f6)); - EXPECT_FALSE(GetController()->Process(f7)); + EXPECT_FALSE(ProcessWithContext(f6)); + EXPECT_FALSE(ProcessWithContext(f7)); DummyBrightnessControlDelegate* delegate = new DummyBrightnessControlDelegate(true); GetController()->SetBrightnessControlDelegate( scoped_ptr<BrightnessControlDelegate>(delegate).Pass()); - EXPECT_FALSE(GetController()->Process(f6)); - EXPECT_FALSE(GetController()->Process(f7)); + EXPECT_FALSE(ProcessWithContext(f6)); + EXPECT_FALSE(ProcessWithContext(f7)); } // Enable internal display. EnableInternalDisplay(); { - EXPECT_FALSE(GetController()->Process(f6)); - EXPECT_FALSE(GetController()->Process(f7)); + EXPECT_FALSE(ProcessWithContext(f6)); + EXPECT_FALSE(ProcessWithContext(f7)); DummyBrightnessControlDelegate* delegate = new DummyBrightnessControlDelegate(false); GetController()->SetBrightnessControlDelegate( scoped_ptr<BrightnessControlDelegate>(delegate).Pass()); EXPECT_EQ(0, delegate->handle_brightness_down_count()); - EXPECT_FALSE(GetController()->Process(f6)); + EXPECT_FALSE(ProcessWithContext(f6)); EXPECT_EQ(1, delegate->handle_brightness_down_count()); EXPECT_EQ(f6, delegate->last_accelerator()); EXPECT_EQ(0, delegate->handle_brightness_up_count()); - EXPECT_FALSE(GetController()->Process(f7)); + EXPECT_FALSE(ProcessWithContext(f7)); EXPECT_EQ(1, delegate->handle_brightness_up_count()); EXPECT_EQ(f7, delegate->last_accelerator()); } @@ -779,11 +832,11 @@ TEST_F(AcceleratorControllerTest, GlobalAccelerators) { GetController()->SetBrightnessControlDelegate( scoped_ptr<BrightnessControlDelegate>(delegate).Pass()); EXPECT_EQ(0, delegate->handle_brightness_down_count()); - EXPECT_TRUE(GetController()->Process(f6)); + EXPECT_TRUE(ProcessWithContext(f6)); EXPECT_EQ(1, delegate->handle_brightness_down_count()); EXPECT_EQ(f6, delegate->last_accelerator()); EXPECT_EQ(0, delegate->handle_brightness_up_count()); - EXPECT_TRUE(GetController()->Process(f7)); + EXPECT_TRUE(ProcessWithContext(f7)); EXPECT_EQ(1, delegate->handle_brightness_up_count()); EXPECT_EQ(f7, delegate->last_accelerator()); } @@ -796,11 +849,11 @@ TEST_F(AcceleratorControllerTest, GlobalAccelerators) { GetController()->SetBrightnessControlDelegate( scoped_ptr<BrightnessControlDelegate>(delegate).Pass()); EXPECT_EQ(0, delegate->handle_brightness_down_count()); - EXPECT_FALSE(GetController()->Process(brightness_down)); + EXPECT_FALSE(ProcessWithContext(brightness_down)); EXPECT_EQ(1, delegate->handle_brightness_down_count()); EXPECT_EQ(brightness_down, delegate->last_accelerator()); EXPECT_EQ(0, delegate->handle_brightness_up_count()); - EXPECT_FALSE(GetController()->Process(brightness_up)); + EXPECT_FALSE(ProcessWithContext(brightness_up)); EXPECT_EQ(1, delegate->handle_brightness_up_count()); EXPECT_EQ(brightness_up, delegate->last_accelerator()); } @@ -810,11 +863,11 @@ TEST_F(AcceleratorControllerTest, GlobalAccelerators) { GetController()->SetBrightnessControlDelegate( scoped_ptr<BrightnessControlDelegate>(delegate).Pass()); EXPECT_EQ(0, delegate->handle_brightness_down_count()); - EXPECT_TRUE(GetController()->Process(brightness_down)); + EXPECT_TRUE(ProcessWithContext(brightness_down)); EXPECT_EQ(1, delegate->handle_brightness_down_count()); EXPECT_EQ(brightness_down, delegate->last_accelerator()); EXPECT_EQ(0, delegate->handle_brightness_up_count()); - EXPECT_TRUE(GetController()->Process(brightness_up)); + EXPECT_TRUE(ProcessWithContext(brightness_up)); EXPECT_EQ(1, delegate->handle_brightness_up_count()); EXPECT_EQ(brightness_up, delegate->last_accelerator()); } @@ -823,18 +876,18 @@ TEST_F(AcceleratorControllerTest, GlobalAccelerators) { const ui::Accelerator alt_f6(ui::VKEY_F6, ui::EF_ALT_DOWN); const ui::Accelerator alt_f7(ui::VKEY_F7, ui::EF_ALT_DOWN); { - EXPECT_TRUE(GetController()->Process(alt_f6)); - EXPECT_TRUE(GetController()->Process(alt_f7)); + EXPECT_TRUE(ProcessWithContext(alt_f6)); + EXPECT_TRUE(ProcessWithContext(alt_f7)); DummyKeyboardBrightnessControlDelegate* delegate = new DummyKeyboardBrightnessControlDelegate(false); GetController()->SetKeyboardBrightnessControlDelegate( scoped_ptr<KeyboardBrightnessControlDelegate>(delegate).Pass()); EXPECT_EQ(0, delegate->handle_keyboard_brightness_down_count()); - EXPECT_FALSE(GetController()->Process(alt_f6)); + EXPECT_FALSE(ProcessWithContext(alt_f6)); EXPECT_EQ(1, delegate->handle_keyboard_brightness_down_count()); EXPECT_EQ(alt_f6, delegate->last_accelerator()); EXPECT_EQ(0, delegate->handle_keyboard_brightness_up_count()); - EXPECT_FALSE(GetController()->Process(alt_f7)); + EXPECT_FALSE(ProcessWithContext(alt_f7)); EXPECT_EQ(1, delegate->handle_keyboard_brightness_up_count()); EXPECT_EQ(alt_f7, delegate->last_accelerator()); } @@ -844,11 +897,11 @@ TEST_F(AcceleratorControllerTest, GlobalAccelerators) { GetController()->SetKeyboardBrightnessControlDelegate( scoped_ptr<KeyboardBrightnessControlDelegate>(delegate).Pass()); EXPECT_EQ(0, delegate->handle_keyboard_brightness_down_count()); - EXPECT_TRUE(GetController()->Process(alt_f6)); + EXPECT_TRUE(ProcessWithContext(alt_f6)); EXPECT_EQ(1, delegate->handle_keyboard_brightness_down_count()); EXPECT_EQ(alt_f6, delegate->last_accelerator()); EXPECT_EQ(0, delegate->handle_keyboard_brightness_up_count()); - EXPECT_TRUE(GetController()->Process(alt_f7)); + EXPECT_TRUE(ProcessWithContext(alt_f7)); EXPECT_EQ(1, delegate->handle_keyboard_brightness_up_count()); EXPECT_EQ(alt_f7, delegate->last_accelerator()); } @@ -856,56 +909,56 @@ TEST_F(AcceleratorControllerTest, GlobalAccelerators) { #if !defined(NDEBUG) // RotateScreen - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_HOME, ui::EF_CONTROL_DOWN))); // ToggleDesktopBackgroundMode - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_B, ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN))); #if !defined(OS_LINUX) // ToggleDesktopFullScreen (not implemented yet on Linux) - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_F11, ui::EF_CONTROL_DOWN))); #endif // OS_LINUX #endif // !NDEBUG // Exit - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_Q, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); // New tab - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_T, ui::EF_CONTROL_DOWN))); // New incognito window - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_N, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); // New window - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_N, ui::EF_CONTROL_DOWN))); // Restore tab - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_T, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); // Show task manager - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_SHIFT_DOWN))); #if defined(OS_CHROMEOS) // Open file manager dialog - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_O, ui::EF_CONTROL_DOWN))); // Open file manager tab - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_M, ui::EF_CONTROL_DOWN))); // Lock screen // NOTE: Accelerators that do not work on the lock screen need to be // tested before the sequence below is invoked because it causes a side // effect of locking the screen. - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_L, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); #endif } @@ -919,28 +972,28 @@ TEST_F(AcceleratorControllerTest, ImeGlobalAccelerators) { const ui::Accelerator wide_half_1(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE); const ui::Accelerator wide_half_2(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE); const ui::Accelerator hangul(ui::VKEY_HANGUL, ui::EF_NONE); - EXPECT_FALSE(GetController()->Process(control_space)); - EXPECT_FALSE(GetController()->Process(convert)); - EXPECT_FALSE(GetController()->Process(non_convert)); - EXPECT_FALSE(GetController()->Process(wide_half_1)); - EXPECT_FALSE(GetController()->Process(wide_half_2)); - EXPECT_FALSE(GetController()->Process(hangul)); + EXPECT_FALSE(ProcessWithContext(control_space)); + EXPECT_FALSE(ProcessWithContext(convert)); + EXPECT_FALSE(ProcessWithContext(non_convert)); + EXPECT_FALSE(ProcessWithContext(wide_half_1)); + EXPECT_FALSE(ProcessWithContext(wide_half_2)); + EXPECT_FALSE(ProcessWithContext(hangul)); DummyImeControlDelegate* delegate = new DummyImeControlDelegate(true); GetController()->SetImeControlDelegate( scoped_ptr<ImeControlDelegate>(delegate).Pass()); EXPECT_EQ(0, delegate->handle_previous_ime_count()); - EXPECT_TRUE(GetController()->Process(control_space)); + EXPECT_TRUE(ProcessWithContext(control_space)); EXPECT_EQ(1, delegate->handle_previous_ime_count()); EXPECT_EQ(0, delegate->handle_switch_ime_count()); - EXPECT_TRUE(GetController()->Process(convert)); + EXPECT_TRUE(ProcessWithContext(convert)); EXPECT_EQ(1, delegate->handle_switch_ime_count()); - EXPECT_TRUE(GetController()->Process(non_convert)); + EXPECT_TRUE(ProcessWithContext(non_convert)); EXPECT_EQ(2, delegate->handle_switch_ime_count()); - EXPECT_TRUE(GetController()->Process(wide_half_1)); + EXPECT_TRUE(ProcessWithContext(wide_half_1)); EXPECT_EQ(3, delegate->handle_switch_ime_count()); - EXPECT_TRUE(GetController()->Process(wide_half_2)); + EXPECT_TRUE(ProcessWithContext(wide_half_2)); EXPECT_EQ(4, delegate->handle_switch_ime_count()); - EXPECT_TRUE(GetController()->Process(hangul)); + EXPECT_TRUE(ProcessWithContext(hangul)); EXPECT_EQ(5, delegate->handle_switch_ime_count()); } @@ -957,11 +1010,11 @@ TEST_F(AcceleratorControllerTest, ImeGlobalAccelerators) { GetController()->SetImeControlDelegate( scoped_ptr<ImeControlDelegate>(delegate).Pass()); EXPECT_EQ(0, delegate->handle_next_ime_count()); - EXPECT_FALSE(GetController()->Process(shift_alt_press)); - EXPECT_TRUE(GetController()->Process(shift_alt)); + EXPECT_FALSE(ProcessWithContext(shift_alt_press)); + EXPECT_TRUE(ProcessWithContext(shift_alt)); EXPECT_EQ(1, delegate->handle_next_ime_count()); - EXPECT_FALSE(GetController()->Process(alt_shift_press)); - EXPECT_TRUE(GetController()->Process(alt_shift)); + EXPECT_FALSE(ProcessWithContext(alt_shift_press)); + EXPECT_TRUE(ProcessWithContext(alt_shift)); EXPECT_EQ(2, delegate->handle_next_ime_count()); // We should NOT switch IME when e.g. Shift+Alt+X is pressed and X is @@ -972,10 +1025,10 @@ TEST_F(AcceleratorControllerTest, ImeGlobalAccelerators) { const ReleaseAccelerator shift_alt_x(ui::VKEY_X, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN); - EXPECT_FALSE(GetController()->Process(shift_alt_press)); - EXPECT_FALSE(GetController()->Process(shift_alt_x_press)); - EXPECT_FALSE(GetController()->Process(shift_alt_x)); - EXPECT_FALSE(GetController()->Process(shift_alt)); + EXPECT_FALSE(ProcessWithContext(shift_alt_press)); + EXPECT_FALSE(ProcessWithContext(shift_alt_x_press)); + EXPECT_FALSE(ProcessWithContext(shift_alt_x)); + EXPECT_FALSE(ProcessWithContext(shift_alt)); EXPECT_EQ(2, delegate->handle_next_ime_count()); } @@ -991,11 +1044,11 @@ TEST_F(AcceleratorControllerTest, ImeGlobalAccelerators) { GetController()->SetImeControlDelegate( scoped_ptr<ImeControlDelegate>(delegate).Pass()); EXPECT_EQ(0, delegate->handle_next_ime_count()); - EXPECT_FALSE(GetController()->Process(shift_alt_press)); - EXPECT_TRUE(GetController()->Process(shift_alt)); + EXPECT_FALSE(ProcessWithContext(shift_alt_press)); + EXPECT_TRUE(ProcessWithContext(shift_alt)); EXPECT_EQ(1, delegate->handle_next_ime_count()); - EXPECT_FALSE(GetController()->Process(alt_shift_press)); - EXPECT_TRUE(GetController()->Process(alt_shift)); + EXPECT_FALSE(ProcessWithContext(alt_shift_press)); + EXPECT_TRUE(ProcessWithContext(alt_shift)); EXPECT_EQ(2, delegate->handle_next_ime_count()); // We should NOT switch IME when e.g. Shift+Alt+X is pressed and X is @@ -1006,10 +1059,10 @@ TEST_F(AcceleratorControllerTest, ImeGlobalAccelerators) { const ReleaseAccelerator shift_alt_x(ui::VKEY_X, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN); - EXPECT_FALSE(GetController()->Process(shift_alt_press)); - EXPECT_FALSE(GetController()->Process(shift_alt_x_press)); - EXPECT_FALSE(GetController()->Process(shift_alt_x)); - EXPECT_FALSE(GetController()->Process(shift_alt)); + EXPECT_FALSE(ProcessWithContext(shift_alt_press)); + EXPECT_FALSE(ProcessWithContext(shift_alt_x_press)); + EXPECT_FALSE(ProcessWithContext(shift_alt_x)); + EXPECT_FALSE(ProcessWithContext(shift_alt)); EXPECT_EQ(2, delegate->handle_next_ime_count()); } #endif @@ -1067,23 +1120,23 @@ TEST_F(AcceleratorControllerTest, DisallowedAtModalWindow) { // // Screenshot { - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_F5, ui::EF_CONTROL_DOWN))); - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_PRINT, ui::EF_NONE))); - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_F5, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); DummyScreenshotDelegate* delegate = new DummyScreenshotDelegate; GetController()->SetScreenshotDelegate( scoped_ptr<ScreenshotDelegate>(delegate).Pass()); EXPECT_EQ(0, delegate->handle_take_screenshot_count()); - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_F5, ui::EF_CONTROL_DOWN))); EXPECT_EQ(1, delegate->handle_take_screenshot_count()); - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_PRINT, ui::EF_NONE))); EXPECT_EQ(2, delegate->handle_take_screenshot_count()); - EXPECT_TRUE(GetController()->Process( + EXPECT_TRUE(ProcessWithContext( ui::Accelerator(ui::VKEY_F5, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); EXPECT_EQ(2, delegate->handle_take_screenshot_count()); } @@ -1091,29 +1144,29 @@ TEST_F(AcceleratorControllerTest, DisallowedAtModalWindow) { const ui::Accelerator f6(ui::VKEY_F6, ui::EF_NONE); const ui::Accelerator f7(ui::VKEY_F7, ui::EF_NONE); { - EXPECT_FALSE(GetController()->Process(f6)); - EXPECT_FALSE(GetController()->Process(f7)); + EXPECT_FALSE(ProcessWithContext(f6)); + EXPECT_FALSE(ProcessWithContext(f7)); DummyBrightnessControlDelegate* delegate = new DummyBrightnessControlDelegate(true); GetController()->SetBrightnessControlDelegate( scoped_ptr<BrightnessControlDelegate>(delegate).Pass()); - EXPECT_FALSE(GetController()->Process(f6)); - EXPECT_FALSE(GetController()->Process(f7)); + EXPECT_FALSE(ProcessWithContext(f6)); + EXPECT_FALSE(ProcessWithContext(f7)); } EnableInternalDisplay(); { - EXPECT_FALSE(GetController()->Process(f6)); - EXPECT_FALSE(GetController()->Process(f7)); + EXPECT_FALSE(ProcessWithContext(f6)); + EXPECT_FALSE(ProcessWithContext(f7)); DummyBrightnessControlDelegate* delegate = new DummyBrightnessControlDelegate(false); GetController()->SetBrightnessControlDelegate( scoped_ptr<BrightnessControlDelegate>(delegate).Pass()); EXPECT_EQ(0, delegate->handle_brightness_down_count()); - EXPECT_FALSE(GetController()->Process(f6)); + EXPECT_FALSE(ProcessWithContext(f6)); EXPECT_EQ(1, delegate->handle_brightness_down_count()); EXPECT_EQ(f6, delegate->last_accelerator()); EXPECT_EQ(0, delegate->handle_brightness_up_count()); - EXPECT_FALSE(GetController()->Process(f7)); + EXPECT_FALSE(ProcessWithContext(f7)); EXPECT_EQ(1, delegate->handle_brightness_up_count()); EXPECT_EQ(f7, delegate->last_accelerator()); } @@ -1123,11 +1176,11 @@ TEST_F(AcceleratorControllerTest, DisallowedAtModalWindow) { GetController()->SetBrightnessControlDelegate( scoped_ptr<BrightnessControlDelegate>(delegate).Pass()); EXPECT_EQ(0, delegate->handle_brightness_down_count()); - EXPECT_TRUE(GetController()->Process(f6)); + EXPECT_TRUE(ProcessWithContext(f6)); EXPECT_EQ(1, delegate->handle_brightness_down_count()); EXPECT_EQ(f6, delegate->last_accelerator()); EXPECT_EQ(0, delegate->handle_brightness_up_count()); - EXPECT_TRUE(GetController()->Process(f7)); + EXPECT_TRUE(ProcessWithContext(f7)); EXPECT_EQ(1, delegate->handle_brightness_up_count()); EXPECT_EQ(f7, delegate->last_accelerator()); } @@ -1136,23 +1189,23 @@ TEST_F(AcceleratorControllerTest, DisallowedAtModalWindow) { const ui::Accelerator f9(ui::VKEY_F9, ui::EF_NONE); const ui::Accelerator f10(ui::VKEY_F10, ui::EF_NONE); { - EXPECT_TRUE(GetController()->Process(f8)); - EXPECT_TRUE(GetController()->Process(f9)); - EXPECT_TRUE(GetController()->Process(f10)); + EXPECT_TRUE(ProcessWithContext(f8)); + EXPECT_TRUE(ProcessWithContext(f9)); + EXPECT_TRUE(ProcessWithContext(f10)); DummyVolumeControlDelegate* delegate = new DummyVolumeControlDelegate(false); ash::Shell::GetInstance()->tray_delegate()->SetVolumeControlDelegate( scoped_ptr<VolumeControlDelegate>(delegate).Pass()); EXPECT_EQ(0, delegate->handle_volume_mute_count()); - EXPECT_FALSE(GetController()->Process(f8)); + EXPECT_FALSE(ProcessWithContext(f8)); EXPECT_EQ(1, delegate->handle_volume_mute_count()); EXPECT_EQ(f8, delegate->last_accelerator()); EXPECT_EQ(0, delegate->handle_volume_down_count()); - EXPECT_FALSE(GetController()->Process(f9)); + EXPECT_FALSE(ProcessWithContext(f9)); EXPECT_EQ(1, delegate->handle_volume_down_count()); EXPECT_EQ(f9, delegate->last_accelerator()); EXPECT_EQ(0, delegate->handle_volume_up_count()); - EXPECT_FALSE(GetController()->Process(f10)); + EXPECT_FALSE(ProcessWithContext(f10)); EXPECT_EQ(1, delegate->handle_volume_up_count()); EXPECT_EQ(f10, delegate->last_accelerator()); } @@ -1161,15 +1214,15 @@ TEST_F(AcceleratorControllerTest, DisallowedAtModalWindow) { ash::Shell::GetInstance()->tray_delegate()->SetVolumeControlDelegate( scoped_ptr<VolumeControlDelegate>(delegate).Pass()); EXPECT_EQ(0, delegate->handle_volume_mute_count()); - EXPECT_TRUE(GetController()->Process(f8)); + EXPECT_TRUE(ProcessWithContext(f8)); EXPECT_EQ(1, delegate->handle_volume_mute_count()); EXPECT_EQ(f8, delegate->last_accelerator()); EXPECT_EQ(0, delegate->handle_volume_down_count()); - EXPECT_TRUE(GetController()->Process(f9)); + EXPECT_TRUE(ProcessWithContext(f9)); EXPECT_EQ(1, delegate->handle_volume_down_count()); EXPECT_EQ(f9, delegate->last_accelerator()); EXPECT_EQ(0, delegate->handle_volume_up_count()); - EXPECT_TRUE(GetController()->Process(f10)); + EXPECT_TRUE(ProcessWithContext(f10)); EXPECT_EQ(1, delegate->handle_volume_up_count()); EXPECT_EQ(f10, delegate->last_accelerator()); } diff --git a/ash/accelerators/accelerator_dispatcher.cc b/ash/accelerators/accelerator_dispatcher.cc index 6109b05..a825dde 100644 --- a/ash/accelerators/accelerator_dispatcher.cc +++ b/ash/accelerators/accelerator_dispatcher.cc @@ -77,7 +77,6 @@ bool AcceleratorDispatcher::Dispatch(const base::NativeEvent& event) { DCHECK(event_rewriter); if (event_rewriter->PreHandleKeyEvent(associated_window_, &key_event)) return true; - ash::AcceleratorController* accelerator_controller = ash::Shell::GetInstance()->accelerator_controller(); if (accelerator_controller) { @@ -85,6 +84,10 @@ bool AcceleratorDispatcher::Dispatch(const base::NativeEvent& event) { key_event.flags() & kModifierMask); if (key_event.type() == ui::ET_KEY_RELEASED) accelerator.set_type(ui::ET_KEY_RELEASED); + // Fill out context object so AcceleratorController will know what + // was the previous accelerator or if the current accelerator is repeated. + Shell::GetInstance()->accelerator_controller()->context()-> + UpdateContext(accelerator); if (accelerator_controller->Process(accelerator)) return true; } diff --git a/ash/accelerators/accelerator_dispatcher.h b/ash/accelerators/accelerator_dispatcher.h index 68c94583..d264a4b 100644 --- a/ash/accelerators/accelerator_dispatcher.h +++ b/ash/accelerators/accelerator_dispatcher.h @@ -12,7 +12,8 @@ namespace ash { -// Dispatcher for handling accelerators in ash. +// Dispatcher for handling accelerators from menu. +// // Wraps a nested dispatcher to which control is passed if no accelerator key // has been pressed. // TODO(pkotwicz): Port AcceleratorDispatcher to mac. diff --git a/ash/accelerators/accelerator_filter.cc b/ash/accelerators/accelerator_filter.cc index 6b61d42..5d179d5 100644 --- a/ash/accelerators/accelerator_filter.cc +++ b/ash/accelerators/accelerator_filter.cc @@ -79,6 +79,11 @@ bool AcceleratorFilter::PreHandleKeyEvent(aura::Window* target, event->flags() & kModifierFlagMask); accelerator.set_type(type); + // Fill out context object so AcceleratorController will know what + // was the previous accelerator or if the current accelerator is repeated. + Shell::GetInstance()->accelerator_controller()->context()-> + UpdateContext(accelerator); + if (!ShouldProcessAcceleratorsNow(accelerator, target)) return false; return Shell::GetInstance()->accelerator_controller()->Process(accelerator); diff --git a/ash/accelerators/accelerator_table.cc b/ash/accelerators/accelerator_table.cc index 61524b4..e8f4d4e 100644 --- a/ash/accelerators/accelerator_table.cc +++ b/ash/accelerators/accelerator_table.cc @@ -33,16 +33,11 @@ const AcceleratorData kAcceleratorData[] = { // Shortcut for Koren IME. { true, ui::VKEY_HANGUL, ui::EF_NONE, SWITCH_IME }, - { true, ui::VKEY_TAB, ui::EF_ALT_DOWN, CYCLE_FORWARD_MRU_PRESSED }, - { false, ui::VKEY_TAB, ui::EF_ALT_DOWN, CYCLE_FORWARD_MRU_RELEASED }, + { 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_PRESSED }, - { false, ui::VKEY_TAB, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN, - CYCLE_BACKWARD_MRU_RELEASED }, + CYCLE_BACKWARD_MRU }, { true, ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_NONE, - CYCLE_FORWARD_LINEAR_PRESSED }, - { false, ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_NONE, - CYCLE_FORWARD_LINEAR_RELEASED }, + CYCLE_FORWARD_LINEAR }, #if defined(OS_CHROMEOS) { true, ui::VKEY_BROWSER_SEARCH, ui::EF_NONE, TOGGLE_APP_LIST }, { true, ui::VKEY_WLAN, ui::EF_NONE, TOGGLE_WIFI }, @@ -50,14 +45,11 @@ const AcceleratorData kAcceleratorData[] = { { true, ui::VKEY_BRIGHTNESS_UP, ui::EF_NONE, BRIGHTNESS_UP }, { true, ui::VKEY_KBD_BRIGHTNESS_DOWN, ui::EF_NONE, KEYBOARD_BRIGHTNESS_DOWN }, { true, ui::VKEY_KBD_BRIGHTNESS_UP, ui::EF_NONE, KEYBOARD_BRIGHTNESS_UP }, - { true, ui::VKEY_F4, ui::EF_NONE, TOGGLE_MAXIMIZED_PRESSED }, - { false, ui::VKEY_F4, ui::EF_NONE, TOGGLE_MAXIMIZED_RELEASED }, + { true, ui::VKEY_F4, ui::EF_NONE, TOGGLE_MAXIMIZED }, { true, ui::VKEY_F4, ui::EF_CONTROL_DOWN, CYCLE_DISPLAY_MODE }, { true, ui::VKEY_F4, ui::EF_ALT_DOWN, SWAP_PRIMARY_DISPLAY }, - { true, ui::VKEY_F5, ui::EF_NONE, CYCLE_FORWARD_LINEAR_PRESSED }, - { false, ui::VKEY_F5, ui::EF_NONE, CYCLE_FORWARD_LINEAR_RELEASED }, - { true, ui::VKEY_F5, ui::EF_SHIFT_DOWN, CYCLE_BACKWARD_LINEAR_PRESSED }, - { false, ui::VKEY_F5, ui::EF_SHIFT_DOWN, CYCLE_BACKWARD_LINEAR_RELEASED }, + { true, ui::VKEY_F5, ui::EF_NONE, CYCLE_FORWARD_LINEAR }, + { true, ui::VKEY_F5, ui::EF_SHIFT_DOWN, CYCLE_BACKWARD_LINEAR }, { true, ui::VKEY_F5, ui::EF_CONTROL_DOWN, TAKE_SCREENSHOT }, { true, ui::VKEY_F5, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, TAKE_PARTIAL_SCREENSHOT }, @@ -112,9 +104,7 @@ const AcceleratorData kAcceleratorData[] = { ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN, ROTATE_WINDOWS }, { true, ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_SHIFT_DOWN, - CYCLE_BACKWARD_LINEAR_PRESSED }, - { false, ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_SHIFT_DOWN, - CYCLE_BACKWARD_LINEAR_RELEASED }, + CYCLE_BACKWARD_LINEAR }, { true, ui::VKEY_T, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, RESTORE_TAB }, { true, ui::VKEY_PRINT, ui::EF_NONE, TAKE_SCREENSHOT }, // On Chrome OS, Search key is mapped to LWIN. @@ -149,8 +139,7 @@ const AcceleratorData kAcceleratorData[] = { { true, ui::VKEY_OEM_4, ui::EF_ALT_DOWN, WINDOW_SNAP_LEFT }, { true, ui::VKEY_OEM_6, ui::EF_ALT_DOWN, WINDOW_SNAP_RIGHT }, { true, ui::VKEY_OEM_MINUS, ui::EF_ALT_DOWN, WINDOW_MINIMIZE }, - { true, ui::VKEY_OEM_PLUS, ui::EF_ALT_DOWN, TOGGLE_MAXIMIZED_PRESSED }, - { false, ui::VKEY_OEM_PLUS, ui::EF_ALT_DOWN, TOGGLE_MAXIMIZED_RELEASED}, + { true, ui::VKEY_OEM_PLUS, ui::EF_ALT_DOWN, TOGGLE_MAXIMIZED }, { true, ui::VKEY_OEM_PLUS, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN, WINDOW_POSITION_CENTER }, { true, ui::VKEY_F2, ui::EF_CONTROL_DOWN, FOCUS_NEXT_PANE }, @@ -174,12 +163,9 @@ const AcceleratorData kDebugAcceleratorData[] = { { true, ui::VKEY_F11, ui::EF_CONTROL_DOWN, TOGGLE_ROOT_WINDOW_FULL_SCREEN }, { true, ui::VKEY_W, ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN, TOGGLE_WIFI }, // For testing on systems where Alt-Tab is already mapped. - { true, ui::VKEY_W, ui::EF_ALT_DOWN, CYCLE_FORWARD_MRU_PRESSED }, - { false, ui::VKEY_W, ui::EF_ALT_DOWN, CYCLE_FORWARD_MRU_RELEASED }, + { true, ui::VKEY_W, ui::EF_ALT_DOWN, CYCLE_FORWARD_MRU }, { true, ui::VKEY_W, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN, - CYCLE_BACKWARD_MRU_PRESSED }, - { false, ui::VKEY_W, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN, - CYCLE_BACKWARD_MRU_RELEASED }, + CYCLE_BACKWARD_MRU }, { true, ui::VKEY_HOME, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, DISPLAY_TOGGLE_SCALE }, #if !defined(NDEBUG) @@ -196,10 +182,8 @@ const size_t kDebugAcceleratorDataLength = arraysize(kDebugAcceleratorData); const AcceleratorAction kReservedActions[] = { // Window cycling accelerators. - CYCLE_BACKWARD_MRU_PRESSED, // Shift+Alt+Tab - CYCLE_BACKWARD_MRU_RELEASED, - CYCLE_FORWARD_MRU_PRESSED, // Alt+Tab - CYCLE_FORWARD_MRU_RELEASED, + CYCLE_BACKWARD_MRU, // Shift+Alt+Tab + CYCLE_FORWARD_MRU, // Alt+Tab #if defined(OS_CHROMEOS) LOCK_PRESSED, LOCK_RELEASED, @@ -292,4 +276,16 @@ const AcceleratorAction kActionsAllowedAtModalWindow[] = { const size_t kActionsAllowedAtModalWindowLength = arraysize(kActionsAllowedAtModalWindow); +const AcceleratorAction kNonrepeatableActions[] = { + // TODO(mazda): Add other actions which should not be repeated. + CYCLE_BACKWARD_LINEAR, + CYCLE_BACKWARD_MRU, + CYCLE_FORWARD_LINEAR, + CYCLE_FORWARD_MRU, + TOGGLE_MAXIMIZED, +}; + +const size_t kNonrepeatableActionsLength = + arraysize(kNonrepeatableActions); + } // namespace ash diff --git a/ash/accelerators/accelerator_table.h b/ash/accelerators/accelerator_table.h index daa6129..b147127 100644 --- a/ash/accelerators/accelerator_table.h +++ b/ash/accelerators/accelerator_table.h @@ -17,14 +17,10 @@ namespace ash { enum AcceleratorAction { BRIGHTNESS_DOWN, BRIGHTNESS_UP, - CYCLE_BACKWARD_LINEAR_PRESSED, - CYCLE_BACKWARD_LINEAR_RELEASED, - CYCLE_BACKWARD_MRU_PRESSED, - CYCLE_BACKWARD_MRU_RELEASED, - CYCLE_FORWARD_LINEAR_PRESSED, - CYCLE_FORWARD_LINEAR_RELEASED, - CYCLE_FORWARD_MRU_PRESSED, - CYCLE_FORWARD_MRU_RELEASED, + CYCLE_BACKWARD_LINEAR, + CYCLE_BACKWARD_MRU, + CYCLE_FORWARD_LINEAR, + CYCLE_FORWARD_MRU, DISABLE_CAPS_LOCK, DISPLAY_TOGGLE_SCALE, EXIT, @@ -72,8 +68,7 @@ enum AcceleratorAction { TOGGLE_CAPS_LOCK, TOGGLE_CAPS_LOCK_BY_ALT_LWIN, TOGGLE_DESKTOP_BACKGROUND_MODE, - TOGGLE_MAXIMIZED_PRESSED, - TOGGLE_MAXIMIZED_RELEASED, + TOGGLE_MAXIMIZED, TOGGLE_ROOT_WINDOW_FULL_SCREEN, TOGGLE_SPOKEN_FEEDBACK, TOGGLE_WIFI, @@ -144,6 +139,12 @@ ASH_EXPORT extern const AcceleratorAction kActionsAllowedAtModalWindow[]; // The number of elements in kActionsAllowedAtModalWindow. ASH_EXPORT extern const size_t kActionsAllowedAtModalWindowLength; +// Actions which will not be repeated while holding an accelerator key. +ASH_EXPORT extern const AcceleratorAction kNonrepeatableActions[]; + +// The number of elements in kNonrepeatableActions. +ASH_EXPORT extern const size_t kNonrepeatableActionsLength; + } // namespace ash #endif // ASH_ACCELERATORS_ACCELERATOR_TABLE_H_ diff --git a/ash/wm/gestures/bezel_gesture_handler.cc b/ash/wm/gestures/bezel_gesture_handler.cc index 1d82223..9b503bc 100644 --- a/ash/wm/gestures/bezel_gesture_handler.cc +++ b/ash/wm/gestures/bezel_gesture_handler.cc @@ -140,15 +140,10 @@ bool BezelGestureHandler::HandleApplicationControl( ash::AcceleratorController* accelerator = ash::Shell::GetInstance()->accelerator_controller(); if (start_location_ == BEZEL_START_LEFT && event.details().scroll_x() > 0) { - accelerator->PerformAction(CYCLE_BACKWARD_LINEAR_PRESSED, - ui::Accelerator()); - accelerator->PerformAction(CYCLE_BACKWARD_LINEAR_RELEASED, - ui::Accelerator()); + accelerator->PerformAction(CYCLE_BACKWARD_LINEAR, ui::Accelerator()); } else if (start_location_ == BEZEL_START_RIGHT && event.details().scroll_x() < 0) { - accelerator->PerformAction(CYCLE_FORWARD_LINEAR_PRESSED, ui::Accelerator()); - accelerator->PerformAction(CYCLE_FORWARD_LINEAR_RELEASED, - ui::Accelerator()); + accelerator->PerformAction(CYCLE_FORWARD_LINEAR, ui::Accelerator()); } else { return false; } diff --git a/ash/wm/system_gesture_event_filter.cc b/ash/wm/system_gesture_event_filter.cc index 7b28385..6699f4e 100644 --- a/ash/wm/system_gesture_event_filter.cc +++ b/ash/wm/system_gesture_event_filter.cc @@ -115,13 +115,8 @@ ui::EventResult SystemGestureEventFilter::PreHandleGestureEvent( SystemPinchHandler::kSystemGesturePoints) { ash::AcceleratorController* accelerator = ash::Shell::GetInstance()->accelerator_controller(); - if (accelerator->PerformAction(CYCLE_FORWARD_MRU_PRESSED, - ui::Accelerator())) { - accelerator->PerformAction(CYCLE_FORWARD_MRU_RELEASED, - ui::Accelerator()); + if (accelerator->PerformAction(CYCLE_FORWARD_MRU, ui::Accelerator())) return ui::ER_CONSUMED; - } - accelerator->PerformAction(CYCLE_FORWARD_MRU_RELEASED, ui::Accelerator()); } return ui::ER_UNHANDLED; } |