Pass the affected tree in AXTreeDelegate calls.
[chromium-blink-merge.git] / ash / wm / cursor_manager_chromeos.cc
blobaf38d5c41f4531e20caaf8d46573903eb5c02f74
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/keyboard/keyboard_util.h"
9 #include "ui/wm/core/cursor_manager.h"
10 #include "ui/wm/core/native_cursor_manager.h"
12 namespace ash {
14 CursorManager::CursorManager(
15 scoped_ptr< ::wm::NativeCursorManager> delegate)
16 : ::wm::CursorManager(delegate.Pass()) {
19 CursorManager::~CursorManager() {
22 bool CursorManager::ShouldHideCursorOnKeyEvent(
23 const ui::KeyEvent& event) const {
24 if (event.type() != ui::ET_KEY_PRESSED)
25 return false;
27 // Clicking on a key when the accessibility virtual keyboard is enabled should
28 // not hide the cursor.
29 if (keyboard::GetAccessibilityKeyboardEnabled())
30 return false;
31 // All alt and control key commands are ignored.
32 if (event.IsAltDown() || event.IsControlDown())
33 return false;
35 ui::KeyboardCode code = event.key_code();
36 if (code >= ui::VKEY_F1 && code <= ui::VKEY_F24)
37 return false;
38 if (code >= ui::VKEY_BROWSER_BACK && code <= ui::VKEY_MEDIA_LAUNCH_APP2)
39 return false;
40 switch (code) {
41 // Modifiers.
42 case ui::VKEY_SHIFT:
43 case ui::VKEY_CONTROL:
44 case ui::VKEY_MENU:
45 // Search key == VKEY_LWIN.
46 case ui::VKEY_LWIN:
47 case ui::VKEY_WLAN:
48 case ui::VKEY_POWER:
49 case ui::VKEY_BRIGHTNESS_DOWN:
50 case ui::VKEY_BRIGHTNESS_UP:
51 case ui::VKEY_KBD_BRIGHTNESS_UP:
52 case ui::VKEY_KBD_BRIGHTNESS_DOWN:
53 return false;
54 default:
55 return true;
58 } // namespace ash