Find the error of the X11 stop ==> basic corection but it is now more longer than predicted

This commit is contained in:
Edouard Dupin 2012-05-23 10:58:30 +02:00
parent 7afeb4aa80
commit 18099cf376
2 changed files with 68 additions and 13 deletions

View File

@ -149,6 +149,9 @@ static void X11_GetAbsPos(int32_t & x, int32_t & y);
bool CreateX11Context(void) bool CreateX11Context(void)
{ {
#ifdef DEBUG_X11_EVENT
EWOL_INFO("X11: CreateX11Context");
#endif
int x,y, attr_mask; int x,y, attr_mask;
XSizeHints hints; XSizeHints hints;
XWMHints *StartupState; XWMHints *StartupState;
@ -157,6 +160,12 @@ bool CreateX11Context(void)
// basic title of the windows ... // basic title of the windows ...
static char *title = (char*)"Ewol"; static char *title = (char*)"Ewol";
// 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);
}
// 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) {
@ -267,6 +276,10 @@ bool CreateX11Context(void)
void ewol::SetTitle(etk::UString title) void ewol::SetTitle(etk::UString title)
{ {
#ifdef DEBUG_X11_EVENT
EWOL_INFO("X11: Set Title (START)");
#endif
XLockDisplay(m_display);
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;
@ -276,6 +289,10 @@ void ewol::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);
XUnlockDisplay(m_display);
#ifdef DEBUG_X11_EVENT
EWOL_INFO("X11: Set Title (END)");
#endif
} }
/* this variable will contain the ID of the newly created pixmap. */ /* this variable will contain the ID of the newly created pixmap. */
@ -284,13 +301,16 @@ Pixmap icon_pixmap;
// TODO : I don't understand why it does not work .... // TODO : I don't understand why it does not work ....
void SetIcon(etk::File bitmapFile) void SetIcon(etk::File bitmapFile)
{ {
#ifdef DEBUG_X11_EVENT
EWOL_INFO("X11: try to set icon : " << bitmapFile);
#endif
// load bitmap // load bitmap
EWOL_INFO("try to set icon : " << bitmapFile);
if (false == bitmapFile.Exist()) { if (false == bitmapFile.Exist()) {
EWOL_ERROR("X11 Icon File does not Exist ... " << bitmapFile); EWOL_ERROR("X11 Icon File does not Exist ... " << bitmapFile);
} else { } else {
etk::UString fileExtention = bitmapFile.GetExtention(); etk::UString fileExtention = bitmapFile.GetExtention();
if (fileExtention == "bmp") { if (fileExtention == "bmp") {
XLockDisplay(m_display);
// pointer to the WM hints structure. // pointer to the WM hints structure.
XWMHints* win_hints; XWMHints* win_hints;
@ -304,12 +324,15 @@ 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 ");
XUnlockDisplay(m_display);
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.");
XUnlockDisplay(m_display);
return; return;
case BitmapNoMemory: case BitmapNoMemory:
EWOL_ERROR("XReadBitmapFile - not enough memory."); EWOL_ERROR("XReadBitmapFile - not enough memory.");
XUnlockDisplay(m_display);
return; return;
case BitmapSuccess: case BitmapSuccess:
/* bitmap loaded successfully - do something with it... */ /* bitmap loaded successfully - do something with it... */
@ -320,6 +343,7 @@ 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");
XUnlockDisplay(m_display);
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.
@ -331,7 +355,7 @@ 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);
XUnlockDisplay(m_display);
} else { } else {
EWOL_ERROR("X11 Icon Extention not managed " << bitmapFile << " Sopported extention : .bmp "); EWOL_ERROR("X11 Icon Extention not managed " << bitmapFile << " Sopported extention : .bmp ");
} }
@ -341,40 +365,50 @@ void SetIcon(etk::File bitmapFile)
void RemoveDecoration(void) void RemoveDecoration(void)
{ {
#ifdef DEBUG_X11_EVENT
EWOL_INFO("X11:RemoveDecoration");
#endif
XLockDisplay(m_display);
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.
hints.decorations = 0;// 0 (false) means that window decorations should go bye-bye hints.decorations = 0;// 0 (false) means that window decorations should go bye-bye
property = XInternAtom(m_display, "_MOTIF_WM_HINTS", true); property = XInternAtom(m_display, "_MOTIF_WM_HINTS", true);
if (0 != property) { if (0 != property) {
XLockDisplay(m_display);
XChangeProperty(m_display,WindowHandle,property,property,32,PropModeReplace,(unsigned char *)&hints,5); XChangeProperty(m_display,WindowHandle,property,property,32,PropModeReplace,(unsigned char *)&hints,5);
XUnlockDisplay(m_display);
XMapWindow(m_display, WindowHandle); XMapWindow(m_display, WindowHandle);
} 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 ....");
} }
XUnlockDisplay(m_display);
} }
void AddDecoration(void) void AddDecoration(void)
{ {
#ifdef DEBUG_X11_EVENT
EWOL_INFO("X11:AddDecoration");
#endif
XLockDisplay(m_display);
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.
hints.decorations = 1;// 1 (true) means that window decorations should enable hints.decorations = 1;// 1 (true) means that window decorations should enable
property = XInternAtom(m_display, "_MOTIF_WM_HINTS", true); property = XInternAtom(m_display, "_MOTIF_WM_HINTS", true);
if (0 != property) { if (0 != property) {
XLockDisplay(m_display);
XChangeProperty(m_display,WindowHandle,property,property,32,PropModeReplace,(unsigned char *)&hints,5); XChangeProperty(m_display,WindowHandle,property,property,32,PropModeReplace,(unsigned char *)&hints,5);
XUnlockDisplay(m_display);
XMapWindow(m_display, WindowHandle); XMapWindow(m_display, WindowHandle);
} 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 ....");
} }
XUnlockDisplay(m_display);
} }
bool CreateOGlContext(void) bool CreateOGlContext(void)
{ {
#ifdef DEBUG_X11_EVENT
EWOL_INFO("X11:CreateOGlContext");
#endif
XLockDisplay(m_display);
/* 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 */
@ -384,6 +418,7 @@ bool CreateOGlContext(void)
} else { } else {
EWOL_INFO("XF86 DRI NOT available\n"); EWOL_INFO("XF86 DRI NOT available\n");
} }
XUnlockDisplay(m_display);
return true; return true;
} }
@ -426,6 +461,9 @@ void EWOL_NativeRender(void)
void X11_Init(void) void X11_Init(void)
{ {
#ifdef DEBUG_X11_EVENT
EWOL_INFO("X11:INIT");
#endif
m_visual = NULL; m_visual = NULL;
m_previousBouttonId = 0; m_previousBouttonId = 0;
m_previousDown_x = -1; m_previousDown_x = -1;
@ -984,21 +1022,24 @@ void X11_Run(void)
} }
} }
if(true == m_run) { if(true == m_run) {
//#ifdef DEBUG_X11_EVENT #ifdef DEBUG_X11_EVENT
EWOL_INFO("X11 Render..."); EWOL_INFO("X11 Render...");
//#endif #endif
XLockDisplay(m_display); XLockDisplay(m_display);
EWOL_NativeRender(); EWOL_NativeRender();
XUnlockDisplay(m_display); XUnlockDisplay(m_display);
} }
//#ifdef DEBUG_X11_EVENT #ifdef DEBUG_X11_EVENT
EWOL_INFO("X11 endEvent --- "); EWOL_INFO("X11 endEvent --- ");
//#endif #endif
} }
}; };
void X11_ChangeSize(int32_t w, int32_t h) void X11_ChangeSize(int32_t w, int32_t h)
{ {
#ifdef DEBUG_X11_EVENT
EWOL_INFO("X11: X11_ChangeSize");
#endif
XLockDisplay(m_display); XLockDisplay(m_display);
XResizeWindow(m_display, WindowHandle, w, h); XResizeWindow(m_display, WindowHandle, w, h);
XUnlockDisplay(m_display); XUnlockDisplay(m_display);
@ -1006,6 +1047,9 @@ void X11_ChangeSize(int32_t w, int32_t h)
void X11_ChangePos(int32_t x, int32_t y) void X11_ChangePos(int32_t x, int32_t y)
{ {
#ifdef DEBUG_X11_EVENT
EWOL_INFO("X11: X11_ChangePos");
#endif
XLockDisplay(m_display); XLockDisplay(m_display);
XMoveWindow(m_display, WindowHandle, x, y); XMoveWindow(m_display, WindowHandle, x, y);
XUnlockDisplay(m_display); XUnlockDisplay(m_display);
@ -1013,6 +1057,9 @@ void X11_ChangePos(int32_t x, int32_t y)
void X11_GetAbsPos(int32_t & x, int32_t & y) void X11_GetAbsPos(int32_t & x, int32_t & y)
{ {
#ifdef DEBUG_X11_EVENT
EWOL_INFO("X11: X11_GetAbsPos");
#endif
int tmp; int tmp;
unsigned int tmp2; unsigned int tmp2;
Window fromroot, tmpwin; Window fromroot, tmpwin;
@ -1027,7 +1074,9 @@ void X11_GetAbsPos(int32_t & x, int32_t & y)
void guiAbstraction::ClipBoardGet(etk::UString &newData, clipBoardMode_te mode) void guiAbstraction::ClipBoardGet(etk::UString &newData, clipBoardMode_te mode)
{ {
EWOL_INFO("Request Get of a clipboard : " << mode << " size=" << newData.Size() ); #ifdef DEBUG_X11_EVENT
EWOL_INFO("Request Get of a clipboard : " << mode << " size=" << newData.Size() );
#endif
newData = ""; newData = "";
switch (mode) switch (mode)
{ {
@ -1085,7 +1134,9 @@ void guiAbstraction::ClipBoardGet(etk::UString &newData, clipBoardMode_te mode)
void guiAbstraction::ClipBoardSet(etk::UString &newData, clipBoardMode_te mode) void guiAbstraction::ClipBoardSet(etk::UString &newData, clipBoardMode_te mode)
{ {
EWOL_VERBOSE("Request set of a clipboard : " << mode << " size=" << newData.Size() ); #ifdef DEBUG_X11_EVENT
EWOL_INFO("Request set of a clipboard : " << mode << " size=" << newData.Size() );
#endif
switch (mode) switch (mode)
{ {
case CLIPBOARD_MODE_PRIMARY: case CLIPBOARD_MODE_PRIMARY:
@ -1128,6 +1179,9 @@ void guiAbstraction::ClipBoardSet(etk::UString &newData, clipBoardMode_te mode)
void guiAbstraction::Stop(void) void guiAbstraction::Stop(void)
{ {
#ifdef DEBUG_X11_EVENT
EWOL_INFO("X11: Stop");
#endif
m_run = false; m_run = false;
} }

View File

@ -38,6 +38,7 @@ ewol::WidgetScrooled::WidgetScrooled(void)
m_pixelScrolling = 20; m_pixelScrolling = 20;
m_highSpeedMode = SCROLL_DISABLE; m_highSpeedMode = SCROLL_DISABLE;
m_scroollingMode = SCROLL_MODE_NORMAL; m_scroollingMode = SCROLL_MODE_NORMAL;
m_highSpeedType = ewol::INPUT_TYPE_UNKNOW;
m_zoom = 1.0; m_zoom = 1.0;
m_highSpeedButton = -1; m_highSpeedButton = -1;
} }