Linux: Fixed Crashing problem due to locking problems with Xevents in the callback function. This SHOULD also fix the random lockups most/all are having in Linux, cheers

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@506 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Sonicadvance1 2008-09-13 04:32:28 +00:00
parent daabc11592
commit eb150f3114
2 changed files with 59 additions and 56 deletions

View File

@ -89,35 +89,8 @@ BOOL Callback_PeekMessages()
}
return TRUE;
#else // GLX
XEvent event;
while (XPending(GLWin.dpy) > 0) {
XNextEvent(GLWin.dpy, &event);
switch(event.type)
{
case KeyPress:
case KeyRelease:
case ButtonPress:
case ButtonRelease:
XPutBackEvent(GLWin.dpy, &event); // We Don't want to deal with these types, This is a video plugin!
break;
case ConfigureNotify:
Window winDummy;
unsigned int borderDummy;
XGetGeometry(GLWin.dpy, GLWin.win, &winDummy, &GLWin.x, &GLWin.y,
&GLWin.width, &GLWin.height, &borderDummy, &GLWin.depth);
nBackbufferWidth = GLWin.width;
nBackbufferHeight = GLWin.height;
break;
case ClientMessage: //TODO: We aren't reading this correctly, It could be anything, highest change is that it's a close event though
Video_Shutdown(); // Calling from here since returning false does nothing
return false;
break;
default:
//TODO: Should we put the event back if we don't handle it?
break;
}
}
return TRUE;
// This is called from Outside of our video thread, from EmuThread
// The calls are NOT thread safe, so it breaks everything
#endif
}
@ -406,8 +379,7 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
/* create a fullscreen window */
GLWin.attr.override_redirect = True;
GLWin.attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask |
StructureNotifyMask | ResizeRedirectMask;
GLWin.attr.event_mask = ExposureMask | StructureNotifyMask | ResizeRedirectMask;
GLWin.win = XCreateWindow(GLWin.dpy, RootWindow(GLWin.dpy, vi->screen),
0, 0, dpyWidth, dpyHeight, 0, vi->depth, InputOutput, vi->visual,
CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect,
@ -435,7 +407,7 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
//int Y = (rcdesktop.bottom-rcdesktop.top)/2 - (rc.bottom-rc.top)/2;
// create a window in window mode
GLWin.attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask |
GLWin.attr.event_mask = ExposureMask |
StructureNotifyMask | ResizeRedirectMask;
GLWin.win = XCreateWindow(GLWin.dpy, RootWindow(GLWin.dpy, vi->screen),
0, 0, _twidth, _theight, 0, vi->depth, InputOutput, vi->visual,
@ -502,8 +474,7 @@ bool OpenGL_MakeCurrent()
ERROR_LOG("no Direct Rendering possible!");
// better for pad plugin key input (thc)
XSelectInput(GLWin.dpy, GLWin.win, ExposureMask | KeyPressMask | KeyReleaseMask |
ButtonPressMask | StructureNotifyMask | EnterWindowMask | LeaveWindowMask |
XSelectInput(GLWin.dpy, GLWin.win, ExposureMask | StructureNotifyMask | EnterWindowMask | LeaveWindowMask |
FocusChangeMask );
#endif
return true;
@ -530,7 +501,38 @@ void OpenGL_Update()
nBackbufferHeight = height;
#else // GLX
// We do our resizing inside of the Callback function
// We just check all of our events here
XEvent event;
while (XPending(GLWin.dpy) > 0) {
XNextEvent(GLWin.dpy, &event);
switch(event.type)
{
case KeyPress:
case KeyRelease:
case ButtonPress:
case ButtonRelease:
printf("You have reached a section of code that you should never reach in a video plugin\n If you think that you are not in error, please contact the devs\n");
//XPutBackEvent(GLWin.dpy, &event); // We Don't want to deal with these types, This is a video plugin!
break;
case ConfigureNotify:
Window winDummy;
unsigned int borderDummy;
XGetGeometry(GLWin.dpy, GLWin.win, &winDummy, &GLWin.x, &GLWin.y,
&GLWin.width, &GLWin.height, &borderDummy, &GLWin.depth);
nBackbufferWidth = GLWin.width;
nBackbufferHeight = GLWin.height;
break;
case ClientMessage: //TODO: We aren't reading this correctly, It could be anything, highest change is that it's a close event though
Video_Shutdown(); // Calling from here since returning false does nothing
return;
break;
default:
//TODO: Should we put the event back if we don't handle it?
// I think we handle all the needed ones, the rest shouldn't matter
break;
}
}
return;
#endif
float FactorW = 640.0f / (float)nBackbufferWidth;

View File

@ -119,29 +119,30 @@ void DllConfig(HWND _hParent)
glXQueryVersion(GLWin.dpy, &glxMajorVersion, &glxMinorVersion);
XF86VidModeQueryVersion(GLWin.dpy, &vidModeMajorVersion, &vidModeMinorVersion);
//Get all full screen resos for the config dialog
XF86VidModeModeInfo **modes = NULL;
int modeNum = 0;
int bestMode = 0;
XF86VidModeModeInfo **modes = NULL;
int modeNum = 0;
int bestMode = 0;
//set best mode to current
bestMode = 0;
XF86VidModeGetAllModeLines(GLWin.dpy, GLWin.screen, &modeNum, &modes);
int px = 0, py = 0;
if (modeNum > 0 && modes != NULL)
{
for (int i = 0; i < modeNum; i++)
{
if(px != modes[i]->hdisplay && py != modes[i]->vdisplay)
{
char temp[32];
sprintf(temp,"%dx%d", modes[i]->hdisplay, modes[i]->vdisplay);
frame.AddFSReso(temp);
frame.AddWindowReso(temp);//Add same to Window ones, since they should be nearly all that's needed
px = modes[i]->hdisplay;//Used to remove repeating from different screen depths
py = modes[i]->vdisplay;
}
}
//set best mode to current
bestMode = 0;
XF86VidModeGetAllModeLines(GLWin.dpy, GLWin.screen, &modeNum, &modes);
int px = 0, py = 0;
if (modeNum > 0 && modes != NULL)
{
for (int i = 0; i < modeNum; i++)
{
if(px != modes[i]->hdisplay && py != modes[i]->vdisplay)
{
char temp[32];
sprintf(temp,"%dx%d", modes[i]->hdisplay, modes[i]->vdisplay);
frame.AddFSReso(temp);
frame.AddWindowReso(temp);//Add same to Window ones, since they should be nearly all that's needed
px = modes[i]->hdisplay;//Used to remove repeating from different screen depths
py = modes[i]->vdisplay;
}
}
}
XFree(modes);
frame.ShowModal();
#else