@@ -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
86104namespace flutter {
@@ -125,26 +143,25 @@ TizenInputMethodContext::~TizenInputMethodContext() {
125143}
126144
127145bool 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
150167InputPanelGeometry TizenInputMethodContext::GetInputPanelGeometry () {
@@ -175,7 +192,7 @@ void TizenInputMethodContext::HideInputPanel() {
175192void 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
0 commit comments