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
46 * @brief Creates a new InputMethodContext handle
48 * @return InputMethodContext pointer
50 static InputMethodContextPtr New();
54 * @param[in] ecoreXwin, The window is created by application.
56 explicit InputMethodContextX( Ecore_X_Window ecoreXwin );
61 * @brief Initializes member data.
63 void Initialize() override;
66 * Connect Callbacks required for InputMethodContext.
67 * If you don't connect InputMethodContext callbacks, you can't get the key events.
68 * The events are PreeditChanged, Commit and DeleteSurrounding.
70 void ConnectCallbacks() override;
73 * Disconnect Callbacks attached to input method context.
75 void DisconnectCallbacks() override;
78 * @copydoc Dali::InputMethodContext::Finalize()
80 void Finalize() override;
83 * @copydoc Dali::InputMethodContext::Activate()
85 void Activate() override;
88 * @copydoc Dali::InputMethodContext::Deactivate()
90 void Deactivate() override;
93 * @copydoc Dali::InputMethodContext::Reset()
95 void Reset() override;
98 * @copydoc Dali::InputMethodContext::GetContext()
100 ImfContext* GetContext() override;
103 * @copydoc Dali::InputMethodContext::RestoreAfterFocusLost()
105 bool RestoreAfterFocusLost() const override;
108 * @copydoc Dali::InputMethodContext::SetRestoreAfterFocusLost()
110 void SetRestoreAfterFocusLost( bool toggle ) override;
113 * @copydoc Dali::InputMethodContext::PreEditChanged()
115 void PreEditChanged( void* data, ImfContext* imfContext, void* eventInfo ) override;
118 * @copydoc Dali::InputMethodContext::NotifyCursorPosition()
120 void CommitReceived( void* data, ImfContext* imfContext, void* eventInfo ) override;
123 * @copydoc Dali::InputMethodContext::NotifyCursorPosition()
125 bool RetrieveSurrounding( void* data, ImfContext* imfContext, char** text, int* cursorPosition ) override;
128 * @copydoc Dali::InputMethodContext::DeleteSurrounding()
130 void DeleteSurrounding( void* data, ImfContext* imfContext, void* eventInfo ) override;
133 * @copydoc Dali::InputMethodContext::SendPrivateCommand()
135 void SendPrivateCommand( void* data, ImfContext* imfContext, void* eventInfo ) override
139 * @copydoc Dali::InputMethodContext::SendCommitContent()
141 void SendCommitContent( void* data, ImfContext* imfContext, void* eventInfo ) override
146 * @copydoc Dali::InputMethodContext::NotifyCursorPosition()
148 void NotifyCursorPosition() override;
151 * @copydoc Dali::InputMethodContext::SetCursorPosition()
153 void SetCursorPosition( unsigned int cursorPosition ) override;
156 * @copydoc Dali::InputMethodContext::GetCursorPosition()
158 unsigned int GetCursorPosition() const override;
161 * @copydoc Dali::InputMethodContext::SetSurroundingText()
163 void SetSurroundingText( const std::string& text ) override;
166 * @copydoc Dali::InputMethodContext::GetSurroundingText()
168 const std::string& GetSurroundingText() const override;
171 * @copydoc Dali::InputMethodContext::NotifyTextInputMultiLine()
173 void NotifyTextInputMultiLine( bool multiLine ) override;
176 * @copydoc Dali::InputMethodContext::GetTextDirection()
178 Dali::InputMethodContext::TextDirection GetTextDirection() override;
181 * @copydoc Dali::InputMethodContext::GetInputMethodArea()
183 Dali::Rect<int> GetInputMethodArea() override;
186 * @copydoc Dali::InputMethodContext::ApplyOptions()
188 void ApplyOptions( const InputMethodOptions& options ) override;
191 * @copydoc Dali::InputMethodContext::SetInputPanelData()
193 void SetInputPanelData( const std::string& data ) override;
196 * @copydoc Dali::InputMethodContext::GetInputPanelData()
198 void GetInputPanelData( std::string& data ) override;
201 * @copydoc Dali::InputMethodContext::GetInputPanelState()
203 Dali::InputMethodContext::State GetInputPanelState() override;
206 * @copydoc Dali::InputMethodContext::SetReturnKeyState()
208 void SetReturnKeyState( bool visible ) override;
211 * @copydoc Dali::InputMethodContext::AutoEnableInputPanel()
213 void AutoEnableInputPanel( bool enabled ) override;
216 * @copydoc Dali::InputMethodContext::ShowInputPanel()
218 void ShowInputPanel() override;
221 * @copydoc Dali::InputMethodContext::HideInputPanel()
223 void HideInputPanel() override;
226 * @copydoc Dali::InputMethodContext::GetKeyboardType()
228 Dali::InputMethodContext::KeyboardType GetKeyboardType() override;
231 * @copydoc Dali::InputMethodContext::GetInputPanelLocale()
233 std::string GetInputPanelLocale() override;
236 * @copydoc Dali::InputMethodContext::SetContentMIMETypes()
238 void SetContentMIMETypes( const std::string& mimeTypes ) override;
241 * @copydoc Dali::InputMethodContext::FilterEventKey()
243 bool FilterEventKey( const Dali::KeyEvent& keyEvent ) override;
246 * @copydoc Dali::InputMethodContext::AllowTextPrediction()
248 void AllowTextPrediction( bool prediction ) override;
251 * @copydoc Dali::InputMethodContext::IsTextPredictionAllowed()
253 bool IsTextPredictionAllowed() const override;
256 * @copydoc Dali::InputMethodContext::SetInputPanelLanguage()
258 void SetInputPanelLanguage( Dali::InputMethodContext::InputPanelLanguage language ) override;
261 * @copydoc Dali::InputMethodContext::GetInputPanelLanguage()
263 Dali::InputMethodContext::InputPanelLanguage GetInputPanelLanguage() const override;
267 * Context created the first time and kept until deleted.
268 * @param[in] ecoreXwin, The window is created by application.
270 void CreateContext( Ecore_X_Window ecoreXwin );
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 );
315 virtual ~InputMethodContextX();
319 // Undefined copy constructor
320 InputMethodContextX( const InputMethodContextX& inputMethodContext) = delete;
322 // Undefined assignment operator
323 InputMethodContextX& operator=( const InputMethodContextX& inputMethodContext ) = delete;
326 Ecore_IMF_Context* mIMFContext;
327 Ecore_X_Window mEcoreXwin;
328 int mIMFCursorPosition;
329 std::string mSurroundingText;
331 bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
332 bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
333 InputMethodOptions mOptions;
336 } // namespace Adaptor
338 } // namespace Internal
342 #endif // DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_X_H