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) 2021 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/integration-api/events/key-event-integ.h>
26 #include <dali/public-api/common/vector-wrapper.h>
27 #include <dali/public-api/object/base-object.h>
30 #include <dali/internal/input/common/input-method-context-impl.h>
40 class InputMethodContextEcoreWl : public Dali::Internal::Adaptor::InputMethodContext, public Dali::ConnectionTracker
44 * @brief Creates a new InputMethodContext handle
46 * @param[in] actor The actor that uses the new InputMethodContext instance.
47 * @return InputMethodContext pointer
49 static InputMethodContextPtr New(Dali::Actor actor);
52 * @brief Initializes member data.
54 void Initialize() override;
58 * @copydoc Dali::InputMethodContext::Finalize()
60 void Finalize() override;
63 * Connect Callbacks required for InputMethodContext.
64 * If you don't connect InputMethodContext callbacks, you can't get the key events.
65 * The events are PreeditChanged, Commit, DeleteSurrounding and PrivateCommand.
67 void ConnectCallbacks() override;
70 * Disconnect Callbacks attached to input method context.
72 void DisconnectCallbacks() override;
75 * @copydoc Dali::InputMethodContext::Activate()
77 void Activate() override;
80 * @copydoc Dali::InputMethodContext::Deactivate()
82 void Deactivate() override;
85 * @copydoc Dali::InputMethodContext::Reset()
87 void Reset() override;
90 * @copydoc Dali::InputMethodContext::GetContext()
92 ImfContext* GetContext() override;
95 * @copydoc Dali::InputMethodContext::RestoreAfterFocusLost()
97 bool RestoreAfterFocusLost() const override;
100 * @copydoc Dali::InputMethodContext::SetRestoreAfterFocusLost()
102 void SetRestoreAfterFocusLost(bool toggle) override;
105 * @copydoc Dali::InputMethodContext::PreEditChanged()
107 void PreEditChanged(void* data, ImfContext* imfContext, void* eventInfo) override;
110 * @copydoc Dali::InputMethodContext::NotifyCursorPosition()
112 void CommitReceived(void* data, ImfContext* imfContext, void* eventInfo) override;
115 * @copydoc Dali::InputMethodContext::NotifyCursorPosition()
117 bool RetrieveSurrounding(void* data, ImfContext* imfContext, char** text, int* cursorPosition) override;
120 * @copydoc Dali::InputMethodContext::DeleteSurrounding()
122 void DeleteSurrounding(void* data, ImfContext* imfContext, void* eventInfo) override;
125 * @copydoc Dali::InputMethodContext::SendPrivateCommand()
127 void SendPrivateCommand(void* data, ImfContext* imfContext, void* eventInfo) override;
130 * @copydoc Dali::InputMethodContext::SendCommitContent()
132 void SendCommitContent(void* data, ImfContext* imfContext, void* eventInfo) override;
136 * @copydoc Dali::InputMethodContext::NotifyCursorPosition()
138 void NotifyCursorPosition() override;
141 * @copydoc Dali::InputMethodContext::SetCursorPosition()
143 void SetCursorPosition(unsigned int cursorPosition) override;
146 * @copydoc Dali::InputMethodContext::GetCursorPosition()
148 unsigned int GetCursorPosition() const override;
151 * @copydoc Dali::InputMethodContext::SetSurroundingText()
153 void SetSurroundingText(const std::string& text) override;
156 * @copydoc Dali::InputMethodContext::GetSurroundingText()
158 const std::string& GetSurroundingText() const override;
161 * @copydoc Dali::InputMethodContext::NotifyTextInputMultiLine()
163 void NotifyTextInputMultiLine(bool multiLine) override;
166 * @copydoc Dali::InputMethodContext::GetTextDirection()
168 Dali::InputMethodContext::TextDirection GetTextDirection() override;
171 * @copydoc Dali::InputMethodContext::GetInputMethodArea()
173 Dali::Rect<int> GetInputMethodArea() override;
176 * @copydoc Dali::InputMethodContext::ApplyOptions()
178 void ApplyOptions(const InputMethodOptions& options) override;
181 * @copydoc Dali::InputMethodContext::SetInputPanelData()
183 void SetInputPanelData(const std::string& data) override;
186 * @copydoc Dali::InputMethodContext::GetInputPanelData()
188 void GetInputPanelData(std::string& data) override;
191 * @copydoc Dali::InputMethodContext::GetInputPanelState()
193 Dali::InputMethodContext::State GetInputPanelState() override;
196 * @copydoc Dali::InputMethodContext::SetReturnKeyState()
198 void SetReturnKeyState(bool visible) override;
201 * @copydoc Dali::InputMethodContext::AutoEnableInputPanel()
203 void AutoEnableInputPanel(bool enabled) override;
206 * @copydoc Dali::InputMethodContext::ShowInputPanel()
208 void ShowInputPanel() override;
211 * @copydoc Dali::InputMethodContext::HideInputPanel()
213 void HideInputPanel() override;
216 * @copydoc Dali::InputMethodContext::GetKeyboardType()
218 Dali::InputMethodContext::KeyboardType GetKeyboardType() override;
221 * @copydoc Dali::InputMethodContext::GetInputPanelLocale()
223 std::string GetInputPanelLocale() override;
226 * @copydoc Dali::InputMethodContext::SetContentMIMETypes()
228 void SetContentMIMETypes(const std::string& mimeTypes) override;
231 * @copydoc Dali::InputMethodContext::FilterEventKey()
233 bool FilterEventKey(const Dali::KeyEvent& keyEvent) override;
236 * @copydoc Dali::InputMethodContext::AllowTextPrediction()
238 void AllowTextPrediction(bool prediction) override;
241 * @copydoc Dali::InputMethodContext::IsTextPredictionAllowed()
243 bool IsTextPredictionAllowed() const override;
246 * @copydoc Dali::InputMethodContext::SetInputPanelLanguage()
248 void SetInputPanelLanguage(Dali::InputMethodContext::InputPanelLanguage language) override;
251 * @copydoc Dali::InputMethodContext::GetInputPanelLanguage()
253 Dali::InputMethodContext::InputPanelLanguage GetInputPanelLanguage() const override;
256 * @copydoc Dali::InputMethodContext::SetInputPanelPosition()
258 void SetInputPanelPosition(unsigned int x, unsigned int y) override;
261 * @copydoc Dali::InputMethodContext::GetPreeditStyle()
263 void GetPreeditStyle(Dali::InputMethodContext::PreEditAttributeDataContainer& attrs) const override;
267 * Context created the first time and kept until deleted.
269 void CreateContext();
272 * @copydoc Dali::InputMethodContext::DeleteContext()
274 void DeleteContext();
278 * @brief Process event key down, whether filter a key to isf.
280 * @param[in] keyEvent The event key to be handled.
281 * @return Whether the event key is handled.
283 bool ProcessEventKeyDown(const Dali::KeyEvent& keyEvent);
286 * @brief Process event key up, whether filter a key to isf.
288 * @param[in] keyEvent The event key to be handled.
289 * @return Whether the event key is handled.
291 bool ProcessEventKeyUp(const Dali::KeyEvent& keyEvent);
294 * Ecore_Event_Modifier enums in Ecore_Input.h do not match Ecore_IMF_Keyboard_Modifiers in Ecore_IMF.h.
295 * This function converts from Ecore_Event_Modifier to Ecore_IMF_Keyboard_Modifiers enums.
296 * @param[in] ecoreModifier the Ecore_Event_Modifier input.
297 * @return the Ecore_IMF_Keyboard_Modifiers output.
299 Ecore_IMF_Keyboard_Modifiers EcoreInputModifierToEcoreIMFModifier(unsigned int ecoreModifier);
302 * EcoreInputModifierToEcoreIMFLock function converts from Ecore_Event_Modifier to Ecore_IMF_Keyboard_Locks enums.
303 * @param[in] modifier the Ecore_Event_Modifier input.
304 * @return the Ecore_IMF_Keyboard_Locks output.
306 Ecore_IMF_Keyboard_Locks EcoreInputModifierToEcoreIMFLock(unsigned int modifier);
309 * Called when the binded actor is added to a window.
311 void OnStaged(Dali::Actor actor);
315 * @brief Constructor.
317 explicit InputMethodContextEcoreWl(Dali::Actor actor);
323 virtual ~InputMethodContextEcoreWl() override;
326 // Undefined copy constructor
327 explicit InputMethodContextEcoreWl(const InputMethodContextEcoreWl& inputMethodContext) = delete;
329 // Undefined assignment operator
330 InputMethodContextEcoreWl& operator=(const InputMethodContextEcoreWl& inputMethodContext) = delete;
333 Ecore_IMF_Context* mIMFContext;
334 int mIMFCursorPosition;
335 std::string mSurroundingText;
337 bool mRestoreAfterFocusLost : 1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
338 bool mIdleCallbackConnected : 1; ///< Whether the idle callback is already connected.
340 std::vector<Dali::Integration::KeyEvent> mKeyEvents; ///< Stores key events to be sent from idle call-back.
341 InputMethodOptions mOptions;
343 Dali::InputMethodContext::PreEditAttributeDataContainer mPreeditAttrs; ///< Stores preedit attribute data
348 } // namespace Adaptor
350 } // namespace Internal
354 #endif // DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_ECORE_WL_H