GregMiscellaneous: zzogl: add some locking. Work far better.

The trick was to call XInitThreads in the beginning.


git-svn-id: http://pcsx2.googlecode.com/svn/branches/GregMiscellaneous@3732 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
gregory.hainaut@gmail.com 2010-09-05 16:30:47 +00:00
parent 0845dffb5b
commit 65b985698e
1 changed files with 20 additions and 9 deletions

View File

@ -27,6 +27,10 @@
bool GLWindow::CreateWindow(void *pDisplay) bool GLWindow::CreateWindow(void *pDisplay)
{ {
// init support of multi thread
if (!XInitThreads())
ZZLog::Error_Log("Failed to init the xlib concurent threads");
glDisplay = XOpenDisplay(0); glDisplay = XOpenDisplay(0);
glScreen = DefaultScreen(glDisplay); glScreen = DefaultScreen(glDisplay);
@ -137,6 +141,7 @@ void GLWindow::GetGLXVersion()
} }
void GLWindow::UpdateGrabKey() { void GLWindow::UpdateGrabKey() {
XLockDisplay(glDisplay);
if (fullScreen) { if (fullScreen) {
XGrabPointer(glDisplay, glWindow, True, ButtonPressMask, GrabModeAsync, GrabModeAsync, glWindow, None, CurrentTime); XGrabPointer(glDisplay, glWindow, True, ButtonPressMask, GrabModeAsync, GrabModeAsync, glWindow, None, CurrentTime);
XGrabKeyboard(glDisplay, glWindow, True, GrabModeAsync, GrabModeAsync, CurrentTime); XGrabKeyboard(glDisplay, glWindow, True, GrabModeAsync, GrabModeAsync, CurrentTime);
@ -144,6 +149,7 @@ void GLWindow::UpdateGrabKey() {
XUngrabPointer(glDisplay, CurrentTime); XUngrabPointer(glDisplay, CurrentTime);
XUngrabKeyboard(glDisplay, CurrentTime); XUngrabKeyboard(glDisplay, CurrentTime);
} }
XUnlockDisplay(glDisplay);
} }
#define _NET_WM_STATE_REMOVE 0 #define _NET_WM_STATE_REMOVE 0
@ -170,10 +176,12 @@ void GLWindow::ToggleFullscreen()
cme.data.l[3] = 0; cme.data.l[3] = 0;
// send the event // send the event
XLockDisplay(glDisplay);
if (!XSendEvent(glDisplay, RootWindow(glDisplay, vi->screen), False, mask, (XEvent*)(&cme))) if (!XSendEvent(glDisplay, RootWindow(glDisplay, vi->screen), False, mask, (XEvent*)(&cme)))
ZZLog::Error_Log("Failed to send event: toggle fullscreen"); ZZLog::Error_Log("Failed to send event: toggle fullscreen");
else else
fullScreen = (!fullScreen); fullScreen = (!fullScreen);
XUnlockDisplay(glDisplay);
// Apply the change // Apply the change
XSync(glDisplay, False); XSync(glDisplay, False);
@ -257,17 +265,20 @@ void GLWindow::SwapGLBuffers()
void GLWindow::SetTitle(char *strtitle) void GLWindow::SetTitle(char *strtitle)
{ {
if (!fullScreen) if (!glDisplay or !glWindow) return;
{ if (fullScreen) return;
XTextProperty prop;
memset(&prop, 0, sizeof(prop));
char* ptitle = strtitle; XTextProperty prop;
if (XStringListToTextProperty(&ptitle, 1, &prop)) memset(&prop, 0, sizeof(prop));
XSetWMName(glDisplay, glWindow, &prop);
XFree(prop.value); char* ptitle = strtitle;
} if (XStringListToTextProperty(&ptitle, 1, &prop)) {
XLockDisplay(glDisplay);
XSetWMName(glDisplay, glWindow, &prop);
XUnlockDisplay(glDisplay);
}
XFree(prop.value);
} }
void GLWindow::ResizeCheck() void GLWindow::ResizeCheck()