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)
LOCAL_MODULE := etk
LOCAL_STATIC_LIBRARIES := libzip
LOCAL_LIBRARIES := libzip
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_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 \
-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_EXPORT_C_INCLUDES := $(LOCAL_PATH)
LOCAL_EXPORT_LDLIBS := -lGL -lGLU -lz -lX11
LOCAL_EXPORT_LDLIBS := -lGL -lGLU -lX11
LOCAL_CFLAGS := -Wno-write-strings \
-DEWOL_VERSION_TAG_NAME="\"$(LOCAL_VERSION_TAG_SHORT)-$(BUILD_DIRECTORY_MODE)\"" \
@ -31,8 +31,5 @@ LOCAL_SRC_FILES := \
ewol/Audio/interfacePortAudio.cpp \
$(FILE_LIST)
# Ewol Test Software :
LOCAL_LDLIBS := -lGL -lGLU -lz -lX11
include $(BUILD_STATIC_LIBRARY)

View File

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

View File

@ -25,6 +25,7 @@
#include <ewol/Debug.h>
#include <ewol/ClipBoard.h>
#include <ewol/base/gui.h>
#include <ewol/base/MainThread.h>
#undef __class__
#define __class__ "ClipBoard"
@ -36,9 +37,15 @@ note: la copy dans le :
[1..9] : copy interne
10 : bouton du milieux
*/
//!< Local copy of the clipboards
static etk::UString mesCopy[ewol::clipBoard::TOTAL_OF_CLICKBOARD];
/**
* @brief Initialize the clipboard system (done by ewol)
* @param ---
* @return ---
*/
void ewol::clipBoard::Init(void)
{
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)
{
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
if(0 == data.Size()) {
EWOL_INFO("request a copy of nothing");
return;
} else if (ewol::clipBoard::CLIPBOARD_STD == clipboardID) {
guiAbstraction::ClipBoardSet(data, guiAbstraction::CLIPBOARD_MODE_STD);
} else
if(clipboardID >= ewol::clipBoard::TOTAL_OF_CLICKBOARD) {
EWOL_WARNING("request ClickBoard id error");
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;
}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");
return;
}
@ -77,23 +139,24 @@ void ewol::clipBoard::Set(uint8_t clipboardID, etk::UString &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) {
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) {
if(clipboardID >= ewol::clipBoard::TOTAL_OF_CLICKBOARD) {
EWOL_WARNING("request ClickBoard id error");
return;
return "";
}
// Copy datas ...
data = mesCopy[clipboardID];
return mesCopy[clipboardID];
}

View File

@ -32,25 +32,66 @@
namespace ewol {
namespace clipBoard
{
enum {
CLIPBOARD_0,
CLIPBOARD_1,
CLIPBOARD_2,
CLIPBOARD_3,
CLIPBOARD_4,
CLIPBOARD_5,
CLIPBOARD_6,
CLIPBOARD_7,
CLIPBOARD_8,
CLIPBOARD_9,
CLIPBOARD_STD,
CLIPBOARD_SELECTION,
TOTAL_OF_CLICKBOARD,
};
void Init(void);
void UnInit(void);
void Set(uint8_t clipboardID, etk::UString &data);
void Get(uint8_t clipboardID, etk::UString &data);
typedef enum {
CLIPBOARD_0, //!< Internal clipboard 0
CLIPBOARD_1, //!< Internal clipboard 1
CLIPBOARD_2, //!< Internal clipboard 2
CLIPBOARD_3, //!< Internal clipboard 3
CLIPBOARD_4, //!< Internal clipboard 4
CLIPBOARD_5, //!< Internal clipboard 5
CLIPBOARD_6, //!< Internal clipboard 6
CLIPBOARD_7, //!< Internal clipboard 7
CLIPBOARD_8, //!< Internal clipboard 8
CLIPBOARD_9, //!< Internal clipboard 9
CLIPBOARD_STD, //!< External clipboard represent the Copy/Cut/Past buffer
CLIPBOARD_SELECTION, //!< External or internal clipboard depending on the OS, represent the middle button
TOTAL_OF_CLICKBOARD, //!< Total number of clipboard
} clipboardListe_te;
/**
* @brief Initialize the clipboard system (done by ewol)
* @param ---
* @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/OObject.h>
#include <ewol/base/eventInputManagement.h>
#include <ewol/ClipBoard.h>
namespace ewol {
typedef enum {
@ -404,6 +405,13 @@ namespace ewol {
* @return false if the event has not been used
*/
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...

View File

@ -55,6 +55,8 @@ enum {
THREAD_KEYBORAD_KEY,
THREAD_KEYBORAD_MOVE,
THREAD_JUST_DISPLAY,
THREAD_CLIPBOARD_ARRIVE,
};
@ -155,6 +157,12 @@ void ewolProcessEvents(void)
guiAbstraction::SendKeyboardEventMove(tmpData->isDown, tmpData->move);
}
break;
case THREAD_CLIPBOARD_ARRIVE:
{
ewol::clipBoard::clipboardListe_te * tmpdata = (ewol::clipBoard::clipboardListe_te*)data.data;
guiAbstraction::SendClipboard(*tmpdata);
}
break;
case THREAD_HIDE:
EWOL_DEBUG("Receive MSG : THREAD_HIDE");
//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)
{
if (true == isGlobalSystemInit) {

View File

@ -74,6 +74,8 @@ namespace guiSystem
void Hide(void);
void Show(void);
void ClipBoardArrive(ewol::clipBoard::clipboardListe_te clipboardID);
};
// return true if a flush is needed
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 nbCallTime = 0;

View File

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

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