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

Side by Side Diff: webkit/glue/webinputevent_linux.cc

Issue 28186: Reverting key change (again); this breaks every keyboard layout test there is... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 9 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 | « webkit/glue/webinputevent.h ('k') | webkit/glue/webinputevent_mac.mm » ('j') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "config.h" 5 #include "config.h"
6 6
7 #include "webkit/glue/webinputevent.h" 7 #include "webkit/glue/webinputevent.h"
8 8
9 #include "KeyboardCodes.h" 9 #include "KeyboardCodes.h"
10 #include "KeyCodeConversion.h" 10 #include "KeyCodeConversion.h"
11 11
12 #include "webkit/glue/event_conversion.h"
13
14 // This header is out of alphabetical order, but event_conversion.h pulls
15 // in more webkit headers that redefine LOG so I need to undef afterwards.
16 #undef LOG
12 #include "base/logging.h" 17 #include "base/logging.h"
13 #include "base/string_util.h"
14 #include "webkit/glue/webinputevent_utils.h"
15 18
16 #include <gdk/gdk.h> 19 #include <gdk/gdk.h>
17 #include <gdk/gdkkeysyms.h> 20 #include <gdk/gdkkeysyms.h>
18 #include <gtk/gtkversion.h> 21 #include <gtk/gtkversion.h>
19 22
20 namespace { 23 namespace {
21 24
22 double GdkEventTimeToWebEventTime(guint32 time) { 25 double GdkEventTimeToWebEventTime(guint32 time) {
23 // Convert from time in ms to time in sec. 26 // Convert from time in ms to time in sec.
24 return time / 1000.0; 27 return time / 1000.0;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 break; 59 break;
57 case GDK_2BUTTON_PRESS: 60 case GDK_2BUTTON_PRESS:
58 case GDK_3BUTTON_PRESS: 61 case GDK_3BUTTON_PRESS:
59 type = MOUSE_DOUBLE_CLICK; 62 type = MOUSE_DOUBLE_CLICK;
60 break; 63 break;
61 case GDK_BUTTON_RELEASE: 64 case GDK_BUTTON_RELEASE:
62 type = MOUSE_UP; 65 type = MOUSE_UP;
63 break; 66 break;
64 67
65 default: 68 default:
66 NOTREACHED(); 69 ASSERT_NOT_REACHED();
67 }; 70 };
68 71
69 button = BUTTON_NONE; 72 button = BUTTON_NONE;
70 if (event->button == 1) { 73 if (event->button == 1) {
71 button = BUTTON_LEFT; 74 button = BUTTON_LEFT;
72 } else if (event->button == 2) { 75 } else if (event->button == 2) {
73 button = BUTTON_MIDDLE; 76 button = BUTTON_MIDDLE;
74 } else if (event->button == 3) { 77 } else if (event->button == 3) {
75 button = BUTTON_RIGHT; 78 button = BUTTON_RIGHT;
76 } 79 }
77 } 80 }
78 81
79 WebMouseEvent::WebMouseEvent(const GdkEventMotion* event) { 82 WebMouseEvent::WebMouseEvent(const GdkEventMotion* event) {
80 timestamp_sec = GdkEventTimeToWebEventTime(event->time); 83 timestamp_sec = GdkEventTimeToWebEventTime(event->time);
81 modifiers = GdkStateToWebEventModifiers(event->state); 84 modifiers = GdkStateToWebEventModifiers(event->state);
82 x = static_cast<int>(event->x); 85 x = static_cast<int>(event->x);
83 y = static_cast<int>(event->y); 86 y = static_cast<int>(event->y);
84 global_x = static_cast<int>(event->x_root); 87 global_x = static_cast<int>(event->x_root);
85 global_y = static_cast<int>(event->y_root); 88 global_y = static_cast<int>(event->y_root);
86 89
87 switch (event->type) { 90 switch (event->type) {
88 case GDK_MOTION_NOTIFY: 91 case GDK_MOTION_NOTIFY:
89 type = MOUSE_MOVE; 92 type = MOUSE_MOVE;
90 break; 93 break;
91 default: 94 default:
92 NOTREACHED(); 95 ASSERT_NOT_REACHED();
93 } 96 }
94 97
95 button = BUTTON_NONE; 98 button = BUTTON_NONE;
96 if (event->state & GDK_BUTTON1_MASK) { 99 if (event->state & GDK_BUTTON1_MASK) {
97 button = BUTTON_LEFT; 100 button = BUTTON_LEFT;
98 } else if (event->state & GDK_BUTTON2_MASK) { 101 } else if (event->state & GDK_BUTTON2_MASK) {
99 button = BUTTON_MIDDLE; 102 button = BUTTON_MIDDLE;
100 } else if (event->state & GDK_BUTTON3_MASK) { 103 } else if (event->state & GDK_BUTTON3_MASK) {
101 button = BUTTON_RIGHT; 104 button = BUTTON_RIGHT;
102 } 105 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 break; 142 break;
140 case GDK_SCROLL_RIGHT: 143 case GDK_SCROLL_RIGHT:
141 delta_x = kWheelDelta; 144 delta_x = kWheelDelta;
142 break; 145 break;
143 default: 146 default:
144 break; 147 break;
145 } 148 }
146 } 149 }
147 150
148 WebKeyboardEvent::WebKeyboardEvent(const GdkEventKey* event) { 151 WebKeyboardEvent::WebKeyboardEvent(const GdkEventKey* event) {
149 system_key = false;
150 modifiers = GdkStateToWebEventModifiers(event->state); 152 modifiers = GdkStateToWebEventModifiers(event->state);
151 153
154 // GDK only exposes key press and release events. By contrast,
155 // WebKeyboardEvent matches Windows and wants key down/up events along with a
156 // separate CHAR event.
157 // We require the caller to simulate the CHAR event manually. See
158 // test_shell's webwidget_host for an example.
152 switch (event->type) { 159 switch (event->type) {
153 case GDK_KEY_RELEASE: 160 case GDK_KEY_RELEASE:
154 type = KEY_UP; 161 type = KEY_UP;
155 break; 162 break;
156 case GDK_KEY_PRESS: 163 case GDK_KEY_PRESS:
157 type = KEY_DOWN; 164 type = KEY_DOWN;
158 break; 165 break;
159 default: 166 default:
160 NOTREACHED(); 167 NOTREACHED();
161 break; 168 break;
162 } 169 }
163 170
164 // The key code tells us which physical key was pressed (for example, the 171 // The key code tells us which physical key was pressed (for example, the
165 // A key went down or up). It does not determine whether A should be lower 172 // A key went down or up). It does not determine whether A should be lower
166 // or upper case. This is what text does, which should be the keyval. 173 // or upper case. This is what text does, which should be the keyval.
167 windows_key_code = WebCore::windowsKeyCodeForKeyEvent(event->keyval); 174 key_code = WebCore::windowsKeyCodeForKeyEvent(event->keyval);
168 native_key_code = event->hardware_keycode;
169
170 memset(&text, 0, sizeof(text));
171 memset(&unmodified_text, 0, sizeof(unmodified_text));
172 memset(&key_identifier, 0, sizeof(key_identifier));
173 175
174 switch (event->keyval) { 176 switch (event->keyval) {
175 // We need to treat the enter key as a key press of character \r. This 177 // We need to treat the enter key as a key press of character \r. This
176 // is apparently just how webkit handles it and what it expects. 178 // is apparently just how webkit handles it and what it expects.
177 case GDK_ISO_Enter: 179 case GDK_ISO_Enter:
178 case GDK_KP_Enter: 180 case GDK_KP_Enter:
179 case GDK_Return: 181 case GDK_Return:
180 unmodified_text[0] = text[0] = static_cast<char16>('\r'); 182 text = '\r';
181 break; 183 break;
182 default: 184 default:
183 // This should set text to 0 when it's not a real character. 185 // This should set text to 0 when it's not a real character.
184 // TODO(avi): fix for non BMP chars 186 text = gdk_keyval_to_unicode(event->keyval);
185 unmodified_text[0] = text[0] =
186 static_cast<char16>(gdk_keyval_to_unicode(event->keyval));
187 break; 187 break;
188 } 188 }
189 189
190 std::string key_identifier_str =
191 GetKeyIdentifierForWindowsKeyCode(windows_key_code);
192 base::strlcpy(key_identifier, key_identifier_str.c_str(),
193 kIdentifierLengthCap);
194
195 // TODO(tc): Do we need to set IS_AUTO_REPEAT or IS_KEYPAD? 190 // TODO(tc): Do we need to set IS_AUTO_REPEAT or IS_KEYPAD?
196 } 191 }
OLDNEW
« no previous file with comments | « webkit/glue/webinputevent.h ('k') | webkit/glue/webinputevent_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698