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

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) 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/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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 if (xevent->type == KeyPress || xevent->type == KeyRelease) { 298 if (xevent->type == KeyPress || xevent->type == KeyRelease) {
299 // Change the current keyboard layout (or input method) if xevent is one of 299 // Change the current keyboard layout (or input method) if xevent is one of
300 // the input method hotkeys. 300 // the input method hotkeys.
301 input_method::HotkeyManager* hotkey_manager = 301 input_method::HotkeyManager* hotkey_manager =
302 input_method_manager->GetHotkeyManager(); 302 input_method_manager->GetHotkeyManager();
303 if (hotkey_manager->FilterKeyEvent(*xevent)) 303 if (hotkey_manager->FilterKeyEvent(*xevent))
304 return true; 304 return true;
305 } 305 }
306 306
307 if (xevent->type == xkb_event_base_) { 307 if (xevent->type == xkb_event_base_) {
308 // TODO(yusukes): Move this part to aura::RootWindowHost.
308 XkbEvent* xkey_event = reinterpret_cast<XkbEvent*>(xevent); 309 XkbEvent* xkey_event = reinterpret_cast<XkbEvent*>(xevent);
309 if (xkey_event->any.xkb_type == XkbStateNotify) { 310 if (xkey_event->any.xkb_type == XkbStateNotify) {
310 input_method::ModifierLockStatus new_caps_lock_state = 311 input_method::ModifierLockStatus new_caps_lock_state =
311 input_method::kDontChange; 312 input_method::kDontChange;
312 input_method::ModifierLockStatus new_num_lock_state = 313 input_method::ModifierLockStatus new_num_lock_state =
313 input_method::kDontChange; 314 input_method::kDontChange;
314 315
315 bool enabled = (xkey_event->state.locked_mods) & LockMask; 316 bool enabled = (xkey_event->state.locked_mods) & LockMask;
316 if (caps_lock_is_on_ != enabled) { 317 if (caps_lock_is_on_ != enabled) {
317 caps_lock_is_on_ = enabled; 318 caps_lock_is_on_ = enabled;
(...skipping 13 matching lines...) Expand all
331 input_method_manager->GetXKeyboard()->SetLockedModifiers( 332 input_method_manager->GetXKeyboard()->SetLockedModifiers(
332 new_caps_lock_state, new_num_lock_state); 333 new_caps_lock_state, new_num_lock_state);
333 334
334 return true; 335 return true;
335 } 336 }
336 } else if (xevent->type == KeyPress) { 337 } else if (xevent->type == KeyPress) {
337 const int32 keycode = xevent->xkey.keycode; 338 const int32 keycode = xevent->xkey.keycode;
338 if (keycode) { 339 if (keycode) {
339 const unsigned int state = (xevent->xkey.state & kSupportedModifiers); 340 const unsigned int state = (xevent->xkey.state & kSupportedModifiers);
340 341
342 #if !defined(USE_AURA)
341 // Toggle Caps Lock if Shift and Search keys are pressed. 343 // Toggle Caps Lock if Shift and Search keys are pressed.
344 // When Aura is in use, the short cut is handled in ash/.
Daniel Erat 2012/01/18 15:44:31 nit: either just say "Ash" instead of "ash/" or me
Yusuke Sato 2012/01/23 06:53:49 Done.
342 if (XKeycodeToKeysym(ui::GetXDisplay(), keycode, 0) == XK_Super_L) { 345 if (XKeycodeToKeysym(ui::GetXDisplay(), keycode, 0) == XK_Super_L) {
343 const bool shift_is_held = (state & ShiftMask); 346 const bool shift_is_held = (state & ShiftMask);
344 const bool other_mods_are_held = (state & ~(ShiftMask | LockMask)); 347 const bool other_mods_are_held = (state & ~(ShiftMask | LockMask));
345 if (shift_is_held && !other_mods_are_held) 348 if (shift_is_held && !other_mods_are_held)
346 input_method_manager->GetXKeyboard()->SetCapsLockEnabled( 349 input_method_manager->GetXKeyboard()->SetCapsLockEnabled(
347 !caps_lock_is_on_); 350 !caps_lock_is_on_);
348 } 351 }
352 #endif
349 353
350 // Only doing non-Alt/Shift/Ctrl modified keys 354 // Only doing non-Alt/Shift/Ctrl modified keys
351 if (!(state & (Mod1Mask | ShiftMask | ControlMask))) { 355 if (!(state & (Mod1Mask | ShiftMask | ControlMask))) {
352 if (keycode == key_f6_ || keycode == key_brightness_down_) { 356 if (keycode == key_f6_ || keycode == key_brightness_down_) {
353 if (keycode == key_f6_) 357 if (keycode == key_f6_)
354 content::RecordAction( 358 content::RecordAction(
355 UserMetricsAction("Accel_BrightnessDown_F6")); 359 UserMetricsAction("Accel_BrightnessDown_F6"));
356 OnBrightnessDown(); 360 OnBrightnessDown();
357 return true; 361 return true;
358 } else if (keycode == key_f7_ || keycode == key_brightness_up_) { 362 } else if (keycode == key_f7_ || keycode == key_brightness_up_) {
(...skipping 18 matching lines...) Expand all
377 OnVolumeUp(); 381 OnVolumeUp();
378 return true; 382 return true;
379 } 383 }
380 } 384 }
381 } 385 }
382 } 386 }
383 return false; 387 return false;
384 } 388 }
385 389
386 } // namespace chromeos 390 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698