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
, m_selectionClearHandler(0)
, m_selectionNotifyHandler(0)
, m_clientMessageHandler(0)
+ , m_cbhmPropertyChangeHandler(0)
+ , m_clipboardWindowOpened(false)
#endif
{
#if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
}
#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
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);
}
Ecore_X_Window xCbhmWin = getCbhmWindow();
Ecore_X_Atom xAtomCbhmMsg = ecore_x_atom_get("CBHM_MSG");
+ if (!m_viewImpl->view())
+ return false;
+
Evas_Object* parent = elm_object_parent_widget_get(m_viewImpl->view());
+
+ if (!parent)
+ return false;
+
Ecore_X_Window xWin = ecore_evas_gl_x11_window_get(ecore_evas_ecore_evas_get(evas_object_evas_get(parent)));
if (!xWin)
xWin = ecore_evas_software_x11_window_get(ecore_evas_ecore_evas_get(evas_object_evas_get(parent)));
void ClipboardHelper::openClipboardWindow(bool isContentRichlyEditable)
{
- clearClipboardSelectionHandler();
+ if (!isClipboardWindowOpened())
+ clearClipboardSelectionHandler();
initializeAtomList();
if (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()
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)
else
return false;
+ if (dataType == ecore_x_atom_get("application/x-elementary-markup"))
+ *pData = String::fromUTF8(evas_textblock_text_markup_to_utf8(NULL, pData->utf8().data()));
+
return true;
}
switch(format) {
case ELM_SEL_FORMAT_TEXT:
+ case ELM_SEL_FORMAT_MARKUP:
page()->didSelectPasteMenuFromContextMenu(clipboardData, String("PlainText"));
break;
case ELM_SEL_FORMAT_HTML:
- case ELM_SEL_FORMAT_MARKUP:
page()->didSelectPasteMenuFromContextMenu(clipboardData, String("Markup"));
break;
case ELM_SEL_FORMAT_IMAGE:
break;
}
}
+
+void ClipboardHelper::updateClipboardWindowState(Ecore_X_Event_Window_Property* ev)
+{
+ 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