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

Side by Side Diff: app/keyboard_code_conversion_x.cc

Issue 5802003: touchui: Improve key-event processing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "app/keyboard_code_conversion_x.h" 5 #include "app/keyboard_code_conversion_x.h"
6 6
7 #include <X11/keysym.h> 7 #include <X11/keysym.h>
8 #include <X11/Xlib.h> 8 #include <X11/Xlib.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 11
12 namespace app { 12 namespace app {
13 13
14 // Get an app::KeyboardCode from an X keyevent 14 // Get an app::KeyboardCode from an X keyevent
15 KeyboardCode KeyboardCodeFromXKeyEvent(XEvent* xev) { 15 KeyboardCode KeyboardCodeFromXKeyEvent(XEvent* xev) {
16 KeySym keysym = XLookupKeysym(&xev->xkey, 0); 16 KeySym keysym = XLookupKeysym(&xev->xkey, 0);
17 17
18 // Consult GDK key translation (in WindowsKeyCodeForGdkKeyCode) for details
19 // about the following translations.
20
18 // TODO(sad): Have |keysym| go through the X map list? 21 // TODO(sad): Have |keysym| go through the X map list?
19 22
20 switch (keysym) { 23 switch (keysym) {
21 case XK_BackSpace: 24 case XK_BackSpace:
22 return VKEY_BACK; 25 return VKEY_BACK;
26 case XK_Delete:
27 case XK_KP_Delete:
28 return VKEY_DELETE;
23 case XK_Tab: 29 case XK_Tab:
30 case XK_KP_Tab:
24 return VKEY_TAB; 31 return VKEY_TAB;
25 case XK_Linefeed: 32 case XK_Linefeed:
26 case XK_Return: 33 case XK_Return:
34 case XK_KP_Enter:
27 return VKEY_RETURN; 35 return VKEY_RETURN;
28 case XK_Clear: 36 case XK_Clear:
29 return VKEY_CLEAR; 37 return VKEY_CLEAR;
30 case XK_KP_Space: 38 case XK_KP_Space:
31 case XK_space: 39 case XK_space:
32 return VKEY_SPACE; 40 return VKEY_SPACE;
33 case XK_Home: 41 case XK_Home:
34 case XK_KP_Home: 42 case XK_KP_Home:
35 return VKEY_HOME; 43 return VKEY_HOME;
36 case XK_End: 44 case XK_End:
37 case XK_KP_End: 45 case XK_KP_End:
38 return VKEY_END; 46 return VKEY_END;
47 case XK_Page_Up:
48 case XK_KP_Page_Up:
49 return VKEY_PRIOR;
50 case XK_Page_Down:
51 case XK_KP_Page_Down:
52 return VKEY_NEXT;
39 case XK_Left: 53 case XK_Left:
40 case XK_KP_Left: 54 case XK_KP_Left:
41 return VKEY_LEFT; 55 return VKEY_LEFT;
42 case XK_Right: 56 case XK_Right:
43 case XK_KP_Right: 57 case XK_KP_Right:
44 return VKEY_RIGHT; 58 return VKEY_RIGHT;
45 case XK_Down: 59 case XK_Down:
46 case XK_KP_Down: 60 case XK_KP_Down:
47 return VKEY_DOWN; 61 return VKEY_DOWN;
48 case XK_Up: 62 case XK_Up:
49 case XK_KP_Up: 63 case XK_KP_Up:
50 return VKEY_UP; 64 return VKEY_UP;
51 case XK_Control_L:
52 return VKEY_LCONTROL;
53 case XK_Control_R:
54 return VKEY_RCONTROL;
55 case XK_Escape: 65 case XK_Escape:
56 return VKEY_ESCAPE; 66 return VKEY_ESCAPE;
57 case XK_A: 67 case XK_A:
58 case XK_a: 68 case XK_a:
59 return VKEY_A; 69 return VKEY_A;
60 case XK_B: 70 case XK_B:
61 case XK_b: 71 case XK_b:
62 return VKEY_B; 72 return VKEY_B;
63 case XK_C: 73 case XK_C:
64 case XK_c: 74 case XK_c:
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 return VKEY_5; 156 return VKEY_5;
147 case XK_6: 157 case XK_6:
148 return VKEY_6; 158 return VKEY_6;
149 case XK_7: 159 case XK_7:
150 return VKEY_7; 160 return VKEY_7;
151 case XK_8: 161 case XK_8:
152 return VKEY_8; 162 return VKEY_8;
153 case XK_9: 163 case XK_9:
154 return VKEY_9; 164 return VKEY_9;
155 165
156 // TODO(sad): A lot of keycodes are still missing. 166 case XK_multiply:
167 case XK_KP_Multiply:
168 return VKEY_MULTIPLY;
169 case XK_KP_Add:
170 return VKEY_ADD;
171 case XK_KP_Separator:
172 return VKEY_SEPARATOR;
173 case XK_KP_Subtract:
174 return VKEY_SUBTRACT;
175 case XK_KP_Decimal:
176 return VKEY_DECIMAL;
177 case XK_KP_Divide:
178 return VKEY_DIVIDE;
179 case XK_equal:
180 case XK_plus:
181 return VKEY_OEM_PLUS;
182 case XK_comma:
183 case XK_less:
184 return VKEY_OEM_COMMA;
185 case XK_minus:
186 case XK_underscore:
187 return VKEY_OEM_MINUS;
188 case XK_greater:
189 case XK_period:
190 return VKEY_OEM_PERIOD;
191 case XK_colon:
192 case XK_semicolon:
193 return VKEY_OEM_1;
194 case XK_question:
195 case XK_slash:
196 return VKEY_OEM_2;
197 case XK_asciitilde:
198 case XK_quoteleft:
199 return VKEY_OEM_3;
200 case XK_bracketleft:
201 case XK_braceleft:
202 return VKEY_OEM_4;
203 case XK_backslash:
204 case XK_bar:
205 return VKEY_OEM_5;
206 case XK_bracketright:
207 case XK_braceright:
208 return VKEY_OEM_6;
209 case XK_quoteright:
210 case XK_quotedbl:
211 return VKEY_OEM_7;
212 case XK_Shift_L:
213 case XK_Shift_R:
214 return VKEY_SHIFT;
215 case XK_Control_L:
216 case XK_Control_R:
217 return VKEY_CONTROL;
218 case XK_Alt_L:
219 case XK_Alt_R:
220 return VKEY_MENU;
221 case XK_Pause:
222 return VKEY_PAUSE;
223 case XK_Caps_Lock:
224 return VKEY_CAPITAL;
225 case XK_Num_Lock:
226 return VKEY_NUMLOCK;
227 case XK_Scroll_Lock:
228 return VKEY_SCROLL;
229 case XK_Select:
230 return VKEY_SELECT;
231 case XK_Print:
232 return VKEY_PRINT;
233 case XK_Execute:
234 return VKEY_EXECUTE;
235 case XK_Insert:
236 case XK_KP_Insert:
237 return VKEY_INSERT;
238 case XK_Help:
239 return VKEY_HELP;
240 case XK_Meta_L:
241 case XK_Super_L:
242 return VKEY_LWIN;
243 case XK_Meta_R:
244 case XK_Super_R:
245 return VKEY_RWIN;
246 case XK_Menu:
247 return VKEY_APPS;
248 case XK_F1:
249 case XK_F2:
250 case XK_F3:
251 case XK_F4:
252 case XK_F5:
253 case XK_F6:
254 case XK_F7:
255 case XK_F8:
256 case XK_F9:
257 case XK_F10:
258 case XK_F11:
259 case XK_F12:
260 case XK_F13:
261 case XK_F14:
262 case XK_F15:
263 case XK_F16:
264 case XK_F17:
265 case XK_F18:
266 case XK_F19:
267 case XK_F20:
268 case XK_F21:
269 case XK_F22:
270 case XK_F23:
271 case XK_F24:
272 return static_cast<app::KeyboardCode>(VKEY_F1 + (keysym - XK_F1));
273
274 // TODO(sad): some keycodes are still missing.
157 } 275 }
158 276
159 DLOG(WARNING) << "Unknown keycode: " << keysym; 277 DLOG(WARNING) << "Unknown keycode: " << keysym;
160 return VKEY_UNKNOWN; 278 return VKEY_UNKNOWN;
161 } 279 }
162 280
163 } // namespace app 281 } // namespace app
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698