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

Unified Diff: chrome/browser/chromeos/input_method/xkeyboard.cc

Issue 6975057: Listen to XI_HierarchyChanged events and call setxkbmap when needed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added workaround for crbug.com/84694 Created 9 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/input_method/xkeyboard.cc
diff --git a/chrome/browser/chromeos/input_method/xkeyboard.cc b/chrome/browser/chromeos/input_method/xkeyboard.cc
index 118824ef381969399d57a9076a8d4d679b5665fa..2e5a6088096d80cf56f06cbe2a66b73bfb920e7c 100644
--- a/chrome/browser/chromeos/input_method/xkeyboard.cc
+++ b/chrome/browser/chromeos/input_method/xkeyboard.cc
@@ -137,19 +137,31 @@ class XKeyboard {
// Sets the current keyboard layout to |layout_name|. This function does not
// change the current mapping of the modifier keys. Returns true on success.
bool SetLayout(const std::string& layout_name) {
- if (SetLayoutInternal(layout_name, current_modifier_map_)) {
+ if (SetLayoutInternal(layout_name, current_modifier_map_, false)) {
current_layout_name_ = layout_name;
return true;
}
return false;
}
+ // Sets the current keyboard layout to |current_layout_name_| again.
+ // See crosbug.com/15851 for details.
+ bool ReapplyLayout() {
+ if (current_layout_name_.empty()) {
+ LOG(ERROR) << "Can't reapply XKB layout: layout unknown";
+ return false;
+ }
+ VLOG(1) << "ReapplyLayout: setting to " << current_layout_name_;
+ return SetLayoutInternal(
+ current_layout_name_, current_modifier_map_, true /* force */);
+ }
+
// Remaps modifier keys. This function does not change the current keyboard
// layout. Returns true on success.
bool RemapModifierKeys(const ModifierMap& modifier_map) {
const std::string layout_name = current_layout_name_.empty() ?
kDefaultLayoutName : current_layout_name_;
- if (SetLayoutInternal(layout_name, modifier_map)) {
+ if (SetLayoutInternal(layout_name, modifier_map, false)) {
current_layout_name_ = layout_name;
current_modifier_map_ = modifier_map;
return true;
@@ -210,7 +222,8 @@ class XKeyboard {
// This function is used by SetLayout() and RemapModifierKeys(). Calls
// setxkbmap command if needed, and updates the last_full_layout_name_ cache.
bool SetLayoutInternal(const std::string& layout_name,
- const ModifierMap& modifier_map) {
+ const ModifierMap& modifier_map,
+ bool force) {
if (!CrosLibrary::Get()->EnsureLoaded()) {
// We should not try to change a layout inside ui_tests.
return false;
@@ -225,7 +238,7 @@ class XKeyboard {
if (!current_layout_name_.empty()) {
const std::string current_layout = CreateFullXkbLayoutName(
current_layout_name_, current_modifier_map_);
- if (current_layout == layouts_to_set) {
+ if (!force && (current_layout == layouts_to_set)) {
DLOG(INFO) << "The requested layout is already set: " << layouts_to_set;
return true;
}
@@ -391,6 +404,10 @@ bool SetCurrentKeyboardLayoutByName(const std::string& layout_name) {
return XKeyboard::GetInstance()->SetLayout(layout_name);
}
+bool ReapplyCurrentKeyboardLayout() {
+ return XKeyboard::GetInstance()->ReapplyLayout();
+}
+
bool RemapModifierKeys(const ModifierMap& modifier_map) {
return XKeyboard::GetInstance()->RemapModifierKeys(modifier_map);
}
« no previous file with comments | « chrome/browser/chromeos/input_method/xkeyboard.h ('k') | chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698