OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/input_method/xkeyboard.h" | 5 #include "chrome/browser/chromeos/input_method/xkeyboard.h" |
6 | 6 |
7 #include <queue> | 7 #include <queue> |
8 #include <utility> | |
9 #include <set> | 8 #include <set> |
10 #include <string> | 9 #include <string> |
| 10 #include <utility> |
11 | 11 |
12 #include <X11/XKBlib.h> | 12 #include <X11/XKBlib.h> |
13 #include <X11/Xlib.h> | 13 #include <X11/Xlib.h> |
14 #include <glib.h> | 14 #include <glib.h> |
15 #include <stdlib.h> | 15 #include <stdlib.h> |
16 #include <string.h> | 16 #include <string.h> |
17 | 17 |
| 18 #include "base/logging.h" |
18 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
19 #include "base/memory/singleton.h" | 20 #include "base/memory/singleton.h" |
20 #include "base/logging.h" | 21 #include "base/process_util.h" |
21 #include "base/string_util.h" | 22 #include "base/string_util.h" |
22 #include "base/process_util.h" | 23 #include "base/stringprintf.h" |
23 #include "chrome/browser/chromeos/cros/cros_library.h" | 24 #include "chrome/browser/chromeos/cros/cros_library.h" |
24 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 25 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
25 #include "content/browser/browser_thread.h" | 26 #include "content/browser/browser_thread.h" |
26 #include "ui/base/x/x11_util.h" | 27 #include "ui/base/x/x11_util.h" |
27 | 28 |
28 namespace chromeos { | 29 namespace chromeos { |
29 namespace input_method { | 30 namespace input_method { |
30 namespace { | 31 namespace { |
31 | 32 |
32 // The default keyboard layout name in the xorg config file. | 33 // The default keyboard layout name in the xorg config file. |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 use_left_alt_key_as_str.empty()) { | 376 use_left_alt_key_as_str.empty()) { |
376 LOG(ERROR) << "Incomplete ModifierMap: size=" << modifier_map.size(); | 377 LOG(ERROR) << "Incomplete ModifierMap: size=" << modifier_map.size(); |
377 return ""; | 378 return ""; |
378 } | 379 } |
379 | 380 |
380 if (XkbLayoutSets::KeepCapsLock(layout_name)) { | 381 if (XkbLayoutSets::KeepCapsLock(layout_name)) { |
381 use_search_key_as_str = ModifierKeyToString(kSearchKey); | 382 use_search_key_as_str = ModifierKeyToString(kSearchKey); |
382 } | 383 } |
383 | 384 |
384 std::string full_xkb_layout_name = | 385 std::string full_xkb_layout_name = |
385 StringPrintf("%s+chromeos(%s_%s_%s%s)", layout_name.c_str(), | 386 base::StringPrintf( |
386 use_search_key_as_str.c_str(), | 387 "%s+chromeos(%s_%s_%s%s)", |
387 use_left_control_key_as_str.c_str(), | 388 layout_name.c_str(), |
388 use_left_alt_key_as_str.c_str(), | 389 use_search_key_as_str.c_str(), |
389 XkbLayoutSets::KeepRightAlt(layout_name) ? "_keepralt" : ""); | 390 use_left_control_key_as_str.c_str(), |
| 391 use_left_alt_key_as_str.c_str(), |
| 392 XkbLayoutSets::KeepRightAlt(layout_name) ? "_keepralt" : ""); |
390 | 393 |
391 if ((full_xkb_layout_name.substr(0, 3) != "us+") && | 394 if ((full_xkb_layout_name.substr(0, 3) != "us+") && |
392 (full_xkb_layout_name.substr(0, 3) != "us(")) { | 395 (full_xkb_layout_name.substr(0, 3) != "us(")) { |
393 full_xkb_layout_name += ",us"; | 396 full_xkb_layout_name += ",us"; |
394 } | 397 } |
395 | 398 |
396 return full_xkb_layout_name; | 399 return full_xkb_layout_name; |
397 } | 400 } |
398 | 401 |
399 bool CapsLockIsEnabled() { | 402 bool CapsLockIsEnabled() { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 bool SetAutoRepeatEnabled(bool enabled) { | 439 bool SetAutoRepeatEnabled(bool enabled) { |
437 return XKeyboard::GetInstance()->SetAutoRepeatEnabled(enabled); | 440 return XKeyboard::GetInstance()->SetAutoRepeatEnabled(enabled); |
438 } | 441 } |
439 | 442 |
440 bool SetAutoRepeatRate(const AutoRepeatRate& rate) { | 443 bool SetAutoRepeatRate(const AutoRepeatRate& rate) { |
441 return XKeyboard::GetInstance()->SetAutoRepeatRate(rate); | 444 return XKeyboard::GetInstance()->SetAutoRepeatRate(rate); |
442 } | 445 } |
443 | 446 |
444 } // namespace input_method | 447 } // namespace input_method |
445 } // namespace chromeos | 448 } // namespace chromeos |
OLD | NEW |