OLD | NEW |
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 "webkit/tools/test_shell/webwidget_host.h" | 5 #include "webkit/tools/test_shell/webwidget_host.h" |
6 | 6 |
7 #include <cairo/cairo.h> | 7 #include <cairo/cairo.h> |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 return FALSE; | 141 return FALSE; |
142 } | 142 } |
143 | 143 |
144 // Keyboard key pressed. | 144 // Keyboard key pressed. |
145 static gboolean HandleKeyPress(GtkWidget* widget, | 145 static gboolean HandleKeyPress(GtkWidget* widget, |
146 GdkEventKey* event, | 146 GdkEventKey* event, |
147 WebWidgetHost* host) { | 147 WebWidgetHost* host) { |
148 WebKeyboardEvent wke(event); | 148 WebKeyboardEvent wke(event); |
149 host->webwidget()->HandleInputEvent(&wke); | 149 host->webwidget()->HandleInputEvent(&wke); |
150 | 150 |
| 151 // The WebKeyboardEvent model, when holding down a key, is: |
| 152 // KEY_DOWN, CHAR, (repeated CHAR as key repeats,) KEY_UP |
| 153 // The GDK model for the same sequence is just: |
| 154 // KEY_PRESS, (repeated KEY_PRESS as key repeats,) KEY_RELEASE |
| 155 // So we must simulate a CHAR event for every key press. |
| 156 if (event->type == GDK_KEY_PRESS) { |
| 157 wke.type = WebKeyboardEvent::CHAR; |
| 158 host->webwidget()->HandleInputEvent(&wke); |
| 159 } |
| 160 |
151 return FALSE; | 161 return FALSE; |
152 } | 162 } |
153 | 163 |
154 // Keyboard key released. | 164 // Keyboard key released. |
155 static gboolean HandleKeyRelease(GtkWidget* widget, | 165 static gboolean HandleKeyRelease(GtkWidget* widget, |
156 GdkEventKey* event, | 166 GdkEventKey* event, |
157 WebWidgetHost* host) { | 167 WebWidgetHost* host) { |
158 return HandleKeyPress(widget, event, host); | 168 return HandleKeyPress(widget, event, host); |
159 } | 169 } |
160 | 170 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 | 364 |
355 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { | 365 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { |
356 set_painting(true); | 366 set_painting(true); |
357 webwidget_->Paint(canvas_.get(), rect); | 367 webwidget_->Paint(canvas_.get(), rect); |
358 set_painting(false); | 368 set_painting(false); |
359 } | 369 } |
360 | 370 |
361 void WebWidgetHost::WindowDestroyed() { | 371 void WebWidgetHost::WindowDestroyed() { |
362 delete this; | 372 delete this; |
363 } | 373 } |
OLD | NEW |