2 * Copyright (c) 2018 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/imf-manager-impl-ecore-wl.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/window-render-surface-ecore-wl.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
293 Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
294 Any nativeWindow = adaptorImpl.GetNativeWindowHandle();
296 // The Ecore_Wl_Window needs to use the ImfManager.
297 // Only when the render surface is window, we can get the Ecore_Wl_Window.
298 Ecore_Wl_Window *ecoreWwin( AnyCast< Ecore_Wl_Window* >( nativeWindow ) );
301 // If we fail to get Ecore_Wl_Window, we can't use the ImfManager correctly.
302 // Thus you have to call "ecore_imf_context_client_window_set" somewhere.
303 // In EvasPlugIn, this function is called in EvasPlugin::ConnectEcoreEvent().
305 manager = Dali::ImfManager( new ImfManagerEcoreWl( ecoreWwin ) );
306 service.Register( typeid( manager ), manager );
310 DALI_LOG_ERROR("Failed to get native window handle\n");
318 ImfManagerEcoreWl::ImfManagerEcoreWl( Ecore_Wl_Window *ecoreWlwin )
320 mIMFCursorPosition( 0 ),
322 mRestoreAfterFocusLost( false ),
323 mIdleCallbackConnected( false )
326 CreateContext( ecoreWlwin );
331 ImfManagerEcoreWl::~ImfManagerEcoreWl()
334 ecore_imf_shutdown();
337 void ImfManagerEcoreWl::Finalize()
339 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::Finalize\n" );
340 DisconnectCallbacks();
344 void ImfManagerEcoreWl::CreateContext( Ecore_Wl_Window *ecoreWlwin )
346 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::CreateContext\n" );
348 const char *contextId = ecore_imf_context_default_id_get();
351 mIMFContext = ecore_imf_context_add( contextId );
357 ecore_imf_context_client_window_set( mIMFContext,
358 reinterpret_cast<void*>( ecore_wl_window_id_get(ecoreWlwin)) );
363 DALI_LOG_WARNING("IMF Unable to get IMF Context\n");
368 DALI_LOG_WARNING("IMF Unable to get IMF Context\n");
372 void ImfManagerEcoreWl::DeleteContext()
374 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::DeleteContext\n" );
378 ecore_imf_context_del( mIMFContext );
383 // Callbacks for predicitive text support.
384 void ImfManagerEcoreWl::ConnectCallbacks()
388 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::ConnectCallbacks\n" );
390 ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, PreEdit, this );
391 ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_COMMIT, Commit, this );
392 ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding, this );
393 ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_PRIVATE_COMMAND_SEND, PrivateCommand, this );
395 ecore_imf_context_input_panel_event_callback_add( mIMFContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, InputPanelStateChangeCallback, this );
396 ecore_imf_context_input_panel_event_callback_add( mIMFContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, InputPanelLanguageChangeCallback, this );
397 ecore_imf_context_input_panel_event_callback_add( mIMFContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, InputPanelGeometryChangedCallback, this );
398 ecore_imf_context_input_panel_event_callback_add( mIMFContext, ECORE_IMF_INPUT_PANEL_KEYBOARD_MODE_EVENT, InputPanelKeyboardTypeChangedCallback, this );
400 ecore_imf_context_retrieve_surrounding_callback_set( mIMFContext, ImfRetrieveSurrounding, this);
404 void ImfManagerEcoreWl::DisconnectCallbacks()
408 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::DisconnectCallbacks\n" );
410 ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, PreEdit );
411 ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_COMMIT, Commit );
412 ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding );
413 ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_PRIVATE_COMMAND_SEND, PrivateCommand );
415 ecore_imf_context_input_panel_event_callback_del( mIMFContext, ECORE_IMF_INPUT_PANEL_STATE_EVENT, InputPanelStateChangeCallback );
416 ecore_imf_context_input_panel_event_callback_del( mIMFContext, ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT, InputPanelLanguageChangeCallback );
417 ecore_imf_context_input_panel_event_callback_del( mIMFContext, ECORE_IMF_INPUT_PANEL_GEOMETRY_EVENT, InputPanelGeometryChangedCallback );
418 ecore_imf_context_input_panel_event_callback_del( mIMFContext, ECORE_IMF_INPUT_PANEL_KEYBOARD_MODE_EVENT, InputPanelKeyboardTypeChangedCallback );
420 // We do not need to unset the retrieve surrounding callback.
424 void ImfManagerEcoreWl::Activate()
426 // Reset mIdleCallbackConnected
427 mIdleCallbackConnected = false;
431 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::Activate\n" );
433 ecore_imf_context_focus_in( mIMFContext );
435 // emit keyboard activated signal
436 Dali::ImfManager handle( this );
437 mActivatedSignal.Emit( handle );
441 void ImfManagerEcoreWl::Deactivate()
445 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::Deactivate\n" );
448 ecore_imf_context_focus_out( mIMFContext );
451 // Reset mIdleCallbackConnected
452 mIdleCallbackConnected = false;
455 void ImfManagerEcoreWl::Reset()
457 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::Reset\n" );
461 ecore_imf_context_reset( mIMFContext );
465 ImfContext* ImfManagerEcoreWl::GetContext()
467 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetContext\n" );
469 return reinterpret_cast<ImfContext*>(mIMFContext);
472 bool ImfManagerEcoreWl::RestoreAfterFocusLost() const
474 return mRestoreAfterFocusLost;
477 void ImfManagerEcoreWl::SetRestoreAfterFocusLost( bool toggle )
479 mRestoreAfterFocusLost = toggle;
483 * Called when an IMF Pre-Edit changed event is received.
484 * We are still predicting what the user is typing. The latest string is what the IMF module thinks
485 * the user wants to type.
487 void ImfManagerEcoreWl::PreEditChanged( void*, Ecore_IMF_Context* imfContext, void* event_info )
489 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::PreEditChanged\n" );
491 char* preEditString( NULL );
492 int cursorPosition( 0 );
493 Eina_List* attrs = NULL;
496 Ecore_IMF_Preedit_Attr* attr;
498 // Retrieves attributes as well as the string the cursor position offset from start of pre-edit string.
499 // the attributes (attrs) is used in languages that use the soft arrows keys to insert characters into a current pre-edit string.
500 ecore_imf_context_preedit_string_with_attributes_get( imfContext, &preEditString, &attrs, &cursorPosition );
504 // iterate through the list of attributes getting the type, start and end position.
505 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) ) ))
507 #ifdef DALI_PROFILE_UBUNTU
508 if ( attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB3 ) // (Ecore_IMF)
509 #else // DALI_PROFILE_UBUNTU
510 if ( attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB4 ) // (Ecore_IMF)
511 #endif // DALI_PROFILE_UBUNTU
513 // 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.
515 size_t visualCharacterIndex = 0;
516 size_t byteIndex = 0;
518 // iterate through null terminated string checking each character's position against the given byte position ( attr->end_index ).
519 const char leadByte = preEditString[byteIndex];
520 while( leadByte != '\0' )
522 // attr->end_index is provided as a byte position not character and we need to know the character position.
523 const size_t currentSequenceLength = Utf8SequenceLength( leadByte ); // returns number of bytes used to represent character.
524 if ( byteIndex == attr->end_index )
526 cursorPosition = visualCharacterIndex;
528 // end loop as found cursor position that matches byte position
532 byteIndex += currentSequenceLength; // jump to next character
533 visualCharacterIndex++; // increment character count so we know our position for when we get a match
536 DALI_ASSERT_DEBUG( visualCharacterIndex < strlen( preEditString ));
542 if ( Dali::Adaptor::IsAvailable() )
544 Dali::ImfManager handle( this );
545 Dali::ImfManager::ImfEventData imfEventData( Dali::ImfManager::PREEDIT, preEditString, cursorPosition, 0 );
546 Dali::ImfManager::ImfCallbackData callbackData = mEventSignal.Emit( handle, imfEventData );
548 if ( callbackData.update )
550 SetCursorPosition( callbackData.cursorPosition );
551 SetSurroundingText( callbackData.currentText );
553 NotifyCursorPosition();
556 if ( callbackData.preeditResetRequired )
561 free( preEditString );
564 void ImfManagerEcoreWl::CommitReceived( void*, Ecore_IMF_Context* imfContext, void* event_info )
566 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::CommitReceived\n" );
568 if ( Dali::Adaptor::IsAvailable() )
570 const std::string keyString( static_cast<char*>( event_info ) );
572 Dali::ImfManager handle( this );
573 Dali::ImfManager::ImfEventData imfEventData( Dali::ImfManager::COMMIT, keyString, 0, 0 );
574 Dali::ImfManager::ImfCallbackData callbackData = mEventSignal.Emit( handle, imfEventData );
576 if( callbackData.update )
578 SetCursorPosition( callbackData.cursorPosition );
579 SetSurroundingText( callbackData.currentText );
581 NotifyCursorPosition();
587 * Called when an IMF retrieve surround event is received.
588 * Here the IMF module wishes to know the string we are working with and where within the string the cursor is
589 * We need to signal the application to tell us this information.
591 Eina_Bool ImfManagerEcoreWl::RetrieveSurrounding( void* data, Ecore_IMF_Context* imfContext, char** text, int* cursorPosition )
593 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::RetrieveSurrounding\n" );
595 Dali::ImfManager::ImfEventData imfData( Dali::ImfManager::GETSURROUNDING, std::string(), 0, 0 );
596 Dali::ImfManager handle( this );
597 Dali::ImfManager::ImfCallbackData callbackData = mEventSignal.Emit( handle, imfData );
599 if( callbackData.update )
603 // The memory allocated by strdup() can be freed by ecore_imf_context_surrounding_get() internally.
604 *text = strdup( callbackData.currentText.c_str() );
609 mIMFCursorPosition = static_cast<int>( callbackData.cursorPosition );
610 *cursorPosition = mIMFCursorPosition;
618 * Called when an IMF delete surrounding event is received.
619 * Here we tell the application that it should delete a certain range.
621 void ImfManagerEcoreWl::DeleteSurrounding( void* data, Ecore_IMF_Context* imfContext, void* event_info )
623 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::DeleteSurrounding\n" );
625 if( Dali::Adaptor::IsAvailable() )
627 Ecore_IMF_Event_Delete_Surrounding* deleteSurroundingEvent = static_cast<Ecore_IMF_Event_Delete_Surrounding*>( event_info );
629 Dali::ImfManager::ImfEventData imfData( Dali::ImfManager::DELETESURROUNDING, std::string(), deleteSurroundingEvent->offset, deleteSurroundingEvent->n_chars );
630 Dali::ImfManager handle( this );
631 mEventSignal.Emit( handle, imfData );
636 * Called when the input method sends a private command.
638 void ImfManagerEcoreWl::SendPrivateCommand( void* data, Ecore_IMF_Context* imfContext, void* event_info )
640 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::SendPrivateCommand\n" );
642 if( Dali::Adaptor::IsAvailable() )
644 const char* privateCommandSendEvent = static_cast<const char*>( event_info );
646 Dali::ImfManager::ImfEventData imfData( Dali::ImfManager::PRIVATECOMMAND, privateCommandSendEvent, 0, 0 );
647 Dali::ImfManager handle( this );
648 mEventSignal.Emit( handle, imfData );
652 void ImfManagerEcoreWl::NotifyCursorPosition()
654 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::NotifyCursorPosition\n" );
658 ecore_imf_context_cursor_position_set( mIMFContext, mIMFCursorPosition );
662 void ImfManagerEcoreWl::SetCursorPosition( unsigned int cursorPosition )
664 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::SetCursorPosition\n" );
666 mIMFCursorPosition = static_cast<int>( cursorPosition );
669 unsigned int ImfManagerEcoreWl::GetCursorPosition() const
671 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetCursorPosition\n" );
673 return static_cast<unsigned int>( mIMFCursorPosition );
676 void ImfManagerEcoreWl::SetSurroundingText( const std::string& text )
678 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::SetSurroundingText\n" );
680 mSurroundingText = text;
683 const std::string& ImfManagerEcoreWl::GetSurroundingText() const
685 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetSurroundingText\n" );
687 return mSurroundingText;
690 void ImfManagerEcoreWl::NotifyTextInputMultiLine( bool multiLine )
692 Ecore_IMF_Input_Hints currentHint = ecore_imf_context_input_hint_get(mIMFContext);
693 ecore_imf_context_input_hint_set( mIMFContext,
694 static_cast< Ecore_IMF_Input_Hints >( multiLine ?
695 (currentHint | ECORE_IMF_INPUT_HINT_MULTILINE) :
696 (currentHint & ~ECORE_IMF_INPUT_HINT_MULTILINE)));
699 Dali::ImfManager::TextDirection ImfManagerEcoreWl::GetTextDirection()
701 Dali::ImfManager::TextDirection direction ( Dali::ImfManager::LeftToRight );
703 if ( ImfManager::IsAvailable() /* We do not want to create an instance of ImfManager */ )
707 char* locale( NULL );
708 ecore_imf_context_input_panel_language_locale_get( mIMFContext, &locale );
712 direction = static_cast< Dali::ImfManager::TextDirection >( Locale::GetDirection( std::string( locale ) ) );
720 Rect<int> ImfManagerEcoreWl::GetInputMethodArea()
722 int xPos, yPos, width, height;
724 width = height = xPos = yPos = 0;
728 ecore_imf_context_input_panel_geometry_get( mIMFContext, &xPos, &yPos, &width, &height );
732 DALI_LOG_WARNING("VKB Unable to get IMF Context so GetSize unavailable\n");
733 // return 0 as real size unknown.
736 return Rect<int>(xPos,yPos,width,height);
739 void ImfManagerEcoreWl::ApplyOptions( const InputMethodOptions& options )
741 using namespace Dali::InputMethod::Category;
745 if (mIMFContext == NULL)
747 DALI_LOG_WARNING("VKB Unable to excute ApplyOptions with Null ImfContext\n");
751 if ( mOptions.CompareAndSet(PANEL_LAYOUT, options, index) )
753 ecore_imf_context_input_panel_layout_set( mIMFContext, panelLayoutMap[index] );
755 if ( mOptions.CompareAndSet(AUTO_CAPITALISE, options, index) )
757 ecore_imf_context_autocapital_type_set( mIMFContext, autoCapitalMap[index] );
759 if ( mOptions.CompareAndSet(ACTION_BUTTON_TITLE, options, index) )
761 ecore_imf_context_input_panel_return_key_type_set( mIMFContext, returnKeyTypeMap[index] );
763 if ( mOptions.CompareAndSet(VARIATION, options, index) )
765 ecore_imf_context_input_panel_layout_variation_set( mIMFContext, index );
769 void ImfManagerEcoreWl::SetInputPanelData( const std::string& data )
771 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::SetInputPanelData\n" );
775 int length = data.length();
776 ecore_imf_context_input_panel_imdata_set( mIMFContext, data.c_str(), length );
780 void ImfManagerEcoreWl::GetInputPanelData( std::string& data )
782 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetInputPanelData\n" );
786 int length = 4096; // The max length is 4096 bytes
787 Dali::Vector< char > buffer;
788 buffer.Resize( length );
789 ecore_imf_context_input_panel_imdata_get( mIMFContext, &buffer[0], &length );
790 data = std::string( buffer.Begin(), buffer.End() );
794 Dali::ImfManager::State ImfManagerEcoreWl::GetInputPanelState()
796 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetInputPanelState\n" );
801 value = ecore_imf_context_input_panel_state_get( mIMFContext );
805 case ECORE_IMF_INPUT_PANEL_STATE_SHOW:
807 return Dali::ImfManager::SHOW;
811 case ECORE_IMF_INPUT_PANEL_STATE_HIDE:
813 return Dali::ImfManager::HIDE;
817 case ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW:
819 return Dali::ImfManager::WILL_SHOW;
825 return Dali::ImfManager::DEFAULT;
829 return Dali::ImfManager::DEFAULT;
832 void ImfManagerEcoreWl::SetReturnKeyState( bool visible )
834 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::SetReturnKeyState\n" );
838 ecore_imf_context_input_panel_return_key_disabled_set( mIMFContext, !visible );
842 void ImfManagerEcoreWl::AutoEnableInputPanel( bool enabled )
844 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::AutoEnableInputPanel\n" );
848 ecore_imf_context_input_panel_enabled_set( mIMFContext, enabled );
852 void ImfManagerEcoreWl::ShowInputPanel()
854 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::ShowInputPanel\n" );
858 ecore_imf_context_input_panel_show( mIMFContext );
862 void ImfManagerEcoreWl::HideInputPanel()
864 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::HideInputPanel\n" );
868 ecore_imf_context_input_panel_hide( mIMFContext );
872 Dali::ImfManager::KeyboardType ImfManagerEcoreWl::GetKeyboardType()
874 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetKeyboardType\n" );
876 #ifdef OVER_TIZEN_VERSION_4
880 value = ecore_imf_context_keyboard_mode_get( mIMFContext );
884 case ECORE_IMF_INPUT_PANEL_SW_KEYBOARD_MODE:
886 return Dali::ImfManager::SOFTWARE_KEYBOARD;
889 case ECORE_IMF_INPUT_PANEL_HW_KEYBOARD_MODE:
891 return Dali::ImfManager::HARDWARE_KEYBOARD;
896 #endif // OVER_TIZEN_VERSION_4
897 return Dali::ImfManager::KeyboardType::SOFTWARE_KEYBOARD;
900 std::string ImfManagerEcoreWl::GetInputPanelLocale()
902 DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::GetInputPanelLocale\n" );
904 std::string locale = "";
909 ecore_imf_context_input_panel_language_locale_get( mIMFContext, &value );
913 std::string valueCopy( value );
916 // The locale string retrieved must be freed with free().
929 #pragma GCC diagnostic pop