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* event_info ) override;
118 * @copydoc Dali::InputMethodContext::NotifyCursorPosition()
120 void CommitReceived( void* data, ImfContext* imfContext, void* event_info ) 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* event_info ) override;
133 * @copydoc Dali::InputMethodContext::SendPrivateCommand()
135 void SendPrivateCommand( void* data, ImfContext* imfContext, void* event_info ) 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::FilterEventKey()
232 bool FilterEventKey( const Dali::KeyEvent& keyEvent ) override;
235 * @copydoc Dali::InputMethodContext::AllowTextPrediction()
237 void AllowTextPrediction( bool prediction ) override;
240 * @copydoc Dali::InputMethodContext::IsTextPredictionAllowed()
242 bool IsTextPredictionAllowed() const override;
245 * @copydoc Dali::InputMethodContext::SetInputPanelLanguage()
247 void SetInputPanelLanguage( Dali::InputMethodContext::InputPanelLanguage language ) override;
250 * @copydoc Dali::InputMethodContext::GetInputPanelLanguage()
252 Dali::InputMethodContext::InputPanelLanguage GetInputPanelLanguage() const override;
256 * Context created the first time and kept until deleted.
257 * @param[in] ecoreXwin, The window is created by application.
259 void CreateContext( Ecore_X_Window ecoreXwin );
262 * @copydoc Dali::InputMethodContext::DeleteContext()
264 void DeleteContext();
269 * @brief Process event key down, whether filter a key to isf.
271 * @param[in] keyEvent The event key to be handled.
272 * @return Whether the event key is handled.
274 bool ProcessEventKeyDown( const KeyEvent& keyEvent );
277 * @brief Process event key up, whether filter a key to isf.
279 * @param[in] keyEvent The event key to be handled.
280 * @return Whether the event key is handled.
282 bool ProcessEventKeyUp( const KeyEvent& keyEvent );
285 * Ecore_Event_Modifier enums in Ecore_Input.h do not match Ecore_IMF_Keyboard_Modifiers in Ecore_IMF.h.
286 * This function converts from Ecore_Event_Modifier to Ecore_IMF_Keyboard_Modifiers enums.
287 * @param[in] ecoreModifier the Ecore_Event_Modifier input.
288 * @return the Ecore_IMF_Keyboard_Modifiers output.
290 Ecore_IMF_Keyboard_Modifiers EcoreInputModifierToEcoreIMFModifier( unsigned int ecoreModifier );
293 * EcoreInputModifierToEcoreIMFLock function converts from Ecore_Event_Modifier to Ecore_IMF_Keyboard_Locks enums.
294 * @param[in] modifier the Ecore_Event_Modifier input.
295 * @return the Ecore_IMF_Keyboard_Locks output.
297 Ecore_IMF_Keyboard_Locks EcoreInputModifierToEcoreIMFLock( unsigned int modifier );
304 virtual ~InputMethodContextX();
308 // Undefined copy constructor
309 InputMethodContextX( const InputMethodContextX& inputMethodContext) = delete;
311 // Undefined assignment operator
312 InputMethodContextX& operator=( const InputMethodContextX& inputMethodContext ) = delete;
315 Ecore_IMF_Context* mIMFContext;
316 Ecore_X_Window mEcoreXwin;
317 int mIMFCursorPosition;
318 std::string mSurroundingText;
320 bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
321 bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
322 InputMethodOptions mOptions;
325 } // namespace Adaptor
327 } // namespace Internal
331 #endif // DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_X_H