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

Side by Side Diff: chrome/browser/chromeos/system_key_event_listener.cc

Issue 9225004: Handle Caps Lock short cut (Shift+Search) in ash [part 2 of 2]. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/system_key_event_listener.h" 5 #include "chrome/browser/chromeos/system_key_event_listener.h"
6 6
7 #define XK_MISCELLANY 1 7 #define XK_MISCELLANY 1
8 #include <X11/keysymdef.h> 8 #include <X11/keysymdef.h>
9 #include <X11/XF86keysym.h> 9 #include <X11/XF86keysym.h>
10 #include <X11/XKBlib.h> 10 #include <X11/XKBlib.h>
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 if (xevent->type == KeyPress || xevent->type == KeyRelease) { 295 if (xevent->type == KeyPress || xevent->type == KeyRelease) {
296 // Change the current keyboard layout (or input method) if xevent is one of 296 // Change the current keyboard layout (or input method) if xevent is one of
297 // the input method hotkeys. 297 // the input method hotkeys.
298 input_method::HotkeyManager* hotkey_manager = 298 input_method::HotkeyManager* hotkey_manager =
299 input_method_manager->GetHotkeyManager(); 299 input_method_manager->GetHotkeyManager();
300 if (hotkey_manager->FilterKeyEvent(*xevent)) 300 if (hotkey_manager->FilterKeyEvent(*xevent))
301 return true; 301 return true;
302 } 302 }
303 303
304 if (xevent->type == xkb_event_base_) { 304 if (xevent->type == xkb_event_base_) {
305 // TODO(yusukes): Move this part to aura::RootWindowHost.
305 XkbEvent* xkey_event = reinterpret_cast<XkbEvent*>(xevent); 306 XkbEvent* xkey_event = reinterpret_cast<XkbEvent*>(xevent);
306 if (xkey_event->any.xkb_type == XkbStateNotify) { 307 if (xkey_event->any.xkb_type == XkbStateNotify) {
307 input_method::ModifierLockStatus new_caps_lock_state = 308 input_method::ModifierLockStatus new_caps_lock_state =
308 input_method::kDontChange; 309 input_method::kDontChange;
309 input_method::ModifierLockStatus new_num_lock_state = 310 input_method::ModifierLockStatus new_num_lock_state =
310 input_method::kDontChange; 311 input_method::kDontChange;
311 312
312 bool enabled = (xkey_event->state.locked_mods) & LockMask; 313 bool enabled = (xkey_event->state.locked_mods) & LockMask;
313 if (caps_lock_is_on_ != enabled) { 314 if (caps_lock_is_on_ != enabled) {
314 caps_lock_is_on_ = enabled; 315 caps_lock_is_on_ = enabled;
(...skipping 13 matching lines...) Expand all
328 input_method_manager->GetXKeyboard()->SetLockedModifiers( 329 input_method_manager->GetXKeyboard()->SetLockedModifiers(
329 new_caps_lock_state, new_num_lock_state); 330 new_caps_lock_state, new_num_lock_state);
330 331
331 return true; 332 return true;
332 } 333 }
333 } else if (xevent->type == KeyPress) { 334 } else if (xevent->type == KeyPress) {
334 const int32 keycode = xevent->xkey.keycode; 335 const int32 keycode = xevent->xkey.keycode;
335 if (keycode) { 336 if (keycode) {
336 const unsigned int state = (xevent->xkey.state & kSupportedModifiers); 337 const unsigned int state = (xevent->xkey.state & kSupportedModifiers);
337 338
339 #if !defined(USE_AURA)
338 // Toggle Caps Lock if Shift and Search keys are pressed. 340 // Toggle Caps Lock if Shift and Search keys are pressed.
341 // When Aura is in use, the shortcut is handled in Ash.
339 if (XKeycodeToKeysym(ui::GetXDisplay(), keycode, 0) == XK_Super_L) { 342 if (XKeycodeToKeysym(ui::GetXDisplay(), keycode, 0) == XK_Super_L) {
340 const bool shift_is_held = (state & ShiftMask); 343 const bool shift_is_held = (state & ShiftMask);
341 const bool other_mods_are_held = (state & ~(ShiftMask | LockMask)); 344 const bool other_mods_are_held = (state & ~(ShiftMask | LockMask));
342 if (shift_is_held && !other_mods_are_held) 345 if (shift_is_held && !other_mods_are_held)
343 input_method_manager->GetXKeyboard()->SetCapsLockEnabled( 346 input_method_manager->GetXKeyboard()->SetCapsLockEnabled(
344 !caps_lock_is_on_); 347 !caps_lock_is_on_);
345 } 348 }
349 #endif
346 350
347 // Only doing non-Alt/Shift/Ctrl modified keys 351 // Only doing non-Alt/Shift/Ctrl modified keys
348 if (!(state & (Mod1Mask | ShiftMask | ControlMask))) { 352 if (!(state & (Mod1Mask | ShiftMask | ControlMask))) {
349 if (keycode == key_f6_ || keycode == key_brightness_down_) { 353 if (keycode == key_f6_ || keycode == key_brightness_down_) {
350 if (keycode == key_f6_) 354 if (keycode == key_f6_)
351 content::RecordAction( 355 content::RecordAction(
352 UserMetricsAction("Accel_BrightnessDown_F6")); 356 UserMetricsAction("Accel_BrightnessDown_F6"));
353 OnBrightnessDown(); 357 OnBrightnessDown();
354 return true; 358 return true;
355 } else if (keycode == key_f7_ || keycode == key_brightness_up_) { 359 } else if (keycode == key_f7_ || keycode == key_brightness_up_) {
(...skipping 18 matching lines...) Expand all
374 OnVolumeUp(); 378 OnVolumeUp();
375 return true; 379 return true;
376 } 380 }
377 } 381 }
378 } 382 }
379 } 383 }
380 return false; 384 return false;
381 } 385 }
382 386
383 } // namespace chromeos 387 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698