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

Side by Side Diff: chrome/browser/ui/ash/event_rewriter.cc

Issue 11346028: Allow Caps Lock to be remapped [part 2 of 2] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 8 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/ash/event_rewriter.h" 5 #include "chrome/browser/ui/ash/event_rewriter.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "chrome/browser/prefs/pref_service.h" 12 #include "chrome/browser/prefs/pref_service.h"
13 #include "chrome/browser/profiles/profile_manager.h" 13 #include "chrome/browser/profiles/profile_manager.h"
14 #include "ui/aura/root_window.h" 14 #include "ui/aura/root_window.h"
15 #include "ui/base/events/event.h" 15 #include "ui/base/events/event.h"
16 #include "ui/base/keycodes/keyboard_code_conversion.h" 16 #include "ui/base/keycodes/keyboard_code_conversion.h"
17 17
18 #if defined(OS_CHROMEOS) 18 #if defined(OS_CHROMEOS)
19 #include <X11/extensions/XInput2.h> 19 #include <X11/extensions/XInput2.h>
20 #include <X11/keysym.h> 20 #include <X11/keysym.h>
21 #include <X11/XF86keysym.h> 21 #include <X11/XF86keysym.h>
22 #include <X11/Xlib.h> 22 #include <X11/Xlib.h>
23 23
24 // Get rid of a macro from Xlib.h that conflicts with OwnershipService class. 24 // Get rid of a macro from Xlib.h that conflicts with OwnershipService class.
25 #undef Status 25 #undef Status
26 26
27 #include "base/chromeos/chromeos_version.h" 27 #include "base/chromeos/chromeos_version.h"
28 #include "base/command_line.h"
28 #include "chrome/browser/chromeos/input_method/input_method_manager.h" 29 #include "chrome/browser/chromeos/input_method/input_method_manager.h"
29 #include "chrome/browser/chromeos/input_method/xkeyboard.h" 30 #include "chrome/browser/chromeos/input_method/xkeyboard.h"
30 #include "chrome/browser/chromeos/login/base_login_display_host.h" 31 #include "chrome/browser/chromeos/login/base_login_display_host.h"
31 #include "chrome/browser/chromeos/login/user_manager.h" 32 #include "chrome/browser/chromeos/login/user_manager.h"
32 #include "chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.h" 33 #include "chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.h"
34 #include "chrome/common/chrome_switches.h"
33 #include "chrome/common/pref_names.h" 35 #include "chrome/common/pref_names.h"
34 #include "ui/base/keycodes/keyboard_code_conversion_x.h" 36 #include "ui/base/keycodes/keyboard_code_conversion_x.h"
35 #include "ui/base/x/x11_util.h" 37 #include "ui/base/x/x11_util.h"
36 38
37 using chromeos::input_method::InputMethodManager; 39 using chromeos::input_method::InputMethodManager;
38 #endif 40 #endif
39 41
40 namespace { 42 namespace {
41 43
42 const int kBadDeviceId = -1; 44 const int kBadDeviceId = -1;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 case XK_Shift_R: 108 case XK_Shift_R:
107 case XK_Super_R: 109 case XK_Super_R:
108 return true; 110 return true;
109 default: 111 default:
110 break; 112 break;
111 } 113 }
112 return false; 114 return false;
113 } 115 }
114 116
115 bool ShouldRemapCapsLock() { 117 bool ShouldRemapCapsLock() {
116 // Since both German Neo2 XKB layout and Caps Lock depend on Mod3Mask, it's 118 return !CommandLine::ForCurrentProcess()->HasSwitch(
117 // not possible to make both features work. For now, we don't remap Mod3Mask 119 switches::kHasChromeOSKeyboard) &&
118 // when Neo2 is in use. 120 // Since both German Neo2 XKB layout and Caps Lock depend on Mod3Mask,
119 // TODO(yusukes): Remove the restriction. 121 // it's not possible to make both features work. For now, we don't remap
120 return InputMethodManager::GetInstance()->GetCurrentInputMethod().id() != 122 // Mod3Mask when Neo2 is in use.
121 kNeo2LayoutId; 123 // TODO(yusukes): Remove the restriction.
124 (InputMethodManager::GetInstance()->GetCurrentInputMethod().id() !=
125 kNeo2LayoutId);
122 } 126 }
123 #endif 127 #endif
124 128
125 const PrefService* GetPrefService() { 129 const PrefService* GetPrefService() {
126 Profile* profile = ProfileManager::GetDefaultProfile(); 130 Profile* profile = ProfileManager::GetDefaultProfile();
127 if (profile) 131 if (profile)
128 return profile->GetPrefs(); 132 return profile->GetPrefs();
129 return NULL; 133 return NULL;
130 } 134 }
131 135
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 const DeviceType type = EventRewriter::GetDeviceType(device_name); 731 const DeviceType type = EventRewriter::GetDeviceType(device_name);
728 if (type == kDeviceAppleKeyboard) { 732 if (type == kDeviceAppleKeyboard) {
729 VLOG(1) << "Apple keyboard '" << device_name << "' connected: " 733 VLOG(1) << "Apple keyboard '" << device_name << "' connected: "
730 << "id=" << device_id; 734 << "id=" << device_id;
731 } 735 }
732 // Always overwrite the existing device_id since the X server may reuse a 736 // Always overwrite the existing device_id since the X server may reuse a
733 // device id for an unattached device. 737 // device id for an unattached device.
734 device_id_to_type_[device_id] = type; 738 device_id_to_type_[device_id] = type;
735 return type; 739 return type;
736 } 740 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698