Checking the clipboard status before appear context menu
authorTaeyun An <ty.an@samsung.com>
Mon, 1 Apr 2013 13:04:34 +0000 (22:04 +0900)
committerGerrit Code Review <gerrit2@kim11>
Thu, 4 Apr 2013 07:55:46 +0000 (16:55 +0900)
[Title] Checking the clipboard status before appear context menu
[Issue#] N_SE-29804
[Problem] Context menu options does disappear after clipboard appear
[Cause] There is appear the context menu routine after clipboard appear
[Solution] Checking clipboard status before appear context menu

Change-Id: Ib86d926733aebc1ddd985157f5d4959714d2639a

Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp
Source/WebKit2/UIProcess/API/efl/PageClientImpl.h
Source/WebKit2/UIProcess/API/efl/ewk_view.cpp
Source/WebKit2/UIProcess/API/efl/tizen/ClipboardHelper.cpp
Source/WebKit2/UIProcess/API/efl/tizen/ClipboardHelper.h
Source/WebKit2/UIProcess/efl/InputMethodContextEfl.cpp

index 11bd36e..e8d6199 100755 (executable)
@@ -1135,9 +1135,9 @@ bool PageClientImpl::isClipboardWindowOpened()
     return m_clipboardHelper->isClipboardWindowOpened();
 }
 
-void PageClientImpl::clearClipboardSelectionHandler()
+void PageClientImpl::closeClipboardWindow()
 {
-    m_clipboardHelper->clearClipboardSelectionHandler();
+    m_clipboardHelper->closeClipboardWindow();
 }
 #endif
 
index 5abbb9a..4e9e02a 100755 (executable)
@@ -237,7 +237,7 @@ public:
 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
     void clipboardContextMenuSelected();
     bool isClipboardWindowOpened();
-    void clearClipboardSelectionHandler();
+    void closeClipboardWindow();
 #endif
 
 #if ENABLE(TIZEN_DRAG_SUPPORT)
index 2f93bec..fcdcee1 100755 (executable)
@@ -315,7 +315,8 @@ static Eina_Bool _ewk_view_smart_focus_out(Ewk_View_Smart_Data* smartData)
 #endif
 
 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
-    impl->pageClient->clearClipboardSelectionHandler();
+    if (impl->pageClient->isClipboardWindowOpened())
+        impl->pageClient->closeClipboardWindow();
 #endif
 
 #if ENABLE(TIZEN_DRAG_SUPPORT)
index 2981c57..2407dcf 100755 (executable)
@@ -101,6 +101,7 @@ struct AtomData
 AtomData atomList[ATOM_MAX];
 ClipData clipList[CLIP_TYPE_MAX];
 
+static Eina_Bool cbhmPropertyChangeCallback(void* data, int type, void* event);
 static Eina_Bool clientMessageCallback(void* data, int type, void* event);
 #endif
 
@@ -110,6 +111,8 @@ ClipboardHelper::ClipboardHelper(EwkViewImpl* viewImpl)
     , m_selectionClearHandler(0)
     , m_selectionNotifyHandler(0)
     , m_clientMessageHandler(0)
+    , m_cbhmPropertyChangeHandler(0)
+    , m_clipboardWindowOpened(false)
 #endif
 {
 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
@@ -236,6 +239,19 @@ void ClipboardHelper::processResult(const String& data, const String& type)
 }
 
 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
+Eina_Bool cbhmPropertyChangeCallback(void* data, int type, void* event)
+{
+    ClipboardHelper *clipboardHelper = static_cast<ClipboardHelper*>(data);
+    Ecore_X_Event_Window_Property *ev = (Ecore_X_Event_Window_Property*) event;
+
+    if (ev->atom != ECORE_X_ATOM_E_ILLUME_CLIPBOARD_STATE)
+        return ECORE_CALLBACK_PASS_ON;
+
+    clipboardHelper->updateClipboardWindowState(ev);
+
+    return ECORE_CALLBACK_PASS_ON;
+}
+
 Eina_Bool clientMessageCallback(void* data, int type, void* event)
 {
     //This callback function is support for open CBHM window from IME clipboard button
@@ -509,6 +525,7 @@ void ClipboardHelper::initializeAtomList()
     for (int i = 0; i < ATOM_MAX; i++)
         atomList[i].atom = ecore_x_atom_get(atomList[i].pName);
 
+    m_cbhmPropertyChangeHandler = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY, cbhmPropertyChangeCallback, this);
     m_selectionClearHandler = ecore_event_handler_add(ECORE_X_EVENT_SELECTION_CLEAR, clearClip, this);
     m_selectionNotifyHandler = ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY, notifyClip, this);
 }
@@ -596,17 +613,14 @@ void ClipboardHelper::openClipboardWindow(bool isContentRichlyEditable)
 #endif
 }
 
-bool ClipboardHelper::isClipboardWindowOpened()
+void ClipboardHelper::closeClipboardWindow()
 {
-    char* windowTitle = ecore_x_icccm_title_get(ecore_x_window_focus_get());
-
-    if (!windowTitle)
-         return false;
-
-    if (!(strcmp("Clipboard History Manager", windowTitle)))
-        return true;
+    sendCbhmMessage(String::fromUTF8(static_cast<const char*>("cbhm_hide")));
+}
 
-    return false;
+bool ClipboardHelper::isClipboardWindowOpened()
+{
+    return m_clipboardWindowOpened;
 }
 
 void ClipboardHelper::connectClipboardWindow()
@@ -624,6 +638,11 @@ void ClipboardHelper::clearClipboardSelectionHandler()
         ecore_event_handler_del(m_selectionNotifyHandler);
         m_selectionNotifyHandler = 0;
     }
+    if (m_cbhmPropertyChangeHandler) {
+        ecore_event_handler_del(m_cbhmPropertyChangeHandler);
+        m_cbhmPropertyChangeHandler = 0;
+    }
+    m_clipboardWindowOpened = false;
 }
 
 bool ClipboardHelper::getSelectedCbhmItem(Ecore_X_Atom* pDataType)
@@ -766,6 +785,21 @@ void ClipboardHelper::pasteClipboardLastItem(bool isContentEditable)
         break;
     }
 }
+
+void ClipboardHelper::updateClipboardWindowState(Ecore_X_Event_Window_Property* ev)
+{
+    Ecore_X_Window zone = ecore_x_e_illume_zone_get(ev->win);
+    Ecore_X_Illume_Clipboard_State state = ecore_x_e_illume_clipboard_state_get(ev->win);
+
+    if (state == ECORE_X_ILLUME_CLIPBOARD_STATE_UNKNOWN)
+        state = ecore_x_e_illume_clipboard_state_get(ev->win);
+
+    if (state == ECORE_X_ILLUME_CLIPBOARD_STATE_OFF)
+        clearClipboardSelectionHandler();
+    else if (state == ECORE_X_ILLUME_CLIPBOARD_STATE_ON)
+        m_clipboardWindowOpened = true;
+}
+
 #endif // TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD
 }// namespace WebKit
 
index 8d09bf2..700bb7c 100755 (executable)
@@ -103,12 +103,14 @@ public:
 
 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
     void openClipboardWindow(bool isContentRichlyEditable);
+    void closeClipboardWindow();
     bool isClipboardWindowOpened();
     void connectClipboardWindow();
     void clearClipboardSelectionHandler();
     Evas_Object* ewkView() { return m_viewImpl->view(); }
     WebPageProxy* page() { return m_viewImpl->page(); }
     bool getSelectedCbhmItem(Ecore_X_Atom* pDataType);
+    void updateClipboardWindowState(Ecore_X_Event_Window_Property* ev);
 #endif
 
 private:
@@ -129,6 +131,9 @@ private:
     Mutex m_callbackQueueLock;
 
 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
+    bool m_clipboardWindowOpened;
+
+    Ecore_Event_Handler* m_cbhmPropertyChangeHandler;
     Ecore_Event_Handler* m_selectionClearHandler;
     Ecore_Event_Handler* m_selectionNotifyHandler;
     Ecore_Event_Handler* m_clientMessageHandler;
index 82e0ecc..47b733e 100755 (executable)
@@ -536,6 +536,11 @@ void InputMethodContextEfl::hideIMFContext()
     if (!m_context)
         return;
 
+#if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
+    if (m_viewImpl->pageClient->isClipboardWindowOpened())
+        m_viewImpl->pageClient->closeClipboardWindow();
+#endif
+
     if (ecore_imf_context_input_panel_state_get(m_context.get()) != ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
         ecore_imf_context_reset(m_context.get());
         ecore_imf_context_input_panel_hide(m_context.get());