X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Finput%2Ftizen-wayland%2Finput-method-context-impl-ecore-wl.cpp;h=34255a55329f8f28f517d585a933c31affb7c9fc;hb=e8e185f7d90010214890c2cb78bdd52c732f63ba;hp=b4f71ea87b3d0c553ff64049b060515af37f7f8c;hpb=3c06904e3aae57e60b48817bece534e44ac3cf8c;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.cpp b/dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.cpp index b4f71ea..34255a5 100755 --- a/dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.cpp +++ b/dali/internal/input/tizen-wayland/input-method-context-impl-ecore-wl.cpp @@ -23,8 +23,8 @@ #include // EXTERNAL INCLUDES -#include #include + #include #include #include @@ -33,10 +33,10 @@ // INTERNAL INCLUDES #include #include -#include #include #include #include +#include #define TOKEN_STRING(x) #x @@ -265,21 +265,17 @@ Dali::TypeRegistration type( typeid(Dali::InputMethodContext), typeid(Dali::Base InputMethodContextPtr InputMethodContextEcoreWl::New() { InputMethodContextPtr inputMethodContext; - if ( Adaptor::IsAvailable() ) + + // Create instance only if the adaptor is available + if ( Dali::Adaptor::IsAvailable() ) { - // Create instance only if the adaptor is available - Adaptor &adaptorImpl(Adaptor::GetImplementation(Adaptor::Get())); - Any nativeWindow = adaptorImpl.GetNativeWindowHandle(); - - // The Ecore_Wl_Window needs to use the InputMethodContext. - // Only when the render surface is window, we can get the Ecore_Wl_Window. - Ecore_Wl_Window *ecoreWwin(AnyCast(nativeWindow)); - if (ecoreWwin) + Any nativeWindow = Dali::Adaptor::Get().GetNativeWindowHandle(); + + // The window needs to use the InputMethodContext. + // Only when the render surface is window, we can get the window. + if( !nativeWindow.Empty() ) { - // If we fail to get Ecore_Wl_Window, we can't use the InputMethodContext correctly. - // Thus you have to call "ecore_imf_context_client_window_set" somewhere. - // In EvasPlugIn, this function is called in EvasPlugin::ConnectEcoreEvent(). - inputMethodContext = new InputMethodContextEcoreWl(ecoreWwin); + inputMethodContext = new InputMethodContextEcoreWl(); } else { @@ -297,9 +293,8 @@ void InputMethodContextEcoreWl::Finalize() DeleteContext(); } -InputMethodContextEcoreWl::InputMethodContextEcoreWl( Ecore_Wl_Window *ecoreWlwin ) +InputMethodContextEcoreWl::InputMethodContextEcoreWl() : mIMFContext(), - mEcoreWlwin( ecoreWlwin ), mIMFCursorPosition( 0 ), mSurroundingText(), mRestoreAfterFocusLost( false ), @@ -316,11 +311,11 @@ InputMethodContextEcoreWl::~InputMethodContextEcoreWl() void InputMethodContextEcoreWl::Initialize() { - CreateContext( mEcoreWlwin ); + CreateContext(); ConnectCallbacks(); } -void InputMethodContextEcoreWl::CreateContext( Ecore_Wl_Window *ecoreWlwin ) +void InputMethodContextEcoreWl::CreateContext() { DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContext::CreateContext\n" ); @@ -331,10 +326,16 @@ void InputMethodContextEcoreWl::CreateContext( Ecore_Wl_Window *ecoreWlwin ) if( mIMFContext ) { - if( ecoreWlwin ) + // If we fail to get window id, we can't use the InputMethodContext correctly. + // Thus you have to call "ecore_imf_context_client_window_set" somewhere. + // In EvasPlugIn, this function is called in EvasPlugin::ConnectEcoreEvent(). + Dali::RenderSurfaceInterface& renderSurface = Dali::Adaptor::Get().GetSurface(); + WindowRenderSurface& windowRenderSurface = static_cast< WindowRenderSurface& >( renderSurface ); + + int windowId = windowRenderSurface.GetNativeWindowId(); + if( windowId != 0 ) { - ecore_imf_context_client_window_set( mIMFContext, - reinterpret_cast( ecore_wl_window_id_get(ecoreWlwin)) ); + ecore_imf_context_client_window_set( mIMFContext, reinterpret_cast< void* >( windowId ) ); } } else @@ -919,21 +920,48 @@ bool InputMethodContextEcoreWl::FilterEventKey( const Dali::KeyEvent& keyEvent ) return eventHandled; } +void InputMethodContextEcoreWl::AllowTextPrediction( bool prediction ) +{ + DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::AllowTextPrediction\n" ); + + if( mIMFContext ) + { + ecore_imf_context_prediction_allow_set( mIMFContext, prediction ); + } +} + +bool InputMethodContextEcoreWl::IsTextPredictionAllowed() const +{ + DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::IsTextPredictionAllowed\n" ); + bool prediction = false; + if( mIMFContext ) + { + prediction = ecore_imf_context_prediction_allow_get( mIMFContext ); + } + return prediction; +} + bool InputMethodContextEcoreWl::ProcessEventKeyDown( const KeyEvent& keyEvent ) { bool eventHandled( false ); if ( mIMFContext ) { + Integration::KeyEvent integKeyEvent( keyEvent ); + std::string key = integKeyEvent.logicalKey; + + std::string compose = keyEvent.GetCompose(); + std::string deviceName = keyEvent.GetDeviceName(); + // We're consuming key down event so we have to pass to InputMethodContext so that it can parse it as well. Ecore_IMF_Event_Key_Down ecoreKeyDownEvent; ecoreKeyDownEvent.keyname = keyEvent.keyPressedName.c_str(); - ecoreKeyDownEvent.key = keyEvent.keyPressedName.c_str(); + ecoreKeyDownEvent.key = key.c_str(); ecoreKeyDownEvent.string = keyEvent.keyPressed.c_str(); - ecoreKeyDownEvent.compose = keyEvent.GetCompose().c_str(); + ecoreKeyDownEvent.compose = compose.c_str(); ecoreKeyDownEvent.timestamp = keyEvent.time; ecoreKeyDownEvent.modifiers = EcoreInputModifierToEcoreIMFModifier( keyEvent.keyModifier ); ecoreKeyDownEvent.locks = EcoreInputModifierToEcoreIMFLock( keyEvent.keyModifier ); - ecoreKeyDownEvent.dev_name = keyEvent.GetDeviceName().c_str(); + ecoreKeyDownEvent.dev_name = deviceName.c_str(); ecoreKeyDownEvent.dev_class = static_cast ( keyEvent.GetDeviceClass() );//ECORE_IMF_DEVICE_CLASS_KEYBOARD; ecoreKeyDownEvent.dev_subclass = static_cast ( keyEvent.GetDeviceSubclass() );//ECORE_IMF_DEVICE_SUBCLASS_NONE; @@ -971,16 +999,22 @@ bool InputMethodContextEcoreWl::ProcessEventKeyUp( const KeyEvent& keyEvent ) bool eventHandled( false ); if( mIMFContext ) { + Integration::KeyEvent integKeyEvent( keyEvent ); + std::string key = integKeyEvent.logicalKey; + + std::string compose = keyEvent.GetCompose(); + std::string deviceName = keyEvent.GetDeviceName(); + // We're consuming key up event so we have to pass to InputMethodContext so that it can parse it as well. Ecore_IMF_Event_Key_Up ecoreKeyUpEvent; ecoreKeyUpEvent.keyname = keyEvent.keyPressedName.c_str(); - ecoreKeyUpEvent.key = keyEvent.keyPressedName.c_str(); + ecoreKeyUpEvent.key = key.c_str(); ecoreKeyUpEvent.string = keyEvent.keyPressed.c_str(); - ecoreKeyUpEvent.compose = keyEvent.GetCompose().c_str(); + ecoreKeyUpEvent.compose = compose.c_str(); ecoreKeyUpEvent.timestamp = keyEvent.time; ecoreKeyUpEvent.modifiers = EcoreInputModifierToEcoreIMFModifier( keyEvent.keyModifier ); ecoreKeyUpEvent.locks = EcoreInputModifierToEcoreIMFLock( keyEvent.keyModifier ); - ecoreKeyUpEvent.dev_name = keyEvent.GetDeviceName().c_str(); + ecoreKeyUpEvent.dev_name = deviceName.c_str(); ecoreKeyUpEvent.dev_class = static_cast ( keyEvent.GetDeviceClass() );//ECORE_IMF_DEVICE_CLASS_KEYBOARD; ecoreKeyUpEvent.dev_subclass = static_cast ( keyEvent.GetDeviceSubclass() );//ECORE_IMF_DEVICE_SUBCLASS_NONE;