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

Side by Side Diff: webkit/api/src/gtk/WebInputEventFactory.cpp

Issue 149248: A quick fix for Issue 15852.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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
« 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 /* 1 /*
2 * Copyright (C) 2006-2009 Google Inc. All rights reserved. 2 * Copyright (C) 2006-2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 GDK_v, // 0x37: GDK_v 132 GDK_v, // 0x37: GDK_v
133 GDK_b, // 0x38: GDK_b 133 GDK_b, // 0x38: GDK_b
134 GDK_n, // 0x39: GDK_n 134 GDK_n, // 0x39: GDK_n
135 GDK_m, // 0x3A: GDK_m 135 GDK_m, // 0x3A: GDK_m
136 GDK_comma, // 0x3B: GDK_comma 136 GDK_comma, // 0x3B: GDK_comma
137 GDK_period, // 0x3C: GDK_period 137 GDK_period, // 0x3C: GDK_period
138 GDK_slash, // 0x3D: GDK_slash 138 GDK_slash, // 0x3D: GDK_slash
139 0, // 0x3E: GDK_Shift_R 139 0, // 0x3E: GDK_Shift_R
140 }; 140 };
141 141
142 // |windowKeyCode| shouldn't change even when we change the keyboard 142 // |windowsKeyCode| has to include a valid virtual-key code even when we
143 // layout, e.g. when we type an 'A' key of a US keyboard on the French 143 // use non-US layouts, e.g. even when we type an 'A' key of a US keyboard
144 // layout, |windowsKeyCode| should be VK_A. On the other hand, 144 // on the Hebrew layout, |windowsKeyCode| should be VK_A.
145 // |event->keyval| may change when we change the keyboard layout (the 145 // On the other hand, |event->keyval| value depends on the current
146 // GdkKeymap object attached to the GdkDisplay object), e.g. when we type 146 // GdkKeymap object, i.e. when we type an 'A' key of a US keyboard on
147 // an 'A' key of a US keyboard on the French (or Hebrew) layout, 147 // the Hebrew layout, |event->keyval| becomes GDK_hebrew_shin and this
148 // |event->keyval| becomes GDK_q (or GDK_hebrew_shin). 148 // WebCore::windowsKeyCodeForKeyEvent() call returns 0.
149 // To improve compatibilty with Windows, we use |event->hardware_keycode| 149 // To improve compatibilty with Windows, we use |event->hardware_keycode|
150 // for retrieving its Windows key-code for the keys that can be changed by 150 // for retrieving its Windows key-code for the keys when the
151 // GdkKeymap objects (keyboard-layout drivers). 151 // WebCore::windowsKeyCodeForEvent() call returns 0.
152 // We shouldn't use |event->hardware_keycode| for keys that GdkKeymap 152 // We shouldn't use |event->hardware_keycode| for keys that GdkKeymap
153 // objects cannot change because |event->hardware_keycode| doesn't change 153 // objects cannot change because |event->hardware_keycode| doesn't change
154 // even when we change the layout options, e.g. when we swap a control 154 // even when we change the layout options, e.g. when we swap a control
155 // key and a caps-lock key, GTK doesn't swap their 155 // key and a caps-lock key, GTK doesn't swap their
156 // |event->hardware_keycode| values but swap their |event->keyval| values. 156 // |event->hardware_keycode| values but swap their |event->keyval| values.
157 int windowsKeyCode = WebCore::windowsKeyCodeForKeyEvent(event->keyval);
158 if (windowsKeyCode)
159 return windowsKeyCode;
160
157 const int tableSize = sizeof(hardwareCodeToGDKKeyval) / sizeof(hardwareCodeToGDKKeyval[0]); 161 const int tableSize = sizeof(hardwareCodeToGDKKeyval) / sizeof(hardwareCodeToGDKKeyval[0]);
158 if (event->hardware_keycode < tableSize) { 162 if (event->hardware_keycode < tableSize) {
159 int keyval = hardwareCodeToGDKKeyval[event->hardware_keycode]; 163 int keyval = hardwareCodeToGDKKeyval[event->hardware_keycode];
160 if (keyval) 164 if (keyval)
161 return WebCore::windowsKeyCodeForKeyEvent(keyval); 165 return WebCore::windowsKeyCodeForKeyEvent(keyval);
162 } 166 }
163 167
164 // This key is one that keyboard-layout drivers cannot change. 168 // This key is one that keyboard-layout drivers cannot change.
165 // Use |event->keyval| to retrieve its |windowsKeyCode| value. 169 // Use |event->keyval| to retrieve its |windowsKeyCode| value.
166 return WebCore::windowsKeyCodeForKeyEvent(event->keyval); 170 return WebCore::windowsKeyCodeForKeyEvent(event->keyval);
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 case GDK_SCROLL_RIGHT: 361 case GDK_SCROLL_RIGHT:
358 result.deltaX = -scrollbarPixelsPerTick; 362 result.deltaX = -scrollbarPixelsPerTick;
359 result.wheelTicksX = 1; 363 result.wheelTicksX = 1;
360 break; 364 break;
361 } 365 }
362 366
363 return result; 367 return result;
364 } 368 }
365 369
366 } // namespace WebKit 370 } // namespace WebKit
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