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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
213 // Notify the GtkIMContext object of this focus-in event and | 213 // Notify the GtkIMContext object of this focus-in event and |
214 // detach this GtkIMContext object from this window. | 214 // detach this GtkIMContext object from this window. |
215 gtk_im_context_focus_out(host_view->im_context_); | 215 gtk_im_context_focus_out(host_view->im_context_); |
216 gtk_im_context_set_client_window(host_view->im_context_, NULL); | 216 gtk_im_context_set_client_window(host_view->im_context_, NULL); |
217 return FALSE; | 217 return FALSE; |
218 } | 218 } |
219 | 219 |
220 static gboolean ButtonPressReleaseEvent( | 220 static gboolean ButtonPressReleaseEvent( |
221 GtkWidget* widget, GdkEventButton* event, | 221 GtkWidget* widget, GdkEventButton* event, |
222 RenderWidgetHostViewGtk* host_view) { | 222 RenderWidgetHostViewGtk* host_view) { |
223 if (!(event->button == 1 || event->button == 2 || event->button == 3)) | |
224 return FALSE; // We do not forward any other buttons to the renderer. | |
225 | |
223 // We want to translate the coordinates of events that do not originate | 226 // We want to translate the coordinates of events that do not originate |
224 // from this widget to be relative to the top left of the widget. | 227 // from this widget to be relative to the top left of the widget. |
225 GtkWidget* event_widget = gtk_get_event_widget( | 228 GtkWidget* event_widget = gtk_get_event_widget( |
226 reinterpret_cast<GdkEvent*>(event)); | 229 reinterpret_cast<GdkEvent*>(event)); |
227 if (event_widget != widget) { | 230 if (event_widget != widget) { |
228 int x = 0; | 231 int x = 0; |
229 int y = 0; | 232 int y = 0; |
230 gtk_widget_get_pointer(widget, &x, &y); | 233 gtk_widget_get_pointer(widget, &x, &y); |
231 // If the mouse event happens outside our popup, force the popup to | 234 // If the mouse event happens outside our popup, force the popup to |
232 // close. We do this so a hung renderer doesn't prevent us from | 235 // close. We do this so a hung renderer doesn't prevent us from |
(...skipping 11 matching lines...) Expand all Loading... | |
244 event->x = x; | 247 event->x = x; |
245 event->y = y; | 248 event->y = y; |
246 } | 249 } |
247 host_view->is_popup_first_mouse_release_ = false; | 250 host_view->is_popup_first_mouse_release_ = false; |
248 host_view->GetRenderWidgetHost()->ForwardMouseEvent( | 251 host_view->GetRenderWidgetHost()->ForwardMouseEvent( |
249 WebInputEventFactory::mouseEvent(event)); | 252 WebInputEventFactory::mouseEvent(event)); |
250 | 253 |
251 // TODO(evanm): why is this necessary here but not in test shell? | 254 // TODO(evanm): why is this necessary here but not in test shell? |
252 // This logic is the same as GtkButton. | 255 // This logic is the same as GtkButton. |
253 if (event->type == GDK_BUTTON_PRESS && !GTK_WIDGET_HAS_FOCUS(widget)) | 256 if (event->type == GDK_BUTTON_PRESS && !GTK_WIDGET_HAS_FOCUS(widget)) |
254 gtk_widget_grab_focus(widget); | 257 gtk_widget_grab_focus(widget); |
Evan Martin
2009/07/09 00:01:08
I wonder if this bit of code is related to the mys
Evan Stade
2009/07/09 00:11:08
I wouldn't be too surprised, it's worth messing ar
| |
255 | 258 |
256 return FALSE; | 259 return TRUE; // We did handle the mouse event. |
257 } | 260 } |
258 | 261 |
259 static gboolean MouseMoveEvent(GtkWidget* widget, GdkEventMotion* event, | 262 static gboolean MouseMoveEvent(GtkWidget* widget, GdkEventMotion* event, |
260 RenderWidgetHostViewGtk* host_view) { | 263 RenderWidgetHostViewGtk* host_view) { |
261 // We want to translate the coordinates of events that do not originate | 264 // We want to translate the coordinates of events that do not originate |
262 // from this widget to be relative to the top left of the widget. | 265 // from this widget to be relative to the top left of the widget. |
263 GtkWidget* event_widget = gtk_get_event_widget( | 266 GtkWidget* event_widget = gtk_get_event_widget( |
264 reinterpret_cast<GdkEvent*>(event)); | 267 reinterpret_cast<GdkEvent*>(event)); |
265 if (event_widget != widget) { | 268 if (event_widget != widget) { |
266 int x = 0; | 269 int x = 0; |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
712 } | 715 } |
713 | 716 |
714 gfx::PluginWindowHandle RenderWidgetHostViewGtk::CreatePluginContainer() { | 717 gfx::PluginWindowHandle RenderWidgetHostViewGtk::CreatePluginContainer() { |
715 return plugin_container_manager_.CreatePluginContainer(); | 718 return plugin_container_manager_.CreatePluginContainer(); |
716 } | 719 } |
717 | 720 |
718 void RenderWidgetHostViewGtk::DestroyPluginContainer( | 721 void RenderWidgetHostViewGtk::DestroyPluginContainer( |
719 gfx::PluginWindowHandle container) { | 722 gfx::PluginWindowHandle container) { |
720 plugin_container_manager_.DestroyPluginContainer(container); | 723 plugin_container_manager_.DestroyPluginContainer(container); |
721 } | 724 } |
OLD | NEW |