Optimize the X11 display to only generate the display when something change, optimise x11 main thread

This commit is contained in:
Edouard Dupin 2012-02-02 14:04:42 +01:00
parent 87380eff95
commit ff3e92fd01
12 changed files with 397 additions and 336 deletions

View File

@ -217,6 +217,7 @@ void ewol::widgetManager::FocusRemoveIfRemove(ewol::Widget * newWidget)
} }
static bool needRedraw = true;
void ewol::widgetManager::GetDoubleBufferFlipFlop(void) void ewol::widgetManager::GetDoubleBufferFlipFlop(void)
{ {
@ -227,6 +228,7 @@ void ewol::widgetManager::GetDoubleBufferFlipFlop(void)
m_widgetList[iii].widgetPointer->DoubleBufferFlipFlop(); m_widgetList[iii].widgetPointer->DoubleBufferFlipFlop();
} }
} }
needRedraw = true;
pthread_mutex_unlock(&localMutex); pthread_mutex_unlock(&localMutex);
} }
@ -235,6 +237,15 @@ void ewol::widgetManager::GetDoubleBufferStartDraw(void)
pthread_mutex_lock(&localMutex); pthread_mutex_lock(&localMutex);
} }
bool ewol::widgetManager::GetDoubleBufferNeedDraw(void)
{
if (true == needRedraw) {
needRedraw = false;
return true;
}
return false;
}
void ewol::widgetManager::GetDoubleBufferStopDraw(void) void ewol::widgetManager::GetDoubleBufferStopDraw(void)
{ {
pthread_mutex_unlock(&localMutex); pthread_mutex_unlock(&localMutex);

View File

@ -50,6 +50,7 @@ namespace ewol {
int32_t GetDoubleBufferCreate(void); int32_t GetDoubleBufferCreate(void);
int32_t GetDoubleBufferDraw(void); int32_t GetDoubleBufferDraw(void);
void GetDoubleBufferFlipFlop(void); void GetDoubleBufferFlipFlop(void);
bool GetDoubleBufferNeedDraw(void);
void GetDoubleBufferStartDraw(void); void GetDoubleBufferStartDraw(void);
void GetDoubleBufferStopDraw(void); void GetDoubleBufferStopDraw(void);
}; };

View File

@ -45,7 +45,6 @@ namespace ewol {
void SysOnShow(void) {}; void SysOnShow(void) {};
void SysOnHide(void) {}; void SysOnHide(void) {};
void SysOnKill(void) {}; void SysOnKill(void) {};
void SysOnExpose(void) {};
public: public:
virtual void OnShow(void) { }; virtual void OnShow(void) { };
virtual void OnHide(void) { }; virtual void OnHide(void) { };

View File

@ -39,20 +39,17 @@ static pthread_t androidJniThread;
//static pthread_attr_t androidJniThreadAttr; //static pthread_attr_t androidJniThreadAttr;
enum { enum {
JNI_NONE, THREAD_UN_INIT,
JNI_INIT, THREAD_RESIZE,
JNI_UN_INIT, THREAD_HIDE,
JNI_DONE, THREAD_SHOW,
JNI_RESIZE,
JNI_INPUT_MOTION, THREAD_INPUT_MOTION,
JNI_INPUT_STATE, THREAD_INPUT_STATE,
JNI_DATA_ARCHIVE_DIR,
JNI_APP_INIT,
JNI_APP_UN_INIT,
JNI_APP_RENDERER,
THREAD_KEYBORAD_KEY, THREAD_KEYBORAD_KEY,
THREAD_KEYBORAD_MOVE, THREAD_KEYBORAD_MOVE,
THREAD_JUST_DISPLAY,
}; };
@ -86,9 +83,6 @@ typedef struct {
ewol::eventKbMoveType_te move; ewol::eventKbMoveType_te move;
} eventKeyboardMove_ts; } eventKeyboardMove_ts;
extern int EWOL_appArgC;
extern char *EWOL_appArgV[];
void EWOL_NativeEventInputMotion(int pointerID, float x, float y ); void EWOL_NativeEventInputMotion(int pointerID, float x, float y );
void EWOL_NativeEventInputState(int pointerID, bool isUp, float x, float y ); void EWOL_NativeEventInputState(int pointerID, bool isUp, float x, float y );
void EWOL_NativeResize(int w, int h ); void EWOL_NativeResize(int w, int h );
@ -106,59 +100,41 @@ static void* BaseAppEntry(void* param)
ewol::theme::Init(); ewol::theme::Init();
ewol::widgetManager::Init(); ewol::widgetManager::Init();
ewol::InitFont(); ewol::InitFont();
APP_Init(EWOL_appArgC, EWOL_appArgV); APP_Init();
int32_t countNbEvent = 0;
EWOL_DEBUG("BThread Init (END)"); EWOL_DEBUG("BThread Init (END)");
while(false == requestEndProcessing) { while(false == requestEndProcessing) {
ewol::threadMsg::threadMsgContent_ts data; ewol::threadMsg::threadMsgContent_ts data;
ewol::threadMsg::WaitMessage(androidJniMsg, data); ewol::threadMsg::WaitMessage(androidJniMsg, data);
if (data.type != THREAD_JUST_DISPLAY) {
countNbEvent++;
//EWOL_DEBUG("EVENT");
switch (data.type) { switch (data.type) {
case JNI_NONE: case THREAD_UN_INIT:
EWOL_DEBUG("Receive MSG : JNI_NONE"); EWOL_DEBUG("Receive MSG : THREAD_UN_INIT");
break;
case JNI_INIT:
EWOL_DEBUG("Receive MSG : JNI_INIT");
//Android : EWOL_NativeApplicationInit();
break;
case JNI_UN_INIT:
EWOL_DEBUG("Receive MSG : JNI_UN_INIT");
requestEndProcessing = true; requestEndProcessing = true;
break; break;
case JNI_DONE: case THREAD_RESIZE:
EWOL_DEBUG("Receive MSG : JNI_DONE"); //EWOL_DEBUG("Receive MSG : THREAD_RESIZE");
break;
case JNI_RESIZE:
EWOL_DEBUG("Receive MSG : JNI_RESIZE");
{ {
eventResize_ts * tmpData = (eventResize_ts*)data.data; eventResize_ts * tmpData = (eventResize_ts*)data.data;
EWOL_NativeResize(tmpData->w, tmpData->h); EWOL_NativeResize(tmpData->w, tmpData->h);
} }
break; break;
case JNI_INPUT_MOTION: case THREAD_INPUT_MOTION:
//EWOL_DEBUG("Receive MSG : JNI_INPUT_MOTION"); //EWOL_DEBUG("Receive MSG : THREAD_INPUT_MOTION");
{ {
eventInputMotion_ts * tmpData = (eventInputMotion_ts*)data.data; eventInputMotion_ts * tmpData = (eventInputMotion_ts*)data.data;
EWOL_NativeEventInputMotion(tmpData->pointerID, tmpData->x, tmpData->y); EWOL_NativeEventInputMotion(tmpData->pointerID, tmpData->x, tmpData->y);
} }
break; break;
case JNI_INPUT_STATE: case THREAD_INPUT_STATE:
//EWOL_DEBUG("Receive MSG : JNI_INPUT_STATE"); //EWOL_DEBUG("Receive MSG : THREAD_INPUT_STATE");
{ {
eventInputState_ts * tmpData = (eventInputState_ts*)data.data; eventInputState_ts * tmpData = (eventInputState_ts*)data.data;
EWOL_NativeEventInputState(tmpData->pointerID, tmpData->state, tmpData->x, tmpData->y); EWOL_NativeEventInputState(tmpData->pointerID, tmpData->state, tmpData->x, tmpData->y);
} }
break; break;
case JNI_DATA_ARCHIVE_DIR:
EWOL_DEBUG("Receive MSG : JNI_DATA_ARCHIVE_DIR");
break;
case JNI_APP_INIT:
EWOL_DEBUG("Receive MSG : JNI_APP_INIT");
break;
case JNI_APP_UN_INIT:
EWOL_DEBUG("Receive MSG : JNI_APP_UN_INIT");
break;
case JNI_APP_RENDERER:
EWOL_DEBUG("Receive MSG : JNI_APP_RENDERER");
break;
case THREAD_KEYBORAD_KEY: case THREAD_KEYBORAD_KEY:
EWOL_DEBUG("Receive MSG : THREAD_KEYBORAD_KEY"); EWOL_DEBUG("Receive MSG : THREAD_KEYBORAD_KEY");
{ {
@ -175,13 +151,27 @@ static void* BaseAppEntry(void* param)
guiAbstraction::SendKeyboardEventMove(tmpData->isDown, tmpData->move); guiAbstraction::SendKeyboardEventMove(tmpData->isDown, tmpData->move);
} }
break; break;
case THREAD_HIDE:
EWOL_DEBUG("Receive MSG : THREAD_HIDE");
//guiAbstraction::SendKeyboardEventMove(tmpData->isDown, tmpData->move);
//gui_uniqueWindows->SysOnHide();
break;
case THREAD_SHOW:
EWOL_DEBUG("Receive MSG : THREAD_SHOW");
//guiAbstraction::SendKeyboardEventMove(tmpData->isDown, tmpData->move);
//gui_uniqueWindows->SysOnShow();
break;
default: default:
EWOL_DEBUG("Receive MSG : UNKNOW"); EWOL_DEBUG("Receive MSG : UNKNOW");
break; break;
} }
// TODO : when no message in the pipe : generate the display, and after, request the flip flop }
if (0 == ewol::threadMsg::WaitingMessage(androidJniMsg)) { if (0 == ewol::threadMsg::WaitingMessage(androidJniMsg)) {
if (countNbEvent > 0) {
// TODO : Generate the display here ... Instead of every time we call the sub-Widget ...
ewol::widgetManager::GetDoubleBufferFlipFlop(); ewol::widgetManager::GetDoubleBufferFlipFlop();
countNbEvent = 0;
}
} }
} }
EWOL_DEBUG("BThread Un-Init (START)"); EWOL_DEBUG("BThread Un-Init (START)");
@ -236,7 +226,6 @@ void EWOL_SystemStart(void)
// init the thread : // init the thread :
pthread_create(&androidJniThread, NULL, BaseAppEntry, NULL); pthread_create(&androidJniThread, NULL, BaseAppEntry, NULL);
isGlobalSystemInit = true; isGlobalSystemInit = true;
ewol::threadMsg::SendMessage(androidJniMsg, JNI_INIT, ewol::threadMsg::MSG_PRIO_REAL_TIME);
} }
} }
@ -244,7 +233,7 @@ void EWOL_SystemStop(void)
{ {
if (true == isGlobalSystemInit) { if (true == isGlobalSystemInit) {
isGlobalSystemInit = false; isGlobalSystemInit = false;
ewol::threadMsg::SendMessage(androidJniMsg, JNI_UN_INIT, ewol::threadMsg::MSG_PRIO_REAL_TIME); ewol::threadMsg::SendMessage(androidJniMsg, THREAD_UN_INIT, ewol::threadMsg::MSG_PRIO_REAL_TIME);
EWOL_DEBUG("Wait end of the thread ..."); EWOL_DEBUG("Wait end of the thread ...");
// Wait end of the thread // Wait end of the thread
@ -260,7 +249,7 @@ void EWOL_ThreadResize(int w, int h )
eventResize_ts tmpData; eventResize_ts tmpData;
tmpData.w = w; tmpData.w = w;
tmpData.h = h; tmpData.h = h;
ewol::threadMsg::SendMessage(androidJniMsg, JNI_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 EWOL_ThreadEventInputMotion(int pointerID, float x, float y )
@ -269,7 +258,7 @@ void EWOL_ThreadEventInputMotion(int pointerID, float x, float y )
tmpData.pointerID = pointerID; tmpData.pointerID = pointerID;
tmpData.x = x; tmpData.x = x;
tmpData.y = y; tmpData.y = y;
ewol::threadMsg::SendMessage(androidJniMsg, JNI_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) );
} }
@ -280,7 +269,7 @@ void EWOL_ThreadEventInputState(int pointerID, bool isUp, float x, float y )
tmpData.state = isUp; tmpData.state = isUp;
tmpData.x = x; tmpData.x = x;
tmpData.y = y; tmpData.y = y;
ewol::threadMsg::SendMessage(androidJniMsg, JNI_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(bool isDown, etk::String &keyInput) void EWOL_ThreadKeyboardEvent(bool isDown, etk::String &keyInput)
@ -299,4 +288,18 @@ void EWOL_ThreadKeyboardEventMove(bool isDown, ewol::eventKbMoveType_te &keyInpu
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_KEYBORAD_MOVE, ewol::threadMsg::MSG_PRIO_LOW, &tmpData, sizeof(eventKeyboardMove_ts) ); ewol::threadMsg::SendMessage(androidJniMsg, THREAD_KEYBORAD_MOVE, ewol::threadMsg::MSG_PRIO_LOW, &tmpData, sizeof(eventKeyboardMove_ts) );
} }
void EWOL_ThreadEventHide(void)
{
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_HIDE, ewol::threadMsg::MSG_PRIO_LOW);
}
void EWOL_ThreadEventShow(void)
{
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_SHOW, ewol::threadMsg::MSG_PRIO_LOW);
}
void EWOL_ThreadEventHasJustDisplay(void)
{
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_JUST_DISPLAY, ewol::threadMsg::MSG_PRIO_REAL_TIME);
}

View File

@ -41,6 +41,9 @@ void EWOL_ThreadKeyboardEvent(bool isDown, etk::String &keyInput);
void EWOL_ThreadKeyboardEventMove(bool isDown, ewol::eventKbMoveType_te &keyInput); void EWOL_ThreadKeyboardEventMove(bool isDown, ewol::eventKbMoveType_te &keyInput);
void EWOL_ThreadEventHide(void);
void EWOL_ThreadEventShow(void);
void EWOL_ThreadEventHasJustDisplay(void);
#endif #endif

View File

@ -130,27 +130,27 @@ void EWOL_NativeEventInputMotion(int pointerID, float x, float y )
if(0<=pointerID && pointerID < NB_MAX_INPUT ) { if(0<=pointerID && pointerID < NB_MAX_INPUT ) {
if(NULL != gui_uniqueWindows) { if(NULL != gui_uniqueWindows) {
//EWOL_DEBUG("ANDROID event: bt=" << pointerID+1 << " ** = \"MotionNotify\" (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")"); //EWOL_DEBUG("ANDROID event: bt=" << pointerID+1 << " ** = \"MotionNotify\" (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")");
gui_uniqueWindows->GenEventInput(pointerID+1, ewol::EVENT_INPUT_TYPE_MOVE, (etkFloat_t)x, (etkFloat_t)y); gui_uniqueWindows->GenEventInput(pointerID, ewol::EVENT_INPUT_TYPE_MOVE, (etkFloat_t)x, (etkFloat_t)y);
} }
} }
} }
void EWOL_NativeEventInputState(int pointerID, bool isUp, float x, float y ) void EWOL_NativeEventInputState(int pointerID, bool isUp, float x, float y )
{ {
//EWOL_INFO("Event : Input ID=" << pointerID << " [" << isUp << "] x=" << x << " y=" << y); //EWOL_INFO("GUI : Input ID=" << pointerID << " [" << isUp << "] x=" << x << " y=" << y);
if (isUp) { if (isUp) {
//EWOL_INFO("Event : Input ID=" << pointerID << " [DOWN] x=" << x << " y=" << y); //EWOL_DEBUG("GUI : Input ID=" << pointerID << " [DOWN] x=" << x << " y=" << y);
if(0<=pointerID && pointerID < NB_MAX_INPUT ) { if(0<=pointerID && pointerID < NB_MAX_INPUT ) {
// Send Down message // Send Down message
if (NULL != gui_uniqueWindows) { if (NULL != gui_uniqueWindows) {
EWOL_DEBUG("ANDROID bt=" << pointerID+1 << " event : **=\"ButtonPress\" (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")"); EWOL_DEBUG("GUI : Input ID=" << pointerID << " [DOWN] (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")");
gui_uniqueWindows->GenEventInput(pointerID+1, ewol::EVENT_INPUT_TYPE_DOWN, (etkFloat_t)x, (etkFloat_t)y); gui_uniqueWindows->GenEventInput(pointerID, ewol::EVENT_INPUT_TYPE_DOWN, (etkFloat_t)x, (etkFloat_t)y);
} }
// Check double or triple click event ... // Check double or triple click event ...
m_previousDown_x = x; m_previousDown_x = x;
m_previousDown_y = y; m_previousDown_y = y;
if (m_previousBouttonId != pointerID+1) { if (m_previousBouttonId != pointerID) {
m_previousBouttonId = pointerID+1; m_previousBouttonId = pointerID;
m_previous_x = -1; m_previous_x = -1;
m_previous_y = -1; m_previous_y = -1;
m_previousTime = 0; m_previousTime = 0;
@ -169,14 +169,14 @@ void EWOL_NativeEventInputState(int pointerID, bool isUp, float x, float y )
} }
} }
} else { } else {
//EWOL_INFO("Event : Input ID=" << pointerID << " [UP] x=" << x << " y=" << y); //EWOL_DEBUG("Event : Input ID=" << pointerID << " [UP] x=" << x << " y=" << y);
if(0<=pointerID && pointerID < NB_MAX_INPUT ) { if(0<=pointerID && pointerID < NB_MAX_INPUT ) {
// Send Down message // Send Down message
if (NULL != gui_uniqueWindows) { if (NULL != gui_uniqueWindows) {
EWOL_DEBUG("ANDROID bt=" << pointerID+1 << " event : **=\"ButtonRelease\" (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")"); EWOL_DEBUG("GUI : Input ID=" << pointerID << " [UP] (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")");
gui_uniqueWindows->GenEventInput(pointerID+1, ewol::EVENT_INPUT_TYPE_UP, (etkFloat_t)x, (etkFloat_t)y); gui_uniqueWindows->GenEventInput(pointerID, ewol::EVENT_INPUT_TYPE_UP, (etkFloat_t)x, (etkFloat_t)y);
} }
if (m_previousBouttonId != pointerID+1) { if (m_previousBouttonId != pointerID) {
m_previousDown_x = -1; m_previousDown_x = -1;
m_previousDown_y = -1; m_previousDown_y = -1;
m_previousBouttonId = 0; m_previousBouttonId = 0;
@ -185,16 +185,16 @@ void EWOL_NativeEventInputState(int pointerID, bool isUp, float x, float y )
m_previousTime = 0; m_previousTime = 0;
m_previousDouble = false; m_previousDouble = false;
} else { } else {
int64_t currentTime = GetCurrentTime(); // return the tic in 10ms int64_t currentTime = GetCurrentTime(); // return the tic in 1ms
//EWOL_DEBUG("time is : " << (int)currentTime << " "<< (int)(currentTime/100) <<"s " << (int)((currentTime%100)*10) << "ms"); EWOL_DEBUG("time is : " << (int)currentTime << " "<< (int)(currentTime/1000) <<"s " << (int)((currentTime%100)*10) << "ms delta : " << (currentTime - m_previousTime) << "<" << separateClickTime );
if (currentTime - m_previousTime >= separateClickTime) { if (currentTime - m_previousTime >= separateClickTime) {
//check if the same area click : //check if the same area click :
if( abs(m_previousDown_x - x) < offsetMoveClicked if( abs(m_previousDown_x - x) < offsetMoveClicked
&& abs(m_previousDown_y - y) < offsetMoveClicked ) && abs(m_previousDown_y - y) < offsetMoveClicked )
{ {
// might generate an sigle event : // might generate an sigle event :
EWOL_DEBUG("ANDROID event : ** = \"ButtonClickedSingle\" (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")"); EWOL_DEBUG("GUI : Input ID=" << pointerID << " [SINGLE] (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")");
gui_uniqueWindows->GenEventInput(pointerID+1, ewol::EVENT_INPUT_TYPE_SINGLE, (etkFloat_t)x, (etkFloat_t)y); gui_uniqueWindows->GenEventInput(pointerID, ewol::EVENT_INPUT_TYPE_SINGLE, (etkFloat_t)x, (etkFloat_t)y);
m_previous_x = m_previousDown_x; m_previous_x = m_previousDown_x;
m_previous_y = m_previousDown_y; m_previous_y = m_previousDown_y;
m_previousTime = currentTime; m_previousTime = currentTime;
@ -216,13 +216,13 @@ void EWOL_NativeEventInputState(int pointerID, bool isUp, float x, float y )
{ {
// might generate an sigle event : // might generate an sigle event :
if (false == m_previousDouble) { if (false == m_previousDouble) {
EWOL_DEBUG("ANDROID event : ** = \"ButtonClickedDouble\" (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")"); EWOL_DEBUG("GUI : Input ID=" << pointerID << " [DOUBLE] (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")");
gui_uniqueWindows->GenEventInput(pointerID+1, ewol::EVENT_INPUT_TYPE_DOUBLE, (etkFloat_t)x, (etkFloat_t)y); gui_uniqueWindows->GenEventInput(pointerID, ewol::EVENT_INPUT_TYPE_DOUBLE, (etkFloat_t)x, (etkFloat_t)y);
m_previousTime = currentTime; m_previousTime = currentTime;
m_previousDouble = true; m_previousDouble = true;
} else { } else {
EWOL_DEBUG("ANDROID event : ** = \"ButtonClickedTriple\" (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")"); EWOL_DEBUG("GUI : Input ID=" << pointerID << " [TRIPLE] (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")");
gui_uniqueWindows->GenEventInput(pointerID+1, ewol::EVENT_INPUT_TYPE_TRIPLE, (etkFloat_t)x, (etkFloat_t)y); gui_uniqueWindows->GenEventInput(pointerID, ewol::EVENT_INPUT_TYPE_TRIPLE, (etkFloat_t)x, (etkFloat_t)y);
// reset values ... // reset values ...
m_previousDown_x = -1; m_previousDown_x = -1;
m_previousDown_y = -1; m_previousDown_y = -1;
@ -248,10 +248,37 @@ void EWOL_NativeEventInputState(int pointerID, bool isUp, float x, float y )
} }
} }
static int64_t startTime = -1;
static int64_t nbCallTime = 0;
static int64_t nbDisplayTime = 0;
#define DISPLAY_PERIODE_MS (1000)
void EWOL_GenericDraw(void) void EWOL_GenericDraw(void)
{ {
ewol::widgetManager::GetDoubleBufferStartDraw(); bool display = false;
gui_uniqueWindows->SysDraw(); nbCallTime++;
ewol::widgetManager::GetDoubleBufferStopDraw(); if (startTime<0) {
startTime = GetCurrentTime();
}
int64_t currentTime = GetCurrentTime();
//EWOL_DEBUG("current : " << currentTime << "time diff : " << (currentTime - startTime));
if ( (currentTime - startTime) > DISPLAY_PERIODE_MS) {
display = true;
}
ewol::widgetManager::GetDoubleBufferStartDraw();
if (true == ewol::widgetManager::GetDoubleBufferNeedDraw()) {
nbDisplayTime++;
gui_uniqueWindows->SysDraw();
}
ewol::widgetManager::GetDoubleBufferStopDraw();
// send Message that we just finished a display ...
EWOL_ThreadEventHasJustDisplay();
if (true == display) {
EWOL_DEBUG("display property : " << (int32_t)((double)nbDisplayTime/(double)DISPLAY_PERIODE_MS*(double)1000) << "/" << (int32_t)((double)nbCallTime/(double)DISPLAY_PERIODE_MS*(double)1000) << "fps");
nbCallTime = 0;
nbDisplayTime = 0;
startTime = -1;
}
} }

View File

@ -51,7 +51,7 @@ namespace guiAbstraction
int64_t GetCurrentTime(void); int64_t GetCurrentTime(void);
//!< must be define in CPP by the application ... //!< must be define in CPP by the application ...
void APP_Init(int argc, char *argv[]); void APP_Init(void);
void APP_UnInit(void); void APP_UnInit(void);
#define NB_MAX_INPUT (20) #define NB_MAX_INPUT (20)

View File

@ -41,9 +41,7 @@
#undef __class__ #undef __class__
#define __class__ "AndroidJNI" #define __class__ "AndroidJNI"
int EWOL_appArgC = 0; int32_t separateClickTime = 200;
char **EWOL_appArgV = NULL;
int32_t separateClickTime = 20;
int32_t offsetMoveClicked = 40; int32_t offsetMoveClicked = 40;
int32_t offsetMoveClickedDouble = 300; int32_t offsetMoveClickedDouble = 300;
@ -254,3 +252,14 @@ void glOrtho(GLfloat left,
} }
#include <ewol/ewol.h>
int32_t ewol::CmdLineNb(void)
{
return 0;
}
etk::String ewol::CmdLineGet(int32_t id)
{
return "";
}

View File

@ -46,7 +46,15 @@
int64_t GetCurrentTime(void) int64_t GetCurrentTime(void)
{ {
return times(NULL); struct timespec now;
int ret = clock_gettime(CLOCK_REALTIME, &now);
if (ret != 0) {
// Error to get the time ...
now.tv_sec = time(NULL);
now.tv_nsec = 0;
}
//EWOL_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us");
return (int64_t)((int64_t)now.tv_sec*(int64_t)1000 + (int64_t)now.tv_nsec/(int64_t)1000000);
} }
#undef __class__ #undef __class__
@ -117,7 +125,7 @@ extern ewol::Windows* gui_uniqueWindows;
extern etkFloat_t gui_width; extern etkFloat_t gui_width;
extern etkFloat_t gui_height; extern etkFloat_t gui_height;
int32_t separateClickTime = 30; int32_t separateClickTime = 300;
int32_t offsetMoveClicked = 10; int32_t offsetMoveClicked = 10;
int32_t offsetMoveClickedDouble = 20; int32_t offsetMoveClickedDouble = 20;
@ -381,9 +389,9 @@ void X11_Run(void)
} }
break; break;
case ConfigureNotify: case ConfigureNotify:
EWOL_NativeResize(event.xconfigure.width, event.xconfigure.height);
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);
break; break;
case ButtonPress: case ButtonPress:
m_cursorEventX = event.xbutton.x; m_cursorEventX = event.xbutton.x;
@ -391,6 +399,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_ThreadEventInputState(event.xbutton.button, true, (float)event.xbutton.x, (float)event.xbutton.y);
break; break;
case ButtonRelease: case ButtonRelease:
m_cursorEventX = event.xbutton.x; m_cursorEventX = event.xbutton.x;
@ -398,72 +407,43 @@ 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_ThreadEventInputState(event.xbutton.button, false, (float)event.xbutton.x, (float)event.xbutton.y);
break; break;
case EnterNotify: case EnterNotify:
m_cursorEventX = event.xcrossing.x;
m_cursorEventY = event.xcrossing.y;
//EWOL_DEBUG("X11 event : " << event.type << " = \"EnterNotify\" (" << (etkFloat_t)event.xcrossing.x << "," << (etkFloat_t)event.xcrossing.y << ")");
//gui_uniqueWindows->GenEventInput(0, ewol::EVENT_INPUT_TYPE_ENTER, (etkFloat_t)event.xcrossing.x, (etkFloat_t)event.xcrossing.y);
break;
case LeaveNotify: case LeaveNotify:
m_cursorEventX = event.xcrossing.x; m_cursorEventX = event.xcrossing.x;
m_cursorEventY = event.xcrossing.y; m_cursorEventY = event.xcrossing.y;
//EWOL_DEBUG("X11 event : " << event.type << " = \"LeaveNotify\" (" << (etkFloat_t)event.xcrossing.x << "," << (etkFloat_t)event.xcrossing.y << ")");
break; break;
case MotionNotify: case MotionNotify:
m_cursorEventX = event.xmotion.x; m_cursorEventX = event.xmotion.x;
m_cursorEventY = event.xmotion.y; m_cursorEventY = event.xmotion.y;
break;
}
// parse event
if(NULL == gui_uniqueWindows) {
EWOL_DEBUG("Has No Windows set...");
} else {
switch (event.type)
{
case ConfigureNotify:
//EWOL_VERBOSE("X11 event : " << event.type << " = \"ConfigureNotify\" Origin(" << event.xconfigure.x << "," << event.xconfigure.y << ") Size(" << event.xconfigure.width << "," << event.xconfigure.height << ")");
//gui_uniqueWindows->CalculateSize((etkFloat_t)event.xconfigure.width, (etkFloat_t)event.xconfigure.height);
//gui_uniqueWindows->SetOrigin(event.xconfigure.x, event.xconfigure.y);
break;
case Expose:
EWOL_VERBOSE("X11 event : " << event.type << " = \"Expose\"");
gui_uniqueWindows->SysOnExpose();
break;
case ButtonPress:
EWOL_ThreadEventInputState(event.xbutton.button-1, true, (float)event.xbutton.x, (float)event.xbutton.y);
break;
case ButtonRelease:
EWOL_ThreadEventInputState(event.xbutton.button-1, false, (float)event.xbutton.x, (float)event.xbutton.y);
break;
case EnterNotify:
//EWOL_DEBUG("X11 event : " << event.type << " = \"EnterNotify\" (" << (etkFloat_t)event.xcrossing.x << "," << (etkFloat_t)event.xcrossing.y << ")");
//gui_uniqueWindows->GenEventInput(0, ewol::EVENT_INPUT_TYPE_ENTER, (etkFloat_t)event.xcrossing.x, (etkFloat_t)event.xcrossing.y);
break;
case MotionNotify:
{ {
// For compatibility of the Android system : // For compatibility of the Android system :
bool findOne = false; bool findOne = false;
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+1 << " " << event.type << " = \"MotionNotify\" (" << (etkFloat_t)event.xmotion.x << "," << (etkFloat_t)event.xmotion.y << ")"); EWOL_VERBOSE("X11 event: bt=" << iii+1 << " " << event.type << " = \"MotionNotify\" (" << (etkFloat_t)event.xmotion.x << "," << (etkFloat_t)event.xmotion.y << ")");
//gui_uniqueWindows->GenEventInput(iii+1, ewol::EVENT_INPUT_TYPE_MOVE, (etkFloat_t)event.xmotion.x, (etkFloat_t)event.xmotion.y);
EWOL_ThreadEventInputMotion(iii+1, (float)event.xmotion.x, (float)event.xmotion.y); EWOL_ThreadEventInputMotion(iii+1, (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\" (" << (etkFloat_t)event.xmotion.x << "," << (etkFloat_t)event.xmotion.y << ")"); EWOL_VERBOSE("X11 event: bt=" << 0 << " " << event.type << " = \"MotionNotify\" (" << (etkFloat_t)event.xmotion.x << "," << (etkFloat_t)event.xmotion.y << ")");
//gui_uniqueWindows->GenEventInput(0, ewol::EVENT_INPUT_TYPE_MOVE, (etkFloat_t)event.xmotion.x, (etkFloat_t)event.xmotion.y);
EWOL_ThreadEventInputMotion(0, (float)event.xmotion.x, (float)event.xmotion.y); EWOL_ThreadEventInputMotion(0, (float)event.xmotion.x, (float)event.xmotion.y);
} }
} }
break; break;
case LeaveNotify:
//EWOL_DEBUG("X11 event : " << event.type << " = \"LeaveNotify\" (" << (etkFloat_t)event.xcrossing.x << "," << (etkFloat_t)event.xcrossing.y << ")");
//gui_uniqueWindows->GenEventInput(0, ewol::EVENT_INPUT_TYPE_LEAVE, (etkFloat_t)event.xcrossing.x, (etkFloat_t)event.xcrossing.y);
break;
case FocusIn: case FocusIn:
EWOL_VERBOSE("X11 event : " << event.type << " = \"FocusIn\""); EWOL_VERBOSE("X11 event : " << event.type << " = \"FocusIn\"");
//gui_uniqueWindows->SetFocus();
break; break;
case FocusOut: case FocusOut:
EWOL_VERBOSE("X11 event : " << event.type << " = \"FocusOut\""); EWOL_VERBOSE("X11 event : " << event.type << " = \"FocusOut\"");
//gui_uniqueWindows->RmFocus();
break; break;
case KeyPress: case KeyPress:
case KeyRelease: case KeyRelease:
@ -624,19 +604,17 @@ void X11_Run(void)
// break; // break;
case MapNotify: case MapNotify:
EWOL_VERBOSE("X11 event : " << event.type << " = \"MapNotify\""); EWOL_VERBOSE("X11 event : " << event.type << " = \"MapNotify\"");
gui_uniqueWindows->SysOnShow(); EWOL_ThreadEventShow();
break; break;
case UnmapNotify: case UnmapNotify:
EWOL_VERBOSE("X11 event : " << event.type << " = \"UnmapNotify\""); EWOL_VERBOSE("X11 event : " << event.type << " = \"UnmapNotify\"");
gui_uniqueWindows->SysOnHide(); EWOL_ThreadEventHide();
break; break;
default: default:
EWOL_DEBUG("X11 event : " << event.type << " = \"???\""); EWOL_DEBUG("X11 event : " << event.type << " = \"???\"");
} }
} }
}
EWOL_NativeRender(); EWOL_NativeRender();
//usleep( 100000 );
} }
}; };
@ -703,15 +681,34 @@ bool guiAbstraction::IsPressedInput(int32_t inputID)
#include <ewol/ewol.h> #include <ewol/ewol.h>
static etk::VectorType<etk::String*> listArgs;
int32_t ewol::CmdLineNb(void)
{
return listArgs.Size();
}
etk::String ewol::CmdLineGet(int32_t id)
{
if (id<0 && id>=listArgs.Size()) {
return "";
}
if (NULL == listArgs[id]) {
return "";
}
return *listArgs[id];
}
int EWOL_appArgC = 0;
char **EWOL_appArgV = NULL;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
//EWOL_appArgC = argc; for( int32_t i=1 ; i<argc; i++) {
//EWOL_appArgV = argv; EWOL_INFO("CmdLine : \"" << argv[i] << "\"" );
etk::String* tmpString = new etk::String(argv[i]);
if (NULL != tmpString) {
listArgs.PushBack(tmpString);
}
}
// start X11 thread ... // start X11 thread ...
X11_Init(); X11_Init();
//start the basic thread : //start the basic thread :
@ -722,7 +719,13 @@ int main(int argc, char *argv[])
guiAbstraction::Stop(); guiAbstraction::Stop();
// uninit ALL : // uninit ALL :
EWOL_SystemStop(); EWOL_SystemStop();
for (int32_t iii=0; iii<listArgs.Size(); iii++) {
if (NULL != listArgs[iii]) {
delete listArgs[iii];
listArgs[iii] = NULL;
}
}
listArgs.Clear();
return 0; return 0;
} }

View File

@ -42,6 +42,8 @@ namespace ewol {
void KeyboardShow(ewol::keyboardMode_te mode); void KeyboardShow(ewol::keyboardMode_te mode);
void KeyboardHide(void); void KeyboardHide(void);
void ForceRedrawAll(void); void ForceRedrawAll(void);
int32_t CmdLineNb(void);
etk::String CmdLineGet(int32_t id);
bool IsSetCapsLock(void); bool IsSetCapsLock(void);
bool IsSetShift(void); bool IsSetShift(void);

View File

@ -165,3 +165,5 @@ int32_t ewol::threadMsg::WaitingMessage(threadMsg_ts& messageData)
pthread_mutex_unlock(&messageData.mutex); pthread_mutex_unlock(&messageData.mutex);
return nbMessage; return nbMessage;
} }

View File

@ -55,6 +55,7 @@ namespace ewol {
pthread_cond_t condition; pthread_cond_t condition;
threadMsgContent_ts listOfMessages[MSG_PRIO_NUMBER][NUMBER_OF_ELEMENT_IN_THE_FIFO]; threadMsgContent_ts listOfMessages[MSG_PRIO_NUMBER][NUMBER_OF_ELEMENT_IN_THE_FIFO];
int32_t nbMessages[MSG_PRIO_NUMBER]; int32_t nbMessages[MSG_PRIO_NUMBER];
bool displayHasDone;
} threadMsg_ts; } threadMsg_ts;
void Init(threadMsg_ts& messageData); void Init(threadMsg_ts& messageData);