Ben Murdoch | c5cede9 | 2014-04-10 11:22:14 +0100 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "ash/wm/cursor_manager_chromeos.h" |
| 6 | |
| 7 | #include "base/logging.h" |
| 8 | #include "ui/keyboard/keyboard_util.h" |
| 9 | #include "ui/wm/core/cursor_manager.h" |
| 10 | #include "ui/wm/core/native_cursor_manager.h" |
| 11 | |
| 12 | namespace ash { |
| 13 | |
| 14 | CursorManager::CursorManager( |
| 15 | scoped_ptr< ::wm::NativeCursorManager> delegate) |
| 16 | : ::wm::CursorManager(delegate.Pass()) { |
| 17 | } |
| 18 | |
| 19 | CursorManager::~CursorManager() { |
| 20 | } |
| 21 | |
| 22 | bool CursorManager::ShouldHideCursorOnKeyEvent( |
| 23 | const ui::KeyEvent& event) const { |
| 24 | // Clicking on a key when the accessibility virtual keyboard is enabled should |
| 25 | // not hide the cursor. |
| 26 | if (keyboard::GetAccessibilityKeyboardEnabled()) |
| 27 | return false; |
| 28 | // All alt and control key commands are ignored. |
| 29 | if (event.IsAltDown() || event.IsControlDown()) |
| 30 | return false; |
| 31 | |
| 32 | ui::KeyboardCode code = event.key_code(); |
| 33 | if (code >= ui::VKEY_F1 && code <= ui::VKEY_F24) |
| 34 | return false; |
| 35 | if (code >= ui::VKEY_BROWSER_BACK && code <= ui::VKEY_MEDIA_LAUNCH_APP2) |
| 36 | return false; |
| 37 | switch (code) { |
| 38 | // Modifiers. |
| 39 | case ui::VKEY_SHIFT: |
| 40 | case ui::VKEY_CONTROL: |
| 41 | case ui::VKEY_MENU: |
| 42 | // Search key == VKEY_LWIN. |
| 43 | case ui::VKEY_LWIN: |
| 44 | case ui::VKEY_WLAN: |
| 45 | case ui::VKEY_POWER: |
| 46 | case ui::VKEY_BRIGHTNESS_DOWN: |
| 47 | case ui::VKEY_BRIGHTNESS_UP: |
| 48 | case ui::VKEY_KBD_BRIGHTNESS_UP: |
| 49 | case ui::VKEY_KBD_BRIGHTNESS_DOWN: |
| 50 | return false; |
| 51 | default: |
| 52 | return true; |
| 53 | } |
| 54 | } |
| 55 | } // namespace ash |