OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chromeos/ime/xkeyboard.h" | 5 #include "chromeos/ime/ime_keyboard.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> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 if (layout_name.find_first_not_of(kValidLayoutNameCharacters) != | 106 if (layout_name.find_first_not_of(kValidLayoutNameCharacters) != |
107 std::string::npos) { | 107 std::string::npos) { |
108 DVLOG(1) << "Invalid layout_name: " << layout_name; | 108 DVLOG(1) << "Invalid layout_name: " << layout_name; |
109 return false; | 109 return false; |
110 } | 110 } |
111 | 111 |
112 return true; | 112 return true; |
113 } | 113 } |
114 | 114 |
115 class XKeyboardImpl : public XKeyboard { | 115 class ImeKeyboardX11 : public ImeKeyboard { |
116 public: | 116 public: |
117 XKeyboardImpl(); | 117 ImeKeyboardX11(); |
118 virtual ~XKeyboardImpl() {} | 118 virtual ~ImeKeyboardX11() {} |
119 | 119 |
120 // Adds/removes observer. | 120 // Adds/removes observer. |
121 virtual void AddObserver(Observer* observer) OVERRIDE; | 121 virtual void AddObserver(Observer* observer) OVERRIDE; |
122 virtual void RemoveObserver(Observer* observer) OVERRIDE; | 122 virtual void RemoveObserver(Observer* observer) OVERRIDE; |
123 | 123 |
124 // Overridden from XKeyboard: | 124 // ImeKeyboard: |
125 virtual bool SetCurrentKeyboardLayoutByName( | 125 virtual bool SetCurrentKeyboardLayoutByName( |
126 const std::string& layout_name) OVERRIDE; | 126 const std::string& layout_name) OVERRIDE; |
127 virtual bool ReapplyCurrentKeyboardLayout() OVERRIDE; | 127 virtual bool ReapplyCurrentKeyboardLayout() OVERRIDE; |
128 virtual void ReapplyCurrentModifierLockStatus() OVERRIDE; | 128 virtual void ReapplyCurrentModifierLockStatus() OVERRIDE; |
129 virtual void DisableNumLock() OVERRIDE; | 129 virtual void DisableNumLock() OVERRIDE; |
130 virtual void SetCapsLockEnabled(bool enable_caps_lock) OVERRIDE; | 130 virtual void SetCapsLockEnabled(bool enable_caps_lock) OVERRIDE; |
131 virtual bool CapsLockIsEnabled() OVERRIDE; | 131 virtual bool CapsLockIsEnabled() OVERRIDE; |
132 virtual bool IsISOLevel5ShiftAvailable() const OVERRIDE; | 132 virtual bool IsISOLevel5ShiftAvailable() const OVERRIDE; |
133 virtual bool IsAltGrAvailable() const OVERRIDE; | 133 virtual bool IsAltGrAvailable() const OVERRIDE; |
134 virtual bool SetAutoRepeatEnabled(bool enabled) OVERRIDE; | 134 virtual bool SetAutoRepeatEnabled(bool enabled) OVERRIDE; |
(...skipping 29 matching lines...) Expand all Loading... |
164 bool current_caps_lock_status_; | 164 bool current_caps_lock_status_; |
165 | 165 |
166 // The XKB layout name which we set last time like "us" and "us(dvorak)". | 166 // The XKB layout name which we set last time like "us" and "us(dvorak)". |
167 std::string current_layout_name_; | 167 std::string current_layout_name_; |
168 | 168 |
169 // A queue for executing setxkbmap one by one. | 169 // A queue for executing setxkbmap one by one. |
170 std::queue<std::string> execute_queue_; | 170 std::queue<std::string> execute_queue_; |
171 | 171 |
172 base::ThreadChecker thread_checker_; | 172 base::ThreadChecker thread_checker_; |
173 | 173 |
174 base::WeakPtrFactory<XKeyboardImpl> weak_factory_; | 174 base::WeakPtrFactory<ImeKeyboardX11> weak_factory_; |
175 | 175 |
176 ObserverList<Observer> observers_; | 176 ObserverList<Observer> observers_; |
177 | 177 |
178 DISALLOW_COPY_AND_ASSIGN(XKeyboardImpl); | 178 DISALLOW_COPY_AND_ASSIGN(ImeKeyboardX11); |
179 }; | 179 }; |
180 | 180 |
181 XKeyboardImpl::XKeyboardImpl() | 181 ImeKeyboardX11::ImeKeyboardX11() |
182 : is_running_on_chrome_os_(base::SysInfo::IsRunningOnChromeOS()), | 182 : is_running_on_chrome_os_(base::SysInfo::IsRunningOnChromeOS()), |
183 weak_factory_(this) { | 183 weak_factory_(this) { |
184 // X must be already initialized. | 184 // X must be already initialized. |
185 CHECK(GetXDisplay()); | 185 CHECK(GetXDisplay()); |
186 | 186 |
187 num_lock_mask_ = GetNumLockMask(); | 187 num_lock_mask_ = GetNumLockMask(); |
188 | 188 |
189 if (is_running_on_chrome_os_) { | 189 if (is_running_on_chrome_os_) { |
190 // Some code seems to assume that Mod2Mask is always assigned to | 190 // Some code seems to assume that Mod2Mask is always assigned to |
191 // Num Lock. | 191 // Num Lock. |
192 // | 192 // |
193 // TODO(yusukes): Check the assumption is really okay. If not, | 193 // TODO(yusukes): Check the assumption is really okay. If not, |
194 // modify the Aura code, and then remove the CHECK below. | 194 // modify the Aura code, and then remove the CHECK below. |
195 LOG_IF(ERROR, num_lock_mask_ != Mod2Mask) | 195 LOG_IF(ERROR, num_lock_mask_ != Mod2Mask) |
196 << "NumLock is not assigned to Mod2Mask. : " << num_lock_mask_; | 196 << "NumLock is not assigned to Mod2Mask. : " << num_lock_mask_; |
197 } | 197 } |
198 | 198 |
199 current_caps_lock_status_ = CapsLockIsEnabled(); | 199 current_caps_lock_status_ = CapsLockIsEnabled(); |
200 } | 200 } |
201 | 201 |
202 void XKeyboardImpl::AddObserver(XKeyboard::Observer* observer) { | 202 void ImeKeyboardX11::AddObserver(Observer* observer) { |
203 observers_.AddObserver(observer); | 203 observers_.AddObserver(observer); |
204 } | 204 } |
205 | 205 |
206 void XKeyboardImpl::RemoveObserver(XKeyboard::Observer* observer) { | 206 void ImeKeyboardX11::RemoveObserver(Observer* observer) { |
207 observers_.RemoveObserver(observer); | 207 observers_.RemoveObserver(observer); |
208 } | 208 } |
209 | 209 |
210 unsigned int XKeyboardImpl::GetNumLockMask() { | 210 unsigned int ImeKeyboardX11::GetNumLockMask() { |
211 DCHECK(thread_checker_.CalledOnValidThread()); | 211 DCHECK(thread_checker_.CalledOnValidThread()); |
212 static const unsigned int kBadMask = 0; | 212 static const unsigned int kBadMask = 0; |
213 | 213 |
214 unsigned int real_mask = kBadMask; | 214 unsigned int real_mask = kBadMask; |
215 XkbDescPtr xkb_desc = | 215 XkbDescPtr xkb_desc = |
216 XkbGetKeyboard(GetXDisplay(), XkbAllComponentsMask, XkbUseCoreKbd); | 216 XkbGetKeyboard(GetXDisplay(), XkbAllComponentsMask, XkbUseCoreKbd); |
217 if (!xkb_desc) | 217 if (!xkb_desc) |
218 return kBadMask; | 218 return kBadMask; |
219 | 219 |
220 if (xkb_desc->dpy && xkb_desc->names) { | 220 if (xkb_desc->dpy && xkb_desc->names) { |
(...skipping 13 matching lines...) Expand all Loading... |
234 real_mask = kBadMask; // reset the return value, just in case. | 234 real_mask = kBadMask; // reset the return value, just in case. |
235 } | 235 } |
236 break; | 236 break; |
237 } | 237 } |
238 } | 238 } |
239 } | 239 } |
240 XkbFreeKeyboard(xkb_desc, 0, True /* free all components */); | 240 XkbFreeKeyboard(xkb_desc, 0, True /* free all components */); |
241 return real_mask; | 241 return real_mask; |
242 } | 242 } |
243 | 243 |
244 void XKeyboardImpl::SetLockedModifiers(bool caps_lock_enabled) { | 244 void ImeKeyboardX11::SetLockedModifiers(bool caps_lock_enabled) { |
245 DCHECK(thread_checker_.CalledOnValidThread()); | 245 DCHECK(thread_checker_.CalledOnValidThread()); |
246 | 246 |
247 // Always turn off num lock. | 247 // Always turn off num lock. |
248 unsigned int affect_mask = num_lock_mask_; | 248 unsigned int affect_mask = num_lock_mask_; |
249 unsigned int value_mask = 0; | 249 unsigned int value_mask = 0; |
250 | 250 |
251 affect_mask |= LockMask; | 251 affect_mask |= LockMask; |
252 value_mask |= (caps_lock_enabled ? LockMask : 0); | 252 value_mask |= (caps_lock_enabled ? LockMask : 0); |
253 current_caps_lock_status_ = caps_lock_enabled; | 253 current_caps_lock_status_ = caps_lock_enabled; |
254 | 254 |
255 XkbLockModifiers(GetXDisplay(), XkbUseCoreKbd, affect_mask, value_mask); | 255 XkbLockModifiers(GetXDisplay(), XkbUseCoreKbd, affect_mask, value_mask); |
256 } | 256 } |
257 | 257 |
258 bool XKeyboardImpl::SetLayoutInternal(const std::string& layout_name, | 258 bool ImeKeyboardX11::SetLayoutInternal(const std::string& layout_name, |
259 bool force) { | 259 bool force) { |
260 if (!is_running_on_chrome_os_) { | 260 if (!is_running_on_chrome_os_) { |
261 // We should not try to change a layout on Linux or inside ui_tests. Just | 261 // We should not try to change a layout on Linux or inside ui_tests. Just |
262 // return true. | 262 // return true. |
263 return true; | 263 return true; |
264 } | 264 } |
265 | 265 |
266 if (!CheckLayoutName(layout_name)) | 266 if (!CheckLayoutName(layout_name)) |
267 return false; | 267 return false; |
268 | 268 |
269 if (!force && (current_layout_name_ == layout_name)) { | 269 if (!force && (current_layout_name_ == layout_name)) { |
(...skipping 12 matching lines...) Expand all Loading... |
282 execute_queue_.push(layout_name); | 282 execute_queue_.push(layout_name); |
283 if (start_execution) | 283 if (start_execution) |
284 MaybeExecuteSetLayoutCommand(); | 284 MaybeExecuteSetLayoutCommand(); |
285 | 285 |
286 return true; | 286 return true; |
287 } | 287 } |
288 | 288 |
289 // Executes 'setxkbmap -layout ...' command asynchronously using a layout name | 289 // Executes 'setxkbmap -layout ...' command asynchronously using a layout name |
290 // in the |execute_queue_|. Do nothing if the queue is empty. | 290 // in the |execute_queue_|. Do nothing if the queue is empty. |
291 // TODO(yusukes): Use libxkbfile.so instead of the command (crosbug.com/13105) | 291 // TODO(yusukes): Use libxkbfile.so instead of the command (crosbug.com/13105) |
292 void XKeyboardImpl::MaybeExecuteSetLayoutCommand() { | 292 void ImeKeyboardX11::MaybeExecuteSetLayoutCommand() { |
293 if (execute_queue_.empty()) | 293 if (execute_queue_.empty()) |
294 return; | 294 return; |
295 const std::string layout_to_set = execute_queue_.front(); | 295 const std::string layout_to_set = execute_queue_.front(); |
296 | 296 |
297 std::vector<std::string> argv; | 297 std::vector<std::string> argv; |
298 base::ProcessHandle handle = base::kNullProcessHandle; | 298 base::ProcessHandle handle = base::kNullProcessHandle; |
299 | 299 |
300 argv.push_back(kSetxkbmapCommand); | 300 argv.push_back(kSetxkbmapCommand); |
301 argv.push_back("-layout"); | 301 argv.push_back("-layout"); |
302 argv.push_back(layout_to_set); | 302 argv.push_back(layout_to_set); |
303 argv.push_back("-synch"); | 303 argv.push_back("-synch"); |
304 | 304 |
305 if (!base::LaunchProcess(argv, base::LaunchOptions(), &handle)) { | 305 if (!base::LaunchProcess(argv, base::LaunchOptions(), &handle)) { |
306 DVLOG(1) << "Failed to execute setxkbmap: " << layout_to_set; | 306 DVLOG(1) << "Failed to execute setxkbmap: " << layout_to_set; |
307 execute_queue_ = std::queue<std::string>(); // clear the queue. | 307 execute_queue_ = std::queue<std::string>(); // clear the queue. |
308 return; | 308 return; |
309 } | 309 } |
310 | 310 |
311 PollUntilChildFinish(handle); | 311 PollUntilChildFinish(handle); |
312 | 312 |
313 DVLOG(1) << "ExecuteSetLayoutCommand: " | 313 DVLOG(1) << "ExecuteSetLayoutCommand: " << layout_to_set |
314 << layout_to_set << ": pid=" << base::GetProcId(handle); | 314 << ": pid=" << base::GetProcId(handle); |
315 } | 315 } |
316 | 316 |
317 // Delay and loop until child process finishes and call the callback. | 317 // Delay and loop until child process finishes and call the callback. |
318 void XKeyboardImpl::PollUntilChildFinish(const base::ProcessHandle handle) { | 318 void ImeKeyboardX11::PollUntilChildFinish(const base::ProcessHandle handle) { |
319 int exit_code; | 319 int exit_code; |
320 DVLOG(1) << "PollUntilChildFinish: poll for pid=" << base::GetProcId(handle); | 320 DVLOG(1) << "PollUntilChildFinish: poll for pid=" << base::GetProcId(handle); |
321 switch (base::GetTerminationStatus(handle, &exit_code)) { | 321 switch (base::GetTerminationStatus(handle, &exit_code)) { |
322 case base::TERMINATION_STATUS_STILL_RUNNING: | 322 case base::TERMINATION_STATUS_STILL_RUNNING: |
323 DVLOG(1) << "PollUntilChildFinish: Try waiting again"; | 323 DVLOG(1) << "PollUntilChildFinish: Try waiting again"; |
324 base::MessageLoop::current()->PostDelayedTask( | 324 base::MessageLoop::current()->PostDelayedTask( |
325 FROM_HERE, | 325 FROM_HERE, |
326 base::Bind(&XKeyboardImpl::PollUntilChildFinish, | 326 base::Bind(&ImeKeyboardX11::PollUntilChildFinish, |
327 weak_factory_.GetWeakPtr(), handle), | 327 weak_factory_.GetWeakPtr(), |
| 328 handle), |
328 base::TimeDelta::FromMilliseconds(kSetLayoutCommandCheckDelayMs)); | 329 base::TimeDelta::FromMilliseconds(kSetLayoutCommandCheckDelayMs)); |
329 return; | 330 return; |
330 | 331 |
331 case base::TERMINATION_STATUS_NORMAL_TERMINATION: | 332 case base::TERMINATION_STATUS_NORMAL_TERMINATION: |
332 DVLOG(1) << "PollUntilChildFinish: Child process finished"; | 333 DVLOG(1) << "PollUntilChildFinish: Child process finished"; |
333 OnSetLayoutFinish(); | 334 OnSetLayoutFinish(); |
334 return; | 335 return; |
335 | 336 |
336 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: | 337 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: |
337 DVLOG(1) << "PollUntilChildFinish: Abnormal exit code: " << exit_code; | 338 DVLOG(1) << "PollUntilChildFinish: Abnormal exit code: " << exit_code; |
338 OnSetLayoutFinish(); | 339 OnSetLayoutFinish(); |
339 return; | 340 return; |
340 | 341 |
341 default: | 342 default: |
342 NOTIMPLEMENTED(); | 343 NOTIMPLEMENTED(); |
343 OnSetLayoutFinish(); | 344 OnSetLayoutFinish(); |
344 return; | 345 return; |
345 } | 346 } |
346 } | 347 } |
347 | 348 |
348 bool XKeyboardImpl::CapsLockIsEnabled() { | 349 bool ImeKeyboardX11::CapsLockIsEnabled() { |
349 DCHECK(thread_checker_.CalledOnValidThread()); | 350 DCHECK(thread_checker_.CalledOnValidThread()); |
350 XkbStateRec status; | 351 XkbStateRec status; |
351 XkbGetState(GetXDisplay(), XkbUseCoreKbd, &status); | 352 XkbGetState(GetXDisplay(), XkbUseCoreKbd, &status); |
352 return (status.locked_mods & LockMask); | 353 return (status.locked_mods & LockMask); |
353 } | 354 } |
354 | 355 |
355 bool XKeyboardImpl::IsISOLevel5ShiftAvailable() const { | 356 bool ImeKeyboardX11::IsISOLevel5ShiftAvailable() const { |
356 for (size_t i = 0; i < arraysize(kISOLevel5ShiftLayoutIds); ++i) { | 357 for (size_t i = 0; i < arraysize(kISOLevel5ShiftLayoutIds); ++i) { |
357 if (current_layout_name_ == kISOLevel5ShiftLayoutIds[i]) | 358 if (current_layout_name_ == kISOLevel5ShiftLayoutIds[i]) |
358 return true; | 359 return true; |
359 } | 360 } |
360 return false; | 361 return false; |
361 } | 362 } |
362 | 363 |
363 bool XKeyboardImpl::IsAltGrAvailable() const { | 364 bool ImeKeyboardX11::IsAltGrAvailable() const { |
364 for (size_t i = 0; i < arraysize(kAltGrLayoutIds); ++i) { | 365 for (size_t i = 0; i < arraysize(kAltGrLayoutIds); ++i) { |
365 if (current_layout_name_ == kAltGrLayoutIds[i]) | 366 if (current_layout_name_ == kAltGrLayoutIds[i]) |
366 return true; | 367 return true; |
367 } | 368 } |
368 return false; | 369 return false; |
369 } | 370 } |
370 | 371 |
371 | 372 bool ImeKeyboardX11::SetAutoRepeatEnabled(bool enabled) { |
372 bool XKeyboardImpl::SetAutoRepeatEnabled(bool enabled) { | |
373 if (enabled) | 373 if (enabled) |
374 XAutoRepeatOn(GetXDisplay()); | 374 XAutoRepeatOn(GetXDisplay()); |
375 else | 375 else |
376 XAutoRepeatOff(GetXDisplay()); | 376 XAutoRepeatOff(GetXDisplay()); |
377 DVLOG(1) << "Set auto-repeat mode to: " << (enabled ? "on" : "off"); | 377 DVLOG(1) << "Set auto-repeat mode to: " << (enabled ? "on" : "off"); |
378 return true; | 378 return true; |
379 } | 379 } |
380 | 380 |
381 bool XKeyboardImpl::SetAutoRepeatRate(const AutoRepeatRate& rate) { | 381 bool ImeKeyboardX11::SetAutoRepeatRate(const AutoRepeatRate& rate) { |
382 DVLOG(1) << "Set auto-repeat rate to: " | 382 DVLOG(1) << "Set auto-repeat rate to: " |
383 << rate.initial_delay_in_ms << " ms delay, " | 383 << rate.initial_delay_in_ms << " ms delay, " |
384 << rate.repeat_interval_in_ms << " ms interval"; | 384 << rate.repeat_interval_in_ms << " ms interval"; |
385 if (XkbSetAutoRepeatRate(GetXDisplay(), XkbUseCoreKbd, | 385 if (XkbSetAutoRepeatRate(GetXDisplay(), XkbUseCoreKbd, |
386 rate.initial_delay_in_ms, | 386 rate.initial_delay_in_ms, |
387 rate.repeat_interval_in_ms) != True) { | 387 rate.repeat_interval_in_ms) != True) { |
388 DVLOG(1) << "Failed to set auto-repeat rate"; | 388 DVLOG(1) << "Failed to set auto-repeat rate"; |
389 return false; | 389 return false; |
390 } | 390 } |
391 return true; | 391 return true; |
392 } | 392 } |
393 | 393 |
394 void XKeyboardImpl::SetCapsLockEnabled(bool enable_caps_lock) { | 394 void ImeKeyboardX11::SetCapsLockEnabled(bool enable_caps_lock) { |
395 bool old_state = current_caps_lock_status_; | 395 bool old_state = current_caps_lock_status_; |
396 SetLockedModifiers(enable_caps_lock); | 396 SetLockedModifiers(enable_caps_lock); |
397 if (old_state != enable_caps_lock) { | 397 if (old_state != enable_caps_lock) { |
398 FOR_EACH_OBSERVER(XKeyboard::Observer, observers_, | 398 FOR_EACH_OBSERVER(ImeKeyboard::Observer, observers_, |
399 OnCapsLockChanged(enable_caps_lock)); | 399 OnCapsLockChanged(enable_caps_lock)); |
400 } | 400 } |
401 } | 401 } |
402 | 402 |
403 bool XKeyboardImpl::SetCurrentKeyboardLayoutByName( | 403 bool ImeKeyboardX11::SetCurrentKeyboardLayoutByName( |
404 const std::string& layout_name) { | 404 const std::string& layout_name) { |
405 if (SetLayoutInternal(layout_name, false)) { | 405 if (SetLayoutInternal(layout_name, false)) { |
406 current_layout_name_ = layout_name; | 406 current_layout_name_ = layout_name; |
407 return true; | 407 return true; |
408 } | 408 } |
409 return false; | 409 return false; |
410 } | 410 } |
411 | 411 |
412 bool XKeyboardImpl::ReapplyCurrentKeyboardLayout() { | 412 bool ImeKeyboardX11::ReapplyCurrentKeyboardLayout() { |
413 if (current_layout_name_.empty()) { | 413 if (current_layout_name_.empty()) { |
414 DVLOG(1) << "Can't reapply XKB layout: layout unknown"; | 414 DVLOG(1) << "Can't reapply XKB layout: layout unknown"; |
415 return false; | 415 return false; |
416 } | 416 } |
417 return SetLayoutInternal(current_layout_name_, true /* force */); | 417 return SetLayoutInternal(current_layout_name_, true /* force */); |
418 } | 418 } |
419 | 419 |
420 void XKeyboardImpl::ReapplyCurrentModifierLockStatus() { | 420 void ImeKeyboardX11::ReapplyCurrentModifierLockStatus() { |
421 SetLockedModifiers(current_caps_lock_status_); | 421 SetLockedModifiers(current_caps_lock_status_); |
422 } | 422 } |
423 | 423 |
424 void XKeyboardImpl::DisableNumLock() { | 424 void ImeKeyboardX11::DisableNumLock() { |
425 SetCapsLockEnabled(current_caps_lock_status_); | 425 SetCapsLockEnabled(current_caps_lock_status_); |
426 } | 426 } |
427 | 427 |
428 void XKeyboardImpl::OnSetLayoutFinish() { | 428 void ImeKeyboardX11::OnSetLayoutFinish() { |
429 if (execute_queue_.empty()) { | 429 if (execute_queue_.empty()) { |
430 DVLOG(1) << "OnSetLayoutFinish: execute_queue_ is empty. " | 430 DVLOG(1) << "OnSetLayoutFinish: execute_queue_ is empty. " |
431 << "base::LaunchProcess failed?"; | 431 << "base::LaunchProcess failed?"; |
432 return; | 432 return; |
433 } | 433 } |
434 execute_queue_.pop(); | 434 execute_queue_.pop(); |
435 MaybeExecuteSetLayoutCommand(); | 435 MaybeExecuteSetLayoutCommand(); |
436 } | 436 } |
437 | 437 |
438 } // namespace | 438 } // namespace |
439 | 439 |
440 // static | 440 // static |
441 bool XKeyboard::GetAutoRepeatEnabledForTesting() { | 441 bool ImeKeyboard::GetAutoRepeatEnabledForTesting() { |
442 XKeyboardState state = {}; | 442 XKeyboardState state = {}; |
443 XGetKeyboardControl(GetXDisplay(), &state); | 443 XGetKeyboardControl(GetXDisplay(), &state); |
444 return state.global_auto_repeat != AutoRepeatModeOff; | 444 return state.global_auto_repeat != AutoRepeatModeOff; |
445 } | 445 } |
446 | 446 |
447 // static | 447 // static |
448 bool XKeyboard::GetAutoRepeatRateForTesting(AutoRepeatRate* out_rate) { | 448 bool ImeKeyboard::GetAutoRepeatRateForTesting(AutoRepeatRate* out_rate) { |
449 return XkbGetAutoRepeatRate(GetXDisplay(), XkbUseCoreKbd, | 449 return XkbGetAutoRepeatRate(GetXDisplay(), |
| 450 XkbUseCoreKbd, |
450 &(out_rate->initial_delay_in_ms), | 451 &(out_rate->initial_delay_in_ms), |
451 &(out_rate->repeat_interval_in_ms)) == True; | 452 &(out_rate->repeat_interval_in_ms)) == True; |
452 } | 453 } |
453 | 454 |
454 // static | 455 // static |
455 bool XKeyboard::CheckLayoutNameForTesting(const std::string& layout_name) { | 456 bool ImeKeyboard::CheckLayoutNameForTesting(const std::string& layout_name) { |
456 return CheckLayoutName(layout_name); | 457 return CheckLayoutName(layout_name); |
457 } | 458 } |
458 | 459 |
459 // static | 460 // static |
460 XKeyboard* XKeyboard::Create() { | 461 ImeKeyboard* ImeKeyboard::Create() { return new ImeKeyboardX11(); } |
461 return new XKeyboardImpl(); | |
462 } | |
463 | 462 |
464 } // namespace input_method | 463 } // namespace input_method |
465 } // namespace chromeos | 464 } // namespace chromeos |
OLD | NEW |