#include "PageClientImpl.h"
#include <Evas.h>
#include <Ecore_Evas.h>
+#ifdef HAVE_ECORE_X
#include <Ecore_X.h>
+#endif
#include <Elementary.h>
#include <X11/Xatom.h>
#include <X11/Xlib.h>
struct ClipData
{
+#ifdef HAVE_ECORE_X
Ecore_X_Selection selection;
void (* request)(Ecore_X_Window window, const char* pTarget);
-
+#endif
Elm_Sel_Format format;
Elm_Sel_Format requestedFormat;
ClipboardHelper* clipboardHelper;
};
+#ifdef HAVE_ECORE_X
typedef int (*ClipNotifyHandler)(ClipData* clipData, Ecore_X_Event_Selection_Notify* notifyData);
+#else
+typedef int (*ClipNotifyHandler)(ClipData* clipData, void* notifyData);
+#endif
+#ifdef HAVE_ECORE_X
enum
{
ATOM_TARGETS = 0,
AtomData atomList[ATOM_MAX];
ClipData clipList[CLIP_TYPE_MAX];
+#endif // HAVE_ECORE_X
static Eina_Bool cbhmPropertyChangeCallback(void* data, int type, void* event);
static Eina_Bool clientMessageCallback(void* data, int type, void* event);
#endif
{
#if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
+#ifdef HAVE_ECORE_X
m_clientMessageHandler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, clientMessageCallback, this);
#endif
+#endif
}
ClipboardHelper::~ClipboardHelper()
{
#if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
+#ifdef HAVE_ECORE_X
ecore_event_handler_del(m_clientMessageHandler);
m_clientMessageHandler = 0;
clearClipboardSelectionHandler();
#endif
+#endif
}
// This function references from elementary's cbhm_helper.c
int ClipboardHelper::numberOfItems()
{
+#ifdef HAVE_ECORE_X
// 1. Get CBHM Ecore_X_Window.
Ecore_X_Atom xAtom;
xAtom = ecore_x_atom_get("CBHM_XWIN");
free(data);
return count;
}
-
+#endif
return 0;
}
void ClipboardHelper::setData(const String& data, const String& type)
{
+#ifdef HAVE_ECORE_X
Ecore_X_Atom dataType = 0;
if (type == "PlainText" || type == "URIList" || type == "URL")
}
setClipboardItem(dataType, data);
+#endif
}
void ClipboardHelper::clear()
#if ENABLE(TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD)
Eina_Bool cbhmPropertyChangeCallback(void* data, int type, void* event)
{
+#ifdef HAVE_ECORE_x
ClipboardHelper *clipboardHelper = static_cast<ClipboardHelper*>(data);
Ecore_X_Event_Window_Property *ev = (Ecore_X_Event_Window_Property*) event;
return ECORE_CALLBACK_PASS_ON;
clipboardHelper->updateClipboardWindowState(ev);
-
+#endif
return ECORE_CALLBACK_PASS_ON;
}
Eina_Bool clientMessageCallback(void* data, int type, void* event)
{
+#ifdef HAVE_ECORE_X
//This callback function is support for open CBHM window from IME clipboard button
ClipboardHelper *clipboardHelper = static_cast<ClipboardHelper*>(data);
Ecore_X_Event_Client_Message *ev = (Ecore_X_Event_Client_Message*) event;
if (!strcmp("SET_OWNER", ev->data.b)) {
clipboardHelper->openClipboardWindow(clipboardHelper->page()->editorState().isContentRichlyEditable);
}
-
+#endif
return ECORE_CALLBACK_PASS_ON;
}
static Eina_Bool clearClip(void* data, int type, void* event)
{
+#ifdef HAVE_ECORE_X
Ecore_X_Event_Selection_Clear* clearEvent = (Ecore_X_Event_Selection_Clear*) event;
Ecore_X_Window window = clearEvent->win;
clipList[clipType].requestedFormat = static_cast<Elm_Sel_Format>(ELM_SEL_FORMAT_TEXT | ELM_SEL_FORMAT_IMAGE);
ecore_x_selection_secondary_request(window, ECORE_X_SELECTION_TARGET_TARGETS);
-
+#endif
return ECORE_CALLBACK_PASS_ON;
}
static Eina_Bool notifyClip(void* data , int type, void* event)
{
+#ifdef HAVE_ECORE_X
Ecore_X_Event_Selection_Notify* notifytEvent = (Ecore_X_Event_Selection_Notify*) event;
int i = 0;
}
}
}
-
+#endif
return ECORE_CALLBACK_PASS_ON;
}
+#ifdef HAVE_ECORE_X
static int notifyTarget(ClipData* clipData, Ecore_X_Event_Selection_Notify* notifyData)
{
Ecore_X_Atom dataType = 0;
FOUND:
clipData->request(notifyData->win, atomList[j].pName);
+
return ECORE_CALLBACK_PASS_ON;
}
return 0;
}
+#endif // HAVE_ECORE_X
void ClipboardHelper::initializeAtomList()
{
+#ifdef HAVE_ECORE_X
atomList[ATOM_TARGETS].pName = "TARGETS";
atomList[ATOM_TARGETS].formats = ELM_SEL_FORMAT_TARGETS;
atomList[ATOM_TARGETS].notify = notifyTarget;
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);
+#endif
}
+#ifdef HAVE_ECORE_X
Ecore_X_Window ClipboardHelper::getCbhmWindow()
{
Ecore_X_Atom xAtomCbhm = ecore_x_atom_get("CBHM_XWIN");
return xCbhmWin;
}
+#endif // HAVE_ECORE_X
bool ClipboardHelper::sendCbhmMessage(String message)
{
+#ifdef HAVE_ECORE_X
Ecore_X_Window xCbhmWin = getCbhmWindow();
Ecore_X_Atom xAtomCbhmMsg = ecore_x_atom_get("CBHM_MSG");
ecore_x_sync();
return true;
+#else
+ return false;
+#endif
}
+#ifdef HAVE_ECORE_X
bool ClipboardHelper::setClipboardItem(Ecore_X_Atom dataType,const String& data)
{
Ecore_X_Window cbhmWin = getCbhmWindow();
return false;
}
+#endif // HAVE_ECORE_X
void ClipboardHelper::openClipboardWindow(bool isContentRichlyEditable)
{
void ClipboardHelper::connectClipboardWindow()
{
+#ifdef HAVE_ECORE_X
ecore_x_selection_secondary_set(elm_win_xwindow_get(elm_object_parent_widget_get(m_viewImpl->view())), "",1);
+#endif
}
void ClipboardHelper::clearClipboardSelectionHandler()
m_clipboardWindowOpened = false;
}
+#ifdef HAVE_ECORE_X
bool ClipboardHelper::getSelectedCbhmItem(Ecore_X_Atom* pDataType)
{
Ecore_X_Window cbhmWin = getCbhmWindow();
return chbmData;
}
+#endif // HAVE_ECORE_X
bool ClipboardHelper::retrieveClipboardItem(int index, int* format, String* pData)
{
+#ifdef HAVE_ECORE_X
if (!pData)
return false;
return false;
return true;
+#else
+ return false;
+#endif
}
void ClipboardHelper::pasteClipboardLastItem(bool isContentEditable)
}
}
+#ifdef HAVE_ECORE_X
void ClipboardHelper::updateClipboardWindowState(Ecore_X_Event_Window_Property* ev)
{
Ecore_X_Illume_Clipboard_State state = ecore_x_e_illume_clipboard_state_get(ev->win);
else if (state == ECORE_X_ILLUME_CLIPBOARD_STATE_ON)
m_clipboardWindowOpened = true;
}
+#endif // HAVE_ECORE_X
#endif // TIZEN_WEBKIT2_CONTEXT_MENU_CLIPBOARD
}// namespace WebKit