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

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

Issue 6823055: Consolidate OnKeyEvent and InputMethod code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Refactor X2Event handling, nix Windows InputMethodDelegate, etc. Created 9 years, 8 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
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_ibus.h" 5 #include "views/ime/input_method_ibus.h"
6 6
7 #include <ibus.h> 7 #include <ibus.h>
8 8
9 #include <cstring> 9 #include <cstring>
10 #include <set> 10 #include <set>
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 G_CALLBACK(OnIBusConnectedThunk), this); 302 G_CALLBACK(OnIBusConnectedThunk), this);
303 g_signal_connect(bus, "disconnected", 303 g_signal_connect(bus, "disconnected",
304 G_CALLBACK(OnIBusDisconnectedThunk), this); 304 G_CALLBACK(OnIBusDisconnectedThunk), this);
305 305
306 // Creates the |context_| if the connection is already established. In such 306 // Creates the |context_| if the connection is already established. In such
307 // case, we will not get "connected" signal. 307 // case, we will not get "connected" signal.
308 if (ibus_bus_is_connected(bus)) 308 if (ibus_bus_is_connected(bus))
309 CreateContext(); 309 CreateContext();
310 } 310 }
311 311
312 void InputMethodIBus::DispatchKeyEvent(const KeyEvent& key) { 312 bool InputMethodIBus::OnKeyEvent(const KeyEvent& key) {
313 DCHECK(key.type() == ui::ET_KEY_PRESSED || key.type() == ui::ET_KEY_RELEASED); 313 DCHECK(key.type() == ui::ET_KEY_PRESSED || key.type() == ui::ET_KEY_RELEASED);
314 DCHECK(widget_focused()); 314 DCHECK(widget_focused());
315 315
316 // If |context_| is not usable and |fake_context_| is not created yet, then we 316 // If |context_| is not usable and |fake_context_| is not created yet, then we
317 // can only dispatch the key event as is. We also dispatch the key event 317 // can only dispatch the key event as is. We also dispatch the key event
318 // directly if the current text input type is ui::TEXT_INPUT_TYPE_PASSWORD, 318 // directly if the current text input type is ui::TEXT_INPUT_TYPE_PASSWORD,
319 // to bypass the input method. 319 // to bypass the input method.
320 // Note: We need to send the key event to ibus even if the |context_| is not 320 // Note: We need to send the key event to ibus even if the |context_| is not
321 // enabled, so that ibus can have a chance to enable the |context_|. 321 // enabled, so that ibus can have a chance to enable the |context_|.
322 if (!(context_focused_ || fake_context_) || 322 if (!(context_focused_ || fake_context_) ||
323 GetTextInputType() == ui::TEXT_INPUT_TYPE_PASSWORD) { 323 GetTextInputType() == ui::TEXT_INPUT_TYPE_PASSWORD) {
324 if (key.type() == ui::ET_KEY_PRESSED) 324 if (key.type() == ui::ET_KEY_PRESSED) {
325 ProcessUnfilteredKeyPressEvent(key); 325 ProcessUnfilteredKeyPressEvent(key);
326 else 326 return true;
327 DispatchKeyEventPostIME(key); 327 }
328 return; 328 return false;
329 } 329 }
330 330
331 guint32 ibus_keyval = 0; 331 guint32 ibus_keyval = 0;
332 guint32 ibus_keycode = 0; 332 guint32 ibus_keycode = 0;
333 guint32 ibus_state = 0; 333 guint32 ibus_state = 0;
334 PendingKeyEvent* pending_key = 334 PendingKeyEvent* pending_key =
335 NewPendingKeyEvent(key, &ibus_keyval, &ibus_keycode, &ibus_state); 335 NewPendingKeyEvent(key, &ibus_keyval, &ibus_keycode, &ibus_state);
336 336
337 // Note: 337 // Note:
338 // 1. We currently set timeout to -1, because ibus doesn't have a mechanism to 338 // 1. We currently set timeout to -1, because ibus doesn't have a mechanism to
(...skipping 14 matching lines...) Expand all
353 // fully utilize asynchronous communication without potential problem. 353 // fully utilize asynchronous communication without potential problem.
354 ibus_input_context_process_key_event_async( 354 ibus_input_context_process_key_event_async(
355 context_focused_ ? context_ : fake_context_, 355 context_focused_ ? context_ : fake_context_,
356 ibus_keyval, ibus_keycode, ibus_state, -1, NULL, 356 ibus_keyval, ibus_keycode, ibus_state, -1, NULL,
357 reinterpret_cast<GAsyncReadyCallback>(ProcessKeyEventDone), 357 reinterpret_cast<GAsyncReadyCallback>(ProcessKeyEventDone),
358 pending_key); 358 pending_key);
359 359
360 // We don't want to suppress the result generated by this key event, but it 360 // We don't want to suppress the result generated by this key event, but it
361 // may cause problem. See comment in ResetContext() method. 361 // may cause problem. See comment in ResetContext() method.
362 suppress_next_result_ = false; 362 suppress_next_result_ = false;
363
364 return true;
363 } 365 }
364 366
365 void InputMethodIBus::OnTextInputTypeChanged(View* view) { 367 void InputMethodIBus::OnTextInputTypeChanged(View* view) {
366 if (context_ && IsViewFocused(view)) { 368 if (context_ && IsViewFocused(view)) {
367 ResetContext(); 369 ResetContext();
368 UpdateContextFocusState(); 370 UpdateContextFocusState();
369 } 371 }
370 } 372 }
371 373
372 void InputMethodIBus::OnCaretBoundsChanged(View* view) { 374 void InputMethodIBus::OnCaretBoundsChanged(View* view) {
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 DCHECK_EQ(GetIBus(), bus); 991 DCHECK_EQ(GetIBus(), bus);
990 DCHECK(data); 992 DCHECK(data);
991 IBusInputContext* ic = 993 IBusInputContext* ic =
992 ibus_bus_create_input_context_async_finish(bus, res, NULL); 994 ibus_bus_create_input_context_async_finish(bus, res, NULL);
993 if (ic) 995 if (ic)
994 data->StoreOrAbandonInputContext(ic); 996 data->StoreOrAbandonInputContext(ic);
995 delete data; 997 delete data;
996 } 998 }
997 999
998 } // namespace views 1000 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698