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 | |
161 return FALSE; | 151 return FALSE; |
162 } | 152 } |
163 | 153 |
164 // Keyboard key released. | 154 // Keyboard key released. |
165 static gboolean HandleKeyRelease(GtkWidget* widget, | 155 static gboolean HandleKeyRelease(GtkWidget* widget, |
166 GdkEventKey* event, | 156 GdkEventKey* event, |
167 WebWidgetHost* host) { | 157 WebWidgetHost* host) { |
168 return HandleKeyPress(widget, event, host); | 158 return HandleKeyPress(widget, event, host); |
169 } | 159 } |
170 | 160 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 | 354 |
365 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { | 355 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { |
366 set_painting(true); | 356 set_painting(true); |
367 webwidget_->Paint(canvas_.get(), rect); | 357 webwidget_->Paint(canvas_.get(), rect); |
368 set_painting(false); | 358 set_painting(false); |
369 } | 359 } |
370 | 360 |
371 void WebWidgetHost::WindowDestroyed() { | 361 void WebWidgetHost::WindowDestroyed() { |
372 delete this; | 362 delete this; |
373 } | 363 } |
OLD | NEW |