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

Side by Side Diff: views/ime/input_method_gtk.cc

Issue 7942004: Consolidate/cleanup event cracking code; single out GdkEvents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge removal of compact nav. Created 9 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/focus/accelerator_handler_touch.cc ('k') | views/ime/input_method_ibus.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "views/ime/input_method_gtk.h" 5 #include "views/ime/input_method_gtk.h"
6 6
7 #include <gdk/gdk.h> 7 #include <gdk/gdk.h>
8 #include <gdk/gdkkeysyms.h> 8 #include <gdk/gdkkeysyms.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 if (!GetTextInputClient()) { 120 if (!GetTextInputClient()) {
121 DispatchKeyEventPostIME(key); 121 DispatchKeyEventPostIME(key);
122 return; 122 return;
123 } 123 }
124 124
125 handling_key_event_ = true; 125 handling_key_event_ = true;
126 composition_changed_ = false; 126 composition_changed_ = false;
127 result_text_.clear(); 127 result_text_.clear();
128 128
129 // If it's a fake key event, then we need to synthesize a GdkEventKey. 129 // If it's a fake key event, then we need to synthesize a GdkEventKey.
130 GdkEvent* event = key.native_event() ? key.native_event() : 130 GdkEvent* event = key.gdk_event() ? key.gdk_event() :
131 SynthesizeGdkEventKey(key); 131 SynthesizeGdkEventKey(key);
132 gboolean filtered = gtk_im_context_filter_keypress( 132 gboolean filtered = gtk_im_context_filter_keypress(
133 context_focused_ ? context_ : context_simple_, &event->key); 133 context_focused_ ? context_ : context_simple_, &event->key);
134 134
135 handling_key_event_ = false; 135 handling_key_event_ = false;
136 136
137 const View* old_focused_view = focused_view(); 137 const View* old_focused_view = focused_view();
138 if (key.type() == ui::ET_KEY_PRESSED && filtered) 138 if (key.type() == ui::ET_KEY_PRESSED && filtered)
139 ProcessFilteredKeyPressEvent(key); 139 ProcessFilteredKeyPressEvent(key);
140 140
141 // Ensure no focus change from processing the key event. 141 // Ensure no focus change from processing the key event.
142 if (old_focused_view == focused_view()) { 142 if (old_focused_view == focused_view()) {
143 if (HasInputMethodResult()) 143 if (HasInputMethodResult())
144 ProcessInputMethodResult(key, filtered); 144 ProcessInputMethodResult(key, filtered);
145 // Ensure no focus change sending input method results to the focused View. 145 // Ensure no focus change sending input method results to the focused View.
146 if (old_focused_view == focused_view()) { 146 if (old_focused_view == focused_view()) {
147 if (key.type() == ui::ET_KEY_PRESSED && !filtered) 147 if (key.type() == ui::ET_KEY_PRESSED && !filtered)
148 ProcessUnfilteredKeyPressEvent(key); 148 ProcessUnfilteredKeyPressEvent(key);
149 else if (key.type() == ui::ET_KEY_RELEASED) 149 else if (key.type() == ui::ET_KEY_RELEASED)
150 DispatchKeyEventPostIME(key); 150 DispatchKeyEventPostIME(key);
151 } 151 }
152 } 152 }
153 153
154 // Free the synthesized event if there was no underlying native event. 154 // Free the synthesized event if there was no underlying native event.
155 if (event != key.native_event()) 155 if (event != key.gdk_event())
156 gdk_event_free(event); 156 gdk_event_free(event);
157 } 157 }
158 158
159 void InputMethodGtk::OnTextInputTypeChanged(View* view) { 159 void InputMethodGtk::OnTextInputTypeChanged(View* view) {
160 if (IsViewFocused(view)) { 160 if (IsViewFocused(view)) {
161 DCHECK(!composing_text_); 161 DCHECK(!composing_text_);
162 UpdateContextFocusState(); 162 UpdateContextFocusState();
163 } 163 }
164 InputMethodBase::OnTextInputTypeChanged(view); 164 InputMethodBase::OnTextInputTypeChanged(view);
165 } 165 }
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 gtk_im_context_set_client_window(context_simple_, widget->window); 441 gtk_im_context_set_client_window(context_simple_, widget->window);
442 } 442 }
443 } 443 }
444 444
445 void InputMethodGtk::OnWidgetUnrealize(GtkWidget* widget) { 445 void InputMethodGtk::OnWidgetUnrealize(GtkWidget* widget) {
446 gtk_im_context_set_client_window(context_, NULL); 446 gtk_im_context_set_client_window(context_, NULL);
447 gtk_im_context_set_client_window(context_simple_, NULL); 447 gtk_im_context_set_client_window(context_simple_, NULL);
448 } 448 }
449 449
450 } // namespace views 450 } // namespace views
OLDNEW
« no previous file with comments | « views/focus/accelerator_handler_touch.cc ('k') | views/ime/input_method_ibus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698