1 #ifndef DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_ECORE_WL_H
2 #define DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_ECORE_WL_H
5 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/internal/input/linux/dali-ecore-imf.h>
23 #include <dali/internal/system/linux/dali-ecore.h>
25 #include <dali/public-api/common/vector-wrapper.h>
26 #include <dali/public-api/object/base-object.h>
27 #include <dali/integration-api/events/key-event-integ.h>
30 #include <dali/internal/input/common/input-method-context-impl.h>
43 class InputMethodContextEcoreWl : public Dali::Internal::Adaptor::InputMethodContext
48 * @brief Creates a new InputMethodContext handle
50 * @return InputMethodContext pointer
52 static InputMethodContextPtr New();
55 * @brief Initializes member data.
57 void Initialize() override;
62 * @copydoc Dali::InputMethodContext::Finalize()
64 void Finalize() override;
67 * Connect Callbacks required for InputMethodContext.
68 * If you don't connect InputMethodContext callbacks, you can't get the key events.
69 * The events are PreeditChanged, Commit, DeleteSurrounding and PrivateCommand.
71 void ConnectCallbacks() override;
74 * Disconnect Callbacks attached to input method context.
76 void DisconnectCallbacks() override;
79 * @copydoc Dali::InputMethodContext::Activate()
81 void Activate() override;
84 * @copydoc Dali::InputMethodContext::Deactivate()
86 void Deactivate() override;
89 * @copydoc Dali::InputMethodContext::Reset()
91 void Reset() override;
94 * @copydoc Dali::InputMethodContext::GetContext()
96 ImfContext* GetContext() override;
99 * @copydoc Dali::InputMethodContext::RestoreAfterFocusLost()
101 bool RestoreAfterFocusLost() const override;
104 * @copydoc Dali::InputMethodContext::SetRestoreAfterFocusLost()
106 void SetRestoreAfterFocusLost( bool toggle ) override;
109 * @copydoc Dali::InputMethodContext::PreEditChanged()
111 void PreEditChanged( void *data, ImfContext *imfContext, void *event_info ) override;
114 * @copydoc Dali::InputMethodContext::NotifyCursorPosition()
116 void CommitReceived( void *data, ImfContext *imfContext, void *event_info ) override;
119 * @copydoc Dali::InputMethodContext::NotifyCursorPosition()
121 bool RetrieveSurrounding( void *data, ImfContext *imfContext, char** text, int* cursorPosition ) override;
124 * @copydoc Dali::InputMethodContext::DeleteSurrounding()
126 void DeleteSurrounding( void *data, ImfContext *imfContext, void *event_info ) override;
129 * @copydoc Dali::InputMethodContext::SendPrivateCommand()
131 void SendPrivateCommand( void* data, ImfContext* imfContext, void* event_info ) override;
135 * @copydoc Dali::InputMethodContext::NotifyCursorPosition()
137 void NotifyCursorPosition() override;
140 * @copydoc Dali::InputMethodContext::SetCursorPosition()
142 void SetCursorPosition( unsigned int cursorPosition ) override;
145 * @copydoc Dali::InputMethodContext::GetCursorPosition()
147 unsigned int GetCursorPosition() const override;
150 * @copydoc Dali::InputMethodContext::SetSurroundingText()
152 void SetSurroundingText( const std::string& text ) override;
155 * @copydoc Dali::InputMethodContext::GetSurroundingText()
157 const std::string& GetSurroundingText() const override;
160 * @copydoc Dali::InputMethodContext::NotifyTextInputMultiLine()
162 void NotifyTextInputMultiLine( bool multiLine ) override;
165 * @copydoc Dali::InputMethodContext::GetTextDirection()
167 Dali::InputMethodContext::TextDirection GetTextDirection() override;
170 * @copydoc Dali::InputMethodContext::GetInputMethodArea()
172 Dali::Rect<int> GetInputMethodArea() override;
175 * @copydoc Dali::InputMethodContext::ApplyOptions()
177 void ApplyOptions( const InputMethodOptions& options ) override;
180 * @copydoc Dali::InputMethodContext::SetInputPanelData()
182 void SetInputPanelData( const std::string& data ) override;
185 * @copydoc Dali::InputMethodContext::GetInputPanelData()
187 void GetInputPanelData( std::string& data ) override;
190 * @copydoc Dali::InputMethodContext::GetInputPanelState()
192 Dali::InputMethodContext::State GetInputPanelState() override;
195 * @copydoc Dali::InputMethodContext::SetReturnKeyState()
197 void SetReturnKeyState( bool visible ) override;
200 * @copydoc Dali::InputMethodContext::AutoEnableInputPanel()
202 void AutoEnableInputPanel( bool enabled ) override;
205 * @copydoc Dali::InputMethodContext::ShowInputPanel()
207 void ShowInputPanel() override;
210 * @copydoc Dali::InputMethodContext::HideInputPanel()
212 void HideInputPanel() override;
215 * @copydoc Dali::InputMethodContext::GetKeyboardType()
217 Dali::InputMethodContext::KeyboardType GetKeyboardType() override;
220 * @copydoc Dali::InputMethodContext::GetInputPanelLocale()
222 std::string GetInputPanelLocale() override;
225 * @copydoc Dali::InputMethodContext::FilterEventKey()
227 bool FilterEventKey( const Dali::KeyEvent& keyEvent ) override;
230 * @copydoc Dali::InputMethodContext::AllowTextPrediction()
232 void AllowTextPrediction( bool prediction ) override;
235 * @copydoc Dali::InputMethodContext::IsTextPredictionAllowed()
237 bool IsTextPredictionAllowed() const override;
240 * Context created the first time and kept until deleted.
242 void CreateContext();
245 * @copydoc Dali::InputMethodContext::DeleteContext()
247 void DeleteContext();
252 * @brief Process event key down, whether filter a key to isf.
254 * @param[in] keyEvent The event key to be handled.
255 * @return Whether the event key is handled.
257 bool ProcessEventKeyDown( const KeyEvent& keyEvent );
260 * @brief Process event key up, whether filter a key to isf.
262 * @param[in] keyEvent The event key to be handled.
263 * @return Whether the event key is handled.
265 bool ProcessEventKeyUp( const KeyEvent& keyEvent );
268 * Ecore_Event_Modifier enums in Ecore_Input.h do not match Ecore_IMF_Keyboard_Modifiers in Ecore_IMF.h.
269 * This function converts from Ecore_Event_Modifier to Ecore_IMF_Keyboard_Modifiers enums.
270 * @param[in] ecoreModifier the Ecore_Event_Modifier input.
271 * @return the Ecore_IMF_Keyboard_Modifiers output.
273 Ecore_IMF_Keyboard_Modifiers EcoreInputModifierToEcoreIMFModifier( unsigned int ecoreModifier );
276 * EcoreInputModifierToEcoreIMFLock function converts from Ecore_Event_Modifier to Ecore_IMF_Keyboard_Locks enums.
277 * @param[in] modifier the Ecore_Event_Modifier input.
278 * @return the Ecore_IMF_Keyboard_Locks output.
280 Ecore_IMF_Keyboard_Locks EcoreInputModifierToEcoreIMFLock( unsigned int modifier );
284 * @brief Constructor.
286 explicit InputMethodContextEcoreWl();
292 virtual ~InputMethodContextEcoreWl() override;
295 // Undefined copy constructor
296 explicit InputMethodContextEcoreWl( const InputMethodContextEcoreWl& inputMethodContext) = delete;
298 // Undefined assignment operator
299 InputMethodContextEcoreWl& operator=( const InputMethodContextEcoreWl& inputMethodContext ) = delete;
302 Ecore_IMF_Context* mIMFContext;
303 int mIMFCursorPosition;
304 std::string mSurroundingText;
306 bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
307 bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
309 std::vector<Dali::Integration::KeyEvent> mKeyEvents; ///< Stores key events to be sent from idle call-back.
310 InputMethodOptions mOptions;
314 } // namespace Adaptor
316 } // namespace Internal
320 #endif // DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_ECORE_WL_H