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

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

Issue 149755: This change list improves IME support on Linux. Many corner cases that were n... Base URL: http://src.chromium.org/svn/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 | « chrome/browser/renderer_host/render_widget_host_view_gtk.cc ('k') | 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 case GDK_KEY_RELEASE: 183 case GDK_KEY_RELEASE:
184 result.type = WebInputEvent::KeyUp; 184 result.type = WebInputEvent::KeyUp;
185 break; 185 break;
186 case GDK_KEY_PRESS: 186 case GDK_KEY_PRESS:
187 result.type = WebInputEvent::RawKeyDown; 187 result.type = WebInputEvent::RawKeyDown;
188 break; 188 break;
189 default: 189 default:
190 ASSERT_NOT_REACHED(); 190 ASSERT_NOT_REACHED();
191 } 191 }
192 192
193 // According to MSDN:
194 // http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx
195 // Key events with Alt modifier and F10 are system key events.
196 // We just emulate this behavior. It's necessary to prevent webkit from
197 // processing keypress event generated by alt-d, etc.
198 // F10 is not special on Linux, so don't treat it as system key.
199 if (result.modifiers & WebInputEvent::AltKey)
200 result.isSystemKey = true;
201
193 // The key code tells us which physical key was pressed (for example, the 202 // The key code tells us which physical key was pressed (for example, the
194 // A key went down or up). It does not determine whether A should be lower 203 // A key went down or up). It does not determine whether A should be lower
195 // or upper case. This is what text does, which should be the keyval. 204 // or upper case. This is what text does, which should be the keyval.
196 result.windowsKeyCode = gdkEventToWindowsKeyCode(event); 205 result.windowsKeyCode = gdkEventToWindowsKeyCode(event);
197 result.nativeKeyCode = event->hardware_keycode; 206 result.nativeKeyCode = event->hardware_keycode;
198 207
199 switch (event->keyval) { 208 switch (event->keyval) {
200 // We need to treat the enter key as a key press of character \r. This 209 // We need to treat the enter key as a key press of character \r. This
201 // is apparently just how webkit handles it and what it expects. 210 // is apparently just how webkit handles it and what it expects.
202 case GDK_ISO_Enter: 211 case GDK_ISO_Enter:
203 case GDK_KP_Enter: 212 case GDK_KP_Enter:
204 case GDK_Return: 213 case GDK_Return:
205 result.unmodifiedText[0] = result.text[0] = static_cast<WebUChar>('\r'); 214 result.unmodifiedText[0] = result.text[0] = static_cast<WebUChar>('\r');
206 break; 215 break;
207 default: 216 default:
208 // This should set text to 0 when it's not a real character. 217 // This should set text to 0 when it's not a real character.
209 // FIXME: fix for non BMP chars 218 // FIXME: fix for non BMP chars
219 // TODO(james.su@gmail.com):
220 // Support control characters input like Windows.
221 // See: http://en.wikipedia.org/wiki/Control_characters
210 result.unmodifiedText[0] = result.text[0] = 222 result.unmodifiedText[0] = result.text[0] =
211 static_cast<WebUChar>(gdk_keyval_to_unicode(event->keyval)); 223 static_cast<WebUChar>(gdk_keyval_to_unicode(event->keyval));
212 } 224 }
213 225
214 result.setKeyIdentifierFromWindowsKeyCode(); 226 result.setKeyIdentifierFromWindowsKeyCode();
215 227
216 // FIXME: Do we need to set IsAutoRepeat or IsKeyPad? 228 // FIXME: Do we need to set IsAutoRepeat or IsKeyPad?
217 229
218 return result; 230 return result;
219 } 231 }
220 232
221 WebKeyboardEvent WebInputEventFactory::keyboardEvent(wchar_t character, int state, double timeStampSeconds) 233 WebKeyboardEvent WebInputEventFactory::keyboardEvent(wchar_t character, int state, double timeStampSeconds)
222 { 234 {
223 // keyboardEvent(const GdkEventKey*) depends on the GdkEventKey object and 235 // keyboardEvent(const GdkEventKey*) depends on the GdkEventKey object and
224 // it is hard to use/ it from signal handlers which don't use GdkEventKey 236 // it is hard to use/ it from signal handlers which don't use GdkEventKey
225 // objects (e.g. GtkIMContext signal handlers.) For such handlers, this 237 // objects (e.g. GtkIMContext signal handlers.) For such handlers, this
226 // function creates a WebInputEvent::Char event without using a 238 // function creates a WebInputEvent::Char event without using a
227 // GdkEventKey object. 239 // GdkEventKey object.
228 WebKeyboardEvent result; 240 WebKeyboardEvent result;
229 result.type = WebKit::WebInputEvent::Char; 241 result.type = WebKit::WebInputEvent::Char;
230 result.timeStampSeconds = timeStampSeconds; 242 result.timeStampSeconds = timeStampSeconds;
231 result.modifiers = gdkStateToWebEventModifiers(state); 243 result.modifiers = gdkStateToWebEventModifiers(state);
232 result.windowsKeyCode = character; 244 result.windowsKeyCode = character;
233 result.nativeKeyCode = character; 245 result.nativeKeyCode = character;
234 result.text[0] = character; 246 result.text[0] = character;
235 result.unmodifiedText[0] = character; 247 result.unmodifiedText[0] = character;
248
249 // According to MSDN:
250 // http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx
251 // Key events with Alt modifier and F10 are system key events.
252 // We just emulate this behavior. It's necessary to prevent webkit from
253 // processing keypress event generated by alt-d, etc.
254 // F10 is not special on Linux, so don't treat it as system key.
255 if (result.modifiers & WebInputEvent::AltKey)
256 result.isSystemKey = true;
257
236 return result; 258 return result;
237 } 259 }
238 260
239 // WebMouseEvent -------------------------------------------------------------- 261 // WebMouseEvent --------------------------------------------------------------
240 262
241 WebMouseEvent WebInputEventFactory::mouseEvent(const GdkEventButton* event) 263 WebMouseEvent WebInputEventFactory::mouseEvent(const GdkEventButton* event)
242 { 264 {
243 WebMouseEvent result; 265 WebMouseEvent result;
244 266
245 result.timeStampSeconds = gdkEventTimeToWebEventTime(event->time); 267 result.timeStampSeconds = gdkEventTimeToWebEventTime(event->time);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 case GDK_SCROLL_RIGHT: 383 case GDK_SCROLL_RIGHT:
362 result.deltaX = -scrollbarPixelsPerTick; 384 result.deltaX = -scrollbarPixelsPerTick;
363 result.wheelTicksX = 1; 385 result.wheelTicksX = 1;
364 break; 386 break;
365 } 387 }
366 388
367 return result; 389 return result;
368 } 390 }
369 391
370 } // namespace WebKit 392 } // namespace WebKit
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/render_widget_host_view_gtk.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698