{
}
+void ImfManager::Finalize()
+{
+ Internal::Adaptor::ImfManager::GetImplementation(*this).Finalize();
+}
+
ImfManager ImfManager::Get()
{
return Internal::Adaptor::ImfManager::Get();
public:
+ /**
+ * @brief Finalize the IMF.
+ *
+ * It means that the context will be deleted.
+ */
+ void Finalize();
+
/**
* @brief Retrieve a handle to the instance of ImfManager.
* @return A handle to the ImfManager.
} // unnamed namespace
+void ImfManager::Finalize()
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::Finalize\n" );
+ if ( mInited )
+ {
+ DisconnectCallbacks();
+ DeleteContext();
+ ecore_imf_shutdown();
+ mInited = false;
+ }
+}
+
bool ImfManager::IsAvailable()
{
bool available( false );
Dali::ImfManager ImfManager::Get()
{
Dali::ImfManager manager;
+ ImfManager *imfManager = NULL;
Dali::SingletonService service( SingletonService::Get() );
if ( service )
if( handle )
{
// If so, downcast the handle
- manager = Dali::ImfManager( dynamic_cast< ImfManager* >( handle.GetObjectPtr() ) );
+ imfManager = dynamic_cast< ImfManager* >( handle.GetObjectPtr() );
+ manager = Dali::ImfManager( imfManager );
}
else if ( Adaptor::IsAvailable() )
{
// Create instance and register singleton only if the adaptor is available
-
Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) );
Any nativeWindow = adaptorImpl.GetNativeWindowHandle();
// If we fail to get Ecore_Wl_Window, we can't use the ImfManager correctly.
// Thus you have to call "ecore_imf_context_client_window_set" somewhere.
// In EvasPlugIn, this function is called in EvasPlugin::ConnectEcoreEvent().
-
- manager = Dali::ImfManager( new ImfManager( ecoreWwin ) );
+ imfManager = new ImfManager( ecoreWwin );
+ manager = Dali::ImfManager( imfManager );
service.Register( typeid( manager ), manager );
}
else
}
}
+ if ( ( imfManager != NULL ) && !imfManager->mInited )
+ {
+ ecore_imf_init();
+ imfManager->CreateContext( imfManager->mEcoreWlwin );
+
+ imfManager->ConnectCallbacks();
+ imfManager->mInited = true;
+ }
+
return manager;
}
ImfManager::ImfManager( Ecore_Wl_Window *ecoreWlwin )
: mIMFContext(),
+ mEcoreWlwin( ecoreWlwin ),
mIMFCursorPosition( 0 ),
mSurroundingText(),
+ mInited( false ),
mRestoreAfterFocusLost( false ),
mIdleCallbackConnected( false )
{
- ecore_imf_init();
- CreateContext( ecoreWlwin );
-
- ConnectCallbacks();
}
ImfManager::~ImfManager()
{
- DisconnectCallbacks();
-
- DeleteContext();
- ecore_imf_shutdown();
+ Finalize();
}
-
void ImfManager::CreateContext( Ecore_Wl_Window *ecoreWlwin )
{
DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::CreateContext\n" );
-
const char *contextId = ecore_imf_context_default_id_get();
if( contextId )
{
public:
+ /**
+ * @copydoc Dali::ImfManager::Finalize()
+ */
+ void Finalize();
+
/**
* Check whether the ImfManager is available.
* @return true if available, false otherwise
private:
Ecore_IMF_Context* mIMFContext;
+ Ecore_Wl_Window *mEcoreWlwin;
int mIMFCursorPosition;
std::string mSurroundingText;
+ bool mInited:1; ///< Whether the imf is already inited.
bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
public:
+ /**
+ * @copydoc Dali::ImfManager::Finalize()
+ */
+ void Finalize();
+
/**
* Check whether the ImfManager is available.
* @return true if available, false otherwise
* Constructor
* @param[in] ecoreXwin, The window is created by application.
*/
- ImfManager( Ecore_X_Window ecoreXwin );
+ ImfManager( Ecore_X_Window* ecoreXwin );
/**
* Connect Callbacks required for IMF.
* Context created the first time and kept until deleted.
* @param[in] ecoreXwin, The window is created by application.
*/
- void CreateContext( Ecore_X_Window ecoreXwin );
+ void CreateContext( Ecore_X_Window* ecoreXwin );
/**
* @copydoc Dali::ImfManager::DeleteContext()
private:
Ecore_IMF_Context* mIMFContext;
+ Ecore_X_Window* mEcoreXWin;
int mIMFCursorPosition;
std::string mSurroundingText;
+ bool mInited:1; ///< Whether the imf is already inited.
bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
InputMethodOptions mOptions;
TypeRegistration IMF_MANAGER_TYPE( typeid(Dali::ImfManager), typeid(Dali::BaseHandle), Create );
+}
+void ImfManager::Finalize()
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::Finalize\n" );
+ if ( mInited )
+ {
+ DisconnectCallbacks();
+ mInited = false;
+ }
}
+
bool ImfManager::IsAvailable()
{
bool available( false );
Dali::ImfManager ImfManager::Get()
{
Dali::ImfManager manager;
+ ImfManager *imfManager = NULL;
Dali::SingletonService service( SingletonService::Get() );
if (! service )
if( handle )
{
// If so, downcast the handle
- manager = Dali::ImfManager( dynamic_cast< ImfManager* >( handle.GetObjectPtr() ) );
+ imfManager = dynamic_cast< ImfManager* >( handle.GetObjectPtr() );
+ manager = Dali::ImfManager( imfManager );
}
else if ( Adaptor::IsAvailable() )
{
// Create instance and register singleton only if the adaptor is available
- manager = Dali::ImfManager( new ImfManager() );
+ imfManager = new ImfManager();
+ manager = Dali::ImfManager( imfManager );
service.Register( typeid( manager ), manager );
}
else
{
DALI_LOG_ERROR("Failed to get native window handle\n");
}
+
+ if ( ( imfManager != NULL ) && !imfManager->mInited )
+ {
+ imfManager->ConnectCallbacks();
+ imfManager->mInited = true;
+ }
+
return manager;
}
+
ImfManager::ImfManager()
: mTextInputManager( TextInputManager::Get() ),
mPreEditCursorPosition( 0 ),
mEditCursorPosition( 0 ),
+ mInited( false ),
mRestoreAfterFocusLost( false )
{
- ConnectCallbacks();
}
+
ImfManager::~ImfManager()
{
- DisconnectCallbacks();
+ Finalize();
}
void ImfManager::ConnectCallbacks()
typedef Dali::ImfManager::KeyboardTypeSignalType ImfKeyboardTypeSignalType;
public:
+ /**
+ * @copydoc Dali::ImfManager::Finalize()
+ */
+ void Finalize();
/**
* @brief Check whether the ImfManager is available.
std::string mSurroundingText;
int mPreEditCursorPosition;
int mEditCursorPosition;
+ bool mInited:1; ///< Whether the imf is already inited.
bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
public:
} // unnamed namespace
+void ImfManager::Finalize()
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::Finalize\n" );
+ if ( mInited )
+ {
+ VirtualKeyboard::DisconnectCallbacks( mIMFContext );
+ DisconnectCallbacks();
+ DeleteContext();
+ ecore_imf_shutdown();
+ mInited = false;
+ }
+}
+
bool ImfManager::IsAvailable()
{
bool available( false );
Dali::ImfManager ImfManager::Get()
{
Dali::ImfManager manager;
+ ImfManager *imfManager = NULL;
Dali::SingletonService service( SingletonService::Get() );
if ( service )
if( handle )
{
// If so, downcast the handle
- manager = Dali::ImfManager( dynamic_cast< ImfManager* >( handle.GetObjectPtr() ) );
+ imfManager = dynamic_cast< ImfManager* >( handle.GetObjectPtr() );
+ manager = Dali::ImfManager( imfManager );
}
else if ( Adaptor::IsAvailable() )
{
// The Ecore_X_Window needs to use the ImfManager.
// Only when the render surface is window, we can get the Ecore_X_Window.
- Ecore_X_Window ecoreXwin( AnyCast<Ecore_X_Window>(nativeWindow) );
- if (ecoreXwin)
+ Ecore_X_Window *ecoreXwin( AnyCast< Ecore_X_Window* >( nativeWindow ) );
+ if ( ecoreXwin )
{
// If we fail to get Ecore_X_Window, we can't use the ImfManager correctly.
// Thus you have to call "ecore_imf_context_client_window_set" somewhere.
// In EvasPlugIn, this function is called in EvasPlugin::ConnectEcoreEvent().
-
- manager = Dali::ImfManager( new ImfManager( ecoreXwin ) );
+ imfManager = new ImfManager( ecoreXwin );
+ manager = Dali::ImfManager( imfManager );
service.Register( typeid( manager ), manager );
}
else
}
}
+ if ( ( imfManager != NULL ) !imfManager->mInited )
+ {
+ ecore_imf_init();
+ imfManager->CreateContext( imfManager->mEcoreXWin );
+
+ imfManager->ConnectCallbacks();
+ VirtualKeyboard::ConnectCallbacks( mIMFContext );
+ imfManager->mInited = true;
+ }
+
return manager;
}
-ImfManager::ImfManager( Ecore_X_Window ecoreXwin )
+ImfManager::ImfManager( Ecore_X_Window* ecoreXwin )
: mIMFContext(),
+ mEcoreXWin( ecoreXwin ),
mIMFCursorPosition( 0 ),
mSurroundingText(),
+ mInited( false ),
mRestoreAfterFocusLost( false ),
mIdleCallbackConnected( false )
{
- ecore_imf_init();
- CreateContext( ecoreXwin );
-
- ConnectCallbacks();
- VirtualKeyboard::ConnectCallbacks( mIMFContext );
}
ImfManager::~ImfManager()
{
- VirtualKeyboard::DisconnectCallbacks( mIMFContext );
- DisconnectCallbacks();
-
- DeleteContext();
- ecore_imf_shutdown();
+ Finalize();
}
-void ImfManager::CreateContext( Ecore_X_Window ecoreXwin )
+void ImfManager::CreateContext( Ecore_X_Window* ecoreXwin )
{
DALI_LOG_INFO( gLogFilter, Debug::General, "ImfManager::CreateContext\n" );