From b6cd3ee5308ae619b6cf779f0ac6d6567236e7f9 Mon Sep 17 00:00:00 2001 From: Yunchan Cho Date: Wed, 5 Dec 2012 14:26:07 +0900 Subject: [PATCH] Fix firing serveral times of ime js event when ime shows or hides [Issue#] N/A [Bug] ime js event is fired several times when ime shows or hides [Cause] "inputmethod,changed" webview smart event is fired serveral time when ime show or hides [Solution] "inputmethod,changed" event is used just for getting width/height of ime, and wrt fires once ime js event to web contents when "editorclient,ime,opened" event is emitted by webkit Change-Id: I1ddc353297513bd4004d4b9bbccfc1eab44e3f8f --- src/view/webkit/view_logic.cpp | 49 ++++++++++++++++++++++++++++-------------- src/view/webkit/view_logic.h | 12 ++++++++--- 2 files changed, 42 insertions(+), 19 deletions(-) diff --git a/src/view/webkit/view_logic.cpp b/src/view/webkit/view_logic.cpp index 9a8f331..2712554 100644 --- a/src/view/webkit/view_logic.cpp +++ b/src/view/webkit/view_logic.cpp @@ -114,6 +114,7 @@ const char * const EWK_FULLSCREEN_EXIT = "fullscreen,exitfullscreen"; // IME Callback const char * const EWK_INPUTMETHOD_CHANGED = "inputmethod,changed"; +const char * const EWK_EDITORCLIENT_IME_OPENED = "editorclient,ime,opened"; const char * const EWK_EDITORCLIENT_IME_CLOSED = "editorclient,ime,closed"; // Custom handlers @@ -652,12 +653,12 @@ void ViewLogic::ewkClientInit(Evas_Object *wkView) { this); - // when ime start to be showed on the webview, - // this callback will be called + // when ime start to be showed on the webview, + // this callback will be called evas_object_smart_callback_add( wkView, EWK_INPUTMETHOD_CHANGED, - imeOpenCallback, + imeChangedCallback, this); // this callback will be called @@ -666,18 +667,18 @@ void ViewLogic::ewkClientInit(Evas_Object *wkView) { // if web content should know size of ime, // use "inputmethod,changed" instead of this. // - //evas_object_smart_callback_add( - // wkView, - // "editorclient,ime,opened", - // imeSomethingCallback, - // this); + evas_object_smart_callback_add( + wkView, + EWK_EDITORCLIENT_IME_OPENED, + imeOpenedCallback, + this); // when ime finished to be hidden, // this callback will be called evas_object_smart_callback_add( wkView, EWK_EDITORCLIENT_IME_CLOSED, - imeCloseCallback, + imeClosedCallback, this); // custom content/scheme handlers @@ -825,15 +826,19 @@ void ViewLogic::ewkClientDeinit(Evas_Object *wkView) { NULL, NULL); - // ime show/hide callback + // ime change/show/hide callback evas_object_smart_callback_del( wkView, EWK_INPUTMETHOD_CHANGED, - imeOpenCallback); + imeChangedCallback); + evas_object_smart_callback_del( + wkView, + EWK_EDITORCLIENT_IME_OPENED, + imeOpenedCallback); evas_object_smart_callback_del( wkView, EWK_EDITORCLIENT_IME_CLOSED, - imeCloseCallback); + imeClosedCallback); // custom content/scheme handlers evas_object_smart_callback_del( @@ -1629,7 +1634,7 @@ void ViewLogic::exitFullscreenCallback( } } -void ViewLogic::imeOpenCallback( +void ViewLogic::imeChangedCallback( void* data, Evas_Object* /*obj*/, void* eventInfo) @@ -1639,18 +1644,30 @@ void ViewLogic::imeOpenCallback( Assert(eventInfo); ViewLogic* This = static_cast(data); Eina_Rectangle *rect = static_cast(eventInfo); + This->m_imeWidth = rect->w; + This->m_imeHeight = rect->h; +} + +void ViewLogic::imeOpenedCallback( + void* data, + Evas_Object* /*obj*/, + void* /*eventInfo*/) +{ + LogDebug("enter"); + Assert(data); + ViewLogic* This = static_cast(data); using namespace WrtPlugins::W3C; SoftKeyboardChangeArgs args; args.state = IME_STATE_ON; - args.width = rect->w; - args.height = rect->h; + args.width = This->m_imeWidth; + args.height = This->m_imeHeight; This->fireJavascriptEvent( static_cast(SoftKeyboardChangeCustomEvent), &args); } -void ViewLogic::imeCloseCallback( +void ViewLogic::imeClosedCallback( void* data, Evas_Object* /*obj*/, void* /*eventInfo*/) diff --git a/src/view/webkit/view_logic.h b/src/view/webkit/view_logic.h index b48e524..bf7f7af 100644 --- a/src/view/webkit/view_logic.h +++ b/src/view/webkit/view_logic.h @@ -205,12 +205,16 @@ class ViewLogic : public ViewModule::IViewModule Evas_Object* obj, void* eventInfo); - // EWK IME Show/Hide Callback - static void imeOpenCallback( + // EWK IME Change/Show/Hide Callback + static void imeChangedCallback( void* data, Evas_Object* obj, void* eventInfo); - static void imeCloseCallback( + static void imeOpenedCallback( + void* data, + Evas_Object* obj, + void* eventInfo); + static void imeClosedCallback( void* data, Evas_Object* obj, void* eventInfo); @@ -287,6 +291,8 @@ class ViewLogic : public ViewModule::IViewModule std::string m_theme; std::string m_startUrl; WRT::UserDelegatesPtr m_cbs; + size_t m_imeWidth; + size_t m_imeHeight; std::unique_ptr m_schemeSupport; std::unique_ptr m_appsSupport; -- 2.7.4