Roll src/third_party/WebKit c8d1660:ae3684d (svn 197337:197343)
[chromium-blink-merge.git] / ash / wm / cursor_manager_chromeos.cc
blob3a1162f9d05f600b1696065b342cf9624e503445
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.
5 #include "ash/wm/cursor_manager_chromeos.h"
7 #include "base/logging.h"
8 #include "ui/events/event.h"
9 #include "ui/keyboard/keyboard_util.h"
10 #include "ui/wm/core/cursor_manager.h"
11 #include "ui/wm/core/native_cursor_manager.h"
13 namespace ash {
15 CursorManager::CursorManager(
16 scoped_ptr< ::wm::NativeCursorManager> delegate)
17 : ::wm::CursorManager(delegate.Pass()) {
20 CursorManager::~CursorManager() {
23 bool CursorManager::ShouldHideCursorOnKeyEvent(
24 const ui::KeyEvent& event) const {
25 if (event.type() != ui::ET_KEY_PRESSED)
26 return false;
28 // Clicking on a key when the accessibility virtual keyboard is enabled should
29 // not hide the cursor.
30 if (keyboard::GetAccessibilityKeyboardEnabled())
31 return false;
32 // All alt and control key commands are ignored.
33 if (event.IsAltDown() || event.IsControlDown())
34 return false;
36 ui::KeyboardCode code = event.key_code();
37 if (code >= ui::VKEY_F1 && code <= ui::VKEY_F24)
38 return false;
39 if (code >= ui::VKEY_BROWSER_BACK && code <= ui::VKEY_MEDIA_LAUNCH_APP2)
40 return false;
41 switch (code) {
42 // Modifiers.
43 case ui::VKEY_SHIFT:
44 case ui::VKEY_CONTROL:
45 case ui::VKEY_MENU:
46 // Search key == VKEY_LWIN.
47 case ui::VKEY_LWIN:
48 case ui::VKEY_WLAN:
49 case ui::VKEY_POWER:
50 case ui::VKEY_BRIGHTNESS_DOWN:
51 case ui::VKEY_BRIGHTNESS_UP:
52 case ui::VKEY_KBD_BRIGHTNESS_UP:
53 case ui::VKEY_KBD_BRIGHTNESS_DOWN:
54 return false;
55 default:
56 return true;
59 } // namespace ash