OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ui/views/ime/input_method_wayland.h" | |
6 | |
7 #include "views/widget/widget.h" | |
8 | |
9 namespace views { | |
10 | |
11 InputMethodWayland::InputMethodWayland( | |
12 internal::InputMethodDelegate *delegate) { | |
13 set_delegate(delegate); | |
14 } | |
15 | |
16 void InputMethodWayland::DispatchKeyEvent(const KeyEvent& key) { | |
17 if (!GetTextInputClient()) { | |
18 DispatchKeyEventPostIME(key); | |
19 return; | |
20 } | |
21 | |
22 if (key.type() == ui::ET_KEY_PRESSED) { | |
23 ProcessKeyPressEvent(key); | |
24 } else if (key.type() == ui::ET_KEY_RELEASED) { | |
25 DispatchKeyEventPostIME(key); | |
26 } | |
27 } | |
28 | |
29 void InputMethodWayland::OnTextInputTypeChanged(View* view) { | |
30 NOTIMPLEMENTED(); | |
31 } | |
32 | |
33 void InputMethodWayland::OnCaretBoundsChanged(View* view) { | |
34 NOTIMPLEMENTED(); | |
35 } | |
36 | |
37 void InputMethodWayland::CancelComposition(View* view) { | |
38 NOTIMPLEMENTED(); | |
39 } | |
40 | |
41 std::string InputMethodWayland::GetInputLocale() { | |
42 return std::string(""); | |
43 } | |
44 | |
45 base::i18n::TextDirection InputMethodWayland::GetInputTextDirection() { | |
46 return base::i18n::UNKNOWN_DIRECTION; | |
47 } | |
48 | |
49 bool InputMethodWayland::IsActive() { | |
50 return true; | |
51 } | |
52 | |
53 ////////////////////////////////////////////////////////////////////////////// | |
54 // InputMethodWayland private | |
55 | |
56 void InputMethodWayland::ProcessKeyPressEvent(const KeyEvent& key) { | |
57 const View* old_focused_view = focused_view(); | |
58 DispatchKeyEventPostIME(key); | |
59 | |
60 // We shouldn't dispatch the character anymore if the key event caused focus | |
61 // change. | |
62 if (old_focused_view != focused_view()) | |
63 return; | |
64 | |
65 // If a key event was not filtered by |context_| or |context_simple_|, then | |
66 // it means the key event didn't generate any result text. For some cases, | |
67 // the key event may still generate a valid character, eg. a control-key | |
68 // event (ctrl-a, return, tab, etc.). We need to send the character to the | |
69 // focused text input client by calling TextInputClient::InsertChar(). | |
70 char16 ch = key.GetCharacter(); | |
71 ui::TextInputClient* client = GetTextInputClient(); | |
72 if (ch && client) | |
73 client->InsertChar(ch, key.flags()); | |
74 } | |
75 | |
76 } // namespace views | |
OLD | NEW |