2 * Copyright (c) 2017 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>
24 #include <dali/integration-api/debug.h>
27 // Ecore is littered with C style cast
28 #pragma GCC diagnostic push
29 #pragma GCC diagnostic ignored "-Wold-style-cast"
30 #include <dali/internal/input/tizen-wayland/ecore-virtual-keyboard.h>
31 #include <dali/integration-api/adaptor.h>
32 #include <dali/internal/system/common/locale-utils.h>
33 #include <dali/internal/input/common/input-method-context-impl.h>
44 namespace VirtualKeyboard
49 #if defined(DEBUG_ENABLED)
50 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_VIRTUAL_KEYBOARD");
53 #define TOKEN_STRING(x) #x
55 //forward declarations
56 void InputPanelGeometryChangedCallback ( void *data, Ecore_IMF_Context *context, int value );
57 void InputPanelLanguageChangeCallback( void* data, Ecore_IMF_Context* context, int value );
60 Dali::VirtualKeyboard::StatusSignalType gKeyboardStatusSignal;
61 Dali::VirtualKeyboard::VoidSignalType gKeyboardResizeSignal;
62 Dali::VirtualKeyboard::VoidSignalType gKeyboardLanguageChangedSignal;
64 void InputPanelStateChangeCallback( void* data, Ecore_IMF_Context* context, int value )
68 case ECORE_IMF_INPUT_PANEL_STATE_SHOW:
70 DALI_LOG_INFO( gLogFilter, Debug::General, "VKB ECORE_IMF_INPUT_PANEL_STATE_SHOW\n" );
72 gKeyboardStatusSignal.Emit( true );
77 case ECORE_IMF_INPUT_PANEL_STATE_HIDE:
79 DALI_LOG_INFO( gLogFilter, Debug::General, "VKB ECORE_IMF_INPUT_PANEL_STATE_HIDE\n" );
81 gKeyboardStatusSignal.Emit( false );
86 case ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW:
95 void InputPanelLanguageChangeCallback( void* data, Ecore_IMF_Context* context, int value )
97 DALI_LOG_INFO( gLogFilter, Debug::General, "VKB InputPanelLanguageChangeCallback\n" );
99 // Emit the signal that the language has changed
100 gKeyboardLanguageChangedSignal.Emit();
103 void InputPanelGeometryChangedCallback ( void *data, Ecore_IMF_Context *context, int value )
105 DALI_LOG_INFO( gLogFilter, Debug::General, "VKB InputPanelGeometryChangedCallback\n" );
107 // Emit signal that the keyboard is resized
108 gKeyboardResizeSignal.Emit();
111 } // unnamed namespace
113 void ConnectCallbacks( Ecore_IMF_Context *imfContext )
117 DALI_LOG_INFO( gLogFilter, Debug::General, "VKB ConnectPanelCallbacks\n" );
119 ecore_imf_context_input_panel_event_callback_add( imfContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, InputPanelStateChangeCallback, NULL );
120 ecore_imf_context_input_panel_event_callback_add( imfContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, InputPanelLanguageChangeCallback, NULL );
121 ecore_imf_context_input_panel_event_callback_add( imfContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, InputPanelGeometryChangedCallback, NULL );
125 void DisconnectCallbacks( Ecore_IMF_Context *imfContext )
129 DALI_LOG_INFO( gLogFilter, Debug::General, "VKB DisconnectPanelCallbacks\n" );
131 ecore_imf_context_input_panel_event_callback_del( imfContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, InputPanelStateChangeCallback );
132 ecore_imf_context_input_panel_event_callback_del( imfContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, InputPanelLanguageChangeCallback );
133 ecore_imf_context_input_panel_event_callback_del( imfContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, InputPanelGeometryChangedCallback );
139 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: Show() is deprecated and will be removed from next release. Use InputMethodContext.Activate() instead.\n" );
144 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: Hide() is deprecated and will be removed from next release. Use InputMethodContext.Deactivate() instead.\n" );
149 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: IsVisible() is deprecated and will be removed from next release.\n" );
153 void ApplySettings( const Property::Map& settingsMap )
155 using namespace InputMethod; // Allows exclusion of namespace in TOKEN_STRING.
157 for ( unsigned int i = 0, count = settingsMap.Count(); i < count; ++i )
159 Property::Key key = settingsMap.GetKeyAt( i );
160 if( key.type == Property::Key::INDEX )
165 Property::Value item = settingsMap.GetValue(i);
167 if ( key == TOKEN_STRING( BUTTON_ACTION ) )
169 if ( item.GetType() == Property::INTEGER )
171 int value = item.Get< int >();
172 VirtualKeyboard::SetReturnKeyType( static_cast<InputMethod::ButtonAction::Type>(value) );
177 DALI_LOG_INFO( gLogFilter, Debug::General, "Provided Settings Key not supported\n" );
182 void EnablePrediction(const bool enable)
186 bool IsPredictionEnabled()
191 Rect<int> GetSizeAndPosition()
193 int xPos, yPos, width, height;
195 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetSizeAndPosition() is deprecated and will be removed from next release. Use InputMethodContext.GetInputMethodArea() instead.\n" );
197 width = height = xPos = yPos = 0;
198 return Rect<int>(xPos,yPos,width,height);
201 Dali::VirtualKeyboard::TextDirection GetTextDirection()
203 Dali::VirtualKeyboard::TextDirection direction ( Dali::VirtualKeyboard::LeftToRight );
207 } // namespace VirtualKeyboard
209 } // namespace Adaptor
211 } // namespace Internal
215 #pragma GCC diagnostic pop