diff options
author | bryeung@google.com <bryeung@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-17 19:28:54 +0000 |
---|---|---|
committer | bryeung@google.com <bryeung@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-17 19:28:54 +0000 |
commit | df86e0fd8f414d97b631e0cd511d6ef3c763b393 (patch) | |
tree | 10b71b3bee7d4b22f64d4bf0386d610ead4c7a7e /views | |
parent | 64bfe131e4db2620c6f6fa9b15cbc00c4e10b565 (diff) | |
download | chromium_src-df86e0fd8f414d97b631e0cd511d6ef3c763b393.zip chromium_src-df86e0fd8f414d97b631e0cd511d6ef3c763b393.tar.gz chromium_src-df86e0fd8f414d97b631e0cd511d6ef3c763b393.tar.bz2 |
Adding capslock flag to KeyEvent class. Without this flag, when converting from
GDK event to KeyEvent, the case information is lost (see
keyboard_code_conversion_gtk.cc).
BUG=none.
TEST=none.
Patch from Varun Jain <varunjain@chromium.org>
Review URL: http://codereview.chromium.org/3226015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66496 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/event.h | 19 | ||||
-rw-r--r-- | views/event_gtk.cc | 2 |
2 files changed, 14 insertions, 7 deletions
diff --git a/views/event.h b/views/event.h index 9da3945..89909b5 100644 --- a/views/event.h +++ b/views/event.h @@ -61,13 +61,14 @@ class Event { // file, this header is used on non-views platforms (e.g. OSX). For // example, these EventFlags are used by the automation provider for // all platforms. - enum EventFlags { EF_SHIFT_DOWN = 1 << 0, - EF_CONTROL_DOWN = 1 << 1, - EF_ALT_DOWN = 1 << 2, - EF_LEFT_BUTTON_DOWN = 1 << 3, - EF_MIDDLE_BUTTON_DOWN = 1 << 4, - EF_RIGHT_BUTTON_DOWN = 1 << 5, - EF_COMMAND_DOWN = 1 << 6, // Only useful on OSX + enum EventFlags { EF_CAPS_LOCK_DOWN = 1 << 0, + EF_SHIFT_DOWN = 1 << 1, + EF_CONTROL_DOWN = 1 << 2, + EF_ALT_DOWN = 1 << 3, + EF_LEFT_BUTTON_DOWN = 1 << 4, + EF_MIDDLE_BUTTON_DOWN = 1 << 5, + EF_RIGHT_BUTTON_DOWN = 1 << 6, + EF_COMMAND_DOWN = 1 << 7, // Only useful on OSX }; // Return the event type @@ -99,6 +100,10 @@ class Event { return (flags_ & EF_CONTROL_DOWN) != 0; } + bool IsCapsLockDown() const { + return (flags_ & EF_CAPS_LOCK_DOWN) != 0; + } + // Return whether the alt modifier is down bool IsAltDown() const { return (flags_ & EF_ALT_DOWN) != 0; diff --git a/views/event_gtk.cc b/views/event_gtk.cc index 6ffd449..cae426d 100644 --- a/views/event_gtk.cc +++ b/views/event_gtk.cc @@ -23,6 +23,8 @@ KeyEvent::KeyEvent(GdkEventKey* event) // static int Event::GetFlagsFromGdkState(int state) { int flags = 0; + if (state & GDK_LOCK_MASK) + flags |= Event::EF_CAPS_LOCK_DOWN; if (state & GDK_CONTROL_MASK) flags |= Event::EF_CONTROL_DOWN; if (state & GDK_SHIFT_MASK) |