Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Unified Diff: views/focus/accelerator_handler_touch.cc

Issue 6675005: Integrate the new input method API for Views into Chromium. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..a358fedfa4dcf9b567a6ad64e5d29566be9e8fec 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)
@@ -162,13 +163,24 @@ bool DispatchXEvent(XEvent* xev) {
#endif
GdkWindow* gwind = gdk_window_lookup_for_display(gdisp, xwindow);
-
- if (RootView* root = FindRootViewForGdkWindow(gwind)) {
+ Widget* widget = FindWidgetForGdkWindow(gwind);
+ if (widget) {
+ 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.
+ View* focused_view = widget->GetFocusManager()->GetFocusedView();
+ if (ime && focused_view && focused_view->GetTextInputClient()) {
Peng 2011/03/24 03:58:43 If the focused_view->GetTextInputClient() is NULL,
Peng 2011/03/29 03:04:46 Did you fix this? On 2011/03/24 03:58:43, Peng wr
James Su 2011/03/29 05:00:20 Good point. I'll fix it asap.
Peng 2011/03/31 19:18:58 Did you fix this one?
James Su 2011/03/31 19:23:01 Yes, it's fixed already.
+ ime->DispatchKeyEvent(keyev);
+ return true;
+ }
return root->ProcessKeyEvent(keyev);
}

Powered by Google App Engine
This is Rietveld 408576698