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 // Ecore is littered with C style cast
20 #pragma GCC diagnostic push
21 #pragma GCC diagnostic ignored "-Wold-style-cast"
23 #include <dali/internal/input/tizen-wayland/ecore-wl2/imf-manager-impl-ecore-wl2.h>
24 #include <Ecore_Input.h>
27 #include <dali/public-api/events/key-event.h>
28 #include <dali/public-api/object/type-registry.h>
29 #include <dali/integration-api/debug.h>
32 #include <dali/devel-api/adaptor-framework/input-method-devel.h>
33 #include <dali/integration-api/adaptor.h>
34 #include <dali/internal/system/common/locale-utils.h>
35 #include <dali/internal/window-system/tizen-wayland/ecore-wl2/window-render-surface-ecore-wl2.h>
36 #include <dali/internal/adaptor/common/adaptor-impl.h>
37 #include <dali/internal/system/common/singleton-service-impl.h>
39 #define TOKEN_STRING(x) #x
41 Ecore_IMF_Input_Panel_Layout panelLayoutMap[] =
43 ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL,
44 ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBER,
45 ECORE_IMF_INPUT_PANEL_LAYOUT_EMAIL,
46 ECORE_IMF_INPUT_PANEL_LAYOUT_URL,
47 ECORE_IMF_INPUT_PANEL_LAYOUT_PHONENUMBER,
48 ECORE_IMF_INPUT_PANEL_LAYOUT_IP,
49 ECORE_IMF_INPUT_PANEL_LAYOUT_MONTH,
50 ECORE_IMF_INPUT_PANEL_LAYOUT_NUMBERONLY,
51 ECORE_IMF_INPUT_PANEL_LAYOUT_HEX,
52 ECORE_IMF_INPUT_PANEL_LAYOUT_TERMINAL,
53 ECORE_IMF_INPUT_PANEL_LAYOUT_PASSWORD,
54 ECORE_IMF_INPUT_PANEL_LAYOUT_DATETIME,
55 ECORE_IMF_INPUT_PANEL_LAYOUT_EMOTICON,
56 ECORE_IMF_INPUT_PANEL_LAYOUT_VOICE
59 Ecore_IMF_Autocapital_Type autoCapitalMap[] =
61 ECORE_IMF_AUTOCAPITAL_TYPE_NONE,
62 ECORE_IMF_AUTOCAPITAL_TYPE_WORD,
63 ECORE_IMF_AUTOCAPITAL_TYPE_SENTENCE,
64 ECORE_IMF_AUTOCAPITAL_TYPE_ALLCHARACTER,
67 Ecore_IMF_Input_Panel_Return_Key_Type returnKeyTypeMap[] =
69 ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT,
70 ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE,
71 ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_GO,
72 ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_JOIN,
73 ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN,
74 ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT,
75 ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH,
76 ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEND,
77 ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SIGNIN
91 #if defined(DEBUG_ENABLED)
92 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_IMF_MANAGER");
95 // Currently this code is internal to dali/dali/internal/event/text/utf8.h but should be made Public and used from there instead.
96 size_t Utf8SequenceLength(const unsigned char leadByte)
100 if ((leadByte & 0x80) == 0 ) //ASCII character (lead bit zero)
104 else if (( leadByte & 0xe0 ) == 0xc0 ) //110x xxxx
108 else if (( leadByte & 0xf0 ) == 0xe0 ) //1110 xxxx
112 else if (( leadByte & 0xf8 ) == 0xf0 ) //1111 0xxx
120 // Static function calls used by ecore 'c' style callback registration
121 void Commit( void *data, Ecore_IMF_Context *imfContext, void *event_info )
125 ImfManagerEcoreWl* imfManager = reinterpret_cast< ImfManagerEcoreWl* > ( data );
126 imfManager->CommitReceived( data, imfContext, event_info );
130 void PreEdit( void *data, Ecore_IMF_Context *imfContext, void *event_info )
134 ImfManagerEcoreWl* imfManager = reinterpret_cast< ImfManagerEcoreWl* > ( data );
135 imfManager->PreEditChanged( data, imfContext, event_info );
139 Eina_Bool ImfRetrieveSurrounding(void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition )
143 ImfManagerEcoreWl* imfManager = reinterpret_cast< ImfManagerEcoreWl* > ( data );
144 return imfManager->RetrieveSurrounding( data, imfContext, text, cursorPosition );
152 void InputPanelStateChangeCallback( void* data, Ecore_IMF_Context* context, int value )
158 ImfManagerEcoreWl* imfManager = reinterpret_cast< ImfManagerEcoreWl* > ( data );
161 case ECORE_IMF_INPUT_PANEL_STATE_SHOW:
163 imfManager->StatusChangedSignal().Emit( true );
167 case ECORE_IMF_INPUT_PANEL_STATE_HIDE:
169 imfManager->StatusChangedSignal().Emit( false );
173 case ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW:
182 void InputPanelLanguageChangeCallback( void* data, Ecore_IMF_Context* context, int value )
188 ImfManagerEcoreWl* imfManager = reinterpret_cast< ImfManagerEcoreWl* > ( data );
189 // Emit the signal that the language has changed
190 imfManager->LanguageChangedSignal().Emit(value);
193 void InputPanelGeometryChangedCallback ( void *data, Ecore_IMF_Context *context, int value )
199 ImfManagerEcoreWl* imfManager = reinterpret_cast< ImfManagerEcoreWl* > ( data ); // Emit signal that the keyboard is resized
200 // Emit signal that the keyboard is resized
201 imfManager->ResizedSignal().Emit(value);
204 void InputPanelKeyboardTypeChangedCallback( void *data, Ecore_IMF_Context *context, int value )
211 ImfManagerEcoreWl* imfManager = reinterpret_cast< ImfManagerEcoreWl* > ( data );
214 case ECORE_IMF_INPUT_PANEL_SW_KEYBOARD_MODE:
216 // Emit Signal that the keyboard type is changed to Software Keyboard
217 imfManager->KeyboardTypeChangedSignal().Emit( Dali::ImfManager::KeyboardType::SOFTWARE_KEYBOARD );
220 case ECORE_IMF_INPUT_PANEL_HW_KEYBOARD_MODE:
222 // Emit Signal that the keyboard type is changed to Hardware Keyboard
223 imfManager->KeyboardTypeChangedSignal().Emit( Dali::ImfManager::KeyboardType::HARDWARE_KEYBOARD );
230 * Called when an IMF delete surrounding event is received.
231 * Here we tell the application that it should delete a certain range.
233 void ImfDeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info )
237 ImfManagerEcoreWl* imfManager = reinterpret_cast< ImfManagerEcoreWl* > ( data );
238 imfManager->DeleteSurrounding( data, imfContext, event_info );
243 * Called when the input method sends a private command.
245 void PrivateCommand( void *data, Ecore_IMF_Context *imfContext, void *event_info )
249 ImfManagerEcoreWl* imfManager = reinterpret_cast< ImfManagerEcoreWl* > ( data );
250 imfManager->SendPrivateCommand( data, imfContext, event_info );
256 return ImfManagerEcoreWl::Get();
259 TypeRegistration IMF_MANAGER_TYPE( typeid(Dali::ImfManager), typeid(Dali::BaseHandle), Create );
261 } // unnamed namespace
263 bool ImfManagerEcoreWl::IsAvailable()
265 bool available( false );
267 Dali::SingletonService service( SingletonService::Get() );
270 available = service.GetSingleton( typeid( Dali::ImfManager ) );
276 Dali::ImfManager ImfManagerEcoreWl::Get()
278 Dali::ImfManager manager;
280 Dali::SingletonService service( SingletonService::Get() );
283 // Check whether the singleton is already created
284 Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::ImfManager ) );
287 // If so, downcast the handle
288 manager = Dali::ImfManager( dynamic_cast< ImfManager* >( handle.GetObjectPtr() ) );
290 else if ( Adaptor::IsAvailable() )
292 // Create instance and register singleton only if the adaptor is available
294 Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
295 Any nativeWindow = adaptorImpl.GetNativeWindowHandle();
297 // The Ecore_Wl2_Window needs to use the ImfManager.
298 // Only when the render surface is window, we can get the Ecore_Wl2_Window.
299 Ecore_Wl2_Window *ecoreWwin( AnyCast< Ecore_Wl2_Window* >( nativeWindow ) );
302 // If we fail to get Ecore_Wl2_Window, we can't use the ImfManager correctly.
303 // Thus you have to call "ecore_imf_context_client_window_set" somewhere.
304 // In EvasPlugIn, this function is called in EvasPlugin::ConnectEcoreEvent().
306 manager = Dali::ImfManager( new ImfManagerEcoreWl( ecoreWwin ) );
307 service.Register( typeid( manager ), manager );
311 DALI_LOG_ERROR("Failed to get native window handle\n");
319 ImfManagerEcoreWl::ImfManagerEcoreWl( Ecore_Wl2_Window *ecoreWlwin )
321 mIMFCursorPosition( 0 ),
323 mRestoreAfterFocusLost( false ),
324 mIdleCallbackConnected( false )
327 CreateContext( ecoreWlwin );
332 ImfManagerEcoreWl::~ImfManagerEcoreWl()
334 DisconnectCallbacks();
337 ecore_imf_shutdown();
340 void ImfManagerEcoreWl::CreateContext( Ecore_Wl2_Window *ecoreWlwin )
342 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::CreateContext\n" );
344 const char *contextId = ecore_imf_context_default_id_get();
347 mIMFContext = ecore_imf_context_add( contextId );
353 ecore_imf_context_client_window_set( mIMFContext,
354 reinterpret_cast<void*>( ecore_wl2_window_id_get(ecoreWlwin)) );
359 DALI_LOG_WARNING("IMF Unable to get IMF Context\n");
364 DALI_LOG_WARNING("IMF Unable to get IMF Context\n");
368 void ImfManagerEcoreWl::DeleteContext()
370 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::DeleteContext\n" );
374 ecore_imf_context_del( mIMFContext );
379 // Callbacks for predicitive text support.
380 void ImfManagerEcoreWl::ConnectCallbacks()
384 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::ConnectCallbacks\n" );
386 ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, PreEdit, this );
387 ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_COMMIT, Commit, this );
388 ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding, this );
389 ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_PRIVATE_COMMAND_SEND, PrivateCommand, this );
391 ecore_imf_context_input_panel_event_callback_add( mIMFContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, InputPanelStateChangeCallback, this );
392 ecore_imf_context_input_panel_event_callback_add( mIMFContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, InputPanelLanguageChangeCallback, this );
393 ecore_imf_context_input_panel_event_callback_add( mIMFContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, InputPanelGeometryChangedCallback, this );
394 ecore_imf_context_input_panel_event_callback_add( mIMFContext, ECORE_IMF_INPUT_PANEL_KEYBOARD_MODE_EVENT, InputPanelKeyboardTypeChangedCallback, this );
396 ecore_imf_context_retrieve_surrounding_callback_set( mIMFContext, ImfRetrieveSurrounding, this);
400 void ImfManagerEcoreWl::DisconnectCallbacks()
404 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::DisconnectCallbacks\n" );
406 ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, PreEdit );
407 ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_COMMIT, Commit );
408 ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding );
409 ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_PRIVATE_COMMAND_SEND, PrivateCommand );
411 ecore_imf_context_input_panel_event_callback_del( mIMFContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, InputPanelStateChangeCallback );
412 ecore_imf_context_input_panel_event_callback_del( mIMFContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, InputPanelLanguageChangeCallback );
413 ecore_imf_context_input_panel_event_callback_del( mIMFContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, InputPanelGeometryChangedCallback );
414 ecore_imf_context_input_panel_event_callback_del( mIMFContext, ECORE_IMF_INPUT_PANEL_KEYBOARD_MODE_EVENT, InputPanelKeyboardTypeChangedCallback );
416 // We do not need to unset the retrieve surrounding callback.
420 void ImfManagerEcoreWl::Activate()
422 // Reset mIdleCallbackConnected
423 mIdleCallbackConnected = false;
427 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::Activate\n" );
429 ecore_imf_context_focus_in( mIMFContext );
431 // emit keyboard activated signal
432 Dali::ImfManager handle( this );
433 mActivatedSignal.Emit( handle );
437 void ImfManagerEcoreWl::Deactivate()
441 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::Deactivate\n" );
444 ecore_imf_context_focus_out( mIMFContext );
447 // Reset mIdleCallbackConnected
448 mIdleCallbackConnected = false;
451 void ImfManagerEcoreWl::Reset()
453 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::Reset\n" );
457 ecore_imf_context_reset( mIMFContext );
461 ImfContext* ImfManagerEcoreWl::GetContext()
463 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetContext\n" );
465 return reinterpret_cast<ImfContext*>(mIMFContext);
468 bool ImfManagerEcoreWl::RestoreAfterFocusLost() const
470 return mRestoreAfterFocusLost;
473 void ImfManagerEcoreWl::SetRestoreAfterFocusLost( bool toggle )
475 mRestoreAfterFocusLost = toggle;
479 * Called when an IMF Pre-Edit changed event is received.
480 * We are still predicting what the user is typing. The latest string is what the IMF module thinks
481 * the user wants to type.
483 void ImfManagerEcoreWl::PreEditChanged( void*, Ecore_IMF_Context* imfContext, void* event_info )
485 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::PreEditChanged\n" );
487 char* preEditString( NULL );
488 int cursorPosition( 0 );
489 Eina_List* attrs = NULL;
492 Ecore_IMF_Preedit_Attr* attr;
494 // Retrieves attributes as well as the string the cursor position offset from start of pre-edit string.
495 // the attributes (attrs) is used in languages that use the soft arrows keys to insert characters into a current pre-edit string.
496 ecore_imf_context_preedit_string_with_attributes_get( imfContext, &preEditString, &attrs, &cursorPosition );
500 // iterate through the list of attributes getting the type, start and end position.
501 for ( l = attrs, (attr = static_cast<Ecore_IMF_Preedit_Attr*>( eina_list_data_get(l) ) ); l; l = eina_list_next(l), ( attr = static_cast<Ecore_IMF_Preedit_Attr*>( eina_list_data_get(l) ) ))
503 #ifdef DALI_PROFILE_UBUNTU
504 if ( attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB3 ) // (Ecore_IMF)
505 #else // DALI_PROFILE_UBUNTU
506 if ( attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB4 ) // (Ecore_IMF)
507 #endif // DALI_PROFILE_UBUNTU
509 // check first byte so know how many bytes a character is represented by as keyboard returns cursor position in bytes. Which is different for some languages.
511 size_t visualCharacterIndex = 0;
512 size_t byteIndex = 0;
514 // iterate through null terminated string checking each character's position against the given byte position ( attr->end_index ).
515 const char leadByte = preEditString[byteIndex];
516 while( leadByte != '\0' )
518 // attr->end_index is provided as a byte position not character and we need to know the character position.
519 const size_t currentSequenceLength = Utf8SequenceLength( leadByte ); // returns number of bytes used to represent character.
520 if ( byteIndex == attr->end_index )
522 cursorPosition = visualCharacterIndex;
524 // end loop as found cursor position that matches byte position
528 byteIndex += currentSequenceLength; // jump to next character
529 visualCharacterIndex++; // increment character count so we know our position for when we get a match
532 DALI_ASSERT_DEBUG( visualCharacterIndex < strlen( preEditString ));
538 if ( Dali::Adaptor::IsAvailable() )
540 Dali::ImfManager handle( this );
541 Dali::ImfManager::ImfEventData imfEventData( Dali::ImfManager::PREEDIT, preEditString, cursorPosition, 0 );
542 Dali::ImfManager::ImfCallbackData callbackData = mEventSignal.Emit( handle, imfEventData );
544 if ( callbackData.update )
546 SetCursorPosition( callbackData.cursorPosition );
547 SetSurroundingText( callbackData.currentText );
549 NotifyCursorPosition();
552 if ( callbackData.preeditResetRequired )
557 free( preEditString );
560 void ImfManagerEcoreWl::CommitReceived( void*, Ecore_IMF_Context* imfContext, void* event_info )
562 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::CommitReceived\n" );
564 if ( Dali::Adaptor::IsAvailable() )
566 const std::string keyString( static_cast<char*>( event_info ) );
568 Dali::ImfManager handle( this );
569 Dali::ImfManager::ImfEventData imfEventData( Dali::ImfManager::COMMIT, keyString, 0, 0 );
570 Dali::ImfManager::ImfCallbackData callbackData = mEventSignal.Emit( handle, imfEventData );
572 if( callbackData.update )
574 SetCursorPosition( callbackData.cursorPosition );
575 SetSurroundingText( callbackData.currentText );
577 NotifyCursorPosition();
583 * Called when an IMF retrieve surround event is received.
584 * Here the IMF module wishes to know the string we are working with and where within the string the cursor is
585 * We need to signal the application to tell us this information.
587 Eina_Bool ImfManagerEcoreWl::RetrieveSurrounding( void* data, Ecore_IMF_Context* imfContext, char** text, int* cursorPosition )
589 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::RetrieveSurrounding\n" );
591 Dali::ImfManager::ImfEventData imfData( Dali::ImfManager::GETSURROUNDING, std::string(), 0, 0 );
592 Dali::ImfManager handle( this );
593 Dali::ImfManager::ImfCallbackData callbackData = mEventSignal.Emit( handle, imfData );
595 if( callbackData.update )
599 // The memory allocated by strdup() can be freed by ecore_imf_context_surrounding_get() internally.
600 *text = strdup( callbackData.currentText.c_str() );
605 mIMFCursorPosition = static_cast<int>( callbackData.cursorPosition );
606 *cursorPosition = mIMFCursorPosition;
614 * Called when an IMF delete surrounding event is received.
615 * Here we tell the application that it should delete a certain range.
617 void ImfManagerEcoreWl::DeleteSurrounding( void* data, Ecore_IMF_Context* imfContext, void* event_info )
619 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::DeleteSurrounding\n" );
621 if( Dali::Adaptor::IsAvailable() )
623 Ecore_IMF_Event_Delete_Surrounding* deleteSurroundingEvent = static_cast<Ecore_IMF_Event_Delete_Surrounding*>( event_info );
625 Dali::ImfManager::ImfEventData imfData( Dali::ImfManager::DELETESURROUNDING, std::string(), deleteSurroundingEvent->offset, deleteSurroundingEvent->n_chars );
626 Dali::ImfManager handle( this );
627 mEventSignal.Emit( handle, imfData );
632 * Called when the input method sends a private command.
634 void ImfManagerEcoreWl::SendPrivateCommand( void* data, Ecore_IMF_Context* imfContext, void* event_info )
636 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::SendPrivateCommand\n" );
638 if( Dali::Adaptor::IsAvailable() )
640 const char* privateCommandSendEvent = static_cast<const char*>( event_info );
642 Dali::ImfManager::ImfEventData imfData( Dali::ImfManager::PRIVATECOMMAND, privateCommandSendEvent, 0, 0 );
643 Dali::ImfManager handle( this );
644 mEventSignal.Emit( handle, imfData );
648 void ImfManagerEcoreWl::NotifyCursorPosition()
650 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::NotifyCursorPosition\n" );
654 ecore_imf_context_cursor_position_set( mIMFContext, mIMFCursorPosition );
658 void ImfManagerEcoreWl::SetCursorPosition( unsigned int cursorPosition )
660 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::SetCursorPosition\n" );
662 mIMFCursorPosition = static_cast<int>( cursorPosition );
665 unsigned int ImfManagerEcoreWl::GetCursorPosition() const
667 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetCursorPosition\n" );
669 return static_cast<unsigned int>( mIMFCursorPosition );
672 void ImfManagerEcoreWl::SetSurroundingText( const std::string& text )
674 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::SetSurroundingText\n" );
676 mSurroundingText = text;
679 const std::string& ImfManagerEcoreWl::GetSurroundingText() const
681 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetSurroundingText\n" );
683 return mSurroundingText;
686 void ImfManagerEcoreWl::NotifyTextInputMultiLine( bool multiLine )
688 Ecore_IMF_Input_Hints currentHint = ecore_imf_context_input_hint_get(mIMFContext);
689 ecore_imf_context_input_hint_set( mIMFContext,
690 static_cast< Ecore_IMF_Input_Hints >( multiLine ?
691 (currentHint | ECORE_IMF_INPUT_HINT_MULTILINE) :
692 (currentHint & ~ECORE_IMF_INPUT_HINT_MULTILINE)));
695 Dali::ImfManager::TextDirection ImfManagerEcoreWl::GetTextDirection()
697 Dali::ImfManager::TextDirection direction ( Dali::ImfManager::LeftToRight );
699 if ( ImfManager::IsAvailable() /* We do not want to create an instance of ImfManager */ )
703 char* locale( NULL );
704 ecore_imf_context_input_panel_language_locale_get( mIMFContext, &locale );
708 direction = static_cast< Dali::ImfManager::TextDirection >( Locale::GetDirection( std::string( locale ) ) );
716 Rect<int> ImfManagerEcoreWl::GetInputMethodArea()
718 int xPos, yPos, width, height;
720 width = height = xPos = yPos = 0;
724 ecore_imf_context_input_panel_geometry_get( mIMFContext, &xPos, &yPos, &width, &height );
728 DALI_LOG_WARNING("VKB Unable to get IMF Context so GetSize unavailable\n");
729 // return 0 as real size unknown.
732 return Rect<int>(xPos,yPos,width,height);
735 void ImfManagerEcoreWl::ApplyOptions( const InputMethodOptions& options )
737 using namespace Dali::InputMethod::Category;
741 if (mIMFContext == NULL)
743 DALI_LOG_WARNING("VKB Unable to excute ApplyOptions with Null ImfContext\n");
747 if ( mOptions.CompareAndSet(PANEL_LAYOUT, options, index) )
749 ecore_imf_context_input_panel_layout_set( mIMFContext, panelLayoutMap[index] );
751 if ( mOptions.CompareAndSet(AUTO_CAPITALISE, options, index) )
753 ecore_imf_context_autocapital_type_set( mIMFContext, autoCapitalMap[index] );
755 if ( mOptions.CompareAndSet(ACTION_BUTTON_TITLE, options, index) )
757 ecore_imf_context_input_panel_return_key_type_set( mIMFContext, returnKeyTypeMap[index] );
759 if ( mOptions.CompareAndSet(VARIATION, options, index) )
761 ecore_imf_context_input_panel_layout_variation_set( mIMFContext, index );
765 void ImfManagerEcoreWl::SetInputPanelData( const std::string& data )
767 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::SetInputPanelData\n" );
771 int length = data.length();
772 ecore_imf_context_input_panel_imdata_set( mIMFContext, data.c_str(), length );
776 void ImfManagerEcoreWl::GetInputPanelData( std::string& data )
778 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetInputPanelData\n" );
782 int length = 4096; // The max length is 4096 bytes
783 Dali::Vector< char > buffer;
784 buffer.Resize( length );
785 ecore_imf_context_input_panel_imdata_get( mIMFContext, &buffer[0], &length );
786 data = std::string( buffer.Begin(), buffer.End() );
790 Dali::ImfManager::State ImfManagerEcoreWl::GetInputPanelState()
792 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetInputPanelState\n" );
797 value = ecore_imf_context_input_panel_state_get( mIMFContext );
801 case ECORE_IMF_INPUT_PANEL_STATE_SHOW:
803 return Dali::ImfManager::SHOW;
807 case ECORE_IMF_INPUT_PANEL_STATE_HIDE:
809 return Dali::ImfManager::HIDE;
813 case ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW:
815 return Dali::ImfManager::WILL_SHOW;
821 return Dali::ImfManager::DEFAULT;
825 return Dali::ImfManager::DEFAULT;
828 void ImfManagerEcoreWl::SetReturnKeyState( bool visible )
830 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::SetReturnKeyState\n" );
834 ecore_imf_context_input_panel_return_key_disabled_set( mIMFContext, !visible );
838 void ImfManagerEcoreWl::AutoEnableInputPanel( bool enabled )
840 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::AutoEnableInputPanel\n" );
844 ecore_imf_context_input_panel_enabled_set( mIMFContext, enabled );
848 void ImfManagerEcoreWl::ShowInputPanel()
850 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::ShowInputPanel\n" );
854 ecore_imf_context_input_panel_show( mIMFContext );
858 void ImfManagerEcoreWl::HideInputPanel()
860 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::HideInputPanel\n" );
864 ecore_imf_context_input_panel_hide( mIMFContext );
868 Dali::ImfManager::KeyboardType ImfManagerEcoreWl::GetKeyboardType()
870 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetKeyboardType\n" );
872 #ifdef OVER_TIZEN_VERSION_4
876 value = ecore_imf_context_keyboard_mode_get( mIMFContext );
880 case ECORE_IMF_INPUT_PANEL_SW_KEYBOARD_MODE:
882 return Dali::ImfManager::SOFTWARE_KEYBOARD;
885 case ECORE_IMF_INPUT_PANEL_HW_KEYBOARD_MODE:
887 return Dali::ImfManager::HARDWARE_KEYBOARD;
892 #endif // OVER_TIZEN_VERSION_4
893 return Dali::ImfManager::KeyboardType::SOFTWARE_KEYBOARD;
896 std::string ImfManagerEcoreWl::GetInputPanelLocale()
898 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetInputPanelLocale\n" );
900 std::string locale = "";
905 ecore_imf_context_input_panel_language_locale_get( mIMFContext, &value );
909 std::string valueCopy( value );
912 // The locale string retrieved must be freed with free().
925 #pragma GCC diagnostic pop