1 #ifndef DALI_INTERNAL_INPUT_COMMON_IMF_MANAGER_IMPL_ECORE_WL_H
2 #define DALI_INTERNAL_INPUT_COMMON_IMF_MANAGER_IMPL_ECORE_WL_H
5 * Copyright (c) 2018 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 <Ecore_IMF.h>
24 #include <Ecore_Wayland.h>
26 #include <dali/public-api/common/vector-wrapper.h>
27 #include <dali/public-api/object/base-object.h>
28 #include <dali/integration-api/events/key-event-integ.h>
31 #include <dali/internal/input/common/imf-manager-impl.h>
44 class ImfManagerEcoreWl : public Dali::Internal::Adaptor::ImfManager
49 * Check whether the ImfManager is available.
50 * @return true if available, false otherwise
52 static bool IsAvailable();
55 * Get the IMF manager instance, it creates the instance if it has not already been created.
56 * Internally, a check should be made using IsAvailable() before this is called as we do not want
57 * to create an instance if not needed by applications.
60 static Dali::ImfManager Get();
63 * Connect Callbacks required for IMF.
64 * If you don't connect imf 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 imf context.
72 void DisconnectCallbacks() override;
75 * @copydoc Dali::ImfManager::Activate()
77 void Activate() override;
80 * @copydoc Dali::ImfManager::Deactivate()
82 void Deactivate() override;
85 * @copydoc Dali::ImfManager::Reset()
87 void Reset() override;
90 * @copydoc Dali::ImfManager::GetContext()
92 ImfContext* GetContext() override;
95 * @copydoc Dali::ImfManager::RestoreAfterFocusLost()
97 bool RestoreAfterFocusLost() const override;
100 * @copydoc Dali::ImfManager::SetRestoreAfterFocusLost()
102 void SetRestoreAfterFocusLost( bool toggle ) override;
105 * @copydoc Dali::ImfManager::PreEditChanged()
107 void PreEditChanged( void *data, Ecore_IMF_Context *imfContext, void *event_info );
110 * @copydoc Dali::ImfManager::NotifyCursorPosition()
112 void CommitReceived( void *data, Ecore_IMF_Context *imfContext, void *event_info );
115 * @copydoc Dali::ImfManager::NotifyCursorPosition()
117 Eina_Bool RetrieveSurrounding( void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition );
120 * @copydoc Dali::ImfManager::DeleteSurrounding()
122 void DeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info );
125 * @copydoc Dali::ImfManager::SendPrivateCommand()
127 void SendPrivateCommand( void* data, Ecore_IMF_Context* imfContext, void* event_info );
131 * @copydoc Dali::ImfManager::NotifyCursorPosition()
133 void NotifyCursorPosition() override;
136 * @copydoc Dali::ImfManager::SetCursorPosition()
138 void SetCursorPosition( unsigned int cursorPosition ) override;
141 * @copydoc Dali::ImfManager::GetCursorPosition()
143 unsigned int GetCursorPosition() const override;
146 * @copydoc Dali::ImfManager::SetSurroundingText()
148 void SetSurroundingText( const std::string& text ) override;
151 * @copydoc Dali::ImfManager::GetSurroundingText()
153 const std::string& GetSurroundingText() const override;
156 * @copydoc Dali::ImfManager::NotifyTextInputMultiLine()
158 void NotifyTextInputMultiLine( bool multiLine ) override;
161 * @copydoc Dali::ImfManager::GetTextDirection()
163 Dali::ImfManager::TextDirection GetTextDirection() override;
166 * @copydoc Dali::ImfManager::GetInputMethodArea()
168 Dali::Rect<int> GetInputMethodArea() override;
171 * @copydoc Dali::ImfManager::ApplyOptions()
173 void ApplyOptions( const InputMethodOptions& options ) override;
176 * @copydoc Dali::ImfManager::SetInputPanelData()
178 void SetInputPanelData( const std::string& data ) override;
181 * @copydoc Dali::ImfManager::GetInputPanelData()
183 void GetInputPanelData( std::string& data ) override;
186 * @copydoc Dali::ImfManager::GetInputPanelState()
188 Dali::ImfManager::State GetInputPanelState() override;
191 * @copydoc Dali::ImfManager::SetReturnKeyState()
193 void SetReturnKeyState( bool visible ) override;
196 * @copydoc Dali::ImfManager::AutoEnableInputPanel()
198 void AutoEnableInputPanel( bool enabled ) override;
201 * @copydoc Dali::ImfManager::ShowInputPanel()
203 void ShowInputPanel() override;
206 * @copydoc Dali::ImfManager::HideInputPanel()
208 void HideInputPanel() override;
211 * @copydoc Dali::ImfManager::GetKeyboardType()
213 Dali::ImfManager::KeyboardType GetKeyboardType() override;
216 * @copydoc Dali::ImfManager::GetInputPanelLocale()
218 std::string GetInputPanelLocale() override;
225 virtual ~ImfManagerEcoreWl() override;
229 * Context created the first time and kept until deleted.
230 * @param[in] ecoreWlwin, The window is created by application.
232 void CreateContext( Ecore_Wl_Window *ecoreWlwin );
235 * @copydoc Dali::ImfManager::DeleteContext()
237 void DeleteContext();
241 explicit ImfManagerEcoreWl( Ecore_Wl_Window *ecoreWlwin );
242 explicit ImfManagerEcoreWl( const ImfManager& ) = delete;
243 ImfManagerEcoreWl& operator=( ImfManager& ) = delete;
246 Ecore_IMF_Context* mIMFContext;
247 int mIMFCursorPosition;
248 std::string mSurroundingText;
250 bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
251 bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
253 std::vector<Dali::Integration::KeyEvent> mKeyEvents; ///< Stores key events to be sent from idle call-back.
254 InputMethodOptions mOptions;
258 } // namespace Adaptor
260 } // namespace Internal
264 #endif // DALI_INTERNAL_INPUT_COMMON_IMF_MANAGER_IMPL_ECORE_WL_H