Skip to content

Commit 789ddaf

Browse files
authored
Handle the key-up event in text_input_channel (#238)
* Long press event was recently added to the input panel of VD. So we have to handle the key-up event appropriately. Signed-off-by: Boram Bae <[email protected]>
1 parent cea8daa commit 789ddaf

File tree

4 files changed

+44
-26
lines changed

4 files changed

+44
-26
lines changed

shell/platform/tizen/channels/text_input_channel.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,11 @@ TextInputChannel::TextInputChannel(
124124
TextInputChannel::~TextInputChannel() {}
125125

126126
bool TextInputChannel::SendKeyEvent(Ecore_Event_Key* key, bool is_down) {
127-
if (!active_model_ || !is_down) {
127+
if (!active_model_) {
128128
return false;
129129
}
130130

131-
if (!FilterEvent(key)) {
131+
if (!FilterEvent(key, is_down) && is_down) {
132132
HandleUnfilteredEvent(key);
133133
}
134134

@@ -314,7 +314,7 @@ void TextInputChannel::SendStateUpdate(const TextInputModel& model) {
314314
channel_->InvokeMethod(kUpdateEditingStateMethod, std::move(args));
315315
}
316316

317-
bool TextInputChannel::FilterEvent(Ecore_Event_Key* event) {
317+
bool TextInputChannel::FilterEvent(Ecore_Event_Key* event, bool is_down) {
318318
bool handled = false;
319319

320320
#if defined(__X64_SHELL__)
@@ -339,7 +339,8 @@ bool TextInputChannel::FilterEvent(Ecore_Event_Key* event) {
339339
return false;
340340
}
341341

342-
handled = input_method_context_->FilterEvent(event, is_ime ? "ime" : "");
342+
handled =
343+
input_method_context_->FilterEvent(event, is_ime ? "ime" : "", is_down);
343344

344345
#ifdef WEARABLE_PROFILE
345346
if (!handled && !strcmp(event->key, "Return") &&

shell/platform/tizen/channels/text_input_channel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class TextInputChannel {
4343
const MethodCall<rapidjson::Document>& method_call,
4444
std::unique_ptr<MethodResult<rapidjson::Document>> result);
4545
void SendStateUpdate(const TextInputModel& model);
46-
bool FilterEvent(Ecore_Event_Key* event);
46+
bool FilterEvent(Ecore_Event_Key* event, bool is_down);
4747
void HandleUnfilteredEvent(Ecore_Event_Key* event);
4848
void EnterPressed(TextInputModel* model, bool select);
4949
void ResetTextEditingContext() {

shell/platform/tizen/tizen_input_method_context.cc

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const char* GetEcoreImfContextAvailableId() {
2020
return nullptr;
2121
}
2222

23-
Ecore_IMF_Input_Panel_Layout TextInputTypeToEcoreIMFInputPanelLayout(
23+
Ecore_IMF_Input_Panel_Layout TextInputTypeToEcoreImfInputPanelLayout(
2424
const std::string& text_input_type) {
2525
if (text_input_type == "TextInputType.text" ||
2626
text_input_type == "TextInputType.multiline") {
@@ -44,7 +44,7 @@ Ecore_IMF_Input_Panel_Layout TextInputTypeToEcoreIMFInputPanelLayout(
4444
}
4545
}
4646

47-
Ecore_IMF_Keyboard_Modifiers EcoreInputModifiersToEcoreIMFModifiers(
47+
Ecore_IMF_Keyboard_Modifiers EcoreInputModifiersToEcoreImfModifiers(
4848
unsigned int ecore_modifiers) {
4949
unsigned int modifiers(ECORE_IMF_KEYBOARD_MODIFIER_NONE);
5050
if (ecore_modifiers & ECORE_EVENT_MODIFIER_SHIFT) {
@@ -65,7 +65,7 @@ Ecore_IMF_Keyboard_Modifiers EcoreInputModifiersToEcoreIMFModifiers(
6565
return static_cast<Ecore_IMF_Keyboard_Modifiers>(modifiers);
6666
}
6767

68-
Ecore_IMF_Keyboard_Locks EcoreInputModifiersToEcoreIMFLocks(
68+
Ecore_IMF_Keyboard_Locks EcoreInputModifiersToEcoreImfLocks(
6969
unsigned int modifiers) {
7070
// If no other matches, returns NONE.
7171
unsigned int locks(ECORE_IMF_KEYBOARD_LOCK_NONE);
@@ -81,6 +81,24 @@ Ecore_IMF_Keyboard_Locks EcoreInputModifiersToEcoreIMFLocks(
8181
return static_cast<Ecore_IMF_Keyboard_Locks>(locks);
8282
}
8383

84+
template <typename T>
85+
T EcoreEventKeyToEcoreImfEvent(Ecore_Event_Key* event, const char* dev_name) {
86+
T imf_event;
87+
88+
imf_event.keyname = event->keyname;
89+
imf_event.key = event->key;
90+
imf_event.string = event->string;
91+
imf_event.compose = event->compose;
92+
imf_event.timestamp = event->timestamp;
93+
imf_event.modifiers =
94+
EcoreInputModifiersToEcoreImfModifiers(event->modifiers);
95+
imf_event.locks = EcoreInputModifiersToEcoreImfLocks(event->modifiers);
96+
imf_event.dev_name = dev_name;
97+
imf_event.keycode = event->keycode;
98+
99+
return imf_event;
100+
}
101+
84102
} // namespace
85103

86104
namespace flutter {
@@ -125,26 +143,25 @@ TizenInputMethodContext::~TizenInputMethodContext() {
125143
}
126144

127145
bool TizenInputMethodContext::FilterEvent(Ecore_Event_Key* event,
128-
const char* dev_name) {
146+
const char* dev_name,
147+
bool is_down) {
129148
FT_ASSERT(imf_context_);
130149
FT_ASSERT(event);
131150
FT_ASSERT(dev_name);
132-
Ecore_IMF_Event_Key_Down imf_event;
133151

134-
imf_event.keyname = event->keyname;
135-
imf_event.key = event->key;
136-
imf_event.string = event->string;
137-
imf_event.compose = event->compose;
138-
imf_event.timestamp = event->timestamp;
139-
imf_event.modifiers =
140-
EcoreInputModifiersToEcoreIMFModifiers(event->modifiers);
141-
imf_event.locks = EcoreInputModifiersToEcoreIMFLocks(event->modifiers);
142-
imf_event.dev_name = dev_name;
143-
imf_event.keycode = event->keycode;
144-
145-
return ecore_imf_context_filter_event(
146-
imf_context_, ECORE_IMF_EVENT_KEY_DOWN,
147-
reinterpret_cast<Ecore_IMF_Event*>(&imf_event));
152+
if (is_down) {
153+
auto imf_event =
154+
EcoreEventKeyToEcoreImfEvent<Ecore_IMF_Event_Key_Down>(event, dev_name);
155+
return ecore_imf_context_filter_event(
156+
imf_context_, ECORE_IMF_EVENT_KEY_DOWN,
157+
reinterpret_cast<Ecore_IMF_Event*>(&imf_event));
158+
} else {
159+
auto imf_event =
160+
EcoreEventKeyToEcoreImfEvent<Ecore_IMF_Event_Key_Up>(event, dev_name);
161+
return ecore_imf_context_filter_event(
162+
imf_context_, ECORE_IMF_EVENT_KEY_UP,
163+
reinterpret_cast<Ecore_IMF_Event*>(&imf_event));
164+
}
148165
}
149166

150167
InputPanelGeometry TizenInputMethodContext::GetInputPanelGeometry() {
@@ -175,7 +192,7 @@ void TizenInputMethodContext::HideInputPanel() {
175192
void TizenInputMethodContext::SetInputPanelLayout(
176193
const std::string& input_type) {
177194
FT_ASSERT(imf_context_);
178-
auto panel_layout = TextInputTypeToEcoreIMFInputPanelLayout(input_type);
195+
auto panel_layout = TextInputTypeToEcoreImfInputPanelLayout(input_type);
179196
ecore_imf_context_input_panel_layout_set(imf_context_, panel_layout);
180197
}
181198

shell/platform/tizen/tizen_input_method_context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class TizenInputMethodContext {
3232
TizenInputMethodContext(FlutterTizenEngine* engine);
3333
~TizenInputMethodContext();
3434

35-
bool FilterEvent(Ecore_Event_Key* event, const char* dev_name);
35+
bool FilterEvent(Ecore_Event_Key* event, const char* dev_name, bool is_down);
3636

3737
InputPanelGeometry GetInputPanelGeometry();
3838

0 commit comments

Comments
 (0)