Chromium Code Reviews| 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 aaf1444d63d38f12a75c544d7a8dd85af96ab3cb..263721922e9415ea502109ad45361c746bc96b6f 100644 |
| --- a/chrome/browser/chromeos/input_method/xkeyboard.cc |
| +++ b/chrome/browser/chromeos/input_method/xkeyboard.cc |
| @@ -4,6 +4,7 @@ |
| #include "chrome/browser/chromeos/input_method/xkeyboard.h" |
| +#include <queue> |
| #include <utility> |
| #include <X11/XKBlib.h> |
| @@ -253,7 +254,10 @@ class XKeyboard { |
| LOG(WARNING) << (force ? "Reapply" : "Set") |
| << " layout: " << layouts_to_set; |
| - ExecuteSetLayoutCommand(layouts_to_set); |
| + execute_queue_.push(layouts_to_set); |
|
Daniel Kurtz
2011/06/07 03:19:38
Is layouts_to_set a collection or a single layout?
Yusuke Sato
2011/06/07 04:54:58
Done.
|
| + if (execute_queue_.size() == 1) { |
|
satorux1
2011/06/07 03:19:27
Checking the size here looks a bit tricky. Maybe b
Yusuke Sato
2011/06/07 04:54:58
Modifed both this function and the callback. PTAL.
|
| + ExecuteSetLayoutCommand(layouts_to_set); |
| + } |
| return true; |
| } |
| @@ -267,6 +271,7 @@ class XKeyboard { |
| argv.push_back(kSetxkbmapCommand); |
| argv.push_back("-layout"); |
| argv.push_back(layouts_to_set); |
| + argv.push_back("-synch"); |
| const bool result = base::LaunchApp(argv, |
| fds_to_remap, // No remapping. |
| false, // Don't wait. |
| @@ -282,16 +287,24 @@ class XKeyboard { |
| g_child_watch_add(pid, |
| reinterpret_cast<GChildWatchFunc>(OnSetLayoutFinish), |
| this); |
| + VLOG(1) << "ExecuteSetLayoutCommand: " << layouts_to_set << ": pid=" << pid; |
| } |
| static void OnSetLayoutFinish(GPid pid, gint status, XKeyboard* self) { |
| - DLOG(INFO) << "OnSetLayoutFinish: pid=" << pid; |
| + VLOG(1) << "OnSetLayoutFinish: pid=" << pid; |
| + DCHECK(!self->execute_queue_.empty()); |
| + self->execute_queue_.pop(); |
| + if (!self->execute_queue_.empty()) { |
| + self->ExecuteSetLayoutCommand(self->execute_queue_.front()); |
| + } |
| } |
| // The XKB layout name which we set last time like "us" and "us(dvorak)". |
| std::string current_layout_name_; |
| // The mapping of modifier keys we set last time. |
| ModifierMap current_modifier_map_; |
| + // A queue for executing setxkbmap one by one. |
| + std::queue<std::string> execute_queue_; |
| DISALLOW_COPY_AND_ASSIGN(XKeyboard); |
| }; |