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

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

Issue 1068093002: Refactoring for InputMethodAuraLinux. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed interactive_ui_tests failure. Created 5 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
« no previous file with comments | « ui/base/BUILD.gn ('k') | ui/base/ime/input_method_auralinux.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 #ifndef UI_BASE_IME_INPUT_METHOD_AURALINUX_H_ 5 #ifndef UI_BASE_IME_INPUT_METHOD_AURALINUX_H_
6 #define UI_BASE_IME_INPUT_METHOD_AURALINUX_H_ 6 #define UI_BASE_IME_INPUT_METHOD_AURALINUX_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "ui/base/ime/composition_text.h"
9 #include "ui/base/ime/input_method_base.h" 10 #include "ui/base/ime/input_method_base.h"
10 #include "ui/base/ime/linux/linux_input_method_context.h" 11 #include "ui/base/ime/linux/linux_input_method_context.h"
11 12
12 namespace ui { 13 namespace ui {
13 14
14 // A ui::InputMethod implementation for Aura on Linux platforms. The 15 // A ui::InputMethod implementation for Aura on Linux platforms. The
15 // implementation details are separated to ui::LinuxInputMethodContext 16 // implementation details are separated to ui::LinuxInputMethodContext
16 // interface. 17 // interface.
17 class UI_BASE_IME_EXPORT InputMethodAuraLinux 18 class UI_BASE_IME_EXPORT InputMethodAuraLinux
18 : public InputMethodBase, 19 : public InputMethodBase,
19 public LinuxInputMethodContextDelegate { 20 public LinuxInputMethodContextDelegate {
20 public: 21 public:
21 explicit InputMethodAuraLinux(internal::InputMethodDelegate* delegate); 22 explicit InputMethodAuraLinux(internal::InputMethodDelegate* delegate);
22 ~InputMethodAuraLinux() override; 23 ~InputMethodAuraLinux() override;
23 24
25 LinuxInputMethodContext* GetContextForTesting(bool is_simple);
26
24 // Overriden from InputMethod. 27 // Overriden from InputMethod.
25 void Init(bool focused) override; 28 void Init(bool focused) override;
26 bool OnUntranslatedIMEMessage(const base::NativeEvent& event, 29 bool OnUntranslatedIMEMessage(const base::NativeEvent& event,
27 NativeEventResult* result) override; 30 NativeEventResult* result) override;
28 bool DispatchKeyEvent(const ui::KeyEvent& event) override; 31 bool DispatchKeyEvent(const ui::KeyEvent& event) override;
29 void OnTextInputTypeChanged(const TextInputClient* client) override; 32 void OnTextInputTypeChanged(const TextInputClient* client) override;
30 void OnCaretBoundsChanged(const TextInputClient* client) override; 33 void OnCaretBoundsChanged(const TextInputClient* client) override;
31 void CancelComposition(const TextInputClient* client) override; 34 void CancelComposition(const TextInputClient* client) override;
32 void OnInputLocaleChanged() override; 35 void OnInputLocaleChanged() override;
33 std::string GetInputLocale() override; 36 std::string GetInputLocale() override;
34 bool IsActive() override; 37 bool IsActive() override;
35 bool IsCandidatePopupOpen() const override; 38 bool IsCandidatePopupOpen() const override;
39 void OnFocus() override;
40 void OnBlur() override;
36 41
37 // Overriden from ui::LinuxInputMethodContextDelegate 42 // Overriden from ui::LinuxInputMethodContextDelegate
38 void OnCommit(const base::string16& text) override; 43 void OnCommit(const base::string16& text) override;
39 void OnPreeditChanged(const CompositionText& composition_text) override; 44 void OnPreeditChanged(const CompositionText& composition_text) override;
40 void OnPreeditEnd() override; 45 void OnPreeditEnd() override;
41 void OnPreeditStart() override; 46 void OnPreeditStart() override{};
42 47
43 protected: 48 protected:
44 // Overridden from InputMethodBase. 49 // Overridden from InputMethodBase.
50 void OnWillChangeFocusedClient(TextInputClient* focused_before,
51 TextInputClient* focused) override;
45 void OnDidChangeFocusedClient(TextInputClient* focused_before, 52 void OnDidChangeFocusedClient(TextInputClient* focused_before,
46 TextInputClient* focused) override; 53 TextInputClient* focused) override;
47 54
48 private: 55 private:
49 // Allows to fire a VKEY_PROCESSKEY key event. 56 bool HasInputMethodResult();
50 void AllowToFireProcessKey(const ui::KeyEvent& event); 57 bool NeedInsertChar() const;
51 // Fires a VKEY_PROCESSKEY key event if allowed. 58 void SendFakeProcessKeyEvent(int flags) const;
52 void MaybeFireProcessKey(); 59 void ConfirmCompositionText();
53 // Stops firing VKEY_PROCESSKEY key events. 60 void UpdateContextFocusState();
54 void StopFiringProcessKey(); 61 void ResetContext();
55 62
56 scoped_ptr<LinuxInputMethodContext> input_method_context_; 63 scoped_ptr<LinuxInputMethodContext> context_;
64 scoped_ptr<LinuxInputMethodContext> context_simple_;
57 65
58 // IBus in async mode eagerly consumes all the key events first regardless of 66 base::string16 result_text_;
59 // whether the underlying IME consumes the key event or not, and makes 67
60 // gtk_im_context_filter_keypress() always return true, and later pushes 68 ui::CompositionText composition_;
61 // the key event back to the GDK event queue when it turns out that the 69
62 // underlying IME doesn't consume the key event. 70 // The current text input type used to indicates if |context_| and
63 // 71 // |context_simple_| are focused or not.
64 // Thus we have to defer a decision whether or not to dispatch a 72 TextInputType text_input_type_;
65 // VKEY_PROCESSKEY key event. Unlike other InputMethod's subclasses, 73
66 // DispatchKeyEvent() in this class does not directly dispatch a 74 // Indicates if currently in sync mode when handling a key event.
67 // VKEY_PROCESSKEY event, OnCommit or OnPreedit{Start,Changed,End} dispatch 75 // This is used in OnXXX callbacks from GTK IM module.
68 // a VKEY_PROCESSKEY event instead. 76 bool is_sync_mode_;
69 // 77
70 // Because of this hack, there could be chances that we accidentally dispatch 78 // Indicates if the composition text is changed or deleted.
71 // VKEY_PROCESSKEY events and other key events in out of order. 79 bool composition_changed_;
72 // 80
73 // |allowed_to_fire_vkey_process_key_| is used not to dispatch a 81 // If it's true then all input method result received before the next key
74 // VKEY_PROCESSKEY event twice for a single key event. 82 // event will be discarded.
75 bool allowed_to_fire_vkey_process_key_; 83 bool suppress_next_result_;
76 int vkey_processkey_flags_;
77 84
78 DISALLOW_COPY_AND_ASSIGN(InputMethodAuraLinux); 85 DISALLOW_COPY_AND_ASSIGN(InputMethodAuraLinux);
79 }; 86 };
80 87
81 } // namespace ui 88 } // namespace ui
82 89
83 #endif // UI_BASE_IME_INPUT_METHOD_AURALINUX_H_ 90 #endif // UI_BASE_IME_INPUT_METHOD_AURALINUX_H_
OLDNEW
« no previous file with comments | « ui/base/BUILD.gn ('k') | ui/base/ime/input_method_auralinux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698