mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
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:
@ -89,35 +89,8 @@ BOOL Callback_PeekMessages()
|
|||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
#else // GLX
|
#else // GLX
|
||||||
XEvent event;
|
// This is called from Outside of our video thread, from EmuThread
|
||||||
while (XPending(GLWin.dpy) > 0) {
|
// The calls are NOT thread safe, so it breaks everything
|
||||||
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;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,8 +379,7 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
|
|||||||
|
|
||||||
/* create a fullscreen window */
|
/* create a fullscreen window */
|
||||||
GLWin.attr.override_redirect = True;
|
GLWin.attr.override_redirect = True;
|
||||||
GLWin.attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask |
|
GLWin.attr.event_mask = ExposureMask | StructureNotifyMask | ResizeRedirectMask;
|
||||||
StructureNotifyMask | ResizeRedirectMask;
|
|
||||||
GLWin.win = XCreateWindow(GLWin.dpy, RootWindow(GLWin.dpy, vi->screen),
|
GLWin.win = XCreateWindow(GLWin.dpy, RootWindow(GLWin.dpy, vi->screen),
|
||||||
0, 0, dpyWidth, dpyHeight, 0, vi->depth, InputOutput, vi->visual,
|
0, 0, dpyWidth, dpyHeight, 0, vi->depth, InputOutput, vi->visual,
|
||||||
CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect,
|
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;
|
//int Y = (rcdesktop.bottom-rcdesktop.top)/2 - (rc.bottom-rc.top)/2;
|
||||||
|
|
||||||
// create a window in window mode
|
// create a window in window mode
|
||||||
GLWin.attr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask |
|
GLWin.attr.event_mask = ExposureMask |
|
||||||
StructureNotifyMask | ResizeRedirectMask;
|
StructureNotifyMask | ResizeRedirectMask;
|
||||||
GLWin.win = XCreateWindow(GLWin.dpy, RootWindow(GLWin.dpy, vi->screen),
|
GLWin.win = XCreateWindow(GLWin.dpy, RootWindow(GLWin.dpy, vi->screen),
|
||||||
0, 0, _twidth, _theight, 0, vi->depth, InputOutput, vi->visual,
|
0, 0, _twidth, _theight, 0, vi->depth, InputOutput, vi->visual,
|
||||||
@ -502,8 +474,7 @@ bool OpenGL_MakeCurrent()
|
|||||||
ERROR_LOG("no Direct Rendering possible!");
|
ERROR_LOG("no Direct Rendering possible!");
|
||||||
|
|
||||||
// better for pad plugin key input (thc)
|
// better for pad plugin key input (thc)
|
||||||
XSelectInput(GLWin.dpy, GLWin.win, ExposureMask | KeyPressMask | KeyReleaseMask |
|
XSelectInput(GLWin.dpy, GLWin.win, ExposureMask | StructureNotifyMask | EnterWindowMask | LeaveWindowMask |
|
||||||
ButtonPressMask | StructureNotifyMask | EnterWindowMask | LeaveWindowMask |
|
|
||||||
FocusChangeMask );
|
FocusChangeMask );
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
@ -530,7 +501,38 @@ void OpenGL_Update()
|
|||||||
nBackbufferHeight = height;
|
nBackbufferHeight = height;
|
||||||
|
|
||||||
#else // GLX
|
#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
|
#endif
|
||||||
|
|
||||||
float FactorW = 640.0f / (float)nBackbufferWidth;
|
float FactorW = 640.0f / (float)nBackbufferWidth;
|
||||||
|
@ -119,29 +119,30 @@ void DllConfig(HWND _hParent)
|
|||||||
glXQueryVersion(GLWin.dpy, &glxMajorVersion, &glxMinorVersion);
|
glXQueryVersion(GLWin.dpy, &glxMajorVersion, &glxMinorVersion);
|
||||||
XF86VidModeQueryVersion(GLWin.dpy, &vidModeMajorVersion, &vidModeMinorVersion);
|
XF86VidModeQueryVersion(GLWin.dpy, &vidModeMajorVersion, &vidModeMinorVersion);
|
||||||
//Get all full screen resos for the config dialog
|
//Get all full screen resos for the config dialog
|
||||||
XF86VidModeModeInfo **modes = NULL;
|
XF86VidModeModeInfo **modes = NULL;
|
||||||
int modeNum = 0;
|
int modeNum = 0;
|
||||||
int bestMode = 0;
|
int bestMode = 0;
|
||||||
|
|
||||||
//set best mode to current
|
//set best mode to current
|
||||||
bestMode = 0;
|
bestMode = 0;
|
||||||
XF86VidModeGetAllModeLines(GLWin.dpy, GLWin.screen, &modeNum, &modes);
|
XF86VidModeGetAllModeLines(GLWin.dpy, GLWin.screen, &modeNum, &modes);
|
||||||
int px = 0, py = 0;
|
int px = 0, py = 0;
|
||||||
if (modeNum > 0 && modes != NULL)
|
if (modeNum > 0 && modes != NULL)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < modeNum; i++)
|
for (int i = 0; i < modeNum; i++)
|
||||||
{
|
{
|
||||||
if(px != modes[i]->hdisplay && py != modes[i]->vdisplay)
|
if(px != modes[i]->hdisplay && py != modes[i]->vdisplay)
|
||||||
{
|
{
|
||||||
char temp[32];
|
char temp[32];
|
||||||
sprintf(temp,"%dx%d", modes[i]->hdisplay, modes[i]->vdisplay);
|
sprintf(temp,"%dx%d", modes[i]->hdisplay, modes[i]->vdisplay);
|
||||||
frame.AddFSReso(temp);
|
frame.AddFSReso(temp);
|
||||||
frame.AddWindowReso(temp);//Add same to Window ones, since they should be nearly all that's needed
|
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
|
px = modes[i]->hdisplay;//Used to remove repeating from different screen depths
|
||||||
py = modes[i]->vdisplay;
|
py = modes[i]->vdisplay;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
XFree(modes);
|
||||||
frame.ShowModal();
|
frame.ShowModal();
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user