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 "chrome/browser/renderer_host/render_widget_host_view_gtk.h" | 5 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 #include <gdk/gdk.h> | 8 #include <gdk/gdk.h> |
9 #include <gdk/gdkkeysyms.h> | 9 #include <gdk/gdkkeysyms.h> |
10 #include <gdk/gdkx.h> | 10 #include <gdk/gdkx.h> |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 // TODO(hbono): we should not dispatch a key event when the input focus | 138 // TODO(hbono): we should not dispatch a key event when the input focus |
139 // is in a password input? | 139 // is in a password input? |
140 if (!gtk_im_context_filter_keypress(host_view->im_context_, event)) { | 140 if (!gtk_im_context_filter_keypress(host_view->im_context_, event)) { |
141 // The GtkIMContext object cannot handle this key event. | 141 // The GtkIMContext object cannot handle this key event. |
142 // This case is caused by two reasons: | 142 // This case is caused by two reasons: |
143 // 1. The given key event is a control-key event, (e.g. return, page up, | 143 // 1. The given key event is a control-key event, (e.g. return, page up, |
144 // page down, tab, arrows, etc.) or; | 144 // page down, tab, arrows, etc.) or; |
145 // 2. The given key event is not a control-key event but printable | 145 // 2. The given key event is not a control-key event but printable |
146 // characters aren't assigned to the event, (e.g. alt+d, etc.) | 146 // characters aren't assigned to the event, (e.g. alt+d, etc.) |
147 // Create a Char event manually from this key event and send it to the | 147 // Create a Char event manually from this key event and send it to the |
148 // renderer only when this event is a control-key event because | 148 // renderer when this Char event contains a printable character which |
149 // control-key events should be processed by WebKit. | 149 // should be processed by WebKit. |
150 // TODO(hbono): Windows Chrome sends a Char event with its isSystemKey | 150 // TODO(hbono): Windows Chrome sends a Char event with its isSystemKey |
151 // value true for the above case 2. We should emulate this behavior? | 151 // value true for the above case 2. We should emulate this behavior? |
152 if (event->type == GDK_KEY_PRESS && | 152 if (event->type == GDK_KEY_PRESS && |
153 !gdk_keyval_to_unicode(event->keyval)) { | 153 !gdk_keyval_to_unicode(event->keyval)) { |
154 NativeWebKeyboardEvent wke(event); | 154 NativeWebKeyboardEvent wke(event); |
155 wke.type = WebKit::WebInputEvent::Char; | 155 wke.type = WebKit::WebInputEvent::Char; |
156 host_view->GetRenderWidgetHost()->ForwardKeyboardEvent(wke); | 156 if (wke.text[0]) |
| 157 host_view->GetRenderWidgetHost()->ForwardKeyboardEvent(wke); |
157 } | 158 } |
158 } | 159 } |
159 | 160 |
160 // We return TRUE because we did handle the event. If it turns out webkit | 161 // We return TRUE because we did handle the event. If it turns out webkit |
161 // can't handle the event, we'll deal with it in | 162 // can't handle the event, we'll deal with it in |
162 // RenderView::UnhandledKeyboardEvent(). | 163 // RenderView::UnhandledKeyboardEvent(). |
163 return TRUE; | 164 return TRUE; |
164 } | 165 } |
165 | 166 |
166 static gboolean OnFocusIn(GtkWidget* widget, GdkEventFocus* focus, | 167 static gboolean OnFocusIn(GtkWidget* widget, GdkEventFocus* focus, |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 } | 716 } |
716 | 717 |
717 gfx::PluginWindowHandle RenderWidgetHostViewGtk::CreatePluginContainer() { | 718 gfx::PluginWindowHandle RenderWidgetHostViewGtk::CreatePluginContainer() { |
718 return plugin_container_manager_.CreatePluginContainer(); | 719 return plugin_container_manager_.CreatePluginContainer(); |
719 } | 720 } |
720 | 721 |
721 void RenderWidgetHostViewGtk::DestroyPluginContainer( | 722 void RenderWidgetHostViewGtk::DestroyPluginContainer( |
722 gfx::PluginWindowHandle container) { | 723 gfx::PluginWindowHandle container) { |
723 plugin_container_manager_.DestroyPluginContainer(container); | 724 plugin_container_manager_.DestroyPluginContainer(container); |
724 } | 725 } |
OLD | NEW |