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::Finalize()
77 void Finalize() override;
80 * @copydoc Dali::ImfManager::Activate()
82 void Activate() override;
85 * @copydoc Dali::ImfManager::Deactivate()
87 void Deactivate() override;
90 * @copydoc Dali::ImfManager::Reset()
92 void Reset() override;
95 * @copydoc Dali::ImfManager::GetContext()
97 ImfContext* GetContext() override;
100 * @copydoc Dali::ImfManager::RestoreAfterFocusLost()
102 bool RestoreAfterFocusLost() const override;
105 * @copydoc Dali::ImfManager::SetRestoreAfterFocusLost()
107 void SetRestoreAfterFocusLost( bool toggle ) override;
110 * @copydoc Dali::ImfManager::PreEditChanged()
112 void PreEditChanged( void *data, Ecore_IMF_Context *imfContext, void *event_info );
115 * @copydoc Dali::ImfManager::NotifyCursorPosition()
117 void CommitReceived( void *data, Ecore_IMF_Context *imfContext, void *event_info );
120 * @copydoc Dali::ImfManager::NotifyCursorPosition()
122 Eina_Bool RetrieveSurrounding( void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition );
125 * @copydoc Dali::ImfManager::DeleteSurrounding()
127 void DeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info );
130 * @copydoc Dali::ImfManager::SendPrivateCommand()
132 void SendPrivateCommand( void* data, Ecore_IMF_Context* imfContext, void* event_info );
136 * @copydoc Dali::ImfManager::NotifyCursorPosition()
138 void NotifyCursorPosition() override;
141 * @copydoc Dali::ImfManager::SetCursorPosition()
143 void SetCursorPosition( unsigned int cursorPosition ) override;
146 * @copydoc Dali::ImfManager::GetCursorPosition()
148 unsigned int GetCursorPosition() const override;
151 * @copydoc Dali::ImfManager::SetSurroundingText()
153 void SetSurroundingText( const std::string& text ) override;
156 * @copydoc Dali::ImfManager::GetSurroundingText()
158 const std::string& GetSurroundingText() const override;
161 * @copydoc Dali::ImfManager::NotifyTextInputMultiLine()
163 void NotifyTextInputMultiLine( bool multiLine ) override;
166 * @copydoc Dali::ImfManager::GetTextDirection()
168 Dali::ImfManager::TextDirection GetTextDirection() override;
171 * @copydoc Dali::ImfManager::GetInputMethodArea()
173 Dali::Rect<int> GetInputMethodArea() override;
176 * @copydoc Dali::ImfManager::ApplyOptions()
178 void ApplyOptions( const InputMethodOptions& options ) override;
181 * @copydoc Dali::ImfManager::SetInputPanelData()
183 void SetInputPanelData( const std::string& data ) override;
186 * @copydoc Dali::ImfManager::GetInputPanelData()
188 void GetInputPanelData( std::string& data ) override;
191 * @copydoc Dali::ImfManager::GetInputPanelState()
193 Dali::ImfManager::State GetInputPanelState() override;
196 * @copydoc Dali::ImfManager::SetReturnKeyState()
198 void SetReturnKeyState( bool visible ) override;
201 * @copydoc Dali::ImfManager::AutoEnableInputPanel()
203 void AutoEnableInputPanel( bool enabled ) override;
206 * @copydoc Dali::ImfManager::ShowInputPanel()
208 void ShowInputPanel() override;
211 * @copydoc Dali::ImfManager::HideInputPanel()
213 void HideInputPanel() override;
216 * @copydoc Dali::ImfManager::GetKeyboardType()
218 Dali::ImfManager::KeyboardType GetKeyboardType() override;
221 * @copydoc Dali::ImfManager::GetInputPanelLocale()
223 std::string GetInputPanelLocale() override;
230 virtual ~ImfManagerEcoreWl() override;
234 * Context created the first time and kept until deleted.
235 * @param[in] ecoreWlwin, The window is created by application.
237 void CreateContext( Ecore_Wl_Window *ecoreWlwin );
240 * @copydoc Dali::ImfManager::DeleteContext()
242 void DeleteContext();
246 explicit ImfManagerEcoreWl( Ecore_Wl_Window *ecoreWlwin );
247 explicit ImfManagerEcoreWl( const ImfManager& ) = delete;
248 ImfManagerEcoreWl& operator=( ImfManager& ) = delete;
251 Ecore_IMF_Context* mIMFContext;
252 int mIMFCursorPosition;
253 std::string mSurroundingText;
255 bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
256 bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
258 std::vector<Dali::Integration::KeyEvent> mKeyEvents; ///< Stores key events to be sent from idle call-back.
259 InputMethodOptions mOptions;
263 } // namespace Adaptor
265 } // namespace Internal
269 #endif // DALI_INTERNAL_INPUT_COMMON_IMF_MANAGER_IMPL_ECORE_WL_H