diff options
author | rjkroege@google.com <rjkroege@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-26 18:43:18 +0000 |
---|---|---|
committer | rjkroege@google.com <rjkroege@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-26 18:43:18 +0000 |
commit | b2f7ac4583b968d0c20ea8f6c4110aeb6882699a (patch) | |
tree | 7bcf1278af056ab056221da0ee01e81851e9ebde /app/keyboard_code_conversion_x.cc | |
parent | bd2b41afb25b648e3f77dce87064971f63894a7f (diff) | |
download | chromium_src-b2f7ac4583b968d0c20ea8f6c4110aeb6882699a.zip chromium_src-b2f7ac4583b968d0c20ea8f6c4110aeb6882699a.tar.gz chromium_src-b2f7ac4583b968d0c20ea8f6c4110aeb6882699a.tar.bz2 |
touchui: Directly process key and mouse events.
Capture the keyboard and mouse events directly from X, create a corresponding
views::Event out of it, and send it to the associated RootView.
Includes Chad's (wyck) function FindRootViewForGdkEvent (from #3704005) slightly
modified (called FindRootViewForGdkWindow).
BUG=None
TEST=Click/Keypress events in a webpage should work correctly.
Review URL: http://codereview.chromium.org/3801011
Patch from Sadrul Chowdhury <sadrul@chromium.org>.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63916 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/keyboard_code_conversion_x.cc')
-rw-r--r-- | app/keyboard_code_conversion_x.cc | 163 |
1 files changed, 163 insertions, 0 deletions
diff --git a/app/keyboard_code_conversion_x.cc b/app/keyboard_code_conversion_x.cc new file mode 100644 index 0000000..679423b --- /dev/null +++ b/app/keyboard_code_conversion_x.cc @@ -0,0 +1,163 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "app/keyboard_code_conversion_x.h" + +#include <X11/keysym.h> +#include <X11/Xlib.h> + +#include "base/logging.h" + +namespace app { + +// Get an app::KeyboardCode from an X keyevent +KeyboardCode KeyboardCodeFromXKeyEvent(XEvent* xev) { + KeySym keysym = XLookupKeysym(&xev->xkey, 0); + + // TODO(sad): Have |keysym| go through the X map list? + + switch (keysym) { + case XK_BackSpace: + return VKEY_BACK; + case XK_Tab: + return VKEY_TAB; + case XK_Linefeed: + case XK_Return: + return VKEY_RETURN; + case XK_Clear: + return VKEY_CLEAR; + case XK_KP_Space: + case XK_space: + return VKEY_SPACE; + case XK_Home: + case XK_KP_Home: + return VKEY_HOME; + case XK_End: + case XK_KP_End: + return VKEY_END; + case XK_Left: + case XK_KP_Left: + return VKEY_LEFT; + case XK_Right: + case XK_KP_Right: + return VKEY_RIGHT; + case XK_Down: + case XK_KP_Down: + return VKEY_DOWN; + case XK_Up: + case XK_KP_Up: + return VKEY_UP; + case XK_Control_L: + return VKEY_LCONTROL; + case XK_Control_R: + return VKEY_RCONTROL; + case XK_Escape: + return VKEY_ESCAPE; + case XK_A: + case XK_a: + return VKEY_A; + case XK_B: + case XK_b: + return VKEY_B; + case XK_C: + case XK_c: + return VKEY_C; + case XK_D: + case XK_d: + return VKEY_D; + case XK_E: + case XK_e: + return VKEY_E; + case XK_F: + case XK_f: + return VKEY_F; + case XK_G: + case XK_g: + return VKEY_G; + case XK_H: + case XK_h: + return VKEY_H; + case XK_I: + case XK_i: + return VKEY_I; + case XK_J: + case XK_j: + return VKEY_J; + case XK_K: + case XK_k: + return VKEY_K; + case XK_L: + case XK_l: + return VKEY_L; + case XK_M: + case XK_m: + return VKEY_M; + case XK_N: + case XK_n: + return VKEY_N; + case XK_O: + case XK_o: + return VKEY_O; + case XK_P: + case XK_p: + return VKEY_P; + case XK_Q: + case XK_q: + return VKEY_Q; + case XK_R: + case XK_r: + return VKEY_R; + case XK_S: + case XK_s: + return VKEY_S; + case XK_T: + case XK_t: + return VKEY_T; + case XK_U: + case XK_u: + return VKEY_U; + case XK_V: + case XK_v: + return VKEY_V; + case XK_W: + case XK_w: + return VKEY_W; + case XK_X: + case XK_x: + return VKEY_X; + case XK_Y: + case XK_y: + return VKEY_Y; + case XK_Z: + case XK_z: + return VKEY_Z; + case XK_0: + return VKEY_0; + case XK_1: + return VKEY_1; + case XK_2: + return VKEY_2; + case XK_3: + return VKEY_3; + case XK_4: + return VKEY_4; + case XK_5: + return VKEY_5; + case XK_6: + return VKEY_6; + case XK_7: + return VKEY_7; + case XK_8: + return VKEY_8; + case XK_9: + return VKEY_9; + + // TODO(sad): A lot of keycodes are still missing. + } + + DLOG(WARNING) << "Unknown keycode: " << keysym; + return VKEY_UNKNOWN; +} + +} // namespace app |