| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 g_signal_connect(widget, "focus-out-event", | 65 g_signal_connect(widget, "focus-out-event", |
| 66 G_CALLBACK(OnFocusOut), host_view); | 66 G_CALLBACK(OnFocusOut), host_view); |
| 67 g_signal_connect(widget, "grab-notify", | 67 g_signal_connect(widget, "grab-notify", |
| 68 G_CALLBACK(OnGrabNotify), host_view); | 68 G_CALLBACK(OnGrabNotify), host_view); |
| 69 g_signal_connect(widget, "button-press-event", | 69 g_signal_connect(widget, "button-press-event", |
| 70 G_CALLBACK(ButtonPressReleaseEvent), host_view); | 70 G_CALLBACK(ButtonPressReleaseEvent), host_view); |
| 71 g_signal_connect(widget, "button-release-event", | 71 g_signal_connect(widget, "button-release-event", |
| 72 G_CALLBACK(ButtonPressReleaseEvent), host_view); | 72 G_CALLBACK(ButtonPressReleaseEvent), host_view); |
| 73 g_signal_connect(widget, "motion-notify-event", | 73 g_signal_connect(widget, "motion-notify-event", |
| 74 G_CALLBACK(MouseMoveEvent), host_view); | 74 G_CALLBACK(MouseMoveEvent), host_view); |
| 75 g_signal_connect(widget, "scroll-event", | 75 // Connect after so that we are called after the handler installed by the |
| 76 G_CALLBACK(MouseScrollEvent), host_view); | 76 // TabContentsView which handles zoom events. |
| 77 g_signal_connect_after(widget, "scroll-event", |
| 78 G_CALLBACK(MouseScrollEvent), host_view); |
| 77 | 79 |
| 78 // Create a GtkIMContext instance and attach its signal handlers. | 80 // Create a GtkIMContext instance and attach its signal handlers. |
| 79 host_view->im_context_ = gtk_im_multicontext_new(); | 81 host_view->im_context_ = gtk_im_multicontext_new(); |
| 80 g_signal_connect(host_view->im_context_, "preedit_start", | 82 g_signal_connect(host_view->im_context_, "preedit_start", |
| 81 G_CALLBACK(InputMethodPreeditStart), host_view); | 83 G_CALLBACK(InputMethodPreeditStart), host_view); |
| 82 g_signal_connect(host_view->im_context_, "preedit_end", | 84 g_signal_connect(host_view->im_context_, "preedit_end", |
| 83 G_CALLBACK(InputMethodPreeditEnd), host_view); | 85 G_CALLBACK(InputMethodPreeditEnd), host_view); |
| 84 g_signal_connect(host_view->im_context_, "preedit_changed", | 86 g_signal_connect(host_view->im_context_, "preedit_changed", |
| 85 G_CALLBACK(InputMethodPreeditChanged), host_view); | 87 G_CALLBACK(InputMethodPreeditChanged), host_view); |
| 86 g_signal_connect(host_view->im_context_, "commit", | 88 g_signal_connect(host_view->im_context_, "commit", |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 event->x = x; | 286 event->x = x; |
| 285 event->y = y; | 287 event->y = y; |
| 286 } | 288 } |
| 287 host_view->GetRenderWidgetHost()->ForwardMouseEvent( | 289 host_view->GetRenderWidgetHost()->ForwardMouseEvent( |
| 288 WebInputEventFactory::mouseEvent(event)); | 290 WebInputEventFactory::mouseEvent(event)); |
| 289 return FALSE; | 291 return FALSE; |
| 290 } | 292 } |
| 291 | 293 |
| 292 static gboolean MouseScrollEvent(GtkWidget* widget, GdkEventScroll* event, | 294 static gboolean MouseScrollEvent(GtkWidget* widget, GdkEventScroll* event, |
| 293 RenderWidgetHostViewGtk* host_view) { | 295 RenderWidgetHostViewGtk* host_view) { |
| 296 // If the user is holding shift, translate it into a horizontal scroll. We |
| 297 // don't care what other modifiers the user may be holding (zooming is |
| 298 // handled at the TabContentsView level). |
| 299 if (event->state & GDK_SHIFT_MASK) { |
| 300 if (event->direction == GDK_SCROLL_UP) |
| 301 event->direction = GDK_SCROLL_LEFT; |
| 302 else if (event->direction == GDK_SCROLL_DOWN) |
| 303 event->direction = GDK_SCROLL_RIGHT; |
| 304 } |
| 305 |
| 294 host_view->GetRenderWidgetHost()->ForwardWheelEvent( | 306 host_view->GetRenderWidgetHost()->ForwardWheelEvent( |
| 295 WebInputEventFactory::mouseWheelEvent(event)); | 307 WebInputEventFactory::mouseWheelEvent(event)); |
| 296 return FALSE; | 308 return FALSE; |
| 297 } | 309 } |
| 298 | 310 |
| 299 static void InputMethodCommit(GtkIMContext* im_context, | 311 static void InputMethodCommit(GtkIMContext* im_context, |
| 300 gchar* text, | 312 gchar* text, |
| 301 RenderWidgetHostViewGtk* host_view) { | 313 RenderWidgetHostViewGtk* host_view) { |
| 302 std::wstring im_text = UTF8ToWide(text); | 314 std::wstring im_text = UTF8ToWide(text); |
| 303 if (!host_view->im_is_composing_cjk_text_ && im_text.length() == 1) { | 315 if (!host_view->im_is_composing_cjk_text_ && im_text.length() == 1) { |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 } | 759 } |
| 748 } | 760 } |
| 749 | 761 |
| 750 void RenderWidgetHostViewGtk::PluginProcessCrashed(base::ProcessId pid) { | 762 void RenderWidgetHostViewGtk::PluginProcessCrashed(base::ProcessId pid) { |
| 751 for (PluginPidMap::iterator i = plugin_pid_map_.find(pid); | 763 for (PluginPidMap::iterator i = plugin_pid_map_.find(pid); |
| 752 i != plugin_pid_map_.end() && i->first == pid; ++i) { | 764 i != plugin_pid_map_.end() && i->first == pid; ++i) { |
| 753 plugin_container_manager_.DestroyPluginContainer(i->second); | 765 plugin_container_manager_.DestroyPluginContainer(i->second); |
| 754 } | 766 } |
| 755 plugin_pid_map_.erase(pid); | 767 plugin_pid_map_.erase(pid); |
| 756 } | 768 } |
| OLD | NEW |