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 <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
346 XAutoRepeatOn(ui::GetXDisplay()); | 346 XAutoRepeatOn(ui::GetXDisplay()); |
347 } else { | 347 } else { |
348 XAutoRepeatOff(ui::GetXDisplay()); | 348 XAutoRepeatOff(ui::GetXDisplay()); |
349 } | 349 } |
350 DLOG(INFO) << "Set auto-repeat mode to: " << (enabled ? "on" : "off"); | 350 DLOG(INFO) << "Set auto-repeat mode to: " << (enabled ? "on" : "off"); |
351 return true; | 351 return true; |
352 } | 352 } |
353 | 353 |
354 // static | 354 // static |
355 bool XKeyboard::SetAutoRepeatRate(const AutoRepeatRate& rate) { | 355 bool XKeyboard::SetAutoRepeatRate(const AutoRepeatRate& rate) { |
356 // TODO(yusukes): write auto tests for the function. | |
357 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 356 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
358 DLOG(INFO) << "Set auto-repeat rate to: " | 357 DLOG(INFO) << "Set auto-repeat rate to: " |
359 << rate.initial_delay_in_ms << " ms delay, " | 358 << rate.initial_delay_in_ms << " ms delay, " |
360 << rate.repeat_interval_in_ms << " ms interval"; | 359 << rate.repeat_interval_in_ms << " ms interval"; |
361 if (XkbSetAutoRepeatRate(ui::GetXDisplay(), XkbUseCoreKbd, | 360 if (XkbSetAutoRepeatRate(ui::GetXDisplay(), XkbUseCoreKbd, |
362 rate.initial_delay_in_ms, | 361 rate.initial_delay_in_ms, |
363 rate.repeat_interval_in_ms) != True) { | 362 rate.repeat_interval_in_ms) != True) { |
364 LOG(ERROR) << "Failed to set auto-repeat rate"; | 363 LOG(ERROR) << "Failed to set auto-repeat rate"; |
365 return false; | 364 return false; |
366 } | 365 } |
367 return true; | 366 return true; |
368 } | 367 } |
369 | 368 |
369 // static | |
370 bool XKeyboard::GetAutoRepeatEnabled() { | |
371 XKeyboardState state = {}; | |
372 XGetKeyboardControl(ui::GetXDisplay(), &state); | |
373 return state.global_auto_repeat != AutoRepeatModeOff; | |
374 } | |
375 | |
376 // static | |
377 bool XKeyboard::GetAutoRepeatRate(AutoRepeatRate* out_rate) { | |
378 return XkbGetAutoRepeatRate(ui::GetXDisplay(), XkbUseCoreKbd, | |
379 &(out_rate->initial_delay_in_ms), | |
380 &(out_rate->repeat_interval_in_ms)) == True; | |
Zachary Kuznia
2011/11/08 03:55:17
Why "True" instead of "true"?
Yusuke Sato
2011/11/13 23:24:56
because Xlib/XKB functions return True/False inste
| |
381 } | |
382 | |
370 void XKeyboard::SetLockedModifiers(ModifierLockStatus new_caps_lock_status, | 383 void XKeyboard::SetLockedModifiers(ModifierLockStatus new_caps_lock_status, |
371 ModifierLockStatus new_num_lock_status) { | 384 ModifierLockStatus new_num_lock_status) { |
372 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 385 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
373 if (!num_lock_mask_) { | 386 if (!num_lock_mask_) { |
374 LOG(ERROR) << "Cannot set locked modifiers. Num Lock mask unknown."; | 387 LOG(ERROR) << "Cannot set locked modifiers. Num Lock mask unknown."; |
375 return; | 388 return; |
376 } | 389 } |
377 | 390 |
378 unsigned int affect_mask = 0; | 391 unsigned int affect_mask = 0; |
379 unsigned int value_mask = 0; | 392 unsigned int value_mask = 0; |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
514 case kCapsLockKey: | 527 case kCapsLockKey: |
515 return "capslock"; | 528 return "capslock"; |
516 case kNumModifierKeys: | 529 case kNumModifierKeys: |
517 break; | 530 break; |
518 } | 531 } |
519 return ""; | 532 return ""; |
520 } | 533 } |
521 | 534 |
522 } // namespace input_method | 535 } // namespace input_method |
523 } // namespace chromeos | 536 } // namespace chromeos |
OLD | NEW |