Skip to content

Commit f662810

Browse files
authored
Fix input panel bugs (#351)
* Resolve #346. * Corrects deleting character in text composition. * Now, filter makes the key focus move work properly, so no longer need to ignore specific key event handling. Signed-off-by: Boram Bae <[email protected]>
1 parent 6c8e921 commit f662810

File tree

2 files changed

+18
-47
lines changed

2 files changed

+18
-47
lines changed

shell/platform/tizen/tizen_input_method_context.cc

Lines changed: 18 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,32 @@ Ecore_IMF_Keyboard_Locks EcoreInputModifiersToEcoreImfLocks(
8383
}
8484

8585
template <typename T>
86-
T EcoreEventKeyToEcoreImfEvent(Ecore_Event_Key* event, const char* dev_name) {
86+
T EcoreEventKeyToEcoreImfEvent(Ecore_Event_Key* event) {
8787
T imf_event;
8888

8989
imf_event.keyname = event->keyname;
9090
imf_event.key = event->key;
9191
imf_event.string = event->string;
9292
imf_event.compose = event->compose;
9393
imf_event.timestamp = event->timestamp;
94+
imf_event.keycode = event->keycode;
95+
9496
imf_event.modifiers =
9597
EcoreInputModifiersToEcoreImfModifiers(event->modifiers);
9698
imf_event.locks = EcoreInputModifiersToEcoreImfLocks(event->modifiers);
97-
imf_event.dev_name = dev_name;
98-
imf_event.keycode = event->keycode;
99+
100+
if (event->dev) {
101+
const char* device_name = ecore_device_name_get(event->dev);
102+
imf_event.dev_name = device_name ? device_name : "";
103+
imf_event.dev_class =
104+
static_cast<Ecore_IMF_Device_Class>(ecore_device_class_get(event->dev));
105+
imf_event.dev_subclass = static_cast<Ecore_IMF_Device_Subclass>(
106+
ecore_device_subclass_get(event->dev));
107+
} else {
108+
imf_event.dev_name = "";
109+
imf_event.dev_class = ECORE_IMF_DEVICE_CLASS_NONE;
110+
imf_event.dev_subclass = ECORE_IMF_DEVICE_SUBCLASS_NONE;
111+
}
99112

100113
return imf_event;
101114
}
@@ -144,30 +157,15 @@ bool TizenInputMethodContext::HandleEcoreEventKey(Ecore_Event_Key* event,
144157
bool is_down) {
145158
FT_ASSERT(imf_context_);
146159
FT_ASSERT(event);
147-
#ifdef WEARABLE_PROFILE
148-
// Hardware keyboard is not supported on watch devices.
149-
const char* device_name = "ime";
150-
bool is_ime = true;
151-
#else
152-
const char* device_name = ecore_device_name_get(event->dev);
153-
bool is_ime = device_name ? strcmp(device_name, "ime") == 0 : true;
154-
#endif
155-
156-
if (ShouldIgnoreKey(event->key, is_ime)) {
157-
return false;
158-
}
159-
160160
if (is_down) {
161161
Ecore_IMF_Event_Key_Down imf_event =
162-
EcoreEventKeyToEcoreImfEvent<Ecore_IMF_Event_Key_Down>(event,
163-
device_name);
162+
EcoreEventKeyToEcoreImfEvent<Ecore_IMF_Event_Key_Down>(event);
164163
return ecore_imf_context_filter_event(
165164
imf_context_, ECORE_IMF_EVENT_KEY_DOWN,
166165
reinterpret_cast<Ecore_IMF_Event*>(&imf_event));
167166
} else {
168167
Ecore_IMF_Event_Key_Up imf_event =
169-
EcoreEventKeyToEcoreImfEvent<Ecore_IMF_Event_Key_Up>(event,
170-
device_name);
168+
EcoreEventKeyToEcoreImfEvent<Ecore_IMF_Event_Key_Up>(event);
171169
return ecore_imf_context_filter_event(
172170
imf_context_, ECORE_IMF_EVENT_KEY_UP,
173171
reinterpret_cast<Ecore_IMF_Event*>(&imf_event));
@@ -176,10 +174,6 @@ bool TizenInputMethodContext::HandleEcoreEventKey(Ecore_Event_Key* event,
176174

177175
bool TizenInputMethodContext::HandleEvasEventKeyDown(
178176
Evas_Event_Key_Down* event) {
179-
if (ShouldIgnoreKey(event->key, true)) {
180-
return false;
181-
}
182-
183177
Ecore_IMF_Event_Key_Down imf_event;
184178
ecore_imf_evas_event_key_down_wrap(event, &imf_event);
185179

@@ -189,10 +183,6 @@ bool TizenInputMethodContext::HandleEvasEventKeyDown(
189183
}
190184

191185
bool TizenInputMethodContext::HandleEvasEventKeyUp(Evas_Event_Key_Up* event) {
192-
if (ShouldIgnoreKey(event->key, true)) {
193-
return false;
194-
}
195-
196186
Ecore_IMF_Event_Key_Up imf_event;
197187
ecore_imf_evas_event_key_up_wrap(event, &imf_event);
198188

@@ -363,21 +353,4 @@ void TizenInputMethodContext::SetInputPanelOptions() {
363353
imf_context_, ECORE_IMF_INPUT_PANEL_LANG_AUTOMATIC);
364354
}
365355

366-
bool TizenInputMethodContext::ShouldIgnoreKey(std::string key, bool is_ime) {
367-
// The below keys should be handled by the flutter framework.
368-
if (is_ime && (key == "Left" || key == "Right" || key == "Up" ||
369-
key == "Down" || key == "End" || key == "Home" ||
370-
key == "BackSpace" || key == "Delete")) {
371-
return true;
372-
}
373-
#ifdef TV_PROFILE
374-
// The Select key should be handled in the TextInputChannel.
375-
if (is_ime && key == "Select") {
376-
return true;
377-
}
378-
#endif
379-
380-
return false;
381-
}
382-
383356
} // namespace flutter

shell/platform/tizen/tizen_input_method_context.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ class TizenInputMethodContext {
7070
void SetContextOptions();
7171
void SetInputPanelOptions();
7272

73-
bool ShouldIgnoreKey(std::string key, bool is_ime);
74-
7573
Ecore_IMF_Context* imf_context_ = nullptr;
7674
OnCommit on_commit_;
7775
OnPreeditChanged on_preedit_changed_;

0 commit comments

Comments
 (0)