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;
268 * Context created the first time and kept until deleted.
270 void CreateContext();
273 * @copydoc Dali::InputMethodContext::DeleteContext()
275 void DeleteContext();
280 * @brief Process event key down, whether filter a key to isf.
282 * @param[in] keyEvent The event key to be handled.
283 * @return Whether the event key is handled.
285 bool ProcessEventKeyDown( const KeyEvent& keyEvent );
288 * @brief Process event key up, whether filter a key to isf.
290 * @param[in] keyEvent The event key to be handled.
291 * @return Whether the event key is handled.
293 bool ProcessEventKeyUp( const KeyEvent& keyEvent );
296 * Ecore_Event_Modifier enums in Ecore_Input.h do not match Ecore_IMF_Keyboard_Modifiers in Ecore_IMF.h.
297 * This function converts from Ecore_Event_Modifier to Ecore_IMF_Keyboard_Modifiers enums.
298 * @param[in] ecoreModifier the Ecore_Event_Modifier input.
299 * @return the Ecore_IMF_Keyboard_Modifiers output.
301 Ecore_IMF_Keyboard_Modifiers EcoreInputModifierToEcoreIMFModifier( unsigned int ecoreModifier );
304 * EcoreInputModifierToEcoreIMFLock function converts from Ecore_Event_Modifier to Ecore_IMF_Keyboard_Locks enums.
305 * @param[in] modifier the Ecore_Event_Modifier input.
306 * @return the Ecore_IMF_Keyboard_Locks output.
308 Ecore_IMF_Keyboard_Locks EcoreInputModifierToEcoreIMFLock( unsigned int modifier );
311 * Called when the binded actor is added to a window.
313 void OnStaged( Dali::Actor actor );
320 virtual ~InputMethodContextX();
324 // Undefined copy constructor
325 InputMethodContextX( const InputMethodContextX& inputMethodContext) = delete;
327 // Undefined assignment operator
328 InputMethodContextX& operator=( const InputMethodContextX& inputMethodContext ) = delete;
331 Ecore_IMF_Context* mIMFContext;
332 Ecore_X_Window mEcoreXwin;
333 int mIMFCursorPosition;
334 std::string mSurroundingText;
336 bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
337 bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
338 InputMethodOptions mOptions;
341 } // namespace Adaptor
343 } // namespace Internal
347 #endif // DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_X_H