1/*
2 * Copyright (C) 2006, 2007 Apple Inc.  All rights reserved.
3 * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
4 * Copyright (C) 2007 Holger Hans Peter Freyther
5 * Copyright (C) 2008 Collabora, Ltd.  All rights reserved.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in the
15 *    documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
21 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
25 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#include "config.h"
31#include "PlatformKeyboardEvent.h"
32
33#include "KeyboardCodes.h"
34#include "NotImplemented.h"
35#include "TextEncoding.h"
36
37#include <gdk/gdk.h>
38#include <gdk/gdkkeysyms.h>
39
40namespace WebCore {
41
42// FIXME: This is incomplete.  We should change this to mirror
43// more like what Firefox does, and generate these switch statements
44// at build time.
45static String keyIdentifierForGdkKeyCode(guint keyCode)
46{
47    switch (keyCode) {
48        case GDK_Menu:
49        case GDK_Alt_L:
50        case GDK_Alt_R:
51            return "Alt";
52        case GDK_Clear:
53            return "Clear";
54        case GDK_Down:
55            return "Down";
56            // "End"
57        case GDK_End:
58            return "End";
59            // "Enter"
60        case GDK_ISO_Enter:
61        case GDK_KP_Enter:
62        case GDK_Return:
63            return "Enter";
64        case GDK_Execute:
65            return "Execute";
66        case GDK_F1:
67            return "F1";
68        case GDK_F2:
69            return "F2";
70        case GDK_F3:
71            return "F3";
72        case GDK_F4:
73            return "F4";
74        case GDK_F5:
75            return "F5";
76        case GDK_F6:
77            return "F6";
78        case GDK_F7:
79            return "F7";
80        case GDK_F8:
81            return "F8";
82        case GDK_F9:
83            return "F9";
84        case GDK_F10:
85            return "F10";
86        case GDK_F11:
87            return "F11";
88        case GDK_F12:
89            return "F12";
90        case GDK_F13:
91            return "F13";
92        case GDK_F14:
93            return "F14";
94        case GDK_F15:
95            return "F15";
96        case GDK_F16:
97            return "F16";
98        case GDK_F17:
99            return "F17";
100        case GDK_F18:
101            return "F18";
102        case GDK_F19:
103            return "F19";
104        case GDK_F20:
105            return "F20";
106        case GDK_F21:
107            return "F21";
108        case GDK_F22:
109            return "F22";
110        case GDK_F23:
111            return "F23";
112        case GDK_F24:
113            return "F24";
114        case GDK_Help:
115            return "Help";
116        case GDK_Home:
117            return "Home";
118        case GDK_Insert:
119            return "Insert";
120        case GDK_Left:
121            return "Left";
122        case GDK_Page_Down:
123            return "PageDown";
124        case GDK_Page_Up:
125            return "PageUp";
126        case GDK_Pause:
127            return "Pause";
128        case GDK_3270_PrintScreen:
129            return "PrintScreen";
130        case GDK_Right:
131            return "Right";
132        case GDK_Select:
133            return "Select";
134        case GDK_Up:
135            return "Up";
136            // Standard says that DEL becomes U+007F.
137        case GDK_Delete:
138            return "U+007F";
139        case GDK_BackSpace:
140            return "U+0008";
141        case GDK_ISO_Left_Tab:
142        case GDK_3270_BackTab:
143        case GDK_Tab:
144            return "U+0009";
145        default:
146            return String::format("U+%04X", gdk_keyval_to_unicode(gdk_keyval_to_upper(keyCode)));
147    }
148}
149
150static int windowsKeyCodeForKeyEvent(unsigned int keycode)
151{
152    switch (keycode) {
153        case GDK_KP_0:
154            return VK_NUMPAD0;// (60) Numeric keypad 0 key
155        case GDK_KP_1:
156            return VK_NUMPAD1;// (61) Numeric keypad 1 key
157        case GDK_KP_2:
158            return  VK_NUMPAD2; // (62) Numeric keypad 2 key
159        case GDK_KP_3:
160            return VK_NUMPAD3; // (63) Numeric keypad 3 key
161        case GDK_KP_4:
162            return VK_NUMPAD4; // (64) Numeric keypad 4 key
163        case GDK_KP_5:
164            return VK_NUMPAD5; //(65) Numeric keypad 5 key
165        case GDK_KP_6:
166            return VK_NUMPAD6; // (66) Numeric keypad 6 key
167        case GDK_KP_7:
168            return VK_NUMPAD7; // (67) Numeric keypad 7 key
169        case GDK_KP_8:
170            return VK_NUMPAD8; // (68) Numeric keypad 8 key
171        case GDK_KP_9:
172            return VK_NUMPAD9; // (69) Numeric keypad 9 key
173        case GDK_KP_Multiply:
174            return VK_MULTIPLY; // (6A) Multiply key
175        case GDK_KP_Add:
176            return VK_ADD; // (6B) Add key
177        case GDK_KP_Subtract:
178            return VK_SUBTRACT; // (6D) Subtract key
179        case GDK_KP_Decimal:
180            return VK_DECIMAL; // (6E) Decimal key
181        case GDK_KP_Divide:
182            return VK_DIVIDE; // (6F) Divide key
183
184        case GDK_KP_Page_Up:
185            return VK_PRIOR; // (21) PAGE UP key
186        case GDK_KP_Page_Down:
187            return VK_NEXT; // (22) PAGE DOWN key
188        case GDK_KP_End:
189            return VK_END; // (23) END key
190        case GDK_KP_Home:
191            return VK_HOME; // (24) HOME key
192        case GDK_KP_Left:
193            return VK_LEFT; // (25) LEFT ARROW key
194        case GDK_KP_Up:
195            return VK_UP; // (26) UP ARROW key
196        case GDK_KP_Right:
197            return VK_RIGHT; // (27) RIGHT ARROW key
198        case GDK_KP_Down:
199            return VK_DOWN; // (28) DOWN ARROW key
200
201        case GDK_BackSpace:
202            return VK_BACK; // (08) BACKSPACE key
203        case GDK_ISO_Left_Tab:
204        case GDK_3270_BackTab:
205        case GDK_Tab:
206            return VK_TAB; // (09) TAB key
207        case GDK_Clear:
208            return VK_CLEAR; // (0C) CLEAR key
209        case GDK_ISO_Enter:
210        case GDK_KP_Enter:
211        case GDK_Return:
212            return VK_RETURN; //(0D) Return key
213        case GDK_Shift_L:
214        case GDK_Shift_R:
215            return VK_SHIFT; // (10) SHIFT key
216        case GDK_Control_L:
217        case GDK_Control_R:
218            return VK_CONTROL; // (11) CTRL key
219        case GDK_Menu:
220            return VK_APPS;  // (5D) Applications key (Natural keyboard)
221        case GDK_Alt_L:
222        case GDK_Alt_R:
223            return VK_MENU; // (12) ALT key
224
225        case GDK_Pause:
226            return VK_PAUSE; // (13) PAUSE key
227        case GDK_Caps_Lock:
228            return VK_CAPITAL; // (14) CAPS LOCK key
229        case GDK_Kana_Lock:
230        case GDK_Kana_Shift:
231            return VK_KANA; // (15) Input Method Editor (IME) Kana mode
232        case GDK_Hangul:
233            return VK_HANGUL; // VK_HANGUL (15) IME Hangul mode
234            // VK_JUNJA (17) IME Junja mode
235            // VK_FINAL (18) IME final mode
236        case GDK_Hangul_Hanja:
237            return VK_HANJA; // (19) IME Hanja mode
238        case GDK_Kanji:
239            return VK_KANJI; // (19) IME Kanji mode
240        case GDK_Escape:
241            return VK_ESCAPE; // (1B) ESC key
242            // VK_CONVERT (1C) IME convert
243            // VK_NONCONVERT (1D) IME nonconvert
244            // VK_ACCEPT (1E) IME accept
245            // VK_MODECHANGE (1F) IME mode change request
246        case GDK_space:
247            return VK_SPACE; // (20) SPACEBAR
248        case GDK_Page_Up:
249            return VK_PRIOR; // (21) PAGE UP key
250        case GDK_Page_Down:
251            return VK_NEXT; // (22) PAGE DOWN key
252        case GDK_End:
253            return VK_END; // (23) END key
254        case GDK_Home:
255            return VK_HOME; // (24) HOME key
256        case GDK_Left:
257            return VK_LEFT; // (25) LEFT ARROW key
258        case GDK_Up:
259            return VK_UP; // (26) UP ARROW key
260        case GDK_Right:
261            return VK_RIGHT; // (27) RIGHT ARROW key
262        case GDK_Down:
263            return VK_DOWN; // (28) DOWN ARROW key
264        case GDK_Select:
265            return VK_SELECT; // (29) SELECT key
266        case GDK_Print:
267            return VK_PRINT; // (2A) PRINT key
268        case GDK_Execute:
269            return VK_EXECUTE;// (2B) EXECUTE key
270            //dunno on this
271            //case GDK_PrintScreen:
272            //      return VK_SNAPSHOT; // (2C) PRINT SCREEN key
273        case GDK_Insert:
274            return VK_INSERT; // (2D) INS key
275        case GDK_Delete:
276            return VK_DELETE; // (2E) DEL key
277        case GDK_Help:
278            return VK_HELP; // (2F) HELP key
279        case GDK_0:
280        case GDK_parenright:
281            return VK_0;    //  (30) 0) key
282        case GDK_1:
283        case GDK_exclam:
284            return VK_1; //  (31) 1 ! key
285        case GDK_2:
286        case GDK_at:
287            return VK_2; //  (32) 2 & key
288        case GDK_3:
289        case GDK_numbersign:
290            return VK_3; //case '3': case '#';
291        case GDK_4:
292        case GDK_dollar: //  (34) 4 key '$';
293            return VK_4;
294        case GDK_5:
295        case GDK_percent:
296            return VK_5; //  (35) 5 key  '%'
297        case GDK_6:
298        case GDK_asciicircum:
299            return VK_6; //  (36) 6 key  '^'
300        case GDK_7:
301        case GDK_ampersand:
302            return VK_7; //  (37) 7 key  case '&'
303        case GDK_8:
304        case GDK_asterisk:
305            return VK_8; //  (38) 8 key  '*'
306        case GDK_9:
307        case GDK_parenleft:
308            return VK_9; //  (39) 9 key '('
309        case GDK_a:
310        case GDK_A:
311            return VK_A; //  (41) A key case 'a': case 'A': return 0x41;
312        case GDK_b:
313        case GDK_B:
314            return VK_B; //  (42) B key case 'b': case 'B': return 0x42;
315        case GDK_c:
316        case GDK_C:
317            return VK_C; //  (43) C key case 'c': case 'C': return 0x43;
318        case GDK_d:
319        case GDK_D:
320            return VK_D; //  (44) D key case 'd': case 'D': return 0x44;
321        case GDK_e:
322        case GDK_E:
323            return VK_E; //  (45) E key case 'e': case 'E': return 0x45;
324        case GDK_f:
325        case GDK_F:
326            return VK_F; //  (46) F key case 'f': case 'F': return 0x46;
327        case GDK_g:
328        case GDK_G:
329            return VK_G; //  (47) G key case 'g': case 'G': return 0x47;
330        case GDK_h:
331        case GDK_H:
332            return VK_H; //  (48) H key case 'h': case 'H': return 0x48;
333        case GDK_i:
334        case GDK_I:
335            return VK_I; //  (49) I key case 'i': case 'I': return 0x49;
336        case GDK_j:
337        case GDK_J:
338            return VK_J; //  (4A) J key case 'j': case 'J': return 0x4A;
339        case GDK_k:
340        case GDK_K:
341            return VK_K; //  (4B) K key case 'k': case 'K': return 0x4B;
342        case GDK_l:
343        case GDK_L:
344            return VK_L; //  (4C) L key case 'l': case 'L': return 0x4C;
345        case GDK_m:
346        case GDK_M:
347            return VK_M; //  (4D) M key case 'm': case 'M': return 0x4D;
348        case GDK_n:
349        case GDK_N:
350            return VK_N; //  (4E) N key case 'n': case 'N': return 0x4E;
351        case GDK_o:
352        case GDK_O:
353            return VK_O; //  (4F) O key case 'o': case 'O': return 0x4F;
354        case GDK_p:
355        case GDK_P:
356            return VK_P; //  (50) P key case 'p': case 'P': return 0x50;
357        case GDK_q:
358        case GDK_Q:
359            return VK_Q; //  (51) Q key case 'q': case 'Q': return 0x51;
360        case GDK_r:
361        case GDK_R:
362            return VK_R; //  (52) R key case 'r': case 'R': return 0x52;
363        case GDK_s:
364        case GDK_S:
365            return VK_S; //  (53) S key case 's': case 'S': return 0x53;
366        case GDK_t:
367        case GDK_T:
368            return VK_T; //  (54) T key case 't': case 'T': return 0x54;
369        case GDK_u:
370        case GDK_U:
371            return VK_U; //  (55) U key case 'u': case 'U': return 0x55;
372        case GDK_v:
373        case GDK_V:
374            return VK_V; //  (56) V key case 'v': case 'V': return 0x56;
375        case GDK_w:
376        case GDK_W:
377            return VK_W; //  (57) W key case 'w': case 'W': return 0x57;
378        case GDK_x:
379        case GDK_X:
380            return VK_X; //  (58) X key case 'x': case 'X': return 0x58;
381        case GDK_y:
382        case GDK_Y:
383            return VK_Y; //  (59) Y key case 'y': case 'Y': return 0x59;
384        case GDK_z:
385        case GDK_Z:
386            return VK_Z; //  (5A) Z key case 'z': case 'Z': return 0x5A;
387        case GDK_Meta_L:
388            return VK_LWIN; // (5B) Left Windows key (Microsoft Natural keyboard)
389        case GDK_Meta_R:
390            return VK_RWIN; // (5C) Right Windows key (Natural keyboard)
391            // VK_SLEEP (5F) Computer Sleep key
392            // VK_SEPARATOR (6C) Separator key
393            // VK_SUBTRACT (6D) Subtract key
394            // VK_DECIMAL (6E) Decimal key
395            // VK_DIVIDE (6F) Divide key
396            // handled by key code above
397
398        case GDK_Num_Lock:
399            return VK_NUMLOCK; // (90) NUM LOCK key
400
401        case GDK_Scroll_Lock:
402            return VK_SCROLL; // (91) SCROLL LOCK key
403
404            // VK_LSHIFT (A0) Left SHIFT key
405            // VK_RSHIFT (A1) Right SHIFT key
406            // VK_LCONTROL (A2) Left CONTROL key
407            // VK_RCONTROL (A3) Right CONTROL key
408            // VK_LMENU (A4) Left MENU key
409            // VK_RMENU (A5) Right MENU key
410            // VK_BROWSER_BACK (A6) Windows 2000/XP: Browser Back key
411            // VK_BROWSER_FORWARD (A7) Windows 2000/XP: Browser Forward key
412            // VK_BROWSER_REFRESH (A8) Windows 2000/XP: Browser Refresh key
413            // VK_BROWSER_STOP (A9) Windows 2000/XP: Browser Stop key
414            // VK_BROWSER_SEARCH (AA) Windows 2000/XP: Browser Search key
415            // VK_BROWSER_FAVORITES (AB) Windows 2000/XP: Browser Favorites key
416            // VK_BROWSER_HOME (AC) Windows 2000/XP: Browser Start and Home key
417            // VK_VOLUME_MUTE (AD) Windows 2000/XP: Volume Mute key
418            // VK_VOLUME_DOWN (AE) Windows 2000/XP: Volume Down key
419            // VK_VOLUME_UP (AF) Windows 2000/XP: Volume Up key
420            // VK_MEDIA_NEXT_TRACK (B0) Windows 2000/XP: Next Track key
421            // VK_MEDIA_PREV_TRACK (B1) Windows 2000/XP: Previous Track key
422            // VK_MEDIA_STOP (B2) Windows 2000/XP: Stop Media key
423            // VK_MEDIA_PLAY_PAUSE (B3) Windows 2000/XP: Play/Pause Media key
424            // VK_LAUNCH_MAIL (B4) Windows 2000/XP: Start Mail key
425            // VK_LAUNCH_MEDIA_SELECT (B5) Windows 2000/XP: Select Media key
426            // VK_LAUNCH_APP1 (B6) Windows 2000/XP: Start Application 1 key
427            // VK_LAUNCH_APP2 (B7) Windows 2000/XP: Start Application 2 key
428
429            // VK_OEM_1 (BA) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ';:' key
430        case GDK_semicolon:
431        case GDK_colon:
432            return VK_OEM_1; //case ';': case ':': return 0xBA;
433            // VK_OEM_PLUS (BB) Windows 2000/XP: For any country/region, the '+' key
434        case GDK_plus:
435        case GDK_equal:
436            return VK_OEM_PLUS; //case '=': case '+': return 0xBB;
437            // VK_OEM_COMMA (BC) Windows 2000/XP: For any country/region, the ',' key
438        case GDK_comma:
439        case GDK_less:
440            return VK_OEM_COMMA; //case ',': case '<': return 0xBC;
441            // VK_OEM_MINUS (BD) Windows 2000/XP: For any country/region, the '-' key
442        case GDK_minus:
443        case GDK_underscore:
444            return VK_OEM_MINUS; //case '-': case '_': return 0xBD;
445            // VK_OEM_PERIOD (BE) Windows 2000/XP: For any country/region, the '.' key
446        case GDK_period:
447        case GDK_greater:
448            return VK_OEM_PERIOD; //case '.': case '>': return 0xBE;
449            // VK_OEM_2 (BF) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '/?' key
450        case GDK_slash:
451        case GDK_question:
452            return VK_OEM_2; //case '/': case '?': return 0xBF;
453            // VK_OEM_3 (C0) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '`~' key
454        case GDK_asciitilde:
455        case GDK_quoteleft:
456            return VK_OEM_3; //case '`': case '~': return 0xC0;
457            // VK_OEM_4 (DB) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '[{' key
458        case GDK_bracketleft:
459        case GDK_braceleft:
460            return VK_OEM_4; //case '[': case '{': return 0xDB;
461            // VK_OEM_5 (DC) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '\|' key
462        case GDK_backslash:
463        case GDK_bar:
464            return VK_OEM_5; //case '\\': case '|': return 0xDC;
465            // VK_OEM_6 (DD) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ']}' key
466        case GDK_bracketright:
467        case GDK_braceright:
468            return VK_OEM_6; // case ']': case '}': return 0xDD;
469            // VK_OEM_7 (DE) Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the 'single-quote/double-quote' key
470        case GDK_quoteright:
471        case GDK_quotedbl:
472            return VK_OEM_7; // case '\'': case '"': return 0xDE;
473            // VK_OEM_8 (DF) Used for miscellaneous characters; it can vary by keyboard.
474            // VK_OEM_102 (E2) Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard
475            // VK_PROCESSKEY (E5) Windows 95/98/Me, Windows NT 4.0, Windows 2000/XP: IME PROCESS key
476            // VK_PACKET (E7) Windows 2000/XP: Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT,SendInput, WM_KEYDOWN, and WM_KEYUP
477            // VK_ATTN (F6) Attn key
478            // VK_CRSEL (F7) CrSel key
479            // VK_EXSEL (F8) ExSel key
480            // VK_EREOF (F9) Erase EOF key
481            // VK_PLAY (FA) Play key
482            // VK_ZOOM (FB) Zoom key
483            // VK_NONAME (FC) Reserved for future use
484            // VK_PA1 (FD) PA1 key
485            // VK_OEM_CLEAR (FE) Clear key
486        case GDK_F1:
487        case GDK_F2:
488        case GDK_F3:
489        case GDK_F4:
490        case GDK_F5:
491        case GDK_F6:
492        case GDK_F7:
493        case GDK_F8:
494        case GDK_F9:
495        case GDK_F10:
496        case GDK_F11:
497        case GDK_F12:
498        case GDK_F13:
499        case GDK_F14:
500        case GDK_F15:
501        case GDK_F16:
502        case GDK_F17:
503        case GDK_F18:
504        case GDK_F19:
505        case GDK_F20:
506        case GDK_F21:
507        case GDK_F22:
508        case GDK_F23:
509        case GDK_F24:
510            return VK_F1 + (keycode - GDK_F1);
511
512        default:
513            return 0;
514    }
515
516}
517
518static String singleCharacterString(guint val)
519{
520    switch (val) {
521        case GDK_ISO_Enter:
522        case GDK_KP_Enter:
523        case GDK_Return:
524            return String("\r");
525        case GDK_BackSpace:
526            return String("\x8");
527        case GDK_Tab:
528            return String("\t");
529        default:
530            gunichar c = gdk_keyval_to_unicode(val);
531            glong nwc;
532            gunichar2* uchar16 = g_ucs4_to_utf16(&c, 1, 0, &nwc, 0);
533
534            String retVal;
535            if (uchar16)
536                retVal = String((UChar*)uchar16, nwc);
537            else
538                retVal = String();
539
540            g_free(uchar16);
541
542            return retVal;
543    }
544}
545
546// Keep this in sync with the other platform event constructors
547// TODO: m_gdkEventKey should be refcounted
548PlatformKeyboardEvent::PlatformKeyboardEvent(GdkEventKey* event)
549    : m_type((event->type == GDK_KEY_RELEASE) ? KeyUp : KeyDown)
550    , m_text(singleCharacterString(event->keyval))
551    , m_unmodifiedText(singleCharacterString(event->keyval))
552    , m_keyIdentifier(keyIdentifierForGdkKeyCode(event->keyval))
553    , m_autoRepeat(false)
554    , m_windowsVirtualKeyCode(windowsKeyCodeForKeyEvent(event->keyval))
555    , m_nativeVirtualKeyCode(event->keyval)
556    , m_isKeypad(event->keyval >= GDK_KP_Space && event->keyval <= GDK_KP_9)
557    , m_shiftKey((event->state & GDK_SHIFT_MASK) || (event->keyval == GDK_3270_BackTab))
558    , m_ctrlKey(event->state & GDK_CONTROL_MASK)
559    , m_altKey(event->state & GDK_MOD1_MASK)
560    , m_metaKey(event->state & GDK_META_MASK)
561    , m_gdkEventKey(event)
562{
563}
564
565void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool backwardCompatibilityMode)
566{
567    // Can only change type from KeyDown to RawKeyDown or Char, as we lack information for other conversions.
568    ASSERT(m_type == KeyDown);
569    m_type = type;
570
571    if (backwardCompatibilityMode)
572        return;
573
574    if (type == RawKeyDown) {
575        m_text = String();
576        m_unmodifiedText = String();
577    } else {
578        m_keyIdentifier = String();
579        m_windowsVirtualKeyCode = 0;
580    }
581}
582
583bool PlatformKeyboardEvent::currentCapsLockState()
584{
585    notImplemented();
586    return false;
587}
588
589GdkEventKey* PlatformKeyboardEvent::gdkEventKey() const
590{
591    return m_gdkEventKey;
592}
593
594}
595