OLD | NEW |
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/chromeos/input_method/xkeyboard.h" | 5 #include "chrome/browser/chromeos/input_method/xkeyboard.h" |
6 | 6 |
7 #include <cstdlib> | 7 #include <cstdlib> |
8 #include <cstring> | 8 #include <cstring> |
9 #include <queue> | 9 #include <queue> |
10 #include <set> | 10 #include <set> |
(...skipping 24 matching lines...) Expand all Loading... |
35 // The default keyboard layout name in the xorg config file. | 35 // The default keyboard layout name in the xorg config file. |
36 const char kDefaultLayoutName[] = "us"; | 36 const char kDefaultLayoutName[] = "us"; |
37 | 37 |
38 // The command we use to set the current XKB layout and modifier key mapping. | 38 // The command we use to set the current XKB layout and modifier key mapping. |
39 // TODO(yusukes): Use libxkbfile.so instead of the command (crosbug.com/13105) | 39 // TODO(yusukes): Use libxkbfile.so instead of the command (crosbug.com/13105) |
40 const char kSetxkbmapCommand[] = "/usr/bin/setxkbmap"; | 40 const char kSetxkbmapCommand[] = "/usr/bin/setxkbmap"; |
41 | 41 |
42 // See the comment at ModifierKey in the .h file. | 42 // See the comment at ModifierKey in the .h file. |
43 ModifierKey kCustomizableKeys[] = { | 43 ModifierKey kCustomizableKeys[] = { |
44 kSearchKey, | 44 kSearchKey, |
45 kLeftControlKey, | 45 kControlKey, |
46 kLeftAltKey | 46 kAltKey |
47 }; | 47 }; |
48 | 48 |
49 // A string for obtaining a mask value for Num Lock. | 49 // A string for obtaining a mask value for Num Lock. |
50 const char kNumLockVirtualModifierString[] = "NumLock"; | 50 const char kNumLockVirtualModifierString[] = "NumLock"; |
51 | 51 |
52 class XKeyboardImpl : public XKeyboard { | 52 class XKeyboardImpl : public XKeyboard { |
53 public: | 53 public: |
54 explicit XKeyboardImpl(const InputMethodUtil& util); | 54 explicit XKeyboardImpl(const InputMethodUtil& util); |
55 virtual ~XKeyboardImpl() {} | 55 virtual ~XKeyboardImpl() {} |
56 | 56 |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 std::string use_search_key_as_str; | 318 std::string use_search_key_as_str; |
319 std::string use_left_control_key_as_str; | 319 std::string use_left_control_key_as_str; |
320 std::string use_left_alt_key_as_str; | 320 std::string use_left_alt_key_as_str; |
321 | 321 |
322 for (size_t i = 0; i < modifier_map.size(); ++i) { | 322 for (size_t i = 0; i < modifier_map.size(); ++i) { |
323 std::string* target = NULL; | 323 std::string* target = NULL; |
324 switch (modifier_map[i].original) { | 324 switch (modifier_map[i].original) { |
325 case kSearchKey: | 325 case kSearchKey: |
326 target = &use_search_key_as_str; | 326 target = &use_search_key_as_str; |
327 break; | 327 break; |
328 case kLeftControlKey: | 328 case kControlKey: |
329 target = &use_left_control_key_as_str; | 329 target = &use_left_control_key_as_str; |
330 break; | 330 break; |
331 case kLeftAltKey: | 331 case kAltKey: |
332 target = &use_left_alt_key_as_str; | 332 target = &use_left_alt_key_as_str; |
333 break; | 333 break; |
334 default: | 334 default: |
335 break; | 335 break; |
336 } | 336 } |
337 if (!target) { | 337 if (!target) { |
338 DVLOG(1) << "We don't support remaping " | 338 DVLOG(1) << "We don't support remaping " |
339 << ModifierKeyToString(modifier_map[i].original); | 339 << ModifierKeyToString(modifier_map[i].original); |
340 return ""; | 340 return ""; |
341 } | 341 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 return true; | 458 return true; |
459 } | 459 } |
460 return BrowserThread::CurrentlyOn(BrowserThread::UI); | 460 return BrowserThread::CurrentlyOn(BrowserThread::UI); |
461 } | 461 } |
462 | 462 |
463 // static | 463 // static |
464 std::string XKeyboardImpl::ModifierKeyToString(ModifierKey key) { | 464 std::string XKeyboardImpl::ModifierKeyToString(ModifierKey key) { |
465 switch (key) { | 465 switch (key) { |
466 case kSearchKey: | 466 case kSearchKey: |
467 return "search"; | 467 return "search"; |
468 case kLeftControlKey: | 468 case kControlKey: |
469 return "leftcontrol"; | 469 return "leftcontrol"; |
470 case kLeftAltKey: | 470 case kAltKey: |
471 return "leftalt"; | 471 return "leftalt"; |
472 case kVoidKey: | 472 case kVoidKey: |
473 return "disabled"; | 473 return "disabled"; |
474 case kCapsLockKey: | 474 case kCapsLockKey: |
475 return "capslock"; | 475 return "capslock"; |
476 case kNumModifierKeys: | 476 case kNumModifierKeys: |
477 break; | 477 break; |
478 } | 478 } |
479 return ""; | 479 return ""; |
480 } | 480 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 return false; | 549 return false; |
550 } | 550 } |
551 | 551 |
552 // static | 552 // static |
553 XKeyboard* XKeyboard::Create(const InputMethodUtil& util) { | 553 XKeyboard* XKeyboard::Create(const InputMethodUtil& util) { |
554 return new XKeyboardImpl(util); | 554 return new XKeyboardImpl(util); |
555 } | 555 } |
556 | 556 |
557 } // namespace input_method | 557 } // namespace input_method |
558 } // namespace chromeos | 558 } // namespace chromeos |
OLD | NEW |