2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/input/common/virtual-keyboard-impl.h>
22 #include <dali/integration-api/debug.h>
26 #include <dali/integration-api/adaptor-framework/adaptor.h>
27 #include <dali/internal/input/common/input-method-context-impl.h>
28 #include <dali/internal/input/tizen-wayland/ecore-virtual-keyboard.h>
29 #include <dali/internal/system/common/locale-utils.h>
37 namespace VirtualKeyboard
41 #if defined(DEBUG_ENABLED)
42 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_VIRTUAL_KEYBOARD");
45 #define TOKEN_STRING(x) #x
47 //forward declarations
48 void InputPanelGeometryChangedCallback(void* data, Ecore_IMF_Context* context, int value);
49 void InputPanelLanguageChangeCallback(void* data, Ecore_IMF_Context* context, int value);
52 Dali::VirtualKeyboard::StatusSignalType gKeyboardStatusSignal;
53 Dali::VirtualKeyboard::VoidSignalType gKeyboardResizeSignal;
54 Dali::VirtualKeyboard::VoidSignalType gKeyboardLanguageChangedSignal;
56 void InputPanelStateChangeCallback(void* data, Ecore_IMF_Context* context, int value)
60 case ECORE_IMF_INPUT_PANEL_STATE_SHOW:
62 DALI_LOG_INFO(gLogFilter, Debug::General, "VKB ECORE_IMF_INPUT_PANEL_STATE_SHOW\n");
64 gKeyboardStatusSignal.Emit(true);
69 case ECORE_IMF_INPUT_PANEL_STATE_HIDE:
71 DALI_LOG_INFO(gLogFilter, Debug::General, "VKB ECORE_IMF_INPUT_PANEL_STATE_HIDE\n");
73 gKeyboardStatusSignal.Emit(false);
78 case ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW:
87 void InputPanelLanguageChangeCallback(void* data, Ecore_IMF_Context* context, int value)
89 DALI_LOG_INFO(gLogFilter, Debug::General, "VKB InputPanelLanguageChangeCallback\n");
91 // Emit the signal that the language has changed
92 gKeyboardLanguageChangedSignal.Emit();
95 void InputPanelGeometryChangedCallback(void* data, Ecore_IMF_Context* context, int value)
97 DALI_LOG_INFO(gLogFilter, Debug::General, "VKB InputPanelGeometryChangedCallback\n");
99 // Emit signal that the keyboard is resized
100 gKeyboardResizeSignal.Emit();
103 } // unnamed namespace
105 void ConnectCallbacks(Ecore_IMF_Context* imfContext)
109 DALI_LOG_INFO(gLogFilter, Debug::General, "VKB ConnectPanelCallbacks\n");
111 ecore_imf_context_input_panel_event_callback_add(imfContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, InputPanelStateChangeCallback, NULL);
112 ecore_imf_context_input_panel_event_callback_add(imfContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, InputPanelLanguageChangeCallback, NULL);
113 ecore_imf_context_input_panel_event_callback_add(imfContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, InputPanelGeometryChangedCallback, NULL);
117 void DisconnectCallbacks(Ecore_IMF_Context* imfContext)
121 DALI_LOG_INFO(gLogFilter, Debug::General, "VKB DisconnectPanelCallbacks\n");
123 ecore_imf_context_input_panel_event_callback_del(imfContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, InputPanelStateChangeCallback);
124 ecore_imf_context_input_panel_event_callback_del(imfContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, InputPanelLanguageChangeCallback);
125 ecore_imf_context_input_panel_event_callback_del(imfContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, InputPanelGeometryChangedCallback);
131 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: Show() is deprecated and will be removed from next release. Use InputMethodContext.Activate() instead.\n");
136 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: Hide() is deprecated and will be removed from next release. Use InputMethodContext.Deactivate() instead.\n");
141 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: IsVisible() is deprecated and will be removed from next release.\n");
145 void ApplySettings(const Property::Map& settingsMap)
147 using namespace InputMethod; // Allows exclusion of namespace in TOKEN_STRING.
149 for(unsigned long i = 0, count = settingsMap.Count(); i < count; ++i)
151 Property::Key key = settingsMap.GetKeyAt(i);
152 if(key.type == Property::Key::INDEX)
157 Property::Value item = settingsMap.GetValue(i);
159 if(key == TOKEN_STRING(BUTTON_ACTION))
161 if(item.GetType() == Property::INTEGER)
163 int value = item.Get<int>();
164 VirtualKeyboard::SetReturnKeyType(static_cast<InputMethod::ButtonAction::Type>(value));
169 DALI_LOG_INFO(gLogFilter, Debug::General, "Provided Settings Key not supported\n");
174 void EnablePrediction(const bool enable)
178 bool IsPredictionEnabled()
183 Rect<int> GetSizeAndPosition()
185 int xPos, yPos, width, height;
187 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetSizeAndPosition() is deprecated and will be removed from next release. Use InputMethodContext.GetInputMethodArea() instead.\n");
189 width = height = xPos = yPos = 0;
190 return Rect<int>(xPos, yPos, width, height);
193 Dali::VirtualKeyboard::TextDirection GetTextDirection()
195 Dali::VirtualKeyboard::TextDirection direction(Dali::VirtualKeyboard::LEFT_TO_RIGHT);
199 } // namespace VirtualKeyboard
201 } // namespace Adaptor
203 } // namespace Internal