Chromium Code Reviews| Index: views/focus/accelerator_handler_touch.cc |
| diff --git a/views/focus/accelerator_handler_touch.cc b/views/focus/accelerator_handler_touch.cc |
| index ce15c518c83357f4feffdd0c88592181cb61f5df..b9120c5ca39bcb1c84965fd0f07c05da970469ca 100644 |
| --- a/views/focus/accelerator_handler_touch.cc |
| +++ b/views/focus/accelerator_handler_touch.cc |
| @@ -15,6 +15,7 @@ |
| #include "views/accelerator.h" |
| #include "views/events/event.h" |
| #include "views/focus/focus_manager.h" |
| +#include "views/ime/input_method.h" |
| #include "views/touchui/touch_factory.h" |
| #include "views/widget/root_view.h" |
| #include "views/widget/widget_gtk.h" |
| @@ -23,7 +24,7 @@ namespace views { |
| namespace { |
| -RootView* FindRootViewForGdkWindow(GdkWindow* gdk_window) { |
| +Widget* FindWidgetForGdkWindow(GdkWindow* gdk_window) { |
| gpointer data = NULL; |
| gdk_window_get_user_data(gdk_window, &data); |
| GtkWidget* gtk_widget = reinterpret_cast<GtkWidget*>(data); |
| @@ -37,7 +38,7 @@ RootView* FindRootViewForGdkWindow(GdkWindow* gdk_window) { |
| DLOG(WARNING) << "no WidgetGtk found for that GtkWidget"; |
| return NULL; |
| } |
| - return widget->GetWidget()->GetRootView(); |
| + return widget->GetWidget(); |
| } |
| #if defined(HAVE_XINPUT2) |
| @@ -163,12 +164,23 @@ bool DispatchXEvent(XEvent* xev) { |
| GdkWindow* gwind = gdk_window_lookup_for_display(gdisp, xwindow); |
| - if (RootView* root = FindRootViewForGdkWindow(gwind)) { |
| + if (Widget* widget = FindWidgetForGdkWindow(gwind)) { |
|
Ben Goodger (Google)
2011/03/22 20:49:30
Can you pull this out to the line above...
Widget
James Su
2011/03/22 22:35:39
Done.
|
| + RootView* root = widget->GetRootView(); |
| switch (xev->type) { |
| case KeyPress: |
| case KeyRelease: { |
| Event::FromNativeEvent2 from_native; |
| KeyEvent keyev(xev, from_native); |
| + InputMethod* ime = widget->GetInputMethod(); |
| + // Only dispatch the key event to the input method if the focused view |
| + // supports text input, then we can safely return true to prevent the |
| + // event from being dispatched to Gtk native widgets. |
| + // TODO(suzhe): remove it after getting rid of Gtk. |
| + if (ime && |
| + widget->GetFocusManager()->GetFocusedView()->GetTextInputClient()) { |
| + ime->DispatchKeyEvent(keyev); |
| + return true; |
| + } |
| return root->ProcessKeyEvent(keyev); |
| } |