Chromium Code Reviews| 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> | 8 #include <utility> |
| 9 | 9 |
| 10 #include <X11/XKBlib.h> | 10 #include <X11/XKBlib.h> |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 271 // Executes 'setxkbmap -layout ...' command asynchronously using a layout name | 271 // Executes 'setxkbmap -layout ...' command asynchronously using a layout name |
| 272 // in the |execute_queue_|. Do nothing if the queue is empty. | 272 // in the |execute_queue_|. Do nothing if the queue is empty. |
| 273 // TODO(yusukes): Use libxkbfile.so instead of the command (crosbug.com/13105) | 273 // TODO(yusukes): Use libxkbfile.so instead of the command (crosbug.com/13105) |
| 274 void MaybeExecuteSetLayoutCommand() { | 274 void MaybeExecuteSetLayoutCommand() { |
| 275 if (execute_queue_.empty()) { | 275 if (execute_queue_.empty()) { |
| 276 return; | 276 return; |
| 277 } | 277 } |
| 278 const std::string layout_to_set = execute_queue_.front(); | 278 const std::string layout_to_set = execute_queue_.front(); |
| 279 | 279 |
| 280 std::vector<std::string> argv; | 280 std::vector<std::string> argv; |
| 281 base::file_handle_mapping_vector fds_to_remap; | 281 base::file_handle_mapping_vector fds_to_remap; |
|
Yusuke Sato
2011/07/13 01:50:35
ditto
| |
| 282 base::ProcessHandle handle = base::kNullProcessHandle; | 282 base::ProcessHandle handle = base::kNullProcessHandle; |
| 283 | 283 |
| 284 argv.push_back(kSetxkbmapCommand); | 284 argv.push_back(kSetxkbmapCommand); |
| 285 argv.push_back("-layout"); | 285 argv.push_back("-layout"); |
| 286 argv.push_back(layout_to_set); | 286 argv.push_back(layout_to_set); |
| 287 argv.push_back("-synch"); | 287 argv.push_back("-synch"); |
| 288 const bool result = base::LaunchApp(argv, | 288 |
| 289 fds_to_remap, // No remapping. | 289 base::LaunchOptions options; |
| 290 false, // Don't wait. | 290 options.process_handle = &handle; |
| 291 &handle); | 291 if (!base::LaunchProcess(argv, options)) { |
| 292 if (!result) { | |
| 293 LOG(ERROR) << "Failed to execute setxkbmap: " << layout_to_set; | 292 LOG(ERROR) << "Failed to execute setxkbmap: " << layout_to_set; |
| 294 execute_queue_ = std::queue<std::string>(); // clear the queue. | 293 execute_queue_ = std::queue<std::string>(); // clear the queue. |
| 295 return; | 294 return; |
| 296 } | 295 } |
| 297 | 296 |
| 298 // g_child_watch_add is necessary to prevent the process from becoming a | 297 // g_child_watch_add is necessary to prevent the process from becoming a |
| 299 // zombie. | 298 // zombie. |
| 300 const base::ProcessId pid = base::GetProcId(handle); | 299 const base::ProcessId pid = base::GetProcId(handle); |
| 301 g_child_watch_add(pid, | 300 g_child_watch_add(pid, |
| 302 reinterpret_cast<GChildWatchFunc>(OnSetLayoutFinish), | 301 reinterpret_cast<GChildWatchFunc>(OnSetLayoutFinish), |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 447 bool SetAutoRepeatEnabled(bool enabled) { | 446 bool SetAutoRepeatEnabled(bool enabled) { |
| 448 return XKeyboard::GetInstance()->SetAutoRepeatEnabled(enabled); | 447 return XKeyboard::GetInstance()->SetAutoRepeatEnabled(enabled); |
| 449 } | 448 } |
| 450 | 449 |
| 451 bool SetAutoRepeatRate(const AutoRepeatRate& rate) { | 450 bool SetAutoRepeatRate(const AutoRepeatRate& rate) { |
| 452 return XKeyboard::GetInstance()->SetAutoRepeatRate(rate); | 451 return XKeyboard::GetInstance()->SetAutoRepeatRate(rate); |
| 453 } | 452 } |
| 454 | 453 |
| 455 } // namespace input_method | 454 } // namespace input_method |
| 456 } // namespace chromeos | 455 } // namespace chromeos |
| OLD | NEW |