| OLD | NEW |
| 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 "chrome/browser/chromeos/events/event_rewriter.h" | 5 #include "chrome/browser/chromeos/events/event_rewriter.h" |
| 6 | 6 |
| 7 #include <X11/extensions/XInput2.h> | 7 #include <X11/extensions/XInput2.h> |
| 8 #include <X11/keysym.h> | 8 #include <X11/keysym.h> |
| 9 #include <X11/XF86keysym.h> | 9 #include <X11/XF86keysym.h> |
| 10 #include <X11/Xlib.h> | 10 #include <X11/Xlib.h> |
| 11 // Get rid of macros from Xlib.h that conflicts with other parts of the code. | 11 // Get rid of macros from Xlib.h that conflicts with other parts of the code. |
| 12 #undef RootWindow | 12 #undef RootWindow |
| 13 #undef Status | 13 #undef Status |
| 14 | 14 |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "ash/wm/window_state.h" | 17 #include "ash/wm/window_state.h" |
| 18 #include "ash/wm/window_util.h" | 18 #include "ash/wm/window_util.h" |
| 19 #include "base/command_line.h" | 19 #include "base/command_line.h" |
| 20 #include "base/logging.h" | 20 #include "base/logging.h" |
| 21 #include "base/prefs/pref_service.h" | 21 #include "base/prefs/pref_service.h" |
| 22 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
| 23 #include "base/sys_info.h" | 23 #include "base/sys_info.h" |
| 24 #include "chrome/browser/chromeos/events/keyboard_driven_event_rewriter.h" | |
| 25 #include "chrome/browser/chromeos/events/xinput_hierarchy_changed_event_listener
.h" | 24 #include "chrome/browser/chromeos/events/xinput_hierarchy_changed_event_listener
.h" |
| 26 #include "chrome/browser/chromeos/login/login_display_host_impl.h" | 25 #include "chrome/browser/chromeos/login/login_display_host_impl.h" |
| 27 #include "chrome/browser/chromeos/login/user_manager.h" | 26 #include "chrome/browser/chromeos/login/user_manager.h" |
| 28 #include "chrome/browser/profiles/profile_manager.h" | 27 #include "chrome/browser/profiles/profile_manager.h" |
| 29 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 30 #include "chromeos/chromeos_switches.h" | 29 #include "chromeos/chromeos_switches.h" |
| 31 #include "chromeos/ime/ime_keyboard.h" | 30 #include "chromeos/ime/ime_keyboard.h" |
| 32 #include "chromeos/ime/input_method_manager.h" | 31 #include "chromeos/ime/input_method_manager.h" |
| 33 #include "ui/base/x/x11_util.h" | 32 #include "ui/base/x/x11_util.h" |
| 34 #include "ui/events/event.h" | 33 #include "ui/events/event.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 return manager->IsISOLevel5ShiftUsedByCurrentInputMethod(); | 126 return manager->IsISOLevel5ShiftUsedByCurrentInputMethod(); |
| 128 } | 127 } |
| 129 | 128 |
| 130 } // namespace | 129 } // namespace |
| 131 | 130 |
| 132 namespace chromeos { | 131 namespace chromeos { |
| 133 | 132 |
| 134 EventRewriter::EventRewriter() | 133 EventRewriter::EventRewriter() |
| 135 : last_device_id_(kBadDeviceId), | 134 : last_device_id_(kBadDeviceId), |
| 136 keyboard_for_testing_(NULL), | 135 keyboard_for_testing_(NULL), |
| 137 keyboard_driven_event_rewriter_(new KeyboardDrivenEventRewriter), | |
| 138 pref_service_for_testing_(NULL) { | 136 pref_service_for_testing_(NULL) { |
| 139 ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(this); | 137 ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(this); |
| 140 if (base::SysInfo::IsRunningOnChromeOS()) { | 138 if (base::SysInfo::IsRunningOnChromeOS()) { |
| 141 XInputHierarchyChangedEventListener::GetInstance()->AddObserver(this); | 139 XInputHierarchyChangedEventListener::GetInstance()->AddObserver(this); |
| 142 } | 140 } |
| 143 RefreshKeycodes(); | 141 RefreshKeycodes(); |
| 144 } | 142 } |
| 145 | 143 |
| 146 EventRewriter::~EventRewriter() { | 144 EventRewriter::~EventRewriter() { |
| 147 ui::PlatformEventSource::GetInstance()->RemovePlatformEventObserver(this); | 145 ui::PlatformEventSource::GetInstance()->RemovePlatformEventObserver(this); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 Profile* profile = ProfileManager::GetActiveUserProfile(); | 333 Profile* profile = ProfileManager::GetActiveUserProfile(); |
| 336 return profile ? profile->GetPrefs() : NULL; | 334 return profile ? profile->GetPrefs() : NULL; |
| 337 } | 335 } |
| 338 | 336 |
| 339 void EventRewriter::Rewrite(XEvent* event) { | 337 void EventRewriter::Rewrite(XEvent* event) { |
| 340 // Do not rewrite an event sent by ui_controls::SendKeyPress(). See | 338 // Do not rewrite an event sent by ui_controls::SendKeyPress(). See |
| 341 // crbug.com/136465. | 339 // crbug.com/136465. |
| 342 if (event->xkey.send_event) | 340 if (event->xkey.send_event) |
| 343 return; | 341 return; |
| 344 | 342 |
| 345 // Keyboard driven rewriting happen first. Skip further processing if event is | |
| 346 // changed. | |
| 347 if (keyboard_driven_event_rewriter_->RewriteIfKeyboardDrivenOnLoginScreen( | |
| 348 event)) { | |
| 349 return; | |
| 350 } | |
| 351 | |
| 352 RewriteModifiers(event); | 343 RewriteModifiers(event); |
| 353 RewriteNumPadKeys(event); | 344 RewriteNumPadKeys(event); |
| 354 RewriteExtendedKeys(event); | 345 RewriteExtendedKeys(event); |
| 355 RewriteFunctionKeys(event); | 346 RewriteFunctionKeys(event); |
| 356 } | 347 } |
| 357 | 348 |
| 358 bool EventRewriter::IsAppleKeyboard() const { | 349 bool EventRewriter::IsAppleKeyboard() const { |
| 359 if (last_device_id_ == kBadDeviceId) | 350 if (last_device_id_ == kBadDeviceId) |
| 360 return false; | 351 return false; |
| 361 | 352 |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 VLOG(1) << "Apple keyboard '" << device_name << "' connected: " | 883 VLOG(1) << "Apple keyboard '" << device_name << "' connected: " |
| 893 << "id=" << device_id; | 884 << "id=" << device_id; |
| 894 } | 885 } |
| 895 // Always overwrite the existing device_id since the X server may reuse a | 886 // Always overwrite the existing device_id since the X server may reuse a |
| 896 // device id for an unattached device. | 887 // device id for an unattached device. |
| 897 device_id_to_type_[device_id] = type; | 888 device_id_to_type_[device_id] = type; |
| 898 return type; | 889 return type; |
| 899 } | 890 } |
| 900 | 891 |
| 901 } // namespace chromeos | 892 } // namespace chromeos |
| OLD | NEW |