1
0
Fork 0

Adding source/Platform/Unix/X11SharedDisplay.cpp

This commit is contained in:
Henrik Hautakoski 2019-12-24 21:31:08 +01:00
parent c35fd2e287
commit 389d75f3d8
3 changed files with 48 additions and 0 deletions

View file

@ -0,0 +1,32 @@
#include "X11SharedDisplay.h"
namespace sp {
// Define a global display (for simplicity, we always connect to local one.)
::Display* sharedDisplay = NULL;
unsigned int refcount = 0;
::Display* XGetDisplay() {
// Create if we dont have any references.
if (refcount == 0) {
sharedDisplay = XOpenDisplay(NULL);
}
refcount++;
return sharedDisplay;
}
void XReleaseDisplay() {
if (refcount < 1) {
return;
}
if (--refcount == 0) {
XCloseDisplay(sharedDisplay);
}
}
} // namespace sp