Remove compleately the multiple thread and some amelioration of the deletion on the widget

This commit is contained in:
Edouard DUPIN 2012-08-13 18:02:46 +02:00
parent 57480937b7
commit 24cb070116
31 changed files with 517 additions and 773 deletions

2
Build

@ -1 +1 @@
Subproject commit 74da51954cb3a9132775271f4569e4720745f37d
Subproject commit a4e9c62eeb13e6c08c61953185bfb6b82c543530

View File

@ -28,20 +28,12 @@
#include <stdint.h>
#include <pthread.h>
#include <Debug.h>
#include <ewol/base/MainThread.h>
#include <ewol/threadMsg.h>
#include <ewol/Audio/audio.h>
// declaration of the ewol android abstraction ...
void EWOL_SystemStart(void);
void EWOL_SystemStop(void);
void EWOL_ThreadSetArchiveDir(int mode, const char* str);
void EWOL_ThreadResize(int w, int h );
void EWOL_ThreadEventInputMotion(int pointerID, float x, float y);
void EWOL_ThreadEventInputState(int pointerID, bool isUp, float x, float y);
void EWOL_ThreadEventMouseMotion(int pointerID, float x, float y);
void EWOL_ThreadEventMouseState(int pointerID, bool isUp, float x, float y);
void EWOL_NativeRender(void);
void EWOL_NativeGLDestroy(void);
@ -203,7 +195,7 @@ extern "C"
// direct setting of the date in the string system ...
jboolean isCopy;
const char* str = env->GetStringUTFChars(myString, &isCopy);
EWOL_ThreadSetArchiveDir(mode, str);
guiSystem::SetArchiveDir(mode, str);
if (isCopy == JNI_TRUE) {
// from here str is reset ...
env->ReleaseStringUTFChars(myString, str);
@ -282,7 +274,7 @@ extern "C"
APPL_DEBUG("*******************************************");
APPL_DEBUG("** Activity On Create **");
APPL_DEBUG("*******************************************");
EWOL_SystemStart();
guiSystem::Init();
}
void Java_org_ewol_interfaceJNI_ActivityOnStart( JNIEnv* env )
{
@ -323,7 +315,7 @@ extern "C"
APPL_DEBUG("*******************************************");
APPL_DEBUG("** Activity On Destroy **");
APPL_DEBUG("*******************************************");
EWOL_SystemStop();
guiSystem::UnInit();
}
@ -333,22 +325,22 @@ extern "C"
* ********************************************************************************************** */
void Java_org_ewol_interfaceJNI_IOInputEventMotion( JNIEnv* env, jobject thiz, jint pointerID, jfloat x, jfloat y )
{
EWOL_ThreadEventInputMotion(pointerID+1, x, y);
guiSystem::event::SetInputMotion(pointerID+1, x, y);
}
void Java_org_ewol_interfaceJNI_IOInputEventState( JNIEnv* env, jobject thiz, jint pointerID, jboolean isUp, jfloat x, jfloat y )
{
EWOL_ThreadEventInputState(pointerID+1, isUp, x, y);
guiSystem::event::SetInputState(pointerID+1, isUp, x, y);
}
void Java_org_ewol_interfaceJNI_IOMouseEventMotion( JNIEnv* env, jobject thiz, jint pointerID, jfloat x, jfloat y )
{
EWOL_ThreadEventMouseMotion(pointerID+1, x, y);
guiSystem::event::SetMouseMotion(pointerID+1, x, y);
}
void Java_org_ewol_interfaceJNI_IOMouseEventState( JNIEnv* env, jobject thiz, jint pointerID, jboolean isUp, jfloat x, jfloat y )
{
EWOL_ThreadEventMouseState(pointerID+1, isUp, x, y);
guiSystem::event::SetMouseState(pointerID+1, isUp, x, y);
}
void Java_org_ewol_interfaceJNI_IOUnknowEvent( JNIEnv* env, jobject thiz, jint pointerID)
@ -364,8 +356,12 @@ extern "C"
void Java_org_ewol_interfaceJNI_IOKeyboardEventKey( JNIEnv* env, jobject thiz, jint uniChar, jboolean isdown)
{
APPL_DEBUG("IO keyboard Key event : \"" << uniChar << "\" is down=" << isdown);
guiAbstraction::SendKeyboardEvent(isdown, uniChar);
guiSystem::event::keyboardKey_ts keyInput;
keyInput.myChar = uniChar;
keyInput.isDown = isdown;
guiSystem::event::SetKeyboard(keyInput);
}
enum {
SYSTEM_KEY__VOLUME_UP = 1,
SYSTEM_KEY__VOLUME_DOWN,
@ -413,12 +409,12 @@ extern "C"
void Java_org_ewol_interfaceJNI_RenderResize( JNIEnv* env, jobject thiz, jint w, jint h )
{
EWOL_ThreadResize(w, h);
guiSystem::event::Resize(w, h);
}
void Java_org_ewol_interfaceJNI_RenderDraw( JNIEnv* env )
{
EWOL_NativeRender();
guiSystem::Draw();
}
void Java_org_ewol_interfaceJNI_IOAudioPlayback(JNIEnv* env, void* reserved, jshortArray location, jint frameRate, jint nbChannels)

View File

@ -135,9 +135,9 @@ ewol::EObject::EObject(void)
*/
ewol::EObject::~EObject(void)
{
EWOL_DEBUG("delete EObject : [" << m_uniqueId << "]");
ewol::EObjectManager::Rm(this);
MultiCastRm(this);
EWOL_DEBUG("delete EObject : [" << m_uniqueId << "]");
for (int32_t iii=0; iii<m_externEvent.Size(); iii++) {
if (NULL!=m_externEvent[iii]) {
delete(m_externEvent[iii]);
@ -150,6 +150,17 @@ ewol::EObject::~EObject(void)
}
/**
* @brief Auto-destroy the object
* @param ---
* @return ---
*/
void ewol::EObject::AutoDestroy(void)
{
ewol::EObjectManager::AutoRemove(this);
}
/**
* @brief Get the UniqueId of the EObject
* @param ---
@ -288,16 +299,3 @@ void ewol::EObject::OnObjectRemove(ewol::EObject * removeObject)
}
/**
* @brief Receive a message from an other EObject with a specific eventId and data
* @param[in] CallerObject Pointer on the EObject that information came from
* @param[in] eventId Message registered by this class
* @param[in] data Data registered by this class
* @return ---
*/
void ewol::EObject::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
{
// here nothing to do ...
}

View File

@ -75,6 +75,13 @@ namespace ewol {
*/
int32_t GetId(void);
/**
* @brief Auto-destroy the object
* @param ---
* @return ---
*/
void AutoDestroy(void);
/**
* @brief Get the current Object type of the EObject
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
@ -137,7 +144,7 @@ namespace ewol {
* @param[in] data Data registered by this class
* @return ---
*/
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data) { };
};
};

View File

@ -31,16 +31,15 @@
static bool IsInit = false;
// internal element of the widget manager :
static etk::VectorType<ewol::EObject*> m_eObjectList; // all widget allocated ==> all time increment ... never removed ...
static etk::VectorType<ewol::EObject*> m_eObjectDeletedList; // all widget allocated
static etk::VectorType<ewol::EObject*> m_eObjectList; // all widget allocated ==> all time increment ... never removed ...
static etk::VectorType<ewol::EObject*> m_eObjectAutoRemoveList; // all widget allocated
void ewol::EObjectManager::Init(void)
{
EWOL_DEBUG("==> Init EObject-Manager");
// Can create mlemory leak ... ==> but not predictable comportement otherwise ...
// TODO : Check if we can do sotthing better
m_eObjectDeletedList.Clear();
m_eObjectAutoRemoveList.Clear();
m_eObjectList.Clear();
IsInit = true;
}
@ -48,27 +47,22 @@ void ewol::EObjectManager::Init(void)
void ewol::EObjectManager::UnInit(void)
{
EWOL_DEBUG("==> Un-Init EObject-Manager");
// Some call to permit to remove all the needed stack of EObject
for(int32_t iii=0; iii<128 ; iii++) {
ewol::EObjectManager::RemoveAllMark();
}
RemoveAllAutoRemove();
EWOL_INFO(" Remove missing user widget");
while(0<m_eObjectList.Size()) {
if (m_eObjectList[0]!=NULL) {
MarkToRemoved(m_eObjectList[0]);
delete(m_eObjectList[0]);
m_eObjectList[0] = NULL;
} else {
m_eObjectList.Erase(0);
}
}
// local acces ==> this control the mutex Lock
ewol::EObjectManager::RemoveAllMark();
IsInit = false;
}
void ewol::EObjectManager::Add(ewol::EObject* object)
{
// TODO : Chek if not existed before ...
if (NULL != object) {
m_eObjectList.PushBack(object);
} else {
@ -76,32 +70,6 @@ void ewol::EObjectManager::Add(ewol::EObject* object)
}
}
void ewol::EObjectManager::Rm(ewol::EObject* object)
{
if (NULL == object) {
EWOL_ERROR("Try to remove (NULL) EObject");
return;
}
for (int32_t iii=0; iii<m_eObjectList.Size(); iii++) {
if (m_eObjectList[iii] == object) {
// Remove Element
m_eObjectList.Erase(iii);
EWOL_CRITICAL("EObject direct remove is really DANGEROUS due to the multithreading ...");
return;
}
}
for (int32_t iii=0; iii<m_eObjectDeletedList.Size(); iii++) {
if (m_eObjectDeletedList[iii] == object) {
// Remove Element
m_eObjectDeletedList.Erase(iii);
return;
}
}
EWOL_ERROR("EObject already removed ...");
}
void informOneObjectIsRemoved(ewol::EObject* object)
{
for (int32_t iii=0; iii<m_eObjectList.Size(); iii++) {
@ -113,43 +81,55 @@ void informOneObjectIsRemoved(ewol::EObject* object)
ewol::eventInput::OnObjectRemove(object);
}
void ewol::EObjectManager::MarkToRemoved(ewol::EObject* object)
void ewol::EObjectManager::Rm(ewol::EObject* object)
{
if (object == NULL) {
EWOL_WARNING("try to remove a NULL Pointer on the EObject manager");
if (NULL == object) {
EWOL_ERROR("Try to remove (NULL) EObject");
return;
}
int32_t findId = -1;
// check if the widget is not destroy :
for(int32_t iii=0; iii<m_eObjectList.Size(); iii++) {
for (int32_t iii=0; iii<m_eObjectList.Size(); iii++) {
if (m_eObjectList[iii] == object) {
findId = iii;
break;
// Remove Element
m_eObjectList[iii] = NULL;
m_eObjectList.Erase(iii);
informOneObjectIsRemoved(object);
return;
}
}
if (-1 == findId) {
EWOL_CRITICAL("Try to mark remove an object already removed (or not registerd [imposible case]) ==> requested for EObject : [" << object->GetId() << "] type=" << object->GetObjectType());
EWOL_ERROR("Try to remove EObject that is not referenced ...");
}
void ewol::EObjectManager::AutoRemove(ewol::EObject* object)
{
if (NULL == object) {
EWOL_ERROR("Try to Auto-Remove (NULL) EObject");
return;
}
m_eObjectList.Erase(findId);
EWOL_DEBUG("MarkToRemoved EObject : [" << object->GetId() << "] type=" << object->GetObjectType());
m_eObjectDeletedList.PushBack(object);
// Informe all EObject to remove reference of this one ...
informOneObjectIsRemoved(object);
}
void ewol::EObjectManager::RemoveAllMark(void)
{
etk::VectorType<ewol::EObject*> m_tmpList = m_eObjectDeletedList;
// direct delete of the current list ...
for(int32_t iii=0; iii<m_tmpList.Size(); iii++) {
if (NULL != m_tmpList[iii]) {
delete(m_tmpList[iii]);
m_tmpList[iii] = NULL;
for (int32_t iii=0; iii<m_eObjectList.Size(); iii++) {
if (m_eObjectList[iii] == object) {
// Remove Element
m_eObjectList[iii] = NULL;
m_eObjectList.Erase(iii);
EWOL_DEBUG("Auto-Remove EObject : [" << object->GetId() << "]");
informOneObjectIsRemoved(object);
m_eObjectAutoRemoveList.PushBack(object);
return;
}
}
EWOL_ERROR("Try to Auto-Remove EObject that is not referenced ...");
}
// clean all EObject that request an autoRemove ...
void ewol::EObjectManager::RemoveAllAutoRemove(void)
{
while(0<m_eObjectAutoRemoveList.Size()) {
if (m_eObjectAutoRemoveList[0]!=NULL) {
delete(m_eObjectAutoRemoveList[0]);
m_eObjectAutoRemoveList[0] = NULL;
} else {
m_eObjectAutoRemoveList.Erase(0);
}
}
m_eObjectAutoRemoveList.Clear();
}

View File

@ -35,8 +35,9 @@ namespace ewol {
void UnInit( void);
void Add( ewol::EObject* object);
void Rm( ewol::EObject* object);
void MarkToRemoved(ewol::EObject* object);
void RemoveAllMark(void);
void AutoRemove( ewol::EObject* object);
void RemoveAllAutoRemove(void);
};
};

View File

@ -57,7 +57,6 @@ etk::VectorType<LoadedTexture*> l_listLoadedTexture;
#undef __class__
#define __class__ "texture"
static pthread_mutex_t localMutex;
/**
* @brief Initialise the texture namespace (init a mutex)
@ -67,9 +66,6 @@ static pthread_mutex_t localMutex;
void ewol::texture::Init(void)
{
EWOL_DEBUG("==> Init Texture-Manager");
// create interface mutex :
int ret = pthread_mutex_init(&localMutex, NULL);
EWOL_ASSERT(ret == 0, "Error creating Mutex ...");
}
@ -80,7 +76,6 @@ void ewol::texture::Init(void)
*/
void ewol::texture::UnInit(void)
{
pthread_mutex_lock(&localMutex);
EWOL_DEBUG("==> Un-Init Texture-Manager");
for (int32_t iii=0; iii<l_listLoadedTexture.Size(); iii++) {
if (l_listLoadedTexture[iii] != NULL) {
@ -89,9 +84,6 @@ void ewol::texture::UnInit(void)
l_listLoadedTexture[iii] = NULL;
}
l_listLoadedTexture.Clear();
pthread_mutex_unlock(&localMutex);
int ret = pthread_mutex_destroy(&localMutex);
EWOL_ASSERT(ret == 0, "Error destroying Mutex ...");
}
@ -104,7 +96,6 @@ void ewol::texture::UnInit(void)
*/
void ewol::texture::UpdateContextIsDestroy(void)
{
pthread_mutex_lock(&localMutex);
for (int32_t iii=0; iii < l_listLoadedTexture.Size(); iii++) {
if( NULL != l_listLoadedTexture[iii]
&& NULL != l_listLoadedTexture[iii]->m_data)
@ -117,7 +108,6 @@ void ewol::texture::UpdateContextIsDestroy(void)
//glDeleteTextures(1, &l_listLoadedTexture[iii]->m_openGlTextureID);
}
}
pthread_mutex_unlock(&localMutex);
}
@ -126,11 +116,9 @@ void ewol::texture::UpdateContextIsDestroy(void)
* @param ---
* @return ---
*/
// TODO : The reload might be writen ...
void ewol::texture::UpdateContext(void)
{
bool needRedraw = false;
pthread_mutex_lock(&localMutex);
for (int32_t iii=0; iii < l_listLoadedTexture.Size(); iii++) {
if( NULL != l_listLoadedTexture[iii]
&& NULL != l_listLoadedTexture[iii]->m_data)
@ -181,7 +169,6 @@ void ewol::texture::UpdateContext(void)
}
}
}
pthread_mutex_unlock(&localMutex);
if (true == needRedraw) {
ewol::ForceRedrawAll();
}
@ -240,10 +227,8 @@ int32_t ewol::texture::Load(int32_t target, int32_t level, int32_t internalForma
}
memcpy(tmpTex->m_data, data, sizeof(char) * tmpTex->m_nbBytes);
pthread_mutex_lock(&localMutex);
l_listLoadedTexture.PushBack(tmpTex);
outTextureID = l_listLoadedTexture.Size()-1;
pthread_mutex_unlock(&localMutex);
return outTextureID;
}
@ -284,6 +269,8 @@ int32_t ewol::texture::Load(etk::UString tmpfileName, int32_t requestedWidth)
if (NULL != l_listLoadedTexture[iii]) {
if (l_listLoadedTexture[iii]->m_filename == tmpfileName) {
l_listLoadedTexture[iii]->m_nbTimeLoaded++;
// this prevent the removing of the texture while the cycle is not ended ...
l_listLoadedTexture[iii]->m_destroy = false;
return iii;
}
}
@ -376,7 +363,11 @@ void ewol::texture::UnLoad(uint32_t textureID)
uint32_t ewol::texture::GetGLID(uint32_t textureID)
{
if ((int32_t)textureID<l_listLoadedTexture.Size()) {
return l_listLoadedTexture[textureID]->m_openGlTextureID;
if (l_listLoadedTexture[textureID]!=NULL) {
return l_listLoadedTexture[textureID]->m_openGlTextureID;
} else {
EWOL_ERROR("Texture has been removed previously : " << textureID);
}
}
return 0;
}
@ -390,8 +381,12 @@ uint32_t ewol::texture::GetGLID(uint32_t textureID)
int32_t ewol::texture::GetSize(uint32_t textureID)
{
for (int32_t iii=0; iii<l_listLoadedTexture.Size(); iii++) {
if (l_listLoadedTexture[iii]->m_openGlTextureID == textureID) {
return l_listLoadedTexture[iii]->m_width;
if (l_listLoadedTexture[textureID]!=NULL) {
if (l_listLoadedTexture[iii]->m_openGlTextureID == textureID) {
return l_listLoadedTexture[iii]->m_width;
}
} else {
EWOL_ERROR("Texture has been removed previously : " << textureID);
}
}
EWOL_ERROR("Can not find TextureId=" << textureID << " in the list of texture loaded...");

View File

@ -103,6 +103,18 @@ ewol::Widget::Widget(void)
}
/**
* @brief Destructor of the widget classes
* @param ---
* @return (no execption generated (not managed in embended platform))
*/
ewol::Widget::~Widget(void)
{
// Remove his own focus...
ewol::widgetManager::Rm(this);
}
/**
* @brief Set the widget hidden
* @param ---
@ -129,22 +141,6 @@ void ewol::Widget::Show(void)
}
/**
* @brief This will be equivalent at the destructor @ref ~Widget
* @note this fuction "mark" the widget as removed an inform the widget manager that the widget has been removed by the user.
* @note All the EObject are inform that an other EObject is removed ... @ref ewol::EObject
* @param ---
* @return ---
*/
void ewol::Widget::MarkToRemove(void)
{
// Remove his own focus...
ewol::widgetManager::Rm(this);
// merk to remova at the next cycle
ewol::EObjectManager::MarkToRemoved(this);
}
/**
* @brief Parrent set the possible diplay size of the current widget whith his own possibilities
* By default this save the widget availlable size in the widget size

View File

@ -43,6 +43,8 @@ namespace ewol {
EVENT_INPUT_TYPE_SINGLE,
EVENT_INPUT_TYPE_DOUBLE,
EVENT_INPUT_TYPE_TRIPLE,
EVENT_INPUT_TYPE_QUAD,
EVENT_INPUT_TYPE_QUINTE,
EVENT_INPUT_TYPE_UP,
EVENT_INPUT_TYPE_ENTER,
EVENT_INPUT_TYPE_LEAVE,
@ -112,15 +114,10 @@ namespace ewol {
Widget(void);
/**
* @brief Destructor of the widget classes
* @note Use must never call this directly, when he will remove a widget he must call @ref MarkToRemove. This restriction is due to
* the internal system (one thread processing data, maybe one to regenerate the display(later) and one tha drawing on openGL)
* then when user want to remove a widget, it must be stored in the current pipe-line of ewol ...
* @param ---
* @return ---
*/
// TODO : Set this in private if possible ...
virtual ~Widget(void) { };
virtual ~Widget(void);
/**
* @brief Get the current Object type of the EObject
* @note In Embended platforme, it is many time no -rtti flag, then it is not possible to use dynamic cast ==> this will replace it
@ -128,14 +125,6 @@ namespace ewol {
* @return true if the object is compatible, otherwise false
*/
virtual const char * const GetObjectType(void) { return "EwolWidget"; };
/**
* @brief This will be equivalent at the destructor @ref ~Widget
* @note this fuction "mark" the widget as removed an inform the widget manager that the widget has been removed by the user.
* @note All the EObject are inform that an other EObject is removed ... @ref ewol::EObject
* @param ---
* @return ---
*/
void MarkToRemove(void);
// ----------------------------------------------------------------------------------------------------------------
// -- Widget Size:
// ----------------------------------------------------------------------------------------------------------------

View File

@ -214,39 +214,3 @@ bool ewol::widgetManager::PeriodicCallHave(void)
return l_havePeriodic;
}
static bool needRedraw = true;
void ewol::widgetManager::DoubleBufferLock(void)
{
if (IsInit) {
//EWOL_DEBUG("DoubleBuffer-Lock");
pthread_mutex_lock(&localMutex);
//EWOL_DEBUG("DoubleBuffer-Lock (DONE)");
}
}
void ewol::widgetManager::SetDoubleBufferNeedDraw(void)
{
needRedraw = true;
}
bool ewol::widgetManager::GetDoubleBufferNeedDraw(void)
{
if (true == needRedraw) {
needRedraw = false;
return true;
}
return false;
}
void ewol::widgetManager::DoubleBufferUnLock(void)
{
if (IsInit) {
//EWOL_DEBUG("DoubleBuffer-UnLock");
pthread_mutex_unlock(&localMutex);
//EWOL_DEBUG("DoubleBuffer-UnLock (DONE)");
}
}

View File

@ -44,20 +44,11 @@ namespace ewol {
ewol::Widget * FocusGet( void);
void FocusRemoveIfRemove(ewol::Widget * newWidget);
void PeriodicCallAdd(ewol::Widget * pWidget);
void PeriodicCallRm( ewol::Widget * pWidget);
void PeriodicCall(int64_t localTime);
bool PeriodicCallHave(void);
// TODO : Remove this from here ...
int32_t GetDoubleBufferCreate(void);
int32_t GetDoubleBufferDraw(void);
bool GetDoubleBufferNeedDraw(void);
void SetDoubleBufferNeedDraw(void);
void DoubleBufferLock(void);
void DoubleBufferUnLock(void);
};
};

View File

@ -55,13 +55,13 @@ ewol::Windows::Windows(void)
ewol::Windows::~Windows(void)
{
if (NULL != m_subWidget) {
m_subWidget->MarkToRemove();
delete(m_subWidget);
m_subWidget=NULL;
}
for(int32_t iii=0; iii<m_popUpWidgetList.Size(); iii++) {
if (NULL != m_popUpWidgetList[iii]) {
m_popUpWidgetList[iii]->MarkToRemove();
delete(m_popUpWidgetList[iii]);
m_popUpWidgetList[iii]=NULL;
}
}
@ -177,7 +177,7 @@ void ewol::Windows::SetSubWidget(ewol::Widget * widget)
{
if (NULL != m_subWidget) {
EWOL_INFO("Remove current main windows Widget...");
m_subWidget->MarkToRemove();
delete(m_subWidget);
m_subWidget = NULL;
}
m_subWidget = widget;

View File

@ -37,14 +37,9 @@
#include <ewol/ShortCutManager.h>
#include <ewol/base/eventInputManagement.h>
#ifdef __TARGET_OS__Linux
# include <sched.h>
#endif
static ewol::threadMsg::threadMsg_ts androidJniMsg;
static pthread_t androidJniThread;
static pthread_attr_t androidJniThreadAttr;
enum {
THREAD_INIT,
@ -88,32 +83,10 @@ typedef struct {
void EWOL_NativeResize(int w, int h );
void EWOL_NativeRegenerateDisplay(void);
extern eventSpecialKey_ts specialCurrentKey;
extern guiSystem::event::specialKey_ts specialCurrentKey;
static bool requestEndProcessing = false;
void ewolProcessInit(void)
{
requestEndProcessing = false;
EWOL_DEBUG("==> Init BThread (START)");
EWOL_INFO("v" EWOL_VERSION_TAG_NAME);
EWOL_INFO("Build Date: " BUILD_TIME);
etk::InitDefaultFolder("ewolApplNoName");
ewol::EObjectManager::Init();
ewol::EObjectMessageMultiCast::Init();
ewol::eventInput::Init();
ewol::widgetManager::Init();
ewol::texture::Init();
ewol::InitFont();
ewol::shortCut::Init();
APP_Init();
EWOL_DEBUG("==> Init BThread (END)");
}
void ewolProcessEvents(void)
{
int32_t nbEvent = 0;
@ -167,7 +140,7 @@ void ewolProcessEvents(void)
case THREAD_KEYBORAD_KEY:
//EWOL_DEBUG("Receive MSG : THREAD_KEYBORAD_KEY");
{
eventKeyboardKey_ts * tmpData = (eventKeyboardKey_ts*)data.data;
guiSystem::event::keyboardKey_ts * tmpData = (guiSystem::event::keyboardKey_ts*)data.data;
specialCurrentKey = tmpData->special;
if (false==ewol::shortCut::Process(tmpData->special.shift, tmpData->special.ctrl, tmpData->special.alt, tmpData->special.meta, tmpData->myChar, tmpData->isDown)) {
guiAbstraction::SendKeyboardEvent(tmpData->isDown, tmpData->myChar);
@ -177,7 +150,7 @@ void ewolProcessEvents(void)
case THREAD_KEYBORAD_MOVE:
//EWOL_DEBUG("Receive MSG : THREAD_KEYBORAD_MOVE");
{
eventKeyboardMove_ts * tmpData = (eventKeyboardMove_ts*)data.data;
guiSystem::event::keyboardMove_ts * tmpData = (guiSystem::event::keyboardMove_ts*)data.data;
specialCurrentKey = tmpData->special;
guiAbstraction::SendKeyboardEventMove(tmpData->isDown, tmpData->move);
}
@ -200,53 +173,18 @@ void ewolProcessEvents(void)
}
// pb here when dynamic widget ...
if (0 < nbEvent) {
ewolProcessRedraw();
//EWOL_DEBUG(" ******** Redraw");
if(true == ewol::threadMsg::HasDisplayDone(androidJniMsg)) {
int64_t localTime = GetCurrentTime();
ewol::widgetManager::PeriodicCall(localTime);
}
EWOL_NativeRegenerateDisplay();
}
}
void ewolProcessRedraw(void)
{
//EWOL_DEBUG(" ******** Redraw");
if(true == ewol::threadMsg::HasDisplayDone(androidJniMsg)) {
int64_t localTime = GetCurrentTime();
ewol::widgetManager::PeriodicCall(localTime);
}
EWOL_NativeRegenerateDisplay();
}
void ewolProcessUnInit(void)
{
EWOL_DEBUG("==> Un-Init BThread (START)");
// unset all windows
ewol::DisplayWindows(NULL);
// call application to uninit
APP_UnInit();
ewol::shortCut::UnInit();
ewol::texture::UnInit();
ewol::UnInitFont();
ewol::widgetManager::UnInit();
ewol::EObjectMessageMultiCast::UnInit();
ewol::EObjectManager::UnInit();
ewol::eventInput::UnInit();
EWOL_DEBUG("==> Un-Init BThread (END)");
}
static void* BaseAppEntry(void* param)
{
ewolProcessInit();
while(false == requestEndProcessing) {
ewolProcessEvents();
}
ewolProcessUnInit();
pthread_exit(NULL);
}
void EWOL_ThreadSetArchiveDir(int mode, const char* str)
void guiSystem::SetArchiveDir(int mode, const char* str)
{
switch(mode)
{
@ -272,49 +210,61 @@ void EWOL_ThreadSetArchiveDir(int mode, const char* str)
}
bool isGlobalSystemInit = false;
void EWOL_SystemStart(void)
void guiSystem::Init(void)
{
EWOL_INFO("==> Ewol System Init (BEGIN)");
if (false == isGlobalSystemInit) {
// create message system ...
EWOL_DEBUG("Init thread message system");
ewol::threadMsg::Init(androidJniMsg);
#ifdef MODE_MULTY_THREAD
// init the thread :
EWOL_DEBUG("Create the thread");
pthread_attr_init(&androidJniThreadAttr);
pthread_attr_setdetachstate(&androidJniThreadAttr, PTHREAD_CREATE_JOINABLE);
//pthread_attr_setdetachstate(&androidJniThreadAttr, PTHREAD_CREATE_DETACHED);
//pthread_attr_setscope( &androidJniThreadAttr, PTHREAD_SCOPE_SYSTEM);
pthread_setname_np(androidJniThread, "ewol_basic_thread");
pthread_create(&androidJniThread, &androidJniThreadAttr, BaseAppEntry, NULL);
//pthread_create(&androidJniThread, NULL, BaseAppEntry, NULL);
#else
ewolProcessInit();
#endif
requestEndProcessing = false;
EWOL_INFO("v" EWOL_VERSION_TAG_NAME);
EWOL_INFO("Build Date: " BUILD_TIME);
etk::InitDefaultFolder("ewolApplNoName");
ewol::EObjectManager::Init();
ewol::EObjectMessageMultiCast::Init();
ewol::eventInput::Init();
ewol::widgetManager::Init();
ewol::texture::Init();
ewol::InitFont();
ewol::shortCut::Init();
APP_Init();
isGlobalSystemInit = true;
EWOL_DEBUG("Send Init message to the thread");
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_INIT, ewol::threadMsg::MSG_PRIO_REAL_TIME);
EWOL_DEBUG("end basic init");
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_RECALCULATE_SIZE, ewol::threadMsg::MSG_PRIO_MEDIUM);
}
EWOL_INFO("==> Ewol System Init (END)");
}
void EWOL_SystemStop(void)
void guiSystem::UnInit(void)
{
EWOL_INFO("==> Ewol System Un-Init (BEGIN)");
if (true == isGlobalSystemInit) {
isGlobalSystemInit = false;
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_UN_INIT, ewol::threadMsg::MSG_PRIO_REAL_TIME);
#ifdef MODE_MULTY_THREAD
EWOL_DEBUG("Wait end of the thread ...");
// Wait end of the thread
pthread_join(androidJniThread, NULL);
#else
ewolProcessUnInit();
#endif
// unset all windows
ewol::DisplayWindows(NULL);
// call application to uninit
APP_UnInit();
ewol::shortCut::UnInit();
ewol::texture::UnInit();
ewol::UnInitFont();
ewol::widgetManager::UnInit();
ewol::EObjectMessageMultiCast::UnInit();
ewol::EObjectManager::UnInit();
ewol::eventInput::UnInit();
ewol::threadMsg::UnInit(androidJniMsg);
}
EWOL_INFO("==> Ewol System Un-Init (END)");
}
void ewol::RequestUpdateSize(void)
@ -326,81 +276,102 @@ void ewol::RequestUpdateSize(void)
void EWOL_ThreadResize(int w, int h )
void guiSystem::event::Resize(int w, int h )
{
eventResize_ts tmpData;
tmpData.w = w;
tmpData.h = h;
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_RESIZE, ewol::threadMsg::MSG_PRIO_MEDIUM, &tmpData, sizeof(eventResize_ts) );
if (true == isGlobalSystemInit) {
eventResize_ts tmpData;
tmpData.w = w;
tmpData.h = h;
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_RESIZE, ewol::threadMsg::MSG_PRIO_MEDIUM, &tmpData, sizeof(eventResize_ts) );
}
}
void EWOL_ThreadEventInputMotion(int pointerID, float x, float y )
void guiSystem::event::SetInputMotion(int pointerID, float x, float y )
{
eventInputMotion_ts tmpData;
tmpData.type = ewol::INPUT_TYPE_FINGER;
tmpData.pointerID = pointerID;
tmpData.x = x;
tmpData.y = y;
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_INPUT_MOTION, ewol::threadMsg::MSG_PRIO_LOW, &tmpData, sizeof(eventInputMotion_ts) );
if (true == isGlobalSystemInit) {
eventInputMotion_ts tmpData;
tmpData.type = ewol::INPUT_TYPE_FINGER;
tmpData.pointerID = pointerID;
tmpData.x = x;
tmpData.y = y;
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_INPUT_MOTION, ewol::threadMsg::MSG_PRIO_LOW, &tmpData, sizeof(eventInputMotion_ts) );
}
}
void EWOL_ThreadEventInputState(int pointerID, bool isUp, float x, float y )
void guiSystem::event::SetInputState(int pointerID, bool isUp, float x, float y )
{
eventInputState_ts tmpData;
tmpData.type = ewol::INPUT_TYPE_FINGER;
tmpData.pointerID = pointerID;
tmpData.state = isUp;
tmpData.x = x;
tmpData.y = y;
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_INPUT_STATE, ewol::threadMsg::MSG_PRIO_LOW, &tmpData, sizeof(eventInputState_ts) );
if (true == isGlobalSystemInit) {
eventInputState_ts tmpData;
tmpData.type = ewol::INPUT_TYPE_FINGER;
tmpData.pointerID = pointerID;
tmpData.state = isUp;
tmpData.x = x;
tmpData.y = y;
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_INPUT_STATE, ewol::threadMsg::MSG_PRIO_LOW, &tmpData, sizeof(eventInputState_ts) );
}
}
void EWOL_ThreadEventMouseMotion(int pointerID, float x, float y )
void guiSystem::event::SetMouseMotion(int pointerID, float x, float y )
{
eventInputMotion_ts tmpData;
tmpData.type = ewol::INPUT_TYPE_MOUSE;
tmpData.pointerID = pointerID;
tmpData.x = x;
tmpData.y = y;
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_INPUT_MOTION, ewol::threadMsg::MSG_PRIO_LOW, &tmpData, sizeof(eventInputMotion_ts) );
if (true == isGlobalSystemInit) {
eventInputMotion_ts tmpData;
tmpData.type = ewol::INPUT_TYPE_MOUSE;
tmpData.pointerID = pointerID;
tmpData.x = x;
tmpData.y = y;
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_INPUT_MOTION, ewol::threadMsg::MSG_PRIO_LOW, &tmpData, sizeof(eventInputMotion_ts) );
}
}
void EWOL_ThreadEventMouseState(int pointerID, bool isUp, float x, float y )
void guiSystem::event::SetMouseState(int pointerID, bool isUp, float x, float y )
{
eventInputState_ts tmpData;
tmpData.type = ewol::INPUT_TYPE_MOUSE;
tmpData.pointerID = pointerID;
tmpData.state = isUp;
tmpData.x = x;
tmpData.y = y;
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_INPUT_STATE, ewol::threadMsg::MSG_PRIO_LOW, &tmpData, sizeof(eventInputState_ts) );
if (true == isGlobalSystemInit) {
eventInputState_ts tmpData;
tmpData.type = ewol::INPUT_TYPE_MOUSE;
tmpData.pointerID = pointerID;
tmpData.state = isUp;
tmpData.x = x;
tmpData.y = y;
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_INPUT_STATE, ewol::threadMsg::MSG_PRIO_LOW, &tmpData, sizeof(eventInputState_ts) );
}
}
void EWOL_ThreadKeyboardEvent(eventKeyboardKey_ts& keyInput)
void guiSystem::event::SetKeyboard(guiSystem::event::keyboardKey_ts& keyInput)
{
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_KEYBORAD_KEY, ewol::threadMsg::MSG_PRIO_LOW, &keyInput, sizeof(eventKeyboardKey_ts) );
if (true == isGlobalSystemInit) {
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_KEYBORAD_KEY, ewol::threadMsg::MSG_PRIO_LOW, &keyInput, sizeof(guiSystem::event::keyboardKey_ts) );
}
}
void EWOL_ThreadKeyboardEventMove(eventKeyboardMove_ts& keyInput)
void guiSystem::event::SetKeyboardMove(guiSystem::event::keyboardMove_ts& keyInput)
{
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_KEYBORAD_MOVE, ewol::threadMsg::MSG_PRIO_LOW, &keyInput, sizeof(eventKeyboardMove_ts) );
if (true == isGlobalSystemInit) {
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_KEYBORAD_MOVE, ewol::threadMsg::MSG_PRIO_LOW, &keyInput, sizeof(guiSystem::event::keyboardMove_ts) );
}
}
void EWOL_ThreadEventHide(void)
void guiSystem::event::Hide(void)
{
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_HIDE, ewol::threadMsg::MSG_PRIO_LOW);
if (true == isGlobalSystemInit) {
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_HIDE, ewol::threadMsg::MSG_PRIO_LOW);
}
}
void EWOL_ThreadEventShow(void)
void guiSystem::event::Show(void)
{
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_SHOW, ewol::threadMsg::MSG_PRIO_LOW);
if (true == isGlobalSystemInit) {
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_SHOW, ewol::threadMsg::MSG_PRIO_LOW);
}
}
void EWOL_ThreadEventHasJustDisplay(void)
void guiSystem::Draw(void)
{
ewol::threadMsg::SendDisplayDone(androidJniMsg);
//ewol::threadMsg::SendMessage(androidJniMsg, THREAD_JUST_DISPLAY, ewol::threadMsg::MSG_PRIO_REAL_TIME);
if (true == isGlobalSystemInit) {
ewolProcessEvents();
ewol::texture::UpdateContext();
EWOL_NativeRender();
}
}

View File

@ -27,55 +27,57 @@
#ifndef __EWOL_MAIN_TREAD_H__
#define __EWOL_MAIN_TREAD_H__
#include <pthread.h>
#include <ewol/ewol.h>
//#define MODE_MULTY_THREAD
void EWOL_SystemStart(void);
void EWOL_SystemStop(void);
void ewolProcessEvents(void);
void ewolProcessRedraw(void);
void EWOL_ThreadSetArchiveDir(int mode, const char* str);
void EWOL_ThreadResize(int w, int h );
void EWOL_ThreadEventInputMotion(int pointerID, float x, float y);
void EWOL_ThreadEventInputState(int pointerID, bool isUp, float x, float y);
void EWOL_ThreadEventMouseMotion(int pointerID, float x, float y);
void EWOL_ThreadEventMouseState(int pointerID, bool isUp, float x, float y);
typedef struct {
bool capLock;
bool shift;
bool ctrl;
bool meta;
bool alt;
bool altGr;
bool verNum;
bool insert;
} eventSpecialKey_ts;
typedef struct {
bool isDown;
uniChar_t myChar;
eventSpecialKey_ts special;
} eventKeyboardKey_ts;
typedef struct {
bool isDown;
ewol::eventKbMoveType_te move;
eventSpecialKey_ts special;
} eventKeyboardMove_ts;
void EWOL_ThreadKeyboardEvent(eventKeyboardKey_ts& keyInput);
void EWOL_ThreadKeyboardEventMove(eventKeyboardMove_ts& keyInput);
void EWOL_ThreadEventHide(void);
void EWOL_ThreadEventShow(void);
void EWOL_ThreadEventHasJustDisplay(void);
namespace guiSystem
{
void Init(void);
void UnInit(void);
void SetArchiveDir(int mode, const char* str);
namespace event {
void Resize(int w, int h );
void SetInputMotion(int pointerID, float x, float y);
void SetInputState(int pointerID, bool isUp, float x, float y);
void SetMouseMotion(int pointerID, float x, float y);
void SetMouseState(int pointerID, bool isUp, float x, float y);
typedef struct {
bool capLock;
bool shift;
bool ctrl;
bool meta;
bool alt;
bool altGr;
bool verNum;
bool insert;
} specialKey_ts;
typedef struct {
bool isDown;
uniChar_t myChar;
guiSystem::event::specialKey_ts special;
} keyboardKey_ts;
typedef struct {
bool isDown;
ewol::eventKbMoveType_te move;
guiSystem::event::specialKey_ts special;
} keyboardMove_ts;
void SetKeyboard(guiSystem::event::keyboardKey_ts& keyInput);
void SetKeyboardMove(guiSystem::event::keyboardMove_ts& keyInput);
void Hide(void);
void Show(void);
};
void Draw(void);
};
#endif

View File

@ -355,27 +355,25 @@ void ewol::eventInput::State(ewol::inputType_te type, int pointerID, bool isDown
eventTable[pointerID].downStart = pos;
// save start time
eventTable[pointerID].lastTimeEvent = currentTime;
if( eventTable[pointerID].nbClickEvent == 0
&& eventTable[pointerID].curentWidgetEvent != NULL
&& eventTable[pointerID].curentWidgetEvent->GetMouseLimit()>0 ) {
int32_t nbClickMax = 0;
if(eventTable[pointerID].curentWidgetEvent != NULL) {
nbClickMax = eventTable[pointerID].curentWidgetEvent->GetMouseLimit();
if (nbClickMax>5) {
nbClickMax = 5;
}
}
if(eventTable[pointerID].nbClickEvent < nbClickMax) {
// generate event SINGLE :
eventTable[pointerID].nbClickEvent++;
EWOL_VERBOSE("GUI : Input ID=" << pointerID << "==>" << eventTable[pointerID].destinationInputId << " [SINGLE] " << pos);
localEventInput(type, eventTable[pointerID].curentWidgetEvent, eventTable[pointerID].destinationInputId, ewol::EVENT_INPUT_TYPE_SINGLE, pos);
} else if( eventTable[pointerID].nbClickEvent == 1
&& eventTable[pointerID].curentWidgetEvent != NULL
&& eventTable[pointerID].curentWidgetEvent->GetMouseLimit()>1 ) {
// generate event DOUBLE :
eventTable[pointerID].nbClickEvent++;
EWOL_VERBOSE("GUI : Input ID=" << pointerID << "==>" << eventTable[pointerID].destinationInputId << " [DOUBLE] " << pos);
localEventInput(type, eventTable[pointerID].curentWidgetEvent, eventTable[pointerID].destinationInputId, ewol::EVENT_INPUT_TYPE_DOUBLE, pos);
} else if( eventTable[pointerID].nbClickEvent == 2
&& eventTable[pointerID].curentWidgetEvent != NULL
&& eventTable[pointerID].curentWidgetEvent->GetMouseLimit()>2 ) {
// generate event TRIPLE :
eventTable[pointerID].nbClickEvent++;
EWOL_VERBOSE("GUI : Input ID=" << pointerID << "==>" << eventTable[pointerID].destinationInputId << " [TRIPLE] " << pos);
localEventInput(type, eventTable[pointerID].curentWidgetEvent, eventTable[pointerID].destinationInputId, ewol::EVENT_INPUT_TYPE_TRIPLE, pos);
localEventInput(type,
eventTable[pointerID].curentWidgetEvent,
eventTable[pointerID].destinationInputId,
(ewol::eventInputType_te)(ewol::EVENT_INPUT_TYPE_SINGLE + eventTable[pointerID].nbClickEvent-1),
pos);
if( eventTable[pointerID].nbClickEvent >= nbClickMax) {
eventTable[pointerID].nbClickEvent = 0;
}
} else {
eventTable[pointerID].nbClickEvent = 0;
}

View File

@ -34,6 +34,7 @@
#include <ewol/Texture.h>
#include <ewol/base/MainThread.h>
#include <ewol/importgl.h>
ewol::Windows* gui_uniqueWindows = NULL;
float gui_width = 320;
@ -75,26 +76,13 @@ void EWOL_NativeResize(int w, int h )
void EWOL_NativeRegenerateDisplay(void)
{
// Remove all widget that they are no more usefull (these who decided to destroy themself)
ewol::EObjectManager::RemoveAllAutoRemove();
//EWOL_INFO("Resize w=" << w << " h=" << h);
if (NULL != gui_uniqueWindows) {
// Redraw all needed elements
gui_uniqueWindows->OnRegenerateDisplay();
// Keep Inter-thread-lock-mutex
ewol::widgetManager::DoubleBufferLock();
// Inform the main thread of openGl draw that somthing to display
ewol::widgetManager::SetDoubleBufferNeedDraw();
// Release Inter-thread-lock-mutex
ewol::widgetManager::DoubleBufferUnLock();
// Remove deprecated widget (which have no more reference in the system)
ewol::EObjectManager::RemoveAllMark();
}
}
void guiAbstraction::SetDisplayOnWindows(ewol::Windows * newWindows)
{
gui_uniqueWindows = newWindows;
if (NULL != gui_uniqueWindows) {
gui_uniqueWindows->CalculateSize((float)gui_width, (float)gui_height);
}
}
@ -105,6 +93,13 @@ void guiAbstraction::ForceRedrawAll(void)
}
}
void guiAbstraction::SetDisplayOnWindows(ewol::Windows * newWindows)
{
gui_uniqueWindows = newWindows;
ForceRedrawAll();
}
void guiAbstraction::SendKeyboardEvent(bool isDown, uniChar_t keyInput)
{
@ -135,28 +130,6 @@ void guiAbstraction::SendKeyboardEventMove(bool isDown, ewol::eventKbMoveType_te
}
/*
void guiAbstraction::KeyboardShow(ewol::keyboardMode_te mode)
{
if (NULL != gui_uniqueWindows) {
gui_uniqueWindows->KeyboardShow(mode);
}
}
void guiAbstraction::KeyboardHide(void)
{
if (NULL != gui_uniqueWindows) {
gui_uniqueWindows->KeyboardHide();
}
ForceRedrawAll();
}
*/
static int64_t startTime = -1;
static int64_t nbCallTime = 0;
static int64_t nbDisplayTime = 0;
@ -170,61 +143,153 @@ static int64_t max2 = 0;
#define DISPLAY_PERIODE_US (1000000)
static float gTriangleVertices[] = { 0.0f, 0.0f, 200.0f, 0.0f, 0.0f, 200.0f };
static float gTriangleVertices5[] = { 200.0f, 200.0f, 100.0f, 200.0f, 200.0f, 100.0f,
200.0f, 200.0f, 300.0f, 200.0f, 200.0f, 300.0f };
void EWOL_GenericDraw(bool everyTime)
{
bool display = false;
nbCallTime++;
if (startTime<0) {
startTime = GetCurrentTime();
}
int64_t currentTime = GetCurrentTime();
//EWOL_DEBUG("current : " << currentTime << "time diff : " << (currentTime - startTime));
if ( (currentTime - startTime) > DISPLAY_PERIODE_US) {
display = true;
}
// TODO : Remove this ...
if (ewol::widgetManager::PeriodicCallHave()) {
everyTime = true;
}
ewol::widgetManager::DoubleBufferLock();
int64_t currentTime3 = GetCurrentTime();
if( true == ewol::widgetManager::GetDoubleBufferNeedDraw()
|| true == everyTime)
{
ewol::texture::UpdateContext();
nbDisplayTime++;
gui_uniqueWindows->SysDraw();
}
ewol::widgetManager::DoubleBufferUnLock();
// send Message that we just finished a display ...
EWOL_ThreadEventHasJustDisplay();
int64_t currentTime2 = GetCurrentTime();
int64_t processTimeLocal = (currentTime2 - currentTime);
min = etk_min(min, processTimeLocal);
max = etk_max(max, processTimeLocal);
avg += processTimeLocal;
processTimeLocal = (currentTime2 - currentTime3);
min2 = etk_min(min2, processTimeLocal);
max2 = etk_max(max2, processTimeLocal);
avg2 += processTimeLocal;
if (true == display) {
EWOL_DEBUG("display property : " << nbDisplayTime << "/" << nbCallTime << "fps");
EWOL_DEBUG("timeToProcess1 : " << (float)((float)min / 1000.0) << "ms "
<< (float)((float)avg/(float)nbDisplayTime / 1000.0) << "ms "
<< (float)((float)max / 1000.0) << "ms ");
EWOL_DEBUG("timeToProcess2 : " << (float)((float)min2 / 1000.0) << "ms "
<< (float)((float)avg2/(float)nbDisplayTime / 1000.0) << "ms "
<< (float)((float)max2 / 1000.0) << "ms ");
max2 = 0;
max = 0;
min = 99999999999999;
min2 = 99999999999999;
avg=0;
avg2=0;
//EWOL_DEBUG("redraw (" << gui_width << "," << gui_height << ")");
if(NULL == gui_uniqueWindows) {
// set the size of the open GL system
glViewport(0,0,gui_width,gui_height);
nbCallTime = 0;
nbDisplayTime = 0;
startTime = -1;
// Clear the screen with transparency ...
glClearColor(0.0,0.0,0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//glOrtho(0., width, 0., -height, 1., 20.);
glOrthoEwol(-gui_width/2, gui_width/2, gui_height/2, -gui_height/2, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//glTranslatef(0, -height/2, -5);
glTranslatef(-gui_width/2, -gui_height/2, -1.0);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnableClientState( GL_VERTEX_ARRAY );
//LOGI("engine_draw_frame (%d,%d)",width,height);
glColor4f(0.0, 1.0, 1.0, 1.0);
glVertexPointer(2, GL_FLOAT, 0, gTriangleVertices5 );
glDrawArrays( GL_TRIANGLES, 0, 6);
static int vallllll = 0;
static float transparency = 0.0;
if (vallllll <= 1) {
transparency +=0.025;
if (transparency >= 1.0) {
vallllll++;
transparency = 0.0;
glColor4f(1.0, 0.0, 0.0, 1.0);
} else {
glColor4f(1.0, 0.0, 0.0, transparency);
}
} else if (vallllll <= 2) {
transparency +=0.025;
if (transparency >= 1.0) {
vallllll++;
transparency = 0.0;
glColor4f(1.0, 1.0, 0.0, 1.0);
} else {
glColor4f(1.0, 1.0, 0.0, transparency);
}
} else if (vallllll <= 3) {
transparency +=0.025;
if (transparency >= 1.0) {
vallllll++;
transparency = 0.0;
glColor4f(0.0, 1.0, 0.0, 1.0);
} else {
glColor4f(0.0, 1.0, 0.0, transparency);
}
} else if (vallllll <= 4) {
transparency +=0.025;
if (transparency >= 1.0) {
vallllll++;
transparency = 0.0;
glColor4f(0.0, 1.0, 1.0, 1.0);
} else {
glColor4f(0.0, 1.0, 1.0, transparency);
}
} else if (vallllll <= 5) {
transparency +=0.025;
if (transparency >= 1.0) {
vallllll++;
transparency = 0.0;
glColor4f(0.0, 0.0, 1.0, 1.0);
} else {
glColor4f(0.0, 0.0, 1.0, transparency);
}
} else {
transparency +=0.025;
if (transparency >= 1.0) {
vallllll = 0;
transparency = 0.0;
glColor4f(1.0, 0.0, 1.0, 1.0);
} else {
glColor4f(1.0, 0.0, 1.0, transparency);
}
}
glVertexPointer(2, GL_FLOAT, 0, gTriangleVertices );
glDrawArrays( GL_TRIANGLES, 0, 3);
glDisableClientState( GL_VERTEX_ARRAY );
glDisable(GL_BLEND);
} else {
bool display = false;
nbCallTime++;
if (startTime<0) {
startTime = GetCurrentTime();
}
int64_t currentTime = GetCurrentTime();
//EWOL_DEBUG("current : " << currentTime << "time diff : " << (currentTime - startTime));
if ( (currentTime - startTime) > DISPLAY_PERIODE_US) {
display = true;
}
int64_t currentTime3 = GetCurrentTime();
// TODO : Check if somthink has regenerate his display befor redraw ...
{
ewol::texture::UpdateContext();
nbDisplayTime++;
gui_uniqueWindows->SysDraw();
}
// send Message that we just finished a display ...
//EWOL_ThreadEventHasJustDisplay();
int64_t currentTime2 = GetCurrentTime();
int64_t processTimeLocal = (currentTime2 - currentTime);
min = etk_min(min, processTimeLocal);
max = etk_max(max, processTimeLocal);
avg += processTimeLocal;
processTimeLocal = (currentTime2 - currentTime3);
min2 = etk_min(min2, processTimeLocal);
max2 = etk_max(max2, processTimeLocal);
avg2 += processTimeLocal;
if (true == display) {
EWOL_DEBUG("display property : " << nbDisplayTime << "/" << nbCallTime << "fps");
EWOL_DEBUG("timeToProcess1 : " << (float)((float)min / 1000.0) << "ms "
<< (float)((float)avg/(float)nbDisplayTime / 1000.0) << "ms "
<< (float)((float)max / 1000.0) << "ms ");
EWOL_DEBUG("timeToProcess2 : " << (float)((float)min2 / 1000.0) << "ms "
<< (float)((float)avg2/(float)nbDisplayTime / 1000.0) << "ms "
<< (float)((float)max2 / 1000.0) << "ms ");
max2 = 0;
max = 0;
min = 99999999999999;
min2 = 99999999999999;
avg=0;
avg2=0;
nbCallTime = 0;
nbDisplayTime = 0;
startTime = -1;
}
}
}

View File

@ -31,6 +31,7 @@
#include <ewol/Windows.h>
#include <ewol/ewol.h>
void EWOL_NativeRender(void);
void EWOL_NativeResize(int w, int h );
void EWOL_GenericDraw(bool everyTime);
void EWOL_NativeGLDestroy(void);

View File

@ -78,116 +78,10 @@ static etk::UString l_clipBoardPrimary(""); // local copy of the selection
static etk::UString l_clipBoardStd(""); // local copy of the clipboard
static float gTriangleVertices[] = { 0.0f, 0.0f, 200.0f, 0.0f, 0.0f, 200.0f };
static float gTriangleVertices5[] = { 200.0f, 200.0f, 100.0f, 200.0f, 200.0f, 100.0f,
200.0f, 200.0f, 300.0f, 200.0f, 200.0f, 300.0f };
void EWOL_NativeRender(void)
{
#ifdef MODE_MULTY_THREAD
#else
ewolProcessEvents();
#endif
ewol::texture::UpdateContext();
//EWOL_DEBUG("redraw (" << gui_width << "," << gui_height << ")");
if(NULL == gui_uniqueWindows) {
// set the size of the open GL system
glViewport(0,0,gui_width,gui_height);
// Clear the screen with transparency ...
glClearColor(0.0,0.0,0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//glOrtho(0., width, 0., -height, 1., 20.);
glOrthoEwol(-gui_width/2, gui_width/2, gui_height/2, -gui_height/2, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//glTranslatef(0, -height/2, -5);
glTranslatef(-gui_width/2, -gui_height/2, -1.0);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_DST_ALPHA);
//glBlendFunc(GL_SRC_ALPHA, GL_SRC_COLOR);
glEnableClientState( GL_VERTEX_ARRAY );
//LOGI("engine_draw_frame (%d,%d)",width,height);
glColor4f(0.0, 1.0, 1.0, 1.0);
glVertexPointer(2, GL_FLOAT, 0, gTriangleVertices5 );
glDrawArrays( GL_TRIANGLES, 0, 6);
static int vallllll = 0;
static float transparency = 0.0;
if (vallllll <= 1) {
transparency +=0.025;
if (transparency >= 1.0) {
vallllll++;
transparency = 0.0;
glColor4f(1.0, 0.0, 0.0, 1.0);
} else {
glColor4f(1.0, 0.0, 0.0, transparency);
}
} else if (vallllll <= 2) {
transparency +=0.025;
if (transparency >= 1.0) {
vallllll++;
transparency = 0.0;
glColor4f(1.0, 1.0, 0.0, 1.0);
} else {
glColor4f(1.0, 1.0, 0.0, transparency);
}
} else if (vallllll <= 3) {
transparency +=0.025;
if (transparency >= 1.0) {
vallllll++;
transparency = 0.0;
glColor4f(0.0, 1.0, 0.0, 1.0);
} else {
glColor4f(0.0, 1.0, 0.0, transparency);
}
} else if (vallllll <= 4) {
transparency +=0.025;
if (transparency >= 1.0) {
vallllll++;
transparency = 0.0;
glColor4f(0.0, 1.0, 1.0, 1.0);
} else {
glColor4f(0.0, 1.0, 1.0, transparency);
}
} else if (vallllll <= 5) {
transparency +=0.025;
if (transparency >= 1.0) {
vallllll++;
transparency = 0.0;
glColor4f(0.0, 0.0, 1.0, 1.0);
} else {
glColor4f(0.0, 0.0, 1.0, transparency);
}
} else {
transparency +=0.025;
if (transparency >= 1.0) {
vallllll = 0;
transparency = 0.0;
glColor4f(1.0, 0.0, 1.0, 1.0);
} else {
glColor4f(1.0, 0.0, 1.0, transparency);
}
}
glVertexPointer(2, GL_FLOAT, 0, gTriangleVertices );
glDrawArrays( GL_TRIANGLES, 0, 3);
glDisableClientState( GL_VERTEX_ARRAY );
glDisable(GL_BLEND);
} else {
EWOL_GenericDraw(true);
//EWOL_GenericDraw(false);
}
EWOL_GenericDraw(true);
glFlush();
}

View File

@ -43,6 +43,11 @@
#include <X11/Xatom.h>
#include <sys/times.h>
/*
#define GUI_LOCK() XLockDisplay(m_display)
#define GUI_UNLOCK() XUnlockDisplay(m_display)
*/
//#define DEBUG_X11_EVENT
int64_t GetCurrentTime(void)
@ -82,7 +87,7 @@ static int attrListDbl[] = {
None
};
static eventSpecialKey_ts guiKeyBoardMode;
static guiSystem::event::specialKey_ts guiKeyBoardMode;
extern "C" {
@ -123,33 +128,6 @@ int32_t separateClickTime = 300000;
int32_t offsetMoveClicked = 10000;
int32_t offsetMoveClickedDouble = 20000;
// specific for the Multithread management :
// Note we did not use the internal XLockDisplay(m_display); because we have real time disfunctionnement
#define PTHREAD_GUI_LOCK_MULTITHREAD
#ifdef PTHREAD_GUI_LOCK_MULTITHREAD
static pthread_mutex_t l_mutex;
#if 1
#define GUI_LOCK() do { \
/*EWOL_DEBUG("GUI-Lock");*/ \
pthread_mutex_lock(&l_mutex); \
/*EWOL_DEBUG("GUI-Lock (done)");*/ \
}while(0)
#define GUI_UNLOCK() do { \
/*EWOL_DEBUG("GUI-UnLock");*/ \
pthread_mutex_unlock(&l_mutex); \
/*EWOL_DEBUG("GUI-UnLock (done)");*/ \
}while(0)
#else
#define GUI_LOCK() do { \
}while(0)
#define GUI_UNLOCK() do { \
}while(0)
#endif
#else
#define GUI_LOCK() XLockDisplay(m_display)
#define GUI_UNLOCK() XUnlockDisplay(m_display)
#endif
bool l_titleChange = false;
etk::UString l_title = "Ewol";
@ -189,13 +167,6 @@ bool CreateX11Context(void)
// basic title of the windows ...
static char *title = (char*)"Ewol";
#ifndef PTHREAD_GUI_LOCK_MULTITHREAD
// start multiple connection on the display for multiple threading :
Status retStat = XInitThreads();
if (0!=retStat) {
EWOL_ERROR("While XInitThreads() ==> can have some problem sometimes : " << retStat);
}
#endif
// Connect to the X server
m_display = XOpenDisplay(NULL);
if(NULL == m_display) {
@ -309,7 +280,6 @@ static void local_SetTitle(etk::UString title)
#ifdef DEBUG_X11_EVENT
EWOL_INFO("X11: Set Title (START)");
#endif
GUI_LOCK();
XTextProperty tp;
tp.value = (unsigned char *)title.Utf8Data();
tp.encoding = XA_WM_NAME;
@ -319,7 +289,6 @@ static void local_SetTitle(etk::UString title)
XStoreName(m_display, WindowHandle, (const char*)tp.value);
XSetIconName(m_display, WindowHandle, (const char*)tp.value);
XSetWMIconName(m_display, WindowHandle, &tp);
GUI_UNLOCK();
#ifdef DEBUG_X11_EVENT
EWOL_INFO("X11: Set Title (END)");
#endif
@ -353,7 +322,6 @@ void SetIcon(etk::File bitmapFile)
} else {
etk::UString fileExtention = bitmapFile.GetExtention();
if (fileExtention == "bmp") {
GUI_LOCK();
// pointer to the WM hints structure.
XWMHints* win_hints;
@ -367,15 +335,12 @@ void SetIcon(etk::File bitmapFile)
switch (rc) {
case BitmapOpenFailed:
EWOL_ERROR("XReadBitmapFile - could not open file ");
GUI_UNLOCK();
return;
case BitmapFileInvalid:
EWOL_ERROR("XReadBitmapFile - file doesn't contain a valid bitmap.");
GUI_UNLOCK();
return;
case BitmapNoMemory:
EWOL_ERROR("XReadBitmapFile - not enough memory.");
GUI_UNLOCK();
return;
case BitmapSuccess:
/* bitmap loaded successfully - do something with it... */
@ -386,7 +351,6 @@ void SetIcon(etk::File bitmapFile)
win_hints = XAllocWMHints();
if (!win_hints) {
EWOL_ERROR("XAllocWMHints - out of memory");
GUI_UNLOCK();
return;
}
// initialize the structure appropriately. first, specify which size hints we want to fill in. in our case - setting the icon's pixmap.
@ -398,7 +362,6 @@ void SetIcon(etk::File bitmapFile)
EWOL_INFO(" ==> might be done ");
// finally, we can free the WM hints structure.
XFree(win_hints);
GUI_UNLOCK();
} else {
EWOL_ERROR("X11 Icon Extention not managed " << bitmapFile << " Sopported extention : .bmp ");
}
@ -411,7 +374,6 @@ void RemoveDecoration(void)
#ifdef DEBUG_X11_EVENT
EWOL_INFO("X11:RemoveDecoration");
#endif
GUI_LOCK();
Hints hints;
Atom property;
hints.flags = 2;// Specify that we're changing the window decorations.
@ -423,7 +385,6 @@ void RemoveDecoration(void)
} else {
EWOL_ERROR("Can not get the property for the rmoving decoration of the X11 system ....");
}
GUI_UNLOCK();
}
void AddDecoration(void)
@ -431,7 +392,6 @@ void AddDecoration(void)
#ifdef DEBUG_X11_EVENT
EWOL_INFO("X11:AddDecoration");
#endif
GUI_LOCK();
Hints hints;
Atom property;
hints.flags = 2;// Specify that we're changing the window decorations.
@ -443,7 +403,6 @@ void AddDecoration(void)
} else {
EWOL_ERROR("Can not get the property for the rmoving decoration of the X11 system ....");
}
GUI_UNLOCK();
}
bool CreateOGlContext(void)
@ -451,7 +410,6 @@ bool CreateOGlContext(void)
#ifdef DEBUG_X11_EVENT
EWOL_INFO("X11:CreateOGlContext");
#endif
GUI_LOCK();
/* create a GLX context */
GLXContext RenderContext = glXCreateContext(m_display, m_visual, 0, GL_TRUE);
/* connect the glx-context to the window */
@ -461,35 +419,12 @@ bool CreateOGlContext(void)
} else {
EWOL_INFO("XF86 DRI NOT available\n");
}
GUI_UNLOCK();
return true;
}
void EWOL_NativeRender(void)
{
ewol::texture::UpdateContext();
//EWOL_DEBUG("redraw (" << gui_width << "," << gui_height << ")");
if(NULL == gui_uniqueWindows) {
// set the size of the open GL system
glViewport(0,0,gui_width,gui_height);
// Clear the screen with transparency ...
glClearColor(0.750, 0.750, 0.750, 0.5);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0., (float)gui_width, 0., (float)gui_height, 1., 20.);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0, 0, -5);
glBegin(GL_QUADS);
glColor3f(1., 0., 0.); glVertex3f( .25*(float)gui_width, .25*(float)gui_height, 0.);
glColor3f(0., 1., 0.); glVertex3f( .75*(float)gui_width, .25*(float)gui_height, 0.);
glColor3f(0., 0., 1.); glVertex3f( .75*(float)gui_width, .75*(float)gui_height, 0.);
glColor3f(1., 1., 0.); glVertex3f( .25*(float)gui_width, .75*(float)gui_height, 0.);
glEnd();
} else {
EWOL_GenericDraw(false);
}
EWOL_GenericDraw(false);
glFlush();
if (m_doubleBuffered) {
glXSwapBuffers(m_display, WindowHandle);
@ -612,7 +547,6 @@ void X11_Run(void)
Atom type;
int format;
unsigned long nitems, bytes;
GUI_LOCK();
XGetWindowProperty(m_display,
WindowHandle,
event.xselection.property,
@ -626,7 +560,6 @@ void X11_Run(void)
&bytes, // *bytes_after_return
&buf// **prop_return);
);
GUI_UNLOCK();
if (true == l_clipBoardRequestPrimary) {
l_clipBoardPrimary = (char*)buf;
// inform that we have receive the data
@ -666,7 +599,6 @@ void X11_Run(void)
} else {
magatTextToSend = "";
}
GUI_LOCK();
Atom listOfAtom[4];
if(strlen(magatTextToSend) == 0 ) {
respond.xselection.property= None;
@ -721,7 +653,6 @@ void X11_Run(void)
XSendEvent (m_display, req->requestor,0,0,&respond);
// Flush the message on the pipe ...
XFlush (m_display);
GUI_UNLOCK();
}
break;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -781,7 +712,7 @@ void X11_Run(void)
#endif
m_originX = event.xconfigure.x;
m_originY = event.xconfigure.y;
EWOL_ThreadResize(event.xconfigure.width, event.xconfigure.height);
guiSystem::event::Resize(event.xconfigure.width, event.xconfigure.height);
break;
case ButtonPress:
#ifdef DEBUG_X11_EVENT
@ -792,7 +723,7 @@ void X11_Run(void)
if (event.xbutton.button < NB_MAX_INPUT) {
inputIsPressed[event.xbutton.button] = true;
}
EWOL_ThreadEventMouseState(event.xbutton.button, true, (float)event.xbutton.x, (float)event.xbutton.y);
guiSystem::event::SetMouseState(event.xbutton.button, true, (float)event.xbutton.x, (float)event.xbutton.y);
break;
case ButtonRelease:
#ifdef DEBUG_X11_EVENT
@ -803,7 +734,7 @@ void X11_Run(void)
if (event.xbutton.button < NB_MAX_INPUT) {
inputIsPressed[event.xbutton.button] = false;
}
EWOL_ThreadEventMouseState(event.xbutton.button, false, (float)event.xbutton.x, (float)event.xbutton.y);
guiSystem::event::SetMouseState(event.xbutton.button, false, (float)event.xbutton.x, (float)event.xbutton.y);
break;
case EnterNotify:
#ifdef DEBUG_X11_EVENT
@ -834,13 +765,13 @@ void X11_Run(void)
for (int32_t iii=0; iii<NB_MAX_INPUT ; iii++) {
if (true == inputIsPressed[iii]) {
EWOL_VERBOSE("X11 event: bt=" << iii << " " << event.type << " = \"MotionNotify\" (" << (float)event.xmotion.x << "," << (float)event.xmotion.y << ")");
EWOL_ThreadEventMouseMotion(iii, (float)event.xmotion.x, (float)event.xmotion.y);
guiSystem::event::SetMouseMotion(iii, (float)event.xmotion.x, (float)event.xmotion.y);
findOne = true;
}
}
if (false == findOne) {
EWOL_VERBOSE("X11 event: bt=" << 0 << " " << event.type << " = \"MotionNotify\" (" << (float)event.xmotion.x << "," << (float)event.xmotion.y << ")");
EWOL_ThreadEventMouseMotion(0, (float)event.xmotion.x, (float)event.xmotion.y);
guiSystem::event::SetMouseMotion(0, (float)event.xmotion.x, (float)event.xmotion.y);
}
}
break;
@ -965,7 +896,7 @@ void X11_Run(void)
case 91: // Suppr on keypad
find = false;
{
eventKeyboardKey_ts specialEvent;
guiSystem::event::keyboardKey_ts specialEvent;
specialEvent.special = guiKeyBoardMode;
specialEvent.myChar = 0x0000007F;
if(event.type == KeyPress) {
@ -973,13 +904,13 @@ void X11_Run(void)
} else {
specialEvent.isDown = false;
}
EWOL_ThreadKeyboardEvent(specialEvent);
guiSystem::event::SetKeyboard(specialEvent);
}
break;
case 23: // special case for TAB
find = false;
{
eventKeyboardKey_ts specialEvent;
guiSystem::event::keyboardKey_ts specialEvent;
specialEvent.special = guiKeyBoardMode;
specialEvent.myChar = 0x00000009;
if(event.type == KeyPress) {
@ -987,7 +918,7 @@ void X11_Run(void)
} else {
specialEvent.isDown = false;
}
EWOL_ThreadKeyboardEvent(specialEvent);
guiSystem::event::SetKeyboard(specialEvent);
}
break;
default:
@ -1013,7 +944,7 @@ void X11_Run(void)
}
if (count>0) {
// transform iun unicode
eventKeyboardKey_ts specialEvent;
guiSystem::event::keyboardKey_ts specialEvent;
specialEvent.special = guiKeyBoardMode;
unicode::convertIsoToUnicode(unicode::EDN_CHARSET_ISO_8859_15, buf[0], specialEvent.myChar);
//EWOL_INFO("event Key : " << event.xkey.keycode << " char=\"" << buf << "\"'len=" << strlen(buf) << " unicode=" << unicodeValue);
@ -1022,7 +953,7 @@ void X11_Run(void)
} else {
specialEvent.isDown = false;
}
EWOL_ThreadKeyboardEvent(specialEvent);
guiSystem::event::SetKeyboard(specialEvent);
} else {
EWOL_WARNING("Unknow event Key : " << event.xkey.keycode);
}
@ -1031,7 +962,7 @@ void X11_Run(void)
}
if (true == find) {
//EWOL_DEBUG("eventKey Move type : " << GetCharTypeMoveEvent(keyInput) );
eventKeyboardMove_ts specialEvent;
guiSystem::event::keyboardMove_ts specialEvent;
specialEvent.special = guiKeyBoardMode;
if(event.type == KeyPress) {
specialEvent.isDown = true;
@ -1039,7 +970,7 @@ void X11_Run(void)
specialEvent.isDown = false;
}
specialEvent.move = keyInput;
EWOL_ThreadKeyboardEventMove(specialEvent);
guiSystem::event::SetKeyboardMove(specialEvent);
}
}
break;
@ -1049,13 +980,13 @@ void X11_Run(void)
#ifdef DEBUG_X11_EVENT
EWOL_INFO("X11 event : MapNotify");
#endif
EWOL_ThreadEventShow();
guiSystem::event::Show();
break;
case UnmapNotify:
#ifdef DEBUG_X11_EVENT
EWOL_INFO("X11 event : UnmapNotify");
#endif
EWOL_ThreadEventHide();
guiSystem::event::Hide();
break;
default:
#ifdef DEBUG_X11_EVENT
@ -1065,17 +996,7 @@ void X11_Run(void)
}
}
if(true == m_run) {
#ifdef MODE_MULTY_THREAD
#else
ewolProcessEvents();
#endif
#ifdef DEBUG_X11_EVENT
EWOL_INFO("X11 Render...");
#endif
GUI_LOCK();
EWOL_NativeRender();
GUI_UNLOCK();
guiSystem::Draw();
}
#ifdef DEBUG_X11_EVENT
EWOL_INFO("X11 endEvent --- ");
@ -1088,9 +1009,7 @@ void X11_ChangeSize(int32_t w, int32_t h)
#ifdef DEBUG_X11_EVENT
EWOL_INFO("X11: X11_ChangeSize");
#endif
GUI_LOCK();
XResizeWindow(m_display, WindowHandle, w, h);
GUI_UNLOCK();
};
void X11_ChangePos(int32_t x, int32_t y)
@ -1098,9 +1017,7 @@ void X11_ChangePos(int32_t x, int32_t y)
#ifdef DEBUG_X11_EVENT
EWOL_INFO("X11: X11_ChangePos");
#endif
GUI_LOCK();
XMoveWindow(m_display, WindowHandle, x, y);
GUI_UNLOCK();
};
void X11_GetAbsPos(int32_t & x, int32_t & y)
@ -1111,9 +1028,7 @@ void X11_GetAbsPos(int32_t & x, int32_t & y)
int tmp;
unsigned int tmp2;
Window fromroot, tmpwin;
GUI_LOCK();
XQueryPointer(m_display, WindowHandle, &fromroot, &tmpwin, &x, &y, &tmp, &tmp, &tmp2);
GUI_UNLOCK();
};
@ -1134,14 +1049,12 @@ void guiAbstraction::ClipBoardGet(etk::UString &newData, clipBoardMode_te mode)
// clear old request ..
ewol::simpleMsg::Clear(l_clipboardMessage);
// Generate a request on X11
GUI_LOCK();
XConvertSelection(m_display,
XAtomeSelection,// atom,
XAtomeTargetStringUTF8, // type?
XAtomeEWOL, // prop,
WindowHandle,
CurrentTime);
GUI_UNLOCK();
// wait the event ...
int32_t waitTmp = ewol::simpleMsg::WaitingMessage(l_clipboardMessage, 5000);
if (waitTmp == 0) {
@ -1157,14 +1070,12 @@ void guiAbstraction::ClipBoardGet(etk::UString &newData, clipBoardMode_te mode)
// clear old request ..
ewol::simpleMsg::Clear(l_clipboardMessage);
// Generate a request on X11
GUI_LOCK();
XConvertSelection(m_display,
XAtomeClipBoard,// atom,
XAtomeTargetStringUTF8, // type?
XAtomeEWOL, // prop,
WindowHandle,
CurrentTime);
GUI_UNLOCK();
// wait the event ...
int32_t waitTmp = ewol::simpleMsg::WaitingMessage(l_clipboardMessage, 5000);
if (waitTmp == 0) {
@ -1193,9 +1104,7 @@ void guiAbstraction::ClipBoardSet(etk::UString &newData, clipBoardMode_te mode)
l_clipBoardPrimary = newData;
// Request the selection :
if (false == l_clipBoardOwnerPrimary) {
GUI_LOCK();
XSetSelectionOwner(m_display, XAtomeSelection, WindowHandle, CurrentTime);
GUI_UNLOCK();
l_clipBoardOwnerPrimary = true;
}
}
@ -1206,9 +1115,7 @@ void guiAbstraction::ClipBoardSet(etk::UString &newData, clipBoardMode_te mode)
l_clipBoardStd = newData;
// Request the clipBoard :
if (false == l_clipBoardOwnerStd) {
GUI_LOCK();
XSetSelectionOwner(m_display, XAtomeClipBoard, WindowHandle, CurrentTime);
GUI_UNLOCK();
l_clipBoardOwnerStd = true;
}
}
@ -1297,12 +1204,6 @@ etk::File APP_Icon(void);
int main(int argc, char *argv[])
{
#ifdef PTHREAD_GUI_LOCK_MULTITHREAD
// create interface mutex :
int ret = pthread_mutex_init(&l_mutex, NULL);
EWOL_ASSERT(ret == 0, "Error creating Mutex ...");
#endif
for( int32_t i=1 ; i<argc; i++) {
EWOL_INFO("CmdLine : \"" << argv[i] << "\"" );
if (0==strncmp("-l0", argv[i], 256)) {
@ -1329,7 +1230,7 @@ int main(int argc, char *argv[])
// start X11 thread ...
X11_Init();
//start the basic thread :
EWOL_SystemStart();
guiSystem::Init();
usleep(500);
// get the icon file :
etk::File myIcon = APP_Icon();
@ -1340,7 +1241,7 @@ int main(int argc, char *argv[])
// close X11 :
guiAbstraction::Stop();
// uninit ALL :
EWOL_SystemStop();
guiSystem::UnInit();
for (int32_t iii=0; iii<listArgs.Size(); iii++) {
if (NULL != listArgs[iii]) {
delete listArgs[iii];
@ -1348,10 +1249,6 @@ int main(int argc, char *argv[])
}
}
listArgs.Clear();
#ifdef PTHREAD_GUI_LOCK_MULTITHREAD
ret = pthread_mutex_destroy(&l_mutex);
EWOL_ASSERT(ret == 0, "Error destroying Mutex ...");
#endif
return 0;
}

View File

@ -87,7 +87,7 @@ void ewol::ForceRedrawAll(void)
}
eventSpecialKey_ts specialCurrentKey;
guiSystem::event::specialKey_ts specialCurrentKey;
bool ewol::IsSetCapsLock(void)
{
return specialCurrentKey.capLock;

View File

@ -177,7 +177,7 @@ void ewol::ContextMenu::SubWidgetSet(ewol::Widget* newWidget)
void ewol::ContextMenu::SubWidgetRemove(void)
{
if (NULL != m_subWidget) {
m_subWidget->MarkToRemove();
delete(m_subWidget);
m_subWidget = NULL;
}
}
@ -296,7 +296,7 @@ bool ewol::ContextMenu::OnEventInput(ewol::inputType_te type, int32_t IdInput, e
|| typeEvent == ewol::EVENT_INPUT_TYPE_ENTER
|| typeEvent == ewol::EVENT_INPUT_TYPE_LEAVE ) {
// Auto-remove ...
MarkToRemove();
AutoDestroy();
return true;
}
}

View File

@ -123,7 +123,7 @@ void ewol::Layer::LockExpendContamination(bool lockExpend)
void ewol::Layer::SubWidgetRemoveAll(void)
{
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
m_subWidget[iii]->MarkToRemove();
delete(m_subWidget[iii]);
m_subWidget[iii] = NULL;
}
m_subWidget.Clear();
@ -146,7 +146,7 @@ void ewol::Layer::SubWidgetRemove(ewol::Widget* newWidget)
}
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
if (newWidget == m_subWidget[iii]) {
m_subWidget[iii]->MarkToRemove();
delete(m_subWidget[iii]);
m_subWidget[iii] = NULL;
m_subWidget.Erase(iii);
return;

View File

@ -73,7 +73,7 @@ ewol::ListFileSystem::ListFileSystem(void)
AddEventId(ewolEventFSFileValidate);
AddEventId(ewolEventFSFolderSelect);
AddEventId(ewolEventFSFolderValidate);
SetMouseLimit(2);
SetMouseLimit(1);
};
ewol::ListFileSystem::~ListFileSystem(void)
@ -101,6 +101,7 @@ void ewol::ListFileSystem::RegenerateView(void)
m_list[iii] = NULL;
}
}
m_selectedLine = -1;
m_list.Clear();
m_originScrooled.x = 0;
m_originScrooled.y = 0;
@ -266,10 +267,13 @@ bool ewol::ListFileSystem::GetElement(int32_t colomn, int32_t raw, etk::UString
return true;
};
bool ewol::ListFileSystem::OnItemEvent(int32_t IdInput, ewol::eventInputType_te typeEvent, int32_t colomn, int32_t raw, float x, float y) {
bool ewol::ListFileSystem::OnItemEvent(int32_t IdInput, ewol::eventInputType_te typeEvent, int32_t colomn, int32_t raw, float x, float y)
{
if (typeEvent == ewol::EVENT_INPUT_TYPE_SINGLE) {
EWOL_INFO("Event on List : IdInput=" << IdInput << " colomn=" << colomn << " raw=" << raw );
if (1 == IdInput) {
int32_t previousRaw = m_selectedLine;
if (raw > m_list.Size() ) {
m_selectedLine = -1;
} else {
@ -277,28 +281,23 @@ bool ewol::ListFileSystem::OnItemEvent(int32_t IdInput, ewol::eventInputType_te
}
// need to regenerate the display of the list :
MarkToReedraw();
if (m_selectedLine >=0 ) {
// generate event extern :
switch(m_list[m_selectedLine]->m_type)
{
case ewol::EFS_FILE :
GenerateEventId(ewolEventFSFileSelect, m_list[m_selectedLine]->m_name);
break;
case ewol::EFS_FOLDER :
GenerateEventId(ewolEventFSFolderSelect, m_list[m_selectedLine]->m_name);
break;
default:
EWOL_ERROR("Can not generate event on an unknow type");
break;
if (previousRaw != m_selectedLine) {
if (m_selectedLine >=0 ) {
// generate event extern :
switch(m_list[m_selectedLine]->m_type)
{
case ewol::EFS_FILE :
GenerateEventId(ewolEventFSFileSelect, m_list[m_selectedLine]->m_name);
break;
case ewol::EFS_FOLDER :
GenerateEventId(ewolEventFSFolderSelect, m_list[m_selectedLine]->m_name);
break;
default:
EWOL_ERROR("Can not generate event on an unknow type");
break;
}
}
}
return true;
}
}
if (typeEvent == ewol::EVENT_INPUT_TYPE_DOUBLE) {
EWOL_INFO("Event Double on List : IdInput=" << IdInput << " colomn=" << colomn << " raw=" << raw );
if (1 == IdInput) {
if (m_selectedLine >=0 ) {
} else {
switch(m_list[m_selectedLine]->m_type)
{
case ewol::EFS_FILE :
@ -311,8 +310,8 @@ bool ewol::ListFileSystem::OnItemEvent(int32_t IdInput, ewol::eventInputType_te
EWOL_ERROR("Can not generate event on an unknow type");
break;
}
return true;
}
return true;
}
}
return false;

View File

@ -147,9 +147,9 @@ void ewol::Menu::OnReceiveMessage(ewol::EObject * CallerObject, const char * eve
SendMultiCast(m_listElement[iii]->m_generateEvent, m_listElement[iii]->m_message);
if (NULL != m_widgetContextMenu) {
EWOL_DEBUG("Mark the menu to remove ...");
m_widgetContextMenu->MarkToRemove();
delete(m_widgetContextMenu);
m_widgetContextMenu = NULL;
}
m_widgetContextMenu = NULL;
return;
} else{
EWOL_DEBUG("Menu ==> Load Sub Menu");

View File

@ -139,7 +139,7 @@ void ewol::PopUp::SubWidgetSet(ewol::Widget* newWidget)
void ewol::PopUp::SubWidgetRemove(void)
{
if (NULL != m_subWidget) {
m_subWidget->MarkToRemove();;
delete(m_subWidget);
m_subWidget = NULL;
}
MarkToReedraw();

View File

@ -164,7 +164,7 @@ void ewol::SizerHori::SubWidgetRemoveAll(void)
{
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
if (NULL != m_subWidget[iii]) {
m_subWidget[iii]->MarkToRemove();
delete(m_subWidget[iii]);
m_subWidget[iii] = NULL;
}
}
@ -189,7 +189,7 @@ void ewol::SizerHori::SubWidgetRemove(ewol::Widget* newWidget)
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
if (newWidget == m_subWidget[iii]) {
if (NULL != m_subWidget[iii]) {
m_subWidget[iii]->MarkToRemove();
delete(m_subWidget[iii]);
m_subWidget[iii] = NULL;
}
m_subWidget.Erase(iii);

View File

@ -166,7 +166,7 @@ void ewol::SizerVert::LockExpendContamination(bool lockExpend)
void ewol::SizerVert::SubWidgetRemoveAll(void)
{
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
m_subWidget[iii]->MarkToRemove();
delete(m_subWidget[iii]);
m_subWidget[iii] = NULL;
}
m_subWidget.Clear();
@ -189,7 +189,7 @@ void ewol::SizerVert::SubWidgetRemove(ewol::Widget* newWidget)
}
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
if (newWidget == m_subWidget[iii]) {
m_subWidget[iii]->MarkToRemove();
delete(m_subWidget[iii]);
m_subWidget[iii] = NULL;
m_subWidget.Erase(iii);
return;

View File

@ -145,7 +145,7 @@ void ewol::WSlider::LockExpendContamination(bool lockExpend)
void ewol::WSlider::SubWidgetRemoveAll(void)
{
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
m_subWidget[iii]->MarkToRemove();
delete(m_subWidget[iii]);
m_subWidget[iii] = NULL;
}
m_subWidget.Clear();
@ -170,7 +170,7 @@ void ewol::WSlider::SubWidgetRemove(ewol::Widget* newWidget)
}
for (int32_t iii=0; iii<m_subWidget.Size(); iii++) {
if (newWidget == m_subWidget[iii]) {
m_subWidget[iii]->MarkToRemove();
delete(m_subWidget[iii]);
m_subWidget[iii] = NULL;
m_subWidget.Erase(iii);
MarkToReedraw();

View File

@ -328,7 +328,7 @@ void ewol::FileChooser::OnReceiveMessage(ewol::EObject * CallerObject, const cha
} else if (ewolEventFileChooserCancel == eventId) {
//==> Auto remove ...
GenerateEventId(eventId);
MarkToRemove();
AutoDestroy();
} else if (ewolEventFileChooserHidenFileChange == eventId) {
if (data == "true") {
if (NULL!=m_widgetListFolder) {
@ -379,7 +379,7 @@ void ewol::FileChooser::OnReceiveMessage(ewol::EObject * CallerObject, const cha
etk::UString tmpFileCompleatName = m_folder;
tmpFileCompleatName += m_file;
GenerateEventId(ewolEventFileChooserValidate, tmpFileCompleatName);
MarkToRemove();
AutoDestroy();
} else if(ewolEventFileChooserHome == eventId) {
etk::UString tmpUserFolder = etk::GetUserHomeFolder();
char buf[MAX_FILE_NAME];

View File

@ -199,7 +199,7 @@ void ewol::Parameter::OnReceiveMessage(ewol::EObject * CallerObject, const char
// inform that the parameter windows is closed
GenerateEventId(ewolEventParameterClose);
// Close this widget ...
MarkToRemove();
AutoDestroy();
} else if (eventId == l_eventMenuSelected) {
if (NULL != m_wSlider) {
int32_t value = 0;

@ -1 +1 @@
Subproject commit f2199f4485320e51ee447f7a1b8568d8f6eded4b
Subproject commit fa80d21d573ca2a349e9b23a5bc79f5e67bcf5f8