Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_x11.cc

Issue 1023743002: Merge Disable Keyboard in Maximize Mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2311
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/events/platform/x11/x11_hotplug_event_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_x11.h" 5 #include "ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_x11.h"
6 6
7 #include <set> 7 #include <set>
8 #include <X11/extensions/XInput2.h> 8 #include <X11/extensions/XInput2.h>
9 #include <X11/Xlib.h> 9 #include <X11/Xlib.h>
10 10
11 #include "ash/display/display_controller.h" 11 #include "ash/display/display_controller.h"
12 #include "ash/screen_util.h" 12 #include "ash/screen_util.h"
13 #include "ash/shell.h" 13 #include "ash/shell.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "ui/aura/client/cursor_client.h" 16 #include "ui/aura/client/cursor_client.h"
17 #include "ui/aura/client/screen_position_client.h" 17 #include "ui/aura/client/screen_position_client.h"
18 #include "ui/aura/env.h" 18 #include "ui/aura/env.h"
19 #include "ui/aura/window.h" 19 #include "ui/aura/window.h"
20 #include "ui/aura/window_event_dispatcher.h" 20 #include "ui/aura/window_event_dispatcher.h"
21 #include "ui/aura/window_tree_host.h" 21 #include "ui/aura/window_tree_host.h"
22 #include "ui/events/devices/input_device.h"
23 #include "ui/events/devices/keyboard_device.h"
22 #include "ui/events/devices/x11/device_data_manager_x11.h" 24 #include "ui/events/devices/x11/device_data_manager_x11.h"
23 #include "ui/events/devices/x11/device_list_cache_x11.h" 25 #include "ui/events/devices/x11/device_list_cache_x11.h"
24 #include "ui/events/event.h" 26 #include "ui/events/event.h"
25 #include "ui/events/event_utils.h" 27 #include "ui/events/event_utils.h"
26 #include "ui/events/keycodes/keyboard_codes_posix.h" 28 #include "ui/events/keycodes/keyboard_codes_posix.h"
27 #include "ui/events/platform/platform_event_source.h" 29 #include "ui/events/platform/platform_event_source.h"
28 #include "ui/gfx/x/x11_types.h" 30 #include "ui/gfx/x/x11_types.h"
29 31
30 namespace ash { 32 namespace ash {
31 33
32 namespace { 34 namespace {
33 35
34 // The name of the xinput device corresponding to the internal touchpad. 36 // The name of the xinput device corresponding to the internal touchpad.
35 const char kInternalTouchpadName[] = "Elan Touchpad"; 37 const char kInternalTouchpadName[] = "Elan Touchpad";
36 38
37 // The name of the xinput device corresponding to the internal keyboard.
38 const char kInternalKeyboardName[] = "AT Translated Set 2 keyboard";
39
40 // Repeated key events have their source set to the core keyboard device. 39 // Repeated key events have their source set to the core keyboard device.
41 // These must be disabled also until http://crbug.com/402898 is resolved. 40 // These must be disabled also until http://crbug.com/402898 is resolved.
42 const char kCoreKeyboardName[] = "Virtual core keyboard"; 41 const char kCoreKeyboardName[] = "Virtual core keyboard";
43 42
44 // Device id used to indicate that a device has not been detected. 43 // Device id used to indicate that a device has not been detected.
45 const int kDeviceIdNone = -1; 44 const int kDeviceIdNone = -1;
46 45
47 gfx::Point GetMouseLocationInScreen() { 46 gfx::Point GetMouseLocationInScreen() {
48 return aura::Env::GetInstance()->last_mouse_location(); 47 return aura::Env::GetInstance()->last_mouse_location();
49 } 48 }
(...skipping 29 matching lines...) Expand all
79 XIDeviceList xi_dev_list = ui::DeviceListCacheX11::GetInstance()-> 78 XIDeviceList xi_dev_list = ui::DeviceListCacheX11::GetInstance()->
80 GetXI2DeviceList(gfx::GetXDisplay()); 79 GetXI2DeviceList(gfx::GetXDisplay());
81 for (int i = 0; i < xi_dev_list.count; ++i) { 80 for (int i = 0; i < xi_dev_list.count; ++i) {
82 std::string device_name(xi_dev_list[i].name); 81 std::string device_name(xi_dev_list[i].name);
83 base::TrimWhitespaceASCII(device_name, base::TRIM_TRAILING, &device_name); 82 base::TrimWhitespaceASCII(device_name, base::TRIM_TRAILING, &device_name);
84 if (device_name == kInternalTouchpadName) { 83 if (device_name == kInternalTouchpadName) {
85 touchpad_device_id_ = xi_dev_list[i].deviceid; 84 touchpad_device_id_ = xi_dev_list[i].deviceid;
86 device_data_manager->DisableDevice(touchpad_device_id_); 85 device_data_manager->DisableDevice(touchpad_device_id_);
87 aura::client::GetCursorClient( 86 aura::client::GetCursorClient(
88 Shell::GetInstance()->GetPrimaryRootWindow())->HideCursor(); 87 Shell::GetInstance()->GetPrimaryRootWindow())->HideCursor();
89 } else if (device_name == kInternalKeyboardName) {
90 keyboard_device_id_ = xi_dev_list[i].deviceid;
91 device_data_manager->DisableDevice(keyboard_device_id_);
92 } else if (device_name == kCoreKeyboardName) { 88 } else if (device_name == kCoreKeyboardName) {
93 core_keyboard_device_id_ = xi_dev_list[i].deviceid; 89 core_keyboard_device_id_ = xi_dev_list[i].deviceid;
94 device_data_manager->DisableDevice(core_keyboard_device_id_); 90 device_data_manager->DisableDevice(core_keyboard_device_id_);
95 } 91 }
96 } 92 }
93
94 for (const ui::KeyboardDevice& device :
95 device_data_manager->keyboard_devices()) {
96 if (device.type == ui::InputDeviceType::INPUT_DEVICE_INTERNAL) {
97 keyboard_device_id_ = device.id;
98 device_data_manager->DisableDevice(keyboard_device_id_);
99 break;
100 }
101 }
97 } 102 }
98 // Allow the accessible keys present on the side of some devices to continue 103 // Allow the accessible keys present on the side of some devices to continue
99 // working. 104 // working.
100 scoped_ptr<std::set<ui::KeyboardCode> > excepted_keys( 105 scoped_ptr<std::set<ui::KeyboardCode> > excepted_keys(
101 new std::set<ui::KeyboardCode>); 106 new std::set<ui::KeyboardCode>);
102 excepted_keys->insert(ui::VKEY_VOLUME_DOWN); 107 excepted_keys->insert(ui::VKEY_VOLUME_DOWN);
103 excepted_keys->insert(ui::VKEY_VOLUME_UP); 108 excepted_keys->insert(ui::VKEY_VOLUME_UP);
104 excepted_keys->insert(ui::VKEY_POWER); 109 excepted_keys->insert(ui::VKEY_POWER);
105 device_data_manager->SetDisabledKeyboardAllowedKeys(excepted_keys.Pass()); 110 device_data_manager->SetDisabledKeyboardAllowedKeys(excepted_keys.Pass());
106 ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(this); 111 ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(this);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 // blocked. Move the mouse cursor back to its last known location resulting 151 // blocked. Move the mouse cursor back to its last known location resulting
147 // from an external mouse to prevent the internal touchpad from moving it. 152 // from an external mouse to prevent the internal touchpad from moving it.
148 SetMouseLocationInScreen(last_mouse_location_); 153 SetMouseLocationInScreen(last_mouse_location_);
149 } else { 154 } else {
150 // Track the last location seen from an external mouse event. 155 // Track the last location seen from an external mouse event.
151 last_mouse_location_ = GetMouseLocationInScreen(); 156 last_mouse_location_ = GetMouseLocationInScreen();
152 } 157 }
153 } 158 }
154 159
155 } // namespace ash 160 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ui/events/platform/x11/x11_hotplug_event_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698