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 <stdint.h>
#include <pthread.h> #include <pthread.h>
#include <Debug.h> #include <Debug.h>
#include <ewol/base/MainThread.h>
#include <ewol/threadMsg.h> #include <ewol/threadMsg.h>
#include <ewol/Audio/audio.h> #include <ewol/Audio/audio.h>
// declaration of the ewol android abstraction ... // 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_NativeRender(void);
void EWOL_NativeGLDestroy(void); void EWOL_NativeGLDestroy(void);
@ -203,7 +195,7 @@ extern "C"
// direct setting of the date in the string system ... // direct setting of the date in the string system ...
jboolean isCopy; jboolean isCopy;
const char* str = env->GetStringUTFChars(myString, &isCopy); const char* str = env->GetStringUTFChars(myString, &isCopy);
EWOL_ThreadSetArchiveDir(mode, str); guiSystem::SetArchiveDir(mode, str);
if (isCopy == JNI_TRUE) { if (isCopy == JNI_TRUE) {
// from here str is reset ... // from here str is reset ...
env->ReleaseStringUTFChars(myString, str); env->ReleaseStringUTFChars(myString, str);
@ -282,7 +274,7 @@ extern "C"
APPL_DEBUG("*******************************************"); APPL_DEBUG("*******************************************");
APPL_DEBUG("** Activity On Create **"); APPL_DEBUG("** Activity On Create **");
APPL_DEBUG("*******************************************"); APPL_DEBUG("*******************************************");
EWOL_SystemStart(); guiSystem::Init();
} }
void Java_org_ewol_interfaceJNI_ActivityOnStart( JNIEnv* env ) void Java_org_ewol_interfaceJNI_ActivityOnStart( JNIEnv* env )
{ {
@ -323,7 +315,7 @@ extern "C"
APPL_DEBUG("*******************************************"); APPL_DEBUG("*******************************************");
APPL_DEBUG("** Activity On Destroy **"); APPL_DEBUG("** Activity On Destroy **");
APPL_DEBUG("*******************************************"); 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 ) 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 ) 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 ) 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 ) 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) 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) void Java_org_ewol_interfaceJNI_IOKeyboardEventKey( JNIEnv* env, jobject thiz, jint uniChar, jboolean isdown)
{ {
APPL_DEBUG("IO keyboard Key event : \"" << uniChar << "\" is down=" << 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 { enum {
SYSTEM_KEY__VOLUME_UP = 1, SYSTEM_KEY__VOLUME_UP = 1,
SYSTEM_KEY__VOLUME_DOWN, SYSTEM_KEY__VOLUME_DOWN,
@ -413,12 +409,12 @@ extern "C"
void Java_org_ewol_interfaceJNI_RenderResize( JNIEnv* env, jobject thiz, jint w, jint h ) 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 ) 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) 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::EObject::~EObject(void)
{ {
EWOL_DEBUG("delete EObject : [" << m_uniqueId << "]");
ewol::EObjectManager::Rm(this); ewol::EObjectManager::Rm(this);
MultiCastRm(this); MultiCastRm(this);
EWOL_DEBUG("delete EObject : [" << m_uniqueId << "]");
for (int32_t iii=0; iii<m_externEvent.Size(); iii++) { for (int32_t iii=0; iii<m_externEvent.Size(); iii++) {
if (NULL!=m_externEvent[iii]) { if (NULL!=m_externEvent[iii]) {
delete(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 * @brief Get the UniqueId of the EObject
* @param --- * @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); int32_t GetId(void);
/**
* @brief Auto-destroy the object
* @param ---
* @return ---
*/
void AutoDestroy(void);
/** /**
* @brief Get the current Object type of the EObject * @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 * @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 * @param[in] data Data registered by this class
* @return --- * @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

@ -32,15 +32,14 @@ static bool IsInit = false;
// internal element of the widget manager : // 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_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_eObjectAutoRemoveList; // all widget allocated
void ewol::EObjectManager::Init(void) void ewol::EObjectManager::Init(void)
{ {
EWOL_DEBUG("==> Init EObject-Manager"); EWOL_DEBUG("==> Init EObject-Manager");
// Can create mlemory leak ... ==> but not predictable comportement otherwise ... // Can create mlemory leak ... ==> but not predictable comportement otherwise ...
// TODO : Check if we can do sotthing better m_eObjectAutoRemoveList.Clear();
m_eObjectDeletedList.Clear();
m_eObjectList.Clear(); m_eObjectList.Clear();
IsInit = true; IsInit = true;
} }
@ -48,27 +47,22 @@ void ewol::EObjectManager::Init(void)
void ewol::EObjectManager::UnInit(void) void ewol::EObjectManager::UnInit(void)
{ {
EWOL_DEBUG("==> Un-Init EObject-Manager"); EWOL_DEBUG("==> Un-Init EObject-Manager");
// Some call to permit to remove all the needed stack of EObject RemoveAllAutoRemove();
for(int32_t iii=0; iii<128 ; iii++) {
ewol::EObjectManager::RemoveAllMark();
}
EWOL_INFO(" Remove missing user widget"); EWOL_INFO(" Remove missing user widget");
while(0<m_eObjectList.Size()) { while(0<m_eObjectList.Size()) {
if (m_eObjectList[0]!=NULL) { if (m_eObjectList[0]!=NULL) {
MarkToRemoved(m_eObjectList[0]); delete(m_eObjectList[0]);
m_eObjectList[0] = NULL;
} else { } else {
m_eObjectList.Erase(0); m_eObjectList.Erase(0);
} }
} }
// local acces ==> this control the mutex Lock
ewol::EObjectManager::RemoveAllMark();
IsInit = false; IsInit = false;
} }
void ewol::EObjectManager::Add(ewol::EObject* object) void ewol::EObjectManager::Add(ewol::EObject* object)
{ {
// TODO : Chek if not existed before ...
if (NULL != object) { if (NULL != object) {
m_eObjectList.PushBack(object); m_eObjectList.PushBack(object);
} else { } 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) void informOneObjectIsRemoved(ewol::EObject* object)
{ {
for (int32_t iii=0; iii<m_eObjectList.Size(); iii++) { for (int32_t iii=0; iii<m_eObjectList.Size(); iii++) {
@ -113,43 +81,55 @@ void informOneObjectIsRemoved(ewol::EObject* object)
ewol::eventInput::OnObjectRemove(object); ewol::eventInput::OnObjectRemove(object);
} }
void ewol::EObjectManager::Rm(ewol::EObject* object)
void ewol::EObjectManager::MarkToRemoved(ewol::EObject* object)
{ {
if (object == NULL) { if (NULL == object) {
EWOL_WARNING("try to remove a NULL Pointer on the EObject manager"); EWOL_ERROR("Try to remove (NULL) EObject");
return; return;
} }
int32_t findId = -1; for (int32_t iii=0; iii<m_eObjectList.Size(); iii++) {
// check if the widget is not destroy :
for(int32_t iii=0; iii<m_eObjectList.Size(); iii++) {
if (m_eObjectList[iii] == object) { if (m_eObjectList[iii] == object) {
findId = iii; // Remove Element
break; m_eObjectList[iii] = NULL;
} m_eObjectList.Erase(iii);
} informOneObjectIsRemoved(object);
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());
return; return;
} }
m_eObjectList.Erase(findId); }
EWOL_DEBUG("MarkToRemoved EObject : [" << object->GetId() << "] type=" << object->GetObjectType()); EWOL_ERROR("Try to remove EObject that is not referenced ...");
m_eObjectDeletedList.PushBack(object);
// Informe all EObject to remove reference of this one ...
informOneObjectIsRemoved(object);
} }
void ewol::EObjectManager::AutoRemove(ewol::EObject* object)
void ewol::EObjectManager::RemoveAllMark(void)
{ {
etk::VectorType<ewol::EObject*> m_tmpList = m_eObjectDeletedList; if (NULL == object) {
// direct delete of the current list ... EWOL_ERROR("Try to Auto-Remove (NULL) EObject");
for(int32_t iii=0; iii<m_tmpList.Size(); iii++) { return;
if (NULL != m_tmpList[iii]) { }
delete(m_tmpList[iii]); for (int32_t iii=0; iii<m_eObjectList.Size(); iii++) {
m_tmpList[iii] = NULL; 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 UnInit( void);
void Add( ewol::EObject* object); void Add( ewol::EObject* object);
void Rm( 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__ #undef __class__
#define __class__ "texture" #define __class__ "texture"
static pthread_mutex_t localMutex;
/** /**
* @brief Initialise the texture namespace (init a mutex) * @brief Initialise the texture namespace (init a mutex)
@ -67,9 +66,6 @@ static pthread_mutex_t localMutex;
void ewol::texture::Init(void) void ewol::texture::Init(void)
{ {
EWOL_DEBUG("==> Init Texture-Manager"); 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) void ewol::texture::UnInit(void)
{ {
pthread_mutex_lock(&localMutex);
EWOL_DEBUG("==> Un-Init Texture-Manager"); EWOL_DEBUG("==> Un-Init Texture-Manager");
for (int32_t iii=0; iii<l_listLoadedTexture.Size(); iii++) { for (int32_t iii=0; iii<l_listLoadedTexture.Size(); iii++) {
if (l_listLoadedTexture[iii] != NULL) { if (l_listLoadedTexture[iii] != NULL) {
@ -89,9 +84,6 @@ void ewol::texture::UnInit(void)
l_listLoadedTexture[iii] = NULL; l_listLoadedTexture[iii] = NULL;
} }
l_listLoadedTexture.Clear(); 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) void ewol::texture::UpdateContextIsDestroy(void)
{ {
pthread_mutex_lock(&localMutex);
for (int32_t iii=0; iii < l_listLoadedTexture.Size(); iii++) { for (int32_t iii=0; iii < l_listLoadedTexture.Size(); iii++) {
if( NULL != l_listLoadedTexture[iii] if( NULL != l_listLoadedTexture[iii]
&& NULL != l_listLoadedTexture[iii]->m_data) && NULL != l_listLoadedTexture[iii]->m_data)
@ -117,7 +108,6 @@ void ewol::texture::UpdateContextIsDestroy(void)
//glDeleteTextures(1, &l_listLoadedTexture[iii]->m_openGlTextureID); //glDeleteTextures(1, &l_listLoadedTexture[iii]->m_openGlTextureID);
} }
} }
pthread_mutex_unlock(&localMutex);
} }
@ -126,11 +116,9 @@ void ewol::texture::UpdateContextIsDestroy(void)
* @param --- * @param ---
* @return --- * @return ---
*/ */
// TODO : The reload might be writen ...
void ewol::texture::UpdateContext(void) void ewol::texture::UpdateContext(void)
{ {
bool needRedraw = false; bool needRedraw = false;
pthread_mutex_lock(&localMutex);
for (int32_t iii=0; iii < l_listLoadedTexture.Size(); iii++) { for (int32_t iii=0; iii < l_listLoadedTexture.Size(); iii++) {
if( NULL != l_listLoadedTexture[iii] if( NULL != l_listLoadedTexture[iii]
&& NULL != l_listLoadedTexture[iii]->m_data) && NULL != l_listLoadedTexture[iii]->m_data)
@ -181,7 +169,6 @@ void ewol::texture::UpdateContext(void)
} }
} }
} }
pthread_mutex_unlock(&localMutex);
if (true == needRedraw) { if (true == needRedraw) {
ewol::ForceRedrawAll(); 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); memcpy(tmpTex->m_data, data, sizeof(char) * tmpTex->m_nbBytes);
pthread_mutex_lock(&localMutex);
l_listLoadedTexture.PushBack(tmpTex); l_listLoadedTexture.PushBack(tmpTex);
outTextureID = l_listLoadedTexture.Size()-1; outTextureID = l_listLoadedTexture.Size()-1;
pthread_mutex_unlock(&localMutex);
return outTextureID; return outTextureID;
} }
@ -284,6 +269,8 @@ int32_t ewol::texture::Load(etk::UString tmpfileName, int32_t requestedWidth)
if (NULL != l_listLoadedTexture[iii]) { if (NULL != l_listLoadedTexture[iii]) {
if (l_listLoadedTexture[iii]->m_filename == tmpfileName) { if (l_listLoadedTexture[iii]->m_filename == tmpfileName) {
l_listLoadedTexture[iii]->m_nbTimeLoaded++; 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; return iii;
} }
} }
@ -376,7 +363,11 @@ void ewol::texture::UnLoad(uint32_t textureID)
uint32_t ewol::texture::GetGLID(uint32_t textureID) uint32_t ewol::texture::GetGLID(uint32_t textureID)
{ {
if ((int32_t)textureID<l_listLoadedTexture.Size()) { if ((int32_t)textureID<l_listLoadedTexture.Size()) {
if (l_listLoadedTexture[textureID]!=NULL) {
return l_listLoadedTexture[textureID]->m_openGlTextureID; return l_listLoadedTexture[textureID]->m_openGlTextureID;
} else {
EWOL_ERROR("Texture has been removed previously : " << textureID);
}
} }
return 0; return 0;
} }
@ -390,9 +381,13 @@ uint32_t ewol::texture::GetGLID(uint32_t textureID)
int32_t ewol::texture::GetSize(uint32_t textureID) int32_t ewol::texture::GetSize(uint32_t textureID)
{ {
for (int32_t iii=0; iii<l_listLoadedTexture.Size(); iii++) { for (int32_t iii=0; iii<l_listLoadedTexture.Size(); iii++) {
if (l_listLoadedTexture[textureID]!=NULL) {
if (l_listLoadedTexture[iii]->m_openGlTextureID == textureID) { if (l_listLoadedTexture[iii]->m_openGlTextureID == textureID) {
return l_listLoadedTexture[iii]->m_width; 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..."); EWOL_ERROR("Can not find TextureId=" << textureID << " in the list of texture loaded...");
return -1; return -1;

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 * @brief Set the widget hidden
* @param --- * @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 * @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 * 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_SINGLE,
EVENT_INPUT_TYPE_DOUBLE, EVENT_INPUT_TYPE_DOUBLE,
EVENT_INPUT_TYPE_TRIPLE, EVENT_INPUT_TYPE_TRIPLE,
EVENT_INPUT_TYPE_QUAD,
EVENT_INPUT_TYPE_QUINTE,
EVENT_INPUT_TYPE_UP, EVENT_INPUT_TYPE_UP,
EVENT_INPUT_TYPE_ENTER, EVENT_INPUT_TYPE_ENTER,
EVENT_INPUT_TYPE_LEAVE, EVENT_INPUT_TYPE_LEAVE,
@ -112,15 +114,10 @@ namespace ewol {
Widget(void); Widget(void);
/** /**
* @brief Destructor of the widget classes * @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 --- * @param ---
* @return --- * @return ---
*/ */
// TODO : Set this in private if possible ... virtual ~Widget(void);
virtual ~Widget(void) { };
/** /**
* @brief Get the current Object type of the EObject * @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 * @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 * @return true if the object is compatible, otherwise false
*/ */
virtual const char * const GetObjectType(void) { return "EwolWidget"; }; 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: // -- Widget Size:
// ---------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------

View File

@ -214,39 +214,3 @@ bool ewol::widgetManager::PeriodicCallHave(void)
return l_havePeriodic; 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); ewol::Widget * FocusGet( void);
void FocusRemoveIfRemove(ewol::Widget * newWidget); void FocusRemoveIfRemove(ewol::Widget * newWidget);
void PeriodicCallAdd(ewol::Widget * pWidget); void PeriodicCallAdd(ewol::Widget * pWidget);
void PeriodicCallRm( ewol::Widget * pWidget); void PeriodicCallRm( ewol::Widget * pWidget);
void PeriodicCall(int64_t localTime); void PeriodicCall(int64_t localTime);
bool PeriodicCallHave(void); 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) ewol::Windows::~Windows(void)
{ {
if (NULL != m_subWidget) { if (NULL != m_subWidget) {
m_subWidget->MarkToRemove(); delete(m_subWidget);
m_subWidget=NULL; m_subWidget=NULL;
} }
for(int32_t iii=0; iii<m_popUpWidgetList.Size(); iii++) { for(int32_t iii=0; iii<m_popUpWidgetList.Size(); iii++) {
if (NULL != m_popUpWidgetList[iii]) { if (NULL != m_popUpWidgetList[iii]) {
m_popUpWidgetList[iii]->MarkToRemove(); delete(m_popUpWidgetList[iii]);
m_popUpWidgetList[iii]=NULL; m_popUpWidgetList[iii]=NULL;
} }
} }
@ -177,7 +177,7 @@ void ewol::Windows::SetSubWidget(ewol::Widget * widget)
{ {
if (NULL != m_subWidget) { if (NULL != m_subWidget) {
EWOL_INFO("Remove current main windows Widget..."); EWOL_INFO("Remove current main windows Widget...");
m_subWidget->MarkToRemove(); delete(m_subWidget);
m_subWidget = NULL; m_subWidget = NULL;
} }
m_subWidget = widget; m_subWidget = widget;

View File

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

View File

@ -27,26 +27,26 @@
#ifndef __EWOL_MAIN_TREAD_H__ #ifndef __EWOL_MAIN_TREAD_H__
#define __EWOL_MAIN_TREAD_H__ #define __EWOL_MAIN_TREAD_H__
#include <pthread.h> #include <ewol/ewol.h>
//#define MODE_MULTY_THREAD namespace guiSystem
{
void EWOL_SystemStart(void); void Init(void);
void EWOL_SystemStop(void); void UnInit(void);
void ewolProcessEvents(void); void SetArchiveDir(int mode, const char* str);
void ewolProcessRedraw(void);
void EWOL_ThreadSetArchiveDir(int mode, const char* str); namespace event {
void EWOL_ThreadResize(int w, int h ); void Resize(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 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 { typedef struct {
bool capLock; bool capLock;
bool shift; bool shift;
bool ctrl; bool ctrl;
@ -55,27 +55,29 @@ typedef struct {
bool altGr; bool altGr;
bool verNum; bool verNum;
bool insert; bool insert;
} eventSpecialKey_ts; } specialKey_ts;
typedef struct { typedef struct {
bool isDown; bool isDown;
uniChar_t myChar; uniChar_t myChar;
eventSpecialKey_ts special; guiSystem::event::specialKey_ts special;
} eventKeyboardKey_ts; } keyboardKey_ts;
typedef struct { typedef struct {
bool isDown; bool isDown;
ewol::eventKbMoveType_te move; ewol::eventKbMoveType_te move;
eventSpecialKey_ts special; guiSystem::event::specialKey_ts special;
} eventKeyboardMove_ts; } keyboardMove_ts;
void EWOL_ThreadKeyboardEvent(eventKeyboardKey_ts& keyInput); void SetKeyboard(guiSystem::event::keyboardKey_ts& keyInput);
void EWOL_ThreadKeyboardEventMove(eventKeyboardMove_ts& keyInput); void SetKeyboardMove(guiSystem::event::keyboardMove_ts& keyInput);
void Hide(void);
void Show(void);
};
void EWOL_ThreadEventHide(void); void Draw(void);
void EWOL_ThreadEventShow(void); };
void EWOL_ThreadEventHasJustDisplay(void);
#endif #endif

View File

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

View File

@ -34,6 +34,7 @@
#include <ewol/Texture.h> #include <ewol/Texture.h>
#include <ewol/base/MainThread.h> #include <ewol/base/MainThread.h>
#include <ewol/importgl.h>
ewol::Windows* gui_uniqueWindows = NULL; ewol::Windows* gui_uniqueWindows = NULL;
float gui_width = 320; float gui_width = 320;
@ -75,26 +76,13 @@ void EWOL_NativeResize(int w, int h )
void EWOL_NativeRegenerateDisplay(void) 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); //EWOL_INFO("Resize w=" << w << " h=" << h);
if (NULL != gui_uniqueWindows) { if (NULL != gui_uniqueWindows) {
// Redraw all needed elements // Redraw all needed elements
gui_uniqueWindows->OnRegenerateDisplay(); 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) 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 startTime = -1;
static int64_t nbCallTime = 0; static int64_t nbCallTime = 0;
static int64_t nbDisplayTime = 0; static int64_t nbDisplayTime = 0;
@ -170,8 +143,106 @@ static int64_t max2 = 0;
#define DISPLAY_PERIODE_US (1000000) #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) void EWOL_GenericDraw(bool everyTime)
{ {
//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);
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; bool display = false;
nbCallTime++; nbCallTime++;
if (startTime<0) { if (startTime<0) {
@ -182,22 +253,15 @@ void EWOL_GenericDraw(bool everyTime)
if ( (currentTime - startTime) > DISPLAY_PERIODE_US) { if ( (currentTime - startTime) > DISPLAY_PERIODE_US) {
display = true; display = true;
} }
// TODO : Remove this ...
if (ewol::widgetManager::PeriodicCallHave()) {
everyTime = true;
}
ewol::widgetManager::DoubleBufferLock();
int64_t currentTime3 = GetCurrentTime(); int64_t currentTime3 = GetCurrentTime();
if( true == ewol::widgetManager::GetDoubleBufferNeedDraw() // TODO : Check if somthink has regenerate his display befor redraw ...
|| true == everyTime)
{ {
ewol::texture::UpdateContext(); ewol::texture::UpdateContext();
nbDisplayTime++; nbDisplayTime++;
gui_uniqueWindows->SysDraw(); gui_uniqueWindows->SysDraw();
} }
ewol::widgetManager::DoubleBufferUnLock();
// send Message that we just finished a display ... // send Message that we just finished a display ...
EWOL_ThreadEventHasJustDisplay(); //EWOL_ThreadEventHasJustDisplay();
int64_t currentTime2 = GetCurrentTime(); int64_t currentTime2 = GetCurrentTime();
int64_t processTimeLocal = (currentTime2 - currentTime); int64_t processTimeLocal = (currentTime2 - currentTime);
min = etk_min(min, processTimeLocal); min = etk_min(min, processTimeLocal);
@ -226,6 +290,7 @@ void EWOL_GenericDraw(bool everyTime)
nbDisplayTime = 0; nbDisplayTime = 0;
startTime = -1; startTime = -1;
} }
}
} }
void EWOL_NativeGLDestroy(void) void EWOL_NativeGLDestroy(void)

View File

@ -31,6 +31,7 @@
#include <ewol/Windows.h> #include <ewol/Windows.h>
#include <ewol/ewol.h> #include <ewol/ewol.h>
void EWOL_NativeRender(void);
void EWOL_NativeResize(int w, int h ); void EWOL_NativeResize(int w, int h );
void EWOL_GenericDraw(bool everyTime); void EWOL_GenericDraw(bool everyTime);
void EWOL_NativeGLDestroy(void); 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 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) 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(true);
//EWOL_GenericDraw(false);
}
glFlush(); glFlush();
} }

View File

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

View File

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

View File

@ -177,7 +177,7 @@ void ewol::ContextMenu::SubWidgetSet(ewol::Widget* newWidget)
void ewol::ContextMenu::SubWidgetRemove(void) void ewol::ContextMenu::SubWidgetRemove(void)
{ {
if (NULL != m_subWidget) { if (NULL != m_subWidget) {
m_subWidget->MarkToRemove(); delete(m_subWidget);
m_subWidget = NULL; 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_ENTER
|| typeEvent == ewol::EVENT_INPUT_TYPE_LEAVE ) { || typeEvent == ewol::EVENT_INPUT_TYPE_LEAVE ) {
// Auto-remove ... // Auto-remove ...
MarkToRemove(); AutoDestroy();
return true; return true;
} }
} }

View File

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

View File

@ -73,7 +73,7 @@ ewol::ListFileSystem::ListFileSystem(void)
AddEventId(ewolEventFSFileValidate); AddEventId(ewolEventFSFileValidate);
AddEventId(ewolEventFSFolderSelect); AddEventId(ewolEventFSFolderSelect);
AddEventId(ewolEventFSFolderValidate); AddEventId(ewolEventFSFolderValidate);
SetMouseLimit(2); SetMouseLimit(1);
}; };
ewol::ListFileSystem::~ListFileSystem(void) ewol::ListFileSystem::~ListFileSystem(void)
@ -101,6 +101,7 @@ void ewol::ListFileSystem::RegenerateView(void)
m_list[iii] = NULL; m_list[iii] = NULL;
} }
} }
m_selectedLine = -1;
m_list.Clear(); m_list.Clear();
m_originScrooled.x = 0; m_originScrooled.x = 0;
m_originScrooled.y = 0; m_originScrooled.y = 0;
@ -266,10 +267,13 @@ bool ewol::ListFileSystem::GetElement(int32_t colomn, int32_t raw, etk::UString
return true; 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) { if (typeEvent == ewol::EVENT_INPUT_TYPE_SINGLE) {
EWOL_INFO("Event on List : IdInput=" << IdInput << " colomn=" << colomn << " raw=" << raw ); EWOL_INFO("Event on List : IdInput=" << IdInput << " colomn=" << colomn << " raw=" << raw );
if (1 == IdInput) { if (1 == IdInput) {
int32_t previousRaw = m_selectedLine;
if (raw > m_list.Size() ) { if (raw > m_list.Size() ) {
m_selectedLine = -1; m_selectedLine = -1;
} else { } else {
@ -277,6 +281,7 @@ bool ewol::ListFileSystem::OnItemEvent(int32_t IdInput, ewol::eventInputType_te
} }
// need to regenerate the display of the list : // need to regenerate the display of the list :
MarkToReedraw(); MarkToReedraw();
if (previousRaw != m_selectedLine) {
if (m_selectedLine >=0 ) { if (m_selectedLine >=0 ) {
// generate event extern : // generate event extern :
switch(m_list[m_selectedLine]->m_type) switch(m_list[m_selectedLine]->m_type)
@ -292,13 +297,7 @@ bool ewol::ListFileSystem::OnItemEvent(int32_t IdInput, ewol::eventInputType_te
break; break;
} }
} }
return true; } else {
}
}
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 ) {
switch(m_list[m_selectedLine]->m_type) switch(m_list[m_selectedLine]->m_type)
{ {
case ewol::EFS_FILE : 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"); EWOL_ERROR("Can not generate event on an unknow type");
break; break;
} }
return true;
} }
return true;
} }
} }
return false; 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); SendMultiCast(m_listElement[iii]->m_generateEvent, m_listElement[iii]->m_message);
if (NULL != m_widgetContextMenu) { if (NULL != m_widgetContextMenu) {
EWOL_DEBUG("Mark the menu to remove ..."); EWOL_DEBUG("Mark the menu to remove ...");
m_widgetContextMenu->MarkToRemove(); delete(m_widgetContextMenu);
}
m_widgetContextMenu = NULL; m_widgetContextMenu = NULL;
}
return; return;
} else{ } else{
EWOL_DEBUG("Menu ==> Load Sub Menu"); EWOL_DEBUG("Menu ==> Load Sub Menu");

View File

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

View File

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

View File

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

View File

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

View File

@ -328,7 +328,7 @@ void ewol::FileChooser::OnReceiveMessage(ewol::EObject * CallerObject, const cha
} else if (ewolEventFileChooserCancel == eventId) { } else if (ewolEventFileChooserCancel == eventId) {
//==> Auto remove ... //==> Auto remove ...
GenerateEventId(eventId); GenerateEventId(eventId);
MarkToRemove(); AutoDestroy();
} else if (ewolEventFileChooserHidenFileChange == eventId) { } else if (ewolEventFileChooserHidenFileChange == eventId) {
if (data == "true") { if (data == "true") {
if (NULL!=m_widgetListFolder) { if (NULL!=m_widgetListFolder) {
@ -379,7 +379,7 @@ void ewol::FileChooser::OnReceiveMessage(ewol::EObject * CallerObject, const cha
etk::UString tmpFileCompleatName = m_folder; etk::UString tmpFileCompleatName = m_folder;
tmpFileCompleatName += m_file; tmpFileCompleatName += m_file;
GenerateEventId(ewolEventFileChooserValidate, tmpFileCompleatName); GenerateEventId(ewolEventFileChooserValidate, tmpFileCompleatName);
MarkToRemove(); AutoDestroy();
} else if(ewolEventFileChooserHome == eventId) { } else if(ewolEventFileChooserHome == eventId) {
etk::UString tmpUserFolder = etk::GetUserHomeFolder(); etk::UString tmpUserFolder = etk::GetUserHomeFolder();
char buf[MAX_FILE_NAME]; 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 // inform that the parameter windows is closed
GenerateEventId(ewolEventParameterClose); GenerateEventId(ewolEventParameterClose);
// Close this widget ... // Close this widget ...
MarkToRemove(); AutoDestroy();
} else if (eventId == l_eventMenuSelected) { } else if (eventId == l_eventMenuSelected) {
if (NULL != m_wSlider) { if (NULL != m_wSlider) {
int32_t value = 0; int32_t value = 0;

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