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 *eventInfo ) override;
114 * @copydoc Dali::InputMethodContext::NotifyCursorPosition()
116 void CommitReceived( void *data, ImfContext *imfContext, void *eventInfo ) 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 *eventInfo ) override;
129 * @copydoc Dali::InputMethodContext::SendPrivateCommand()
131 void SendPrivateCommand( void* data, ImfContext* imfContext, void* eventInfo ) override;
134 * @copydoc Dali::InputMethodContext::SendCommitContent()
136 void SendCommitContent( void* data, ImfContext* imfContext, void* eventInfo ) override;
140 * @copydoc Dali::InputMethodContext::NotifyCursorPosition()
142 void NotifyCursorPosition() override;
145 * @copydoc Dali::InputMethodContext::SetCursorPosition()
147 void SetCursorPosition( unsigned int cursorPosition ) override;
150 * @copydoc Dali::InputMethodContext::GetCursorPosition()
152 unsigned int GetCursorPosition() const override;
155 * @copydoc Dali::InputMethodContext::SetSurroundingText()
157 void SetSurroundingText( const std::string& text ) override;
160 * @copydoc Dali::InputMethodContext::GetSurroundingText()
162 const std::string& GetSurroundingText() const override;
165 * @copydoc Dali::InputMethodContext::NotifyTextInputMultiLine()
167 void NotifyTextInputMultiLine( bool multiLine ) override;
170 * @copydoc Dali::InputMethodContext::GetTextDirection()
172 Dali::InputMethodContext::TextDirection GetTextDirection() override;
175 * @copydoc Dali::InputMethodContext::GetInputMethodArea()
177 Dali::Rect<int> GetInputMethodArea() override;
180 * @copydoc Dali::InputMethodContext::ApplyOptions()
182 void ApplyOptions( const InputMethodOptions& options ) override;
185 * @copydoc Dali::InputMethodContext::SetInputPanelData()
187 void SetInputPanelData( const std::string& data ) override;
190 * @copydoc Dali::InputMethodContext::GetInputPanelData()
192 void GetInputPanelData( std::string& data ) override;
195 * @copydoc Dali::InputMethodContext::GetInputPanelState()
197 Dali::InputMethodContext::State GetInputPanelState() override;
200 * @copydoc Dali::InputMethodContext::SetReturnKeyState()
202 void SetReturnKeyState( bool visible ) override;
205 * @copydoc Dali::InputMethodContext::AutoEnableInputPanel()
207 void AutoEnableInputPanel( bool enabled ) override;
210 * @copydoc Dali::InputMethodContext::ShowInputPanel()
212 void ShowInputPanel() override;
215 * @copydoc Dali::InputMethodContext::HideInputPanel()
217 void HideInputPanel() override;
220 * @copydoc Dali::InputMethodContext::GetKeyboardType()
222 Dali::InputMethodContext::KeyboardType GetKeyboardType() override;
225 * @copydoc Dali::InputMethodContext::GetInputPanelLocale()
227 std::string GetInputPanelLocale() override;
230 * @copydoc Dali::InputMethodContext::SetContentMIMETypes()
232 void SetContentMIMETypes( const std::string& mimeTypes ) override;
235 * @copydoc Dali::InputMethodContext::FilterEventKey()
237 bool FilterEventKey( const Dali::KeyEvent& keyEvent ) override;
240 * @copydoc Dali::InputMethodContext::AllowTextPrediction()
242 void AllowTextPrediction( bool prediction ) override;
245 * @copydoc Dali::InputMethodContext::IsTextPredictionAllowed()
247 bool IsTextPredictionAllowed() const override;
250 * @copydoc Dali::InputMethodContext::SetInputPanelLanguage()
252 void SetInputPanelLanguage( Dali::InputMethodContext::InputPanelLanguage language ) override;
255 * @copydoc Dali::InputMethodContext::GetInputPanelLanguage()
257 Dali::InputMethodContext::InputPanelLanguage GetInputPanelLanguage() const override;
261 * Context created the first time and kept until deleted.
263 void CreateContext();
266 * @copydoc Dali::InputMethodContext::DeleteContext()
268 void DeleteContext();
273 * @brief Process event key down, whether filter a key to isf.
275 * @param[in] keyEvent The event key to be handled.
276 * @return Whether the event key is handled.
278 bool ProcessEventKeyDown( const KeyEvent& keyEvent );
281 * @brief Process event key up, whether filter a key to isf.
283 * @param[in] keyEvent The event key to be handled.
284 * @return Whether the event key is handled.
286 bool ProcessEventKeyUp( const KeyEvent& keyEvent );
289 * Ecore_Event_Modifier enums in Ecore_Input.h do not match Ecore_IMF_Keyboard_Modifiers in Ecore_IMF.h.
290 * This function converts from Ecore_Event_Modifier to Ecore_IMF_Keyboard_Modifiers enums.
291 * @param[in] ecoreModifier the Ecore_Event_Modifier input.
292 * @return the Ecore_IMF_Keyboard_Modifiers output.
294 Ecore_IMF_Keyboard_Modifiers EcoreInputModifierToEcoreIMFModifier( unsigned int ecoreModifier );
297 * EcoreInputModifierToEcoreIMFLock function converts from Ecore_Event_Modifier to Ecore_IMF_Keyboard_Locks enums.
298 * @param[in] modifier the Ecore_Event_Modifier input.
299 * @return the Ecore_IMF_Keyboard_Locks output.
301 Ecore_IMF_Keyboard_Locks EcoreInputModifierToEcoreIMFLock( unsigned int modifier );
305 * @brief Constructor.
307 explicit InputMethodContextEcoreWl();
313 virtual ~InputMethodContextEcoreWl() override;
316 // Undefined copy constructor
317 explicit InputMethodContextEcoreWl( const InputMethodContextEcoreWl& inputMethodContext) = delete;
319 // Undefined assignment operator
320 InputMethodContextEcoreWl& operator=( const InputMethodContextEcoreWl& inputMethodContext ) = delete;
323 Ecore_IMF_Context* mIMFContext;
324 int mIMFCursorPosition;
325 std::string mSurroundingText;
327 bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
328 bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
330 std::vector<Dali::Integration::KeyEvent> mKeyEvents; ///< Stores key events to be sent from idle call-back.
331 InputMethodOptions mOptions;
335 } // namespace Adaptor
337 } // namespace Internal
341 #endif // DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_ECORE_WL_H