diff options
author | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-13 12:59:30 +0000 |
---|---|---|
committer | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-13 12:59:30 +0000 |
commit | 5f7206f0f73bacec608a4a99b6506868e84015a3 (patch) | |
tree | 3daf336c6e1932e6f8b86999cac6855b5a329c34 | |
parent | abccbb1e57a21250d0d49d13f08ef831ea90fa88 (diff) | |
download | chromium_src-5f7206f0f73bacec608a4a99b6506868e84015a3.zip chromium_src-5f7206f0f73bacec608a4a99b6506868e84015a3.tar.gz chromium_src-5f7206f0f73bacec608a4a99b6506868e84015a3.tar.bz2 |
Call into the IM hooks from the Linux Omnibox keyboard handling.
This should give input methods the proper chance to handle enter and escape.
Review URL: http://codereview.chromium.org/43149
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11627 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc index a22914b..a47eb25 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc @@ -331,27 +331,41 @@ gboolean AutocompleteEditViewGtk::HandleKeyPress(GtkWidget* widget, // handle enter. We can get at the im_context and do it ourselves if needed. if (event->keyval == GDK_Return || event->keyval == GDK_ISO_Enter || - event->keyval == GDK_KP_Enter) { - bool alt_held = (event->state & GDK_MOD1_MASK); - model_->AcceptInput(alt_held ? NEW_FOREGROUND_TAB : CURRENT_TAB, false); - return TRUE; // Don't propagate into GtkTextView. - } - if (event->keyval == GDK_Escape && event->state == 0) { - model_->OnEscapeKeyPressed(); + event->keyval == GDK_KP_Enter || + (event->keyval == GDK_Escape && event->state == 0)) { + // Handle IME. This is basically taken from GtkTextView and reworked a bit. + GtkTextIter iter; + GtkTextView* text_view = GTK_TEXT_VIEW(text_view_); + GtkTextMark* insert = gtk_text_buffer_get_insert(text_buffer_); + gtk_text_buffer_get_iter_at_mark(text_buffer_, &iter, insert); + gboolean can_insert = gtk_text_iter_can_insert(&iter, text_view->editable); + if (gtk_im_context_filter_keypress(text_view->im_context, event)) { + // The IME handled it, do the follow up IME handling. + if (!can_insert) { + gtk_im_context_reset(text_view->im_context); + } else { + text_view->need_im_reset = TRUE; + } + } else { + // Ok, not handled by the IME, we can handle it. + if (event->keyval == GDK_Escape) { + model_->OnEscapeKeyPressed(); + } else { + bool alt_held = (event->state & GDK_MOD1_MASK); + model_->AcceptInput(alt_held ? NEW_FOREGROUND_TAB : CURRENT_TAB, false); + } + } return TRUE; // Don't propagate into GtkTextView. } + return FALSE; // Propagate into GtkTextView. } gboolean AutocompleteEditViewGtk::HandleKeyRelease(GtkWidget* widget, GdkEventKey* event) { - // We ate the press, might as well eat the release. - if (event->keyval == GDK_Return || - event->keyval == GDK_ISO_Enter || - event->keyval == GDK_KP_Enter || - (event->keyval == GDK_Escape && event->state == 0)) { - return TRUE; // Don't propagate into GtkTextView. - } + // Even though we handled the press ourselves, let GtkTextView handle the + // release. It shouldn't do anything particularly interesting, but it will + // handle the IME work for us. return FALSE; // Propagate into GtkTextView. } |