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

Side by Side Diff: ui/base/ime/input_method_auralinux.cc

Issue 224723008: [linux/aura] Supports IBus in async mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review comments. Created 6 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
« no previous file with comments | « ui/base/ime/input_method_auralinux.h ('k') | ui/base/ime/input_method_initializer.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ui/base/ime/input_method_auralinux.h" 5 #include "ui/base/ime/input_method_auralinux.h"
6 6
7 #include "base/environment.h" 7 #include "base/environment.h"
8 #include "ui/base/ime/linux/linux_input_method_context_factory.h" 8 #include "ui/base/ime/linux/linux_input_method_context_factory.h"
9 #include "ui/base/ime/text_input_client.h" 9 #include "ui/base/ime/text_input_client.h"
10 #include "ui/events/event.h" 10 #include "ui/events/event.h"
11 11
12 namespace ui { 12 namespace ui {
13 13
14 InputMethodAuraLinux::InputMethodAuraLinux( 14 InputMethodAuraLinux::InputMethodAuraLinux(
15 internal::InputMethodDelegate* delegate) { 15 internal::InputMethodDelegate* delegate) {
16 SetDelegate(delegate); 16 SetDelegate(delegate);
17 } 17 }
18 18
19 InputMethodAuraLinux::~InputMethodAuraLinux() {} 19 InputMethodAuraLinux::~InputMethodAuraLinux() {}
20 20
21 // static
22 void InputMethodAuraLinux::Initialize() {
23 #if (USE_X11)
24 // Force a IBus IM context to run in synchronous mode.
25 //
26 // Background: IBus IM context runs by default in asynchronous mode. In
27 // this mode, gtk_im_context_filter_keypress() consumes all the key events
28 // and returns true while asynchronously sending the event to an underlying
29 // IME implementation. When the event has not actually been consumed by
30 // the underlying IME implementation, the context pushes the event back to
31 // the GDK event queue marking the event as already handled by the IBus IM
32 // context.
33 //
34 // The problem here is that those pushed-back GDK events are never handled
35 // when base::MessagePumpX11 is used, which only handles X events. So, we
36 // make a IBus IM context run in synchronous mode by setting an environment
37 // variable. This is only the interface to change the mode.
38 //
39 // Another possible solution is to use GDK event loop instead of X event
40 // loop.
41 //
42 // Since there is no reentrant version of setenv(3C), it's a caller's duty
43 // to avoid race conditions. This function should be called in the main
44 // thread on a very early stage, and supposed to be called from
45 // ui::InitializeInputMethod().
46 scoped_ptr<base::Environment> env(base::Environment::Create());
47 env->SetVar("IBUS_ENABLE_SYNC_MODE", "1");
48 #endif
49 }
50
51 // Overriden from InputMethod. 21 // Overriden from InputMethod.
52 22
53 void InputMethodAuraLinux::Init(bool focused) { 23 void InputMethodAuraLinux::Init(bool focused) {
54 CHECK(LinuxInputMethodContextFactory::instance()) 24 CHECK(LinuxInputMethodContextFactory::instance())
55 << "This failure was likely caused because " 25 << "This failure was likely caused because "
56 << "ui::InitializeInputMethod(ForTesting) was not called " 26 << "ui::InitializeInputMethod(ForTesting) was not called "
57 << "before instantiating this class."; 27 << "before instantiating this class.";
58 input_method_context_ = 28 input_method_context_ =
59 LinuxInputMethodContextFactory::instance()->CreateInputMethodContext( 29 LinuxInputMethodContextFactory::instance()->CreateInputMethodContext(
60 this); 30 this);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 TextInputClient* focused_before, 146 TextInputClient* focused_before,
177 TextInputClient* focused) { 147 TextInputClient* focused) {
178 input_method_context_->Reset(); 148 input_method_context_->Reset();
179 input_method_context_->OnTextInputTypeChanged( 149 input_method_context_->OnTextInputTypeChanged(
180 focused ? focused->GetTextInputType() : TEXT_INPUT_TYPE_NONE); 150 focused ? focused->GetTextInputType() : TEXT_INPUT_TYPE_NONE);
181 151
182 InputMethodBase::OnDidChangeFocusedClient(focused_before, focused); 152 InputMethodBase::OnDidChangeFocusedClient(focused_before, focused);
183 } 153 }
184 154
185 } // namespace ui 155 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/ime/input_method_auralinux.h ('k') | ui/base/ime/input_method_initializer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698