1 #ifndef DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_X_H
2 #define DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_X_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-x.h>
25 #include <dali/public-api/object/base-object.h>
28 #include <dali/devel-api/adaptor-framework/input-method-context.h>
29 #include <dali/internal/input/common/input-method-context-impl.h>
42 class InputMethodContextX : public Dali::Internal::Adaptor::InputMethodContext, public Dali::ConnectionTracker
46 * @brief Creates a new InputMethodContext handle
48 * @param[in] actor The actor that uses the new InputMethodContext instance.
49 * @return InputMethodContext pointer
51 static InputMethodContextPtr New( Dali::Actor actor );
55 * @param[in] actor The actor that uses the new InputMethodContext instance.
57 explicit InputMethodContextX( Dali::Actor actor );
62 * @brief Initializes member data.
64 void Initialize() 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 and DeleteSurrounding.
71 void ConnectCallbacks() override;
74 * Disconnect Callbacks attached to input method context.
76 void DisconnectCallbacks() override;
79 * @copydoc Dali::InputMethodContext::Finalize()
81 void Finalize() override;
84 * @copydoc Dali::InputMethodContext::Activate()
86 void Activate() override;
89 * @copydoc Dali::InputMethodContext::Deactivate()
91 void Deactivate() override;
94 * @copydoc Dali::InputMethodContext::Reset()
96 void Reset() override;
99 * @copydoc Dali::InputMethodContext::GetContext()
101 ImfContext* GetContext() override;
104 * @copydoc Dali::InputMethodContext::RestoreAfterFocusLost()
106 bool RestoreAfterFocusLost() const override;
109 * @copydoc Dali::InputMethodContext::SetRestoreAfterFocusLost()
111 void SetRestoreAfterFocusLost( bool toggle ) override;
114 * @copydoc Dali::InputMethodContext::PreEditChanged()
116 void PreEditChanged( void* data, ImfContext* imfContext, void* eventInfo ) override;
119 * @copydoc Dali::InputMethodContext::NotifyCursorPosition()
121 void CommitReceived( void* data, ImfContext* imfContext, void* eventInfo ) override;
124 * @copydoc Dali::InputMethodContext::NotifyCursorPosition()
126 bool RetrieveSurrounding( void* data, ImfContext* imfContext, char** text, int* cursorPosition ) override;
129 * @copydoc Dali::InputMethodContext::DeleteSurrounding()
131 void DeleteSurrounding( void* data, ImfContext* imfContext, void* eventInfo ) override;
134 * @copydoc Dali::InputMethodContext::SendPrivateCommand()
136 void SendPrivateCommand( void* data, ImfContext* imfContext, void* eventInfo ) override
140 * @copydoc Dali::InputMethodContext::SendCommitContent()
142 void SendCommitContent( void* data, ImfContext* imfContext, void* eventInfo ) override
147 * @copydoc Dali::InputMethodContext::NotifyCursorPosition()
149 void NotifyCursorPosition() override;
152 * @copydoc Dali::InputMethodContext::SetCursorPosition()
154 void SetCursorPosition( unsigned int cursorPosition ) override;
157 * @copydoc Dali::InputMethodContext::GetCursorPosition()
159 unsigned int GetCursorPosition() const override;
162 * @copydoc Dali::InputMethodContext::SetSurroundingText()
164 void SetSurroundingText( const std::string& text ) override;
167 * @copydoc Dali::InputMethodContext::GetSurroundingText()
169 const std::string& GetSurroundingText() const override;
172 * @copydoc Dali::InputMethodContext::NotifyTextInputMultiLine()
174 void NotifyTextInputMultiLine( bool multiLine ) override;
177 * @copydoc Dali::InputMethodContext::GetTextDirection()
179 Dali::InputMethodContext::TextDirection GetTextDirection() override;
182 * @copydoc Dali::InputMethodContext::GetInputMethodArea()
184 Dali::Rect<int> GetInputMethodArea() override;
187 * @copydoc Dali::InputMethodContext::ApplyOptions()
189 void ApplyOptions( const InputMethodOptions& options ) override;
192 * @copydoc Dali::InputMethodContext::SetInputPanelData()
194 void SetInputPanelData( const std::string& data ) override;
197 * @copydoc Dali::InputMethodContext::GetInputPanelData()
199 void GetInputPanelData( std::string& data ) override;
202 * @copydoc Dali::InputMethodContext::GetInputPanelState()
204 Dali::InputMethodContext::State GetInputPanelState() override;
207 * @copydoc Dali::InputMethodContext::SetReturnKeyState()
209 void SetReturnKeyState( bool visible ) override;
212 * @copydoc Dali::InputMethodContext::AutoEnableInputPanel()
214 void AutoEnableInputPanel( bool enabled ) override;
217 * @copydoc Dali::InputMethodContext::ShowInputPanel()
219 void ShowInputPanel() override;
222 * @copydoc Dali::InputMethodContext::HideInputPanel()
224 void HideInputPanel() override;
227 * @copydoc Dali::InputMethodContext::GetKeyboardType()
229 Dali::InputMethodContext::KeyboardType GetKeyboardType() override;
232 * @copydoc Dali::InputMethodContext::GetInputPanelLocale()
234 std::string GetInputPanelLocale() override;
237 * @copydoc Dali::InputMethodContext::SetContentMIMETypes()
239 void SetContentMIMETypes( const std::string& mimeTypes ) override;
242 * @copydoc Dali::InputMethodContext::FilterEventKey()
244 bool FilterEventKey( const Dali::KeyEvent& keyEvent ) override;
247 * @copydoc Dali::InputMethodContext::AllowTextPrediction()
249 void AllowTextPrediction( bool prediction ) override;
252 * @copydoc Dali::InputMethodContext::IsTextPredictionAllowed()
254 bool IsTextPredictionAllowed() const override;
257 * @copydoc Dali::InputMethodContext::SetInputPanelLanguage()
259 void SetInputPanelLanguage( Dali::InputMethodContext::InputPanelLanguage language ) override;
262 * @copydoc Dali::InputMethodContext::GetInputPanelLanguage()
264 Dali::InputMethodContext::InputPanelLanguage GetInputPanelLanguage() const override;
267 * @copydoc Dali::InputMethodContext::SetInputPanelPosition()
269 void SetInputPanelPosition( unsigned int x, unsigned int y ) override;
273 * Context created the first time and kept until deleted.
275 void CreateContext();
278 * @copydoc Dali::InputMethodContext::DeleteContext()
280 void DeleteContext();
285 * @brief Process event key down, whether filter a key to isf.
287 * @param[in] keyEvent The event key to be handled.
288 * @return Whether the event key is handled.
290 bool ProcessEventKeyDown( const KeyEvent& keyEvent );
293 * @brief Process event key up, whether filter a key to isf.
295 * @param[in] keyEvent The event key to be handled.
296 * @return Whether the event key is handled.
298 bool ProcessEventKeyUp( const KeyEvent& keyEvent );
301 * Ecore_Event_Modifier enums in Ecore_Input.h do not match Ecore_IMF_Keyboard_Modifiers in Ecore_IMF.h.
302 * This function converts from Ecore_Event_Modifier to Ecore_IMF_Keyboard_Modifiers enums.
303 * @param[in] ecoreModifier the Ecore_Event_Modifier input.
304 * @return the Ecore_IMF_Keyboard_Modifiers output.
306 Ecore_IMF_Keyboard_Modifiers EcoreInputModifierToEcoreIMFModifier( unsigned int ecoreModifier );
309 * EcoreInputModifierToEcoreIMFLock function converts from Ecore_Event_Modifier to Ecore_IMF_Keyboard_Locks enums.
310 * @param[in] modifier the Ecore_Event_Modifier input.
311 * @return the Ecore_IMF_Keyboard_Locks output.
313 Ecore_IMF_Keyboard_Locks EcoreInputModifierToEcoreIMFLock( unsigned int modifier );
316 * Called when the binded actor is added to a window.
318 void OnStaged( Dali::Actor actor );
325 virtual ~InputMethodContextX();
329 // Undefined copy constructor
330 InputMethodContextX( const InputMethodContextX& inputMethodContext) = delete;
332 // Undefined assignment operator
333 InputMethodContextX& operator=( const InputMethodContextX& inputMethodContext ) = delete;
336 Ecore_IMF_Context* mIMFContext;
337 Ecore_X_Window mEcoreXwin;
338 int mIMFCursorPosition;
339 std::string mSurroundingText;
341 bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
342 bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
343 InputMethodOptions mOptions;
346 } // namespace Adaptor
348 } // namespace Internal
352 #endif // DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_X_H