Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ui / base / ime / input_method_auralinux.h
blob245055e309c39107e89626039fdedc59a8d00e62
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
3 // found in the LICENSE file.
5 #ifndef UI_BASE_IME_INPUT_METHOD_AURALINUX_H_
6 #define UI_BASE_IME_INPUT_METHOD_AURALINUX_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "ui/base/ime/input_method_base.h"
10 #include "ui/base/ime/linux/linux_input_method_context.h"
12 namespace ui {
14 // A ui::InputMethod implementation for Aura on Linux platforms. The
15 // implementation details are separated to ui::LinuxInputMethodContext
16 // interface.
17 class UI_BASE_EXPORT InputMethodAuraLinux
18 : public InputMethodBase,
19 public LinuxInputMethodContextDelegate {
20 public:
21 explicit InputMethodAuraLinux(internal::InputMethodDelegate* delegate);
22 virtual ~InputMethodAuraLinux();
24 // Overriden from InputMethod.
25 virtual void Init(bool focused) OVERRIDE;
26 virtual bool OnUntranslatedIMEMessage(const base::NativeEvent& event,
27 NativeEventResult* result) OVERRIDE;
28 virtual bool DispatchKeyEvent(const ui::KeyEvent& event) OVERRIDE;
29 virtual void OnTextInputTypeChanged(const TextInputClient* client) OVERRIDE;
30 virtual void OnCaretBoundsChanged(const TextInputClient* client) OVERRIDE;
31 virtual void CancelComposition(const TextInputClient* client) OVERRIDE;
32 virtual void OnInputLocaleChanged() OVERRIDE;
33 virtual std::string GetInputLocale() OVERRIDE;
34 virtual bool IsActive() OVERRIDE;
35 virtual bool IsCandidatePopupOpen() const OVERRIDE;
37 // Overriden from ui::LinuxInputMethodContextDelegate
38 virtual void OnCommit(const base::string16& text) OVERRIDE;
39 virtual void OnPreeditChanged(const CompositionText& composition_text)
40 OVERRIDE;
41 virtual void OnPreeditEnd() OVERRIDE;
42 virtual void OnPreeditStart() OVERRIDE;
44 protected:
45 // Overridden from InputMethodBase.
46 virtual void OnDidChangeFocusedClient(TextInputClient* focused_before,
47 TextInputClient* focused) OVERRIDE;
49 private:
50 // Allows to fire a VKEY_PROCESSKEY key event.
51 void AllowToFireProcessKey(const ui::KeyEvent& event);
52 // Fires a VKEY_PROCESSKEY key event if allowed.
53 void MaybeFireProcessKey();
54 // Stops firing VKEY_PROCESSKEY key events.
55 void StopFiringProcessKey();
57 scoped_ptr<LinuxInputMethodContext> input_method_context_;
59 // IBus in async mode eagerly consumes all the key events first regardless of
60 // whether the underlying IME consumes the key event or not, and makes
61 // gtk_im_context_filter_keypress() always return true, and later pushes
62 // the key event back to the GDK event queue when it turns out that the
63 // underlying IME doesn't consume the key event.
65 // Thus we have to defer a decision whether or not to dispatch a
66 // VKEY_PROCESSKEY key event. Unlike other InputMethod's subclasses,
67 // DispatchKeyEvent() in this class does not directly dispatch a
68 // VKEY_PROCESSKEY event, OnCommit or OnPreedit{Start,Changed,End} dispatch
69 // a VKEY_PROCESSKEY event instead.
71 // Because of this hack, there could be chances that we accidentally dispatch
72 // VKEY_PROCESSKEY events and other key events in out of order.
74 // |allowed_to_fire_vkey_process_key_| is used not to dispatch a
75 // VKEY_PROCESSKEY event twice for a single key event.
76 bool allowed_to_fire_vkey_process_key_;
77 int vkey_processkey_flags_;
79 DISALLOW_COPY_AND_ASSIGN(InputMethodAuraLinux);
82 } // namespace ui
84 #endif // UI_BASE_IME_INPUT_METHOD_AURALINUX_H_