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

Side by Side Diff: chromeos_keyboard.cc

Issue 3155020: Add GetHardwareKeyboardLayoutName method instead of kHardwareLayout (Closed) Base URL: http://src.chromium.org/git/cros.git
Patch Set: add GethardwareKeyboardLayoutName() Created 10 years, 4 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 | « chromeos_keyboard.h ('k') | load.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 (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS 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 "chromeos_keyboard.h" 5 #include "chromeos_keyboard.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include <X11/XKBlib.h> 9 #include <X11/XKBlib.h>
10 #include <X11/Xlib.h> 10 #include <X11/Xlib.h>
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // layout. Returns true on success. 73 // layout. Returns true on success.
74 bool RemapModifierKeys(const chromeos::ModifierMap& modifier_map) { 74 bool RemapModifierKeys(const chromeos::ModifierMap& modifier_map) {
75 // TODO(yusukes): write auto tests for the function. 75 // TODO(yusukes): write auto tests for the function.
76 const std::string layout_name = GetLayout(); 76 const std::string layout_name = GetLayout();
77 if (layout_name.empty()) { 77 if (layout_name.empty()) {
78 return false; 78 return false;
79 } 79 }
80 return SetLayoutInternal(layout_name, modifier_map); 80 return SetLayoutInternal(layout_name, modifier_map);
81 } 81 }
82 82
83 // Returns the hardware layout name.
84 std::string GetHardwareLayout() {
85 // TODO(peria): write practical code.
86 return "xkb:us::eng";
87 }
88
83 // Returns the current layout name like "us". On error, returns "". 89 // Returns the current layout name like "us". On error, returns "".
84 std::string GetLayout() { 90 std::string GetLayout() {
85 // TODO(yusukes): write auto tests for the function. 91 // TODO(yusukes): write auto tests for the function.
86 std::string command_output = last_full_layout_name_; 92 std::string command_output = last_full_layout_name_;
87 93
88 if (command_output.empty()) { 94 if (command_output.empty()) {
89 // Cache is not available. Execute setxkbmap to get the current layout. 95 // Cache is not available. Execute setxkbmap to get the current layout.
90 if (!ExecuteGetLayoutCommand(&command_output)) { 96 if (!ExecuteGetLayoutCommand(&command_output)) {
91 return ""; 97 return "";
92 } 98 }
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 bool ChromeOSSetCurrentKeyboardLayoutByName(const std::string& layout_name) { 525 bool ChromeOSSetCurrentKeyboardLayoutByName(const std::string& layout_name) {
520 return XKeyboard::Get()->SetLayout(layout_name); 526 return XKeyboard::Get()->SetLayout(layout_name);
521 } 527 }
522 528
523 extern "C" 529 extern "C"
524 bool ChromeOSRemapModifierKeys(const chromeos::ModifierMap& modifier_map) { 530 bool ChromeOSRemapModifierKeys(const chromeos::ModifierMap& modifier_map) {
525 return XKeyboard::Get()->RemapModifierKeys(modifier_map); 531 return XKeyboard::Get()->RemapModifierKeys(modifier_map);
526 } 532 }
527 533
528 extern "C" 534 extern "C"
535 const std::string ChromeOSGetHardwareKeyboardLayoutName() {
536 return XKeyboard::Get()->GetHardwareLayout();
537 }
538
539 extern "C"
529 const std::string ChromeOSGetCurrentKeyboardLayoutName() { 540 const std::string ChromeOSGetCurrentKeyboardLayoutName() {
530 return XKeyboard::Get()->GetLayout(); 541 return XKeyboard::Get()->GetLayout();
531 } 542 }
532 543
533 extern "C" 544 extern "C"
534 bool ChromeOSGetAutoRepeatEnabled(bool* enabled) { 545 bool ChromeOSGetAutoRepeatEnabled(bool* enabled) {
535 return XKeyboard::Get()->GetAutoRepeatEnabled(enabled); 546 return XKeyboard::Get()->GetAutoRepeatEnabled(enabled);
536 } 547 }
537 548
538 extern "C" 549 extern "C"
539 bool ChromeOSSetAutoRepeatEnabled(bool enabled) { 550 bool ChromeOSSetAutoRepeatEnabled(bool enabled) {
540 return XKeyboard::Get()->SetAutoRepeatEnabled(enabled); 551 return XKeyboard::Get()->SetAutoRepeatEnabled(enabled);
541 } 552 }
542 553
543 extern "C" 554 extern "C"
544 bool ChromeOSGetAutoRepeatRate(chromeos::AutoRepeatRate* out_rate) { 555 bool ChromeOSGetAutoRepeatRate(chromeos::AutoRepeatRate* out_rate) {
545 return XKeyboard::Get()->GetAutoRepeatRate(out_rate); 556 return XKeyboard::Get()->GetAutoRepeatRate(out_rate);
546 } 557 }
547 558
548 extern "C" 559 extern "C"
549 bool ChromeOSSetAutoRepeatRate(const chromeos::AutoRepeatRate& rate) { 560 bool ChromeOSSetAutoRepeatRate(const chromeos::AutoRepeatRate& rate) {
550 return XKeyboard::Get()->SetAutoRepeatRate(rate); 561 return XKeyboard::Get()->SetAutoRepeatRate(rate);
551 } 562 }
OLDNEW
« no previous file with comments | « chromeos_keyboard.h ('k') | load.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698