2 * Copyright (c) 2019 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>
23 #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>
40 namespace VirtualKeyboard
45 #if defined(DEBUG_ENABLED)
46 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_VIRTUAL_KEYBOARD");
49 #define TOKEN_STRING(x) #x
51 //forward declarations
52 void InputPanelGeometryChangedCallback ( void *data, Ecore_IMF_Context *context, int value );
53 void InputPanelLanguageChangeCallback( void* data, Ecore_IMF_Context* context, int value );
56 Dali::VirtualKeyboard::StatusSignalType gKeyboardStatusSignal;
57 Dali::VirtualKeyboard::VoidSignalType gKeyboardResizeSignal;
58 Dali::VirtualKeyboard::VoidSignalType gKeyboardLanguageChangedSignal;
60 void InputPanelStateChangeCallback( void* data, Ecore_IMF_Context* context, int value )
64 case ECORE_IMF_INPUT_PANEL_STATE_SHOW:
66 DALI_LOG_INFO( gLogFilter, Debug::General, "VKB ECORE_IMF_INPUT_PANEL_STATE_SHOW\n" );
68 gKeyboardStatusSignal.Emit( true );
73 case ECORE_IMF_INPUT_PANEL_STATE_HIDE:
75 DALI_LOG_INFO( gLogFilter, Debug::General, "VKB ECORE_IMF_INPUT_PANEL_STATE_HIDE\n" );
77 gKeyboardStatusSignal.Emit( false );
82 case ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW:
91 void InputPanelLanguageChangeCallback( void* data, Ecore_IMF_Context* context, int value )
93 DALI_LOG_INFO( gLogFilter, Debug::General, "VKB InputPanelLanguageChangeCallback\n" );
95 // Emit the signal that the language has changed
96 gKeyboardLanguageChangedSignal.Emit();
99 void InputPanelGeometryChangedCallback ( void *data, Ecore_IMF_Context *context, int value )
101 DALI_LOG_INFO( gLogFilter, Debug::General, "VKB InputPanelGeometryChangedCallback\n" );
103 // Emit signal that the keyboard is resized
104 gKeyboardResizeSignal.Emit();
107 } // unnamed namespace
109 void ConnectCallbacks( Ecore_IMF_Context *imfContext )
113 DALI_LOG_INFO( gLogFilter, Debug::General, "VKB ConnectPanelCallbacks\n" );
115 ecore_imf_context_input_panel_event_callback_add( imfContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, InputPanelStateChangeCallback, NULL );
116 ecore_imf_context_input_panel_event_callback_add( imfContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, InputPanelLanguageChangeCallback, NULL );
117 ecore_imf_context_input_panel_event_callback_add( imfContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, InputPanelGeometryChangedCallback, NULL );
121 void DisconnectCallbacks( Ecore_IMF_Context *imfContext )
125 DALI_LOG_INFO( gLogFilter, Debug::General, "VKB DisconnectPanelCallbacks\n" );
127 ecore_imf_context_input_panel_event_callback_del( imfContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, InputPanelStateChangeCallback );
128 ecore_imf_context_input_panel_event_callback_del( imfContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, InputPanelLanguageChangeCallback );
129 ecore_imf_context_input_panel_event_callback_del( imfContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, InputPanelGeometryChangedCallback );
135 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: Show() is deprecated and will be removed from next release. Use InputMethodContext.Activate() instead.\n" );
140 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: Hide() is deprecated and will be removed from next release. Use InputMethodContext.Deactivate() instead.\n" );
145 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: IsVisible() is deprecated and will be removed from next release.\n" );
149 void ApplySettings( const Property::Map& settingsMap )
151 using namespace InputMethod; // Allows exclusion of namespace in TOKEN_STRING.
153 for ( unsigned long i = 0, count = settingsMap.Count(); i < count; ++i )
155 Property::Key key = settingsMap.GetKeyAt( i );
156 if( key.type == Property::Key::INDEX )
161 Property::Value item = settingsMap.GetValue(i);
163 if ( key == TOKEN_STRING( BUTTON_ACTION ) )
165 if ( item.GetType() == Property::INTEGER )
167 int value = item.Get< int >();
168 VirtualKeyboard::SetReturnKeyType( static_cast<InputMethod::ButtonAction::Type>(value) );
173 DALI_LOG_INFO( gLogFilter, Debug::General, "Provided Settings Key not supported\n" );
178 void EnablePrediction(const bool enable)
182 bool IsPredictionEnabled()
187 Rect<int> GetSizeAndPosition()
189 int xPos, yPos, width, height;
191 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetSizeAndPosition() is deprecated and will be removed from next release. Use InputMethodContext.GetInputMethodArea() instead.\n" );
193 width = height = xPos = yPos = 0;
194 return Rect<int>(xPos,yPos,width,height);
197 Dali::VirtualKeyboard::TextDirection GetTextDirection()
199 Dali::VirtualKeyboard::TextDirection direction ( Dali::VirtualKeyboard::LEFT_TO_RIGHT );
203 } // namespace VirtualKeyboard
205 } // namespace Adaptor
207 } // namespace Internal