1 #ifndef DALI_INTERNAL_INPUT_COMMON_IMF_MANAGER_IMPL_ECORE_WL2_H
2 #define DALI_INTERNAL_INPUT_COMMON_IMF_MANAGER_IMPL_ECORE_WL2_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>
25 #include <Ecore_Wl2.h>
29 #include <dali/public-api/common/vector-wrapper.h>
30 #include <dali/public-api/object/base-object.h>
31 #include <dali/integration-api/events/key-event-integ.h>
34 #include <dali/internal/input/common/imf-manager-impl.h>
47 class ImfManagerEcoreWl : public Dali::Internal::Adaptor::ImfManager
52 * Check whether the ImfManager is available.
53 * @return true if available, false otherwise
55 static bool IsAvailable();
58 * Get the IMF manager instance, it creates the instance if it has not already been created.
59 * Internally, a check should be made using IsAvailable() before this is called as we do not want
60 * to create an instance if not needed by applications.
63 static Dali::ImfManager Get();
66 * Connect Callbacks required for IMF.
67 * If you don't connect imf callbacks, you can't get the key events.
68 * The events are PreeditChanged, Commit, DeleteSurrounding and PrivateCommand.
70 void ConnectCallbacks() override;
73 * Disconnect Callbacks attached to imf context.
75 void DisconnectCallbacks() override;
78 * @copydoc Dali::ImfManager::Activate()
80 void Activate() override;
83 * @copydoc Dali::ImfManager::Deactivate()
85 void Deactivate() override;
88 * @copydoc Dali::ImfManager::Reset()
90 void Reset() override;
93 * @copydoc Dali::ImfManager::GetContext()
95 ImfContext* GetContext() override;
98 * @copydoc Dali::ImfManager::RestoreAfterFocusLost()
100 bool RestoreAfterFocusLost() const override;
103 * @copydoc Dali::ImfManager::SetRestoreAfterFocusLost()
105 void SetRestoreAfterFocusLost( bool toggle ) override;
108 * @copydoc Dali::ImfManager::PreEditChanged()
110 void PreEditChanged( void *data, Ecore_IMF_Context *imfContext, void *event_info );
113 * @copydoc Dali::ImfManager::NotifyCursorPosition()
115 void CommitReceived( void *data, Ecore_IMF_Context *imfContext, void *event_info );
118 * @copydoc Dali::ImfManager::NotifyCursorPosition()
120 Eina_Bool RetrieveSurrounding( void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition );
123 * @copydoc Dali::ImfManager::DeleteSurrounding()
125 void DeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info );
128 * @copydoc Dali::ImfManager::SendPrivateCommand()
130 void SendPrivateCommand( void* data, Ecore_IMF_Context* imfContext, void* event_info );
134 * @copydoc Dali::ImfManager::NotifyCursorPosition()
136 void NotifyCursorPosition() override;
139 * @copydoc Dali::ImfManager::SetCursorPosition()
141 void SetCursorPosition( unsigned int cursorPosition ) override;
144 * @copydoc Dali::ImfManager::GetCursorPosition()
146 unsigned int GetCursorPosition() const override;
149 * @copydoc Dali::ImfManager::SetSurroundingText()
151 void SetSurroundingText( const std::string& text ) override;
154 * @copydoc Dali::ImfManager::GetSurroundingText()
156 const std::string& GetSurroundingText() const override;
159 * @copydoc Dali::ImfManager::NotifyTextInputMultiLine()
161 void NotifyTextInputMultiLine( bool multiLine ) override;
164 * @copydoc Dali::ImfManager::GetTextDirection()
166 Dali::ImfManager::TextDirection GetTextDirection() override;
169 * @copydoc Dali::ImfManager::GetInputMethodArea()
171 Dali::Rect<int> GetInputMethodArea() override;
174 * @copydoc Dali::ImfManager::ApplyOptions()
176 void ApplyOptions( const InputMethodOptions& options ) override;
179 * @copydoc Dali::ImfManager::SetInputPanelData()
181 void SetInputPanelData( const std::string& data ) override;
184 * @copydoc Dali::ImfManager::GetInputPanelData()
186 void GetInputPanelData( std::string& data ) override;
189 * @copydoc Dali::ImfManager::GetInputPanelState()
191 Dali::ImfManager::State GetInputPanelState() override;
194 * @copydoc Dali::ImfManager::SetReturnKeyState()
196 void SetReturnKeyState( bool visible ) override;
199 * @copydoc Dali::ImfManager::AutoEnableInputPanel()
201 void AutoEnableInputPanel( bool enabled ) override;
204 * @copydoc Dali::ImfManager::ShowInputPanel()
206 void ShowInputPanel() override;
209 * @copydoc Dali::ImfManager::HideInputPanel()
211 void HideInputPanel() override;
214 * @copydoc Dali::ImfManager::GetKeyboardType()
216 Dali::ImfManager::KeyboardType GetKeyboardType() override;
219 * @copydoc Dali::ImfManager::GetInputPanelLocale()
221 std::string GetInputPanelLocale() override;
228 virtual ~ImfManagerEcoreWl() override;
232 * Context created the first time and kept until deleted.
233 * @param[in] ecoreWlwin, The window is created by application.
235 void CreateContext( Ecore_Wl2_Window *ecoreWlwin );
238 * @copydoc Dali::ImfManager::DeleteContext()
240 void DeleteContext();
244 explicit ImfManagerEcoreWl( Ecore_Wl2_Window *ecoreWlwin );
245 explicit ImfManagerEcoreWl( const ImfManager& ) = delete;
246 ImfManagerEcoreWl& operator=( ImfManager& ) = delete;
249 Ecore_IMF_Context* mIMFContext;
250 int mIMFCursorPosition;
251 std::string mSurroundingText;
253 bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
254 bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
256 std::vector<Dali::Integration::KeyEvent> mKeyEvents; ///< Stores key events to be sent from idle call-back.
257 InputMethodOptions mOptions;
261 } // namespace Adaptor
263 } // namespace Internal
267 #endif // DALI_INTERNAL_INPUT_COMMON_IMF_MANAGER_IMPL_ECORE_WL2_H