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