change the clipboard system (normalisation and standardisation

This commit is contained in:
Edouard Dupin 2012-08-18 21:06:42 +02:00
parent 236d450bd5
commit 3b645645cb
12 changed files with 226 additions and 125 deletions

View File

@ -3,7 +3,7 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_MODULE := etk LOCAL_MODULE := etk
LOCAL_STATIC_LIBRARIES := libzip LOCAL_LIBRARIES := libzip
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)

View File

@ -16,7 +16,7 @@ LOCAL_LIBRARIES := etk freetype tinyxml libzip libpng parsersvg lua
LOCAL_C_INCLUDES := LOCAL_C_INCLUDES :=
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
LOCAL_EXPORT_LDLIBS := -lGLESv1_CM -ldl -llog -lz LOCAL_EXPORT_LDLIBS := -lGLESv1_CM -ldl -llog
LOCAL_CFLAGS := -Wno-write-strings \ LOCAL_CFLAGS := -Wno-write-strings \
-DEWOL_VERSION_TAG_NAME="\"$(LOCAL_VERSION_TAG_SHORT)-$(BUILD_DIRECTORY_MODE)\"" \ -DEWOL_VERSION_TAG_NAME="\"$(LOCAL_VERSION_TAG_SHORT)-$(BUILD_DIRECTORY_MODE)\"" \

View File

@ -16,7 +16,7 @@ LOCAL_LIBRARIES := etk freetype tinyxml libzip libpng parsersvg lua portaudio
LOCAL_C_INCLUDES := LOCAL_C_INCLUDES :=
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
LOCAL_EXPORT_LDLIBS := -lGL -lGLU -lz -lX11 LOCAL_EXPORT_LDLIBS := -lGL -lGLU -lX11
LOCAL_CFLAGS := -Wno-write-strings \ LOCAL_CFLAGS := -Wno-write-strings \
-DEWOL_VERSION_TAG_NAME="\"$(LOCAL_VERSION_TAG_SHORT)-$(BUILD_DIRECTORY_MODE)\"" \ -DEWOL_VERSION_TAG_NAME="\"$(LOCAL_VERSION_TAG_SHORT)-$(BUILD_DIRECTORY_MODE)\"" \
@ -31,8 +31,5 @@ LOCAL_SRC_FILES := \
ewol/Audio/interfacePortAudio.cpp \ ewol/Audio/interfacePortAudio.cpp \
$(FILE_LIST) $(FILE_LIST)
# Ewol Test Software :
LOCAL_LDLIBS := -lGL -lGLU -lz -lX11
include $(BUILD_STATIC_LIBRARY) include $(BUILD_STATIC_LIBRARY)

View File

@ -29,8 +29,5 @@ include $(LOCAL_PATH)/file.mk
LOCAL_SRC_FILES := $(FILE_LIST) ewol/base/guiWindows.cpp LOCAL_SRC_FILES := $(FILE_LIST) ewol/base/guiWindows.cpp
# Ewol Test Software :
LOCAL_LDLIBS :=
include $(BUILD_STATIC_LIBRARY) include $(BUILD_STATIC_LIBRARY)

View File

@ -25,6 +25,7 @@
#include <ewol/Debug.h> #include <ewol/Debug.h>
#include <ewol/ClipBoard.h> #include <ewol/ClipBoard.h>
#include <ewol/base/gui.h> #include <ewol/base/gui.h>
#include <ewol/base/MainThread.h>
#undef __class__ #undef __class__
#define __class__ "ClipBoard" #define __class__ "ClipBoard"
@ -36,9 +37,15 @@ note: la copy dans le :
[1..9] : copy interne [1..9] : copy interne
10 : bouton du milieux 10 : bouton du milieux
*/ */
//!< Local copy of the clipboards
static etk::UString mesCopy[ewol::clipBoard::TOTAL_OF_CLICKBOARD]; static etk::UString mesCopy[ewol::clipBoard::TOTAL_OF_CLICKBOARD];
/**
* @brief Initialize the clipboard system (done by ewol)
* @param ---
* @return ---
*/
void ewol::clipBoard::Init(void) void ewol::clipBoard::Init(void)
{ {
EWOL_INFO("Initialyse ClipBoards"); EWOL_INFO("Initialyse ClipBoards");
@ -47,6 +54,12 @@ void ewol::clipBoard::Init(void)
} }
} }
/**
* @brief Un-Initialize the clipboard system (done by ewol)
* @param ---
* @return ---
*/
void ewol::clipBoard::UnInit(void) void ewol::clipBoard::UnInit(void)
{ {
EWOL_INFO("Initialyse ClipBoards"); EWOL_INFO("Initialyse ClipBoards");
@ -56,20 +69,69 @@ void ewol::clipBoard::UnInit(void)
} }
/**
void ewol::clipBoard::Set(uint8_t clipboardID, etk::UString &data) * @brief Set the string data on a specific clipboard. The Gui system is notify that the clipboard "SELECTION" and "COPY" are change
* @param[in] clipboardID Select the specific ID of the clipboard
* @param[in] data The string that might be send to the clipboard
* @return ---
*/
void ewol::clipBoard::Set(ewol::clipBoard::clipboardListe_te clipboardID, etk::UString &data)
{ {
// check if ID is correct // check if ID is correct
if(0 == data.Size()) { if(0 == data.Size()) {
EWOL_INFO("request a copy of nothing"); EWOL_INFO("request a copy of nothing");
return; return;
} else if (ewol::clipBoard::CLIPBOARD_STD == clipboardID) { } else
guiAbstraction::ClipBoardSet(data, guiAbstraction::CLIPBOARD_MODE_STD);
if(clipboardID >= ewol::clipBoard::TOTAL_OF_CLICKBOARD) {
EWOL_WARNING("request ClickBoard id error");
return; return;
} else if (ewol::clipBoard::CLIPBOARD_SELECTION == clipboardID) { }
guiAbstraction::ClipBoardSet(data, guiAbstraction::CLIPBOARD_MODE_PRIMARY);
ewol::clipBoard::SetSystem(clipboardID, data);
if( ewol::clipBoard::CLIPBOARD_STD == clipboardID
|| ewol::clipBoard::CLIPBOARD_SELECTION == clipboardID) {
guiAbstraction::ClipBoardSet(clipboardID);
}
}
/**
* @brief Call system to request the current clipboard.
* @note Due to some system that manage the clipboard request asynchronous (like X11) and ewol managing the system with only one thread,
* we need the call the system to send us the buffer, this is really ambigous, but the widget (who has focus) receive the
* notification of the arrival of this buffer id
* @param[in] clipboardID the needed clipboard ID
* @return ---
*/
void ewol::clipBoard::Request(ewol::clipBoard::clipboardListe_te clipboardID)
{
if(clipboardID >= ewol::clipBoard::TOTAL_OF_CLICKBOARD) {
EWOL_WARNING("request ClickBoard id error");
return; return;
}else if(clipboardID >= ewol::clipBoard::TOTAL_OF_CLICKBOARD) { }
if( ewol::clipBoard::CLIPBOARD_STD == clipboardID
|| ewol::clipBoard::CLIPBOARD_SELECTION == clipboardID) {
guiAbstraction::ClipBoardGet(clipboardID);
} else {
// generate an event on the main thread ...
guiSystem::event::ClipBoardArrive(clipboardID);
}
}
/**
* @brief Set the ewol internal buffer (no notification at the GUI). This fuction might be use by the
* Gui abstraction to set the buffer we receive. The end user must not use it.
* @param[in] clipboardID selected clipboard ID
* @param[in] data new buffer data
* @return ---
*/
void ewol::clipBoard::SetSystem(ewol::clipBoard::clipboardListe_te clipboardID, etk::UString &data)
{
if(clipboardID >= ewol::clipBoard::TOTAL_OF_CLICKBOARD) {
EWOL_WARNING("request ClickBoard id error"); EWOL_WARNING("request ClickBoard id error");
return; return;
} }
@ -77,23 +139,24 @@ void ewol::clipBoard::Set(uint8_t clipboardID, etk::UString &data)
mesCopy[clipboardID] = data; mesCopy[clipboardID] = data;
} }
void ewol::clipBoard::Get(uint8_t clipboardID, etk::UString &data)
/**
* @brief Get the ewol internal buffer of the curent clipboard. The end user can use it when he receive the event in
* the widget : @ref OnEventClipboard ==> we can nothe this function is the only one which permit it.
* @note if we call this fuction withoutcallin @ref ewol::clipBoard::Request, we only get the previous clipboard
* @param[in] clipboardID selected clipboard ID
* @return the requested buffer
*/
etk::UString ewol::clipBoard::Get(ewol::clipBoard::clipboardListe_te clipboardID)
{ {
if (ewol::clipBoard::CLIPBOARD_STD == clipboardID) { if(clipboardID >= ewol::clipBoard::TOTAL_OF_CLICKBOARD) {
guiAbstraction::ClipBoardGet(data, guiAbstraction::CLIPBOARD_MODE_STD);
return;
} else if (ewol::clipBoard::CLIPBOARD_SELECTION == clipboardID) {
guiAbstraction::ClipBoardGet(data, guiAbstraction::CLIPBOARD_MODE_PRIMARY);
return;
} else if(clipboardID >= ewol::clipBoard::TOTAL_OF_CLICKBOARD) {
EWOL_WARNING("request ClickBoard id error"); EWOL_WARNING("request ClickBoard id error");
return; return "";
} }
// Copy datas ... // Copy datas ...
data = mesCopy[clipboardID]; return mesCopy[clipboardID];
} }

View File

@ -32,25 +32,66 @@
namespace ewol { namespace ewol {
namespace clipBoard namespace clipBoard
{ {
enum { typedef enum {
CLIPBOARD_0, CLIPBOARD_0, //!< Internal clipboard 0
CLIPBOARD_1, CLIPBOARD_1, //!< Internal clipboard 1
CLIPBOARD_2, CLIPBOARD_2, //!< Internal clipboard 2
CLIPBOARD_3, CLIPBOARD_3, //!< Internal clipboard 3
CLIPBOARD_4, CLIPBOARD_4, //!< Internal clipboard 4
CLIPBOARD_5, CLIPBOARD_5, //!< Internal clipboard 5
CLIPBOARD_6, CLIPBOARD_6, //!< Internal clipboard 6
CLIPBOARD_7, CLIPBOARD_7, //!< Internal clipboard 7
CLIPBOARD_8, CLIPBOARD_8, //!< Internal clipboard 8
CLIPBOARD_9, CLIPBOARD_9, //!< Internal clipboard 9
CLIPBOARD_STD, CLIPBOARD_STD, //!< External clipboard represent the Copy/Cut/Past buffer
CLIPBOARD_SELECTION, CLIPBOARD_SELECTION, //!< External or internal clipboard depending on the OS, represent the middle button
TOTAL_OF_CLICKBOARD, TOTAL_OF_CLICKBOARD, //!< Total number of clipboard
}; } clipboardListe_te;
void Init(void); /**
void UnInit(void); * @brief Initialize the clipboard system (done by ewol)
void Set(uint8_t clipboardID, etk::UString &data); * @param ---
void Get(uint8_t clipboardID, etk::UString &data); * @return ---
*/
void Init(void);
/**
* @brief Un-Initialize the clipboard system (done by ewol)
* @param ---
* @return ---
*/
void UnInit(void);
/**
* @brief Set the string data on a specific clipboard. The Gui system is notify that the clipboard "SELECTION" and "COPY" are change
* @param[in] clipboardID Select the specific ID of the clipboard
* @param[in] data The string that might be send to the clipboard
* @return ---
*/
void Set(ewol::clipBoard::clipboardListe_te clipboardID, etk::UString &data);
/**
* @brief Call system to request the current clipboard.
* @note Due to some system that manage the clipboard request asynchronous (like X11) and ewol managing the system with only one thread,
* we need the call the system to send us the buffer, this is really ambigous, but the widget (who has focus) receive the
* notification of the arrival of this buffer id
* @param[in] clipboardID the needed clipboard ID
* @return ---
*/
void Request(ewol::clipBoard::clipboardListe_te clipboardID);
/**
* @brief Set the ewol internal buffer (no notification at the GUI). This fuction might be use by the
* Gui abstraction to set the buffer we receive. The end user must not use it.
* @param[in] clipboardID selected clipboard ID
* @param[in] data new buffer data
* @return ---
*/
void SetSystem(ewol::clipBoard::clipboardListe_te clipboardID, etk::UString &data);
/**
* @brief Get the ewol internal buffer of the curent clipboard. The end user can use it when he receive the event in
* the widget : @ref OnEventClipboard ==> we can nothe this function is the only one which permit it.
* @note if we call this fuction withoutcallin @ref ewol::clipBoard::Request, we only get the previous clipboard
* @param[in] clipboardID selected clipboard ID
* @return the requested buffer
*/
etk::UString Get(ewol::clipBoard::clipboardListe_te clipboardID);
}; };
}; };

View File

@ -35,6 +35,7 @@ namespace ewol {
#include <ewol/Debug.h> #include <ewol/Debug.h>
#include <ewol/OObject.h> #include <ewol/OObject.h>
#include <ewol/base/eventInputManagement.h> #include <ewol/base/eventInputManagement.h>
#include <ewol/ClipBoard.h>
namespace ewol { namespace ewol {
typedef enum { typedef enum {
@ -404,6 +405,13 @@ namespace ewol {
* @return false if the event has not been used * @return false if the event has not been used
*/ */
virtual bool OnEventKbMove(eventKbType_te typeEvent, eventKbMoveType_te moveTypeEvent) { return false; }; virtual bool OnEventKbMove(eventKbType_te typeEvent, eventKbMoveType_te moveTypeEvent) { return false; };
/**
* @brief Event on a past event ==> this event is asynchronous due to all system does not support direct getting datas
* @note : need to have focus ...
* @param[in] mode Mode of data requested
* @return ---
*/
virtual void OnEventClipboard(ewol::clipBoard::clipboardListe_te clipboardID) { };
// ---------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------
// -- Drawing : All drawing must be done in 2 separate buffer 1 for the current display and 1 for the working... // -- Drawing : All drawing must be done in 2 separate buffer 1 for the current display and 1 for the working...

View File

@ -55,6 +55,8 @@ enum {
THREAD_KEYBORAD_KEY, THREAD_KEYBORAD_KEY,
THREAD_KEYBORAD_MOVE, THREAD_KEYBORAD_MOVE,
THREAD_JUST_DISPLAY, THREAD_JUST_DISPLAY,
THREAD_CLIPBOARD_ARRIVE,
}; };
@ -155,6 +157,12 @@ void ewolProcessEvents(void)
guiAbstraction::SendKeyboardEventMove(tmpData->isDown, tmpData->move); guiAbstraction::SendKeyboardEventMove(tmpData->isDown, tmpData->move);
} }
break; break;
case THREAD_CLIPBOARD_ARRIVE:
{
ewol::clipBoard::clipboardListe_te * tmpdata = (ewol::clipBoard::clipboardListe_te*)data.data;
guiAbstraction::SendClipboard(*tmpdata);
}
break;
case THREAD_HIDE: case THREAD_HIDE:
EWOL_DEBUG("Receive MSG : THREAD_HIDE"); EWOL_DEBUG("Receive MSG : THREAD_HIDE");
//guiAbstraction::SendKeyboardEventMove(tmpData->isDown, tmpData->move); //guiAbstraction::SendKeyboardEventMove(tmpData->isDown, tmpData->move);
@ -357,6 +365,15 @@ void guiSystem::event::Show(void)
} }
} }
void guiSystem::event::ClipBoardArrive(ewol::clipBoard::clipboardListe_te clipboardID)
{
if (true == isGlobalSystemInit) {
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_CLIPBOARD_ARRIVE, ewol::threadMsg::MSG_PRIO_LOW, &clipboardID, sizeof(uint8_t));
}
}
bool guiSystem::Draw(bool displayEveryTime) bool guiSystem::Draw(bool displayEveryTime)
{ {
if (true == isGlobalSystemInit) { if (true == isGlobalSystemInit) {

View File

@ -74,6 +74,8 @@ namespace guiSystem
void Hide(void); void Hide(void);
void Show(void); void Show(void);
void ClipBoardArrive(ewol::clipBoard::clipboardListe_te clipboardID);
}; };
// return true if a flush is needed // return true if a flush is needed
bool Draw(bool displayEveryTime); bool Draw(bool displayEveryTime);

View File

@ -129,6 +129,16 @@ void guiAbstraction::SendKeyboardEventMove(bool isDown, ewol::eventKbMoveType_te
} }
} }
void guiAbstraction::SendClipboard(ewol::clipBoard::clipboardListe_te clipboardID)
{
if (NULL != gui_uniqueWindows) {
ewol::Widget * tmpWidget = ewol::widgetManager::FocusGet();
if (tmpWidget != NULL) {
tmpWidget->OnEventClipboard(clipboardID);
}
}
}
static int64_t startTime = -1; static int64_t startTime = -1;
static int64_t nbCallTime = 0; static int64_t nbCallTime = 0;

View File

@ -30,6 +30,7 @@
#include <etk/UString.h> #include <etk/UString.h>
#include <ewol/Windows.h> #include <ewol/Windows.h>
#include <ewol/ewol.h> #include <ewol/ewol.h>
#include <ewol/ClipBoard.h>
void EWOL_NativeRender(void); void EWOL_NativeRender(void);
void EWOL_NativeResize(int w, int h ); void EWOL_NativeResize(int w, int h );
@ -51,14 +52,10 @@ namespace guiAbstraction
void ForceRedrawAll(void); void ForceRedrawAll(void);
void SendKeyboardEvent(bool isDown, uniChar_t keyInput); void SendKeyboardEvent(bool isDown, uniChar_t keyInput);
void SendKeyboardEventMove(bool isDown, ewol::eventKbMoveType_te &keyInput); void SendKeyboardEventMove(bool isDown, ewol::eventKbMoveType_te &keyInput);
void SendClipboard(ewol::clipBoard::clipboardListe_te clipboardID);
// copy and cut generic properties : void ClipBoardGet(ewol::clipBoard::clipboardListe_te clipboardID);
typedef enum { void ClipBoardSet(ewol::clipBoard::clipboardListe_te clipboardID);
CLIPBOARD_MODE_PRIMARY,
CLIPBOARD_MODE_STD,
} clipBoardMode_te;
void ClipBoardGet(etk::UString& newData, clipBoardMode_te mode);
void ClipBoardSet(etk::UString& newData, clipBoardMode_te mode);
}; };

View File

@ -137,9 +137,7 @@ bool inputIsPressed[20];
static ewol::simpleMsg::simpleMsg_ts l_clipboardMessage; /// message to prevent the other thread that we have receive the requested data static ewol::simpleMsg::simpleMsg_ts l_clipboardMessage; /// message to prevent the other thread that we have receive the requested data
static bool l_clipBoardRequestPrimary = false; // if false : request the copy/past buffer, if true : request current selection static bool l_clipBoardRequestPrimary = false; // if false : request the copy/past buffer, if true : request current selection
static bool l_clipBoardOwnerPrimary = false; // we are the owner of the current selection static bool l_clipBoardOwnerPrimary = false; // we are the owner of the current selection
static etk::UString l_clipBoardPrimary(""); // local copy of the selection
static bool l_clipBoardOwnerStd = false; // we are the owner of the current copy buffer static bool l_clipBoardOwnerStd = false; // we are the owner of the current copy buffer
static etk::UString l_clipBoardStd(""); // local copy of the clipboard
// Atom access... // Atom access...
static Atom XAtomeSelection = 0; static Atom XAtomeSelection = 0;
static Atom XAtomeClipBoard = 0; static Atom XAtomeClipBoard = 0;
@ -448,8 +446,6 @@ void X11_Init(void)
l_clipBoardRequestPrimary = false; l_clipBoardRequestPrimary = false;
l_clipBoardOwnerPrimary = false; l_clipBoardOwnerPrimary = false;
l_clipBoardOwnerStd = false; l_clipBoardOwnerStd = false;
l_clipBoardPrimary = "";
l_clipBoardStd = "";
ewol::simpleMsg::Init(l_clipboardMessage); ewol::simpleMsg::Init(l_clipboardMessage);
// reset the Atom properties ... // reset the Atom properties ...
XAtomeSelection = XInternAtom(m_display, "PRIMARY", 0); XAtomeSelection = XInternAtom(m_display, "PRIMARY", 0);
@ -552,15 +548,15 @@ void X11_Run(void)
&buf// **prop_return); &buf// **prop_return);
); );
if (true == l_clipBoardRequestPrimary) { if (true == l_clipBoardRequestPrimary) {
l_clipBoardPrimary = (char*)buf; etk::UString tmpppp((char*)buf);
// inform that we have receive the data ewol::clipBoard::SetSystem(ewol::clipBoard::CLIPBOARD_SELECTION, tmpppp);
ewol::simpleMsg::SendMessage(l_clipboardMessage, 4); // just transmit an event , we have the data in the system
EWOL_VERBOSE(" ==> data : " << l_clipBoardPrimary); guiSystem::event::ClipBoardArrive(ewol::clipBoard::CLIPBOARD_SELECTION);
} else { } else {
l_clipBoardStd = (char*)buf; etk::UString tmpppp((char*)buf);
// inform that we have receive the data ewol::clipBoard::SetSystem(ewol::clipBoard::CLIPBOARD_STD, tmpppp);
ewol::simpleMsg::SendMessage(l_clipboardMessage, 2); // just transmit an event , we have the data in the system
EWOL_VERBOSE(" ==> data : " << l_clipBoardStd); guiSystem::event::ClipBoardArrive(ewol::clipBoard::CLIPBOARD_STD);
} }
} }
break; break;
@ -583,13 +579,13 @@ void X11_Run(void)
#endif #endif
const char * magatTextToSend = NULL; const char * magatTextToSend = NULL;
etk::UString tmpData = "";
if (req->selection == XAtomeSelection) { if (req->selection == XAtomeSelection) {
magatTextToSend = l_clipBoardPrimary.c_str(); tmpData = ewol::clipBoard::Get(ewol::clipBoard::CLIPBOARD_SELECTION);
} else if (req->selection == XAtomeClipBoard) { } else if (req->selection == XAtomeClipBoard) {
magatTextToSend = l_clipBoardStd.c_str(); tmpData = ewol::clipBoard::Get(ewol::clipBoard::CLIPBOARD_STD);
} else {
magatTextToSend = "";
} }
magatTextToSend = tmpData.c_str();
Atom listOfAtom[4]; Atom listOfAtom[4];
if(strlen(magatTextToSend) == 0 ) { if(strlen(magatTextToSend) == 0 ) {
respond.xselection.property= None; respond.xselection.property= None;
@ -993,7 +989,7 @@ void X11_Run(void)
} }
} }
#ifdef DEBUG_X11_EVENT #ifdef DEBUG_X11_EVENT
EWOL_INFO("X11 endEvent --- "); //EWOL_INFO("X11 endEvent --- ");
#endif #endif
} }
}; };
@ -1029,55 +1025,39 @@ void X11_GetAbsPos(int32_t & x, int32_t & y)
// ClipBoard AREA : // ClipBoard AREA :
void guiAbstraction::ClipBoardGet(etk::UString &newData, clipBoardMode_te mode) void guiAbstraction::ClipBoardGet(ewol::clipBoard::clipboardListe_te clipboardID)
{ {
#ifdef DEBUG_X11_EVENT switch (clipboardID)
EWOL_INFO("Request Get of a clipboard : " << mode << " size=" << newData.Size() );
#endif
newData = "";
switch (mode)
{ {
case CLIPBOARD_MODE_PRIMARY: case ewol::clipBoard::CLIPBOARD_SELECTION:
if (false == l_clipBoardOwnerPrimary) { if (false == l_clipBoardOwnerPrimary) {
l_clipBoardRequestPrimary = true; l_clipBoardRequestPrimary = true;
// clear old request ..
ewol::simpleMsg::Clear(l_clipboardMessage);
// Generate a request on X11 // Generate a request on X11
XConvertSelection(m_display, XConvertSelection(m_display,
XAtomeSelection,// atom, XAtomeSelection,
XAtomeTargetStringUTF8, // type? XAtomeTargetStringUTF8,
XAtomeEWOL, // prop, XAtomeEWOL,
WindowHandle, WindowHandle,
CurrentTime); CurrentTime);
// wait the event ... } else {
int32_t waitTmp = ewol::simpleMsg::WaitingMessage(l_clipboardMessage, 5000); // just transmit an event , we have the data in the system
if (waitTmp == 0) { guiSystem::event::ClipBoardArrive(clipboardID);
EWOL_ERROR("Timeout when waiting the current selection");
}
} }
// get our own buffer ...
newData = l_clipBoardPrimary;
break; break;
case CLIPBOARD_MODE_STD: case ewol::clipBoard::CLIPBOARD_STD:
if (false == l_clipBoardOwnerStd) { if (false == l_clipBoardOwnerStd) {
l_clipBoardRequestPrimary = false; l_clipBoardRequestPrimary = false;
// clear old request ..
ewol::simpleMsg::Clear(l_clipboardMessage);
// Generate a request on X11 // Generate a request on X11
XConvertSelection(m_display, XConvertSelection(m_display,
XAtomeClipBoard,// atom, XAtomeClipBoard,
XAtomeTargetStringUTF8, // type? XAtomeTargetStringUTF8,
XAtomeEWOL, // prop, XAtomeEWOL,
WindowHandle, WindowHandle,
CurrentTime); CurrentTime);
// wait the event ... } else {
int32_t waitTmp = ewol::simpleMsg::WaitingMessage(l_clipboardMessage, 5000); // just transmit an event , we have the data in the system
if (waitTmp == 0) { guiSystem::event::ClipBoardArrive(clipboardID);
EWOL_ERROR("Timeout when waiting the current copy buffer");
}
} }
// get our own buffer ...
newData = l_clipBoardStd;
break; break;
default: default:
EWOL_ERROR("Request an unknow ClipBoard ..."); EWOL_ERROR("Request an unknow ClipBoard ...");
@ -1085,33 +1065,22 @@ void guiAbstraction::ClipBoardGet(etk::UString &newData, clipBoardMode_te mode)
} }
} }
void guiAbstraction::ClipBoardSet(etk::UString &newData, clipBoardMode_te mode) void guiAbstraction::ClipBoardSet(ewol::clipBoard::clipboardListe_te clipboardID)
{ {
#ifdef DEBUG_X11_EVENT switch (clipboardID)
EWOL_INFO("Request set of a clipboard : " << mode << " size=" << newData.Size() );
#endif
switch (mode)
{ {
case CLIPBOARD_MODE_PRIMARY: case ewol::clipBoard::CLIPBOARD_SELECTION:
if (newData.Size() > 0) { // Request the selection :
// copy it ... if (false == l_clipBoardOwnerPrimary) {
l_clipBoardPrimary = newData; XSetSelectionOwner(m_display, XAtomeSelection, WindowHandle, CurrentTime);
// Request the selection : l_clipBoardOwnerPrimary = true;
if (false == l_clipBoardOwnerPrimary) {
XSetSelectionOwner(m_display, XAtomeSelection, WindowHandle, CurrentTime);
l_clipBoardOwnerPrimary = true;
}
} }
break; break;
case CLIPBOARD_MODE_STD: case ewol::clipBoard::CLIPBOARD_STD:
if (newData.Size() > 0) { // Request the clipBoard :
// copy it ... if (false == l_clipBoardOwnerStd) {
l_clipBoardStd = newData; XSetSelectionOwner(m_display, XAtomeClipBoard, WindowHandle, CurrentTime);
// Request the clipBoard : l_clipBoardOwnerStd = true;
if (false == l_clipBoardOwnerStd) {
XSetSelectionOwner(m_display, XAtomeClipBoard, WindowHandle, CurrentTime);
l_clipBoardOwnerStd = true;
}
} }
break; break;
default: default: