Adding source/Platform/Unix/X11SharedDisplay.cpp
This commit is contained in:
parent
c41fb6c013
commit
bd38e9e98f
3 changed files with 48 additions and 0 deletions
|
|
@ -65,6 +65,7 @@ if TARGET_OS == "Win32" then
|
|||
elseif TARGET_OS == "Unix" then
|
||||
platform_spec_module = Module("source/Platform/Unix", {
|
||||
"UnixApplication.cpp",
|
||||
"X11SharedDisplay.cpp",
|
||||
"X11Display.cpp",
|
||||
"GLXContext.cpp",
|
||||
"X11Input.cpp",
|
||||
|
|
|
|||
32
source/Platform/Unix/X11SharedDisplay.cpp
Normal file
32
source/Platform/Unix/X11SharedDisplay.cpp
Normal 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
|
||||
15
source/Platform/Unix/X11SharedDisplay.h
Normal file
15
source/Platform/Unix/X11SharedDisplay.h
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
#ifndef SPECTRE_PLATFORM_UNIX_X11SHAREDDISPLAY_H
|
||||
#define SPECTRE_PLATFORM_UNIX_X11SHAREDDISPLAY_H
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
namespace sp {
|
||||
|
||||
::Display* XGetDisplay();
|
||||
|
||||
void XReleaseDisplay();
|
||||
|
||||
} // namespace sp
|
||||
|
||||
#endif /* SPECTRE_PLATFORM_UNIX_X11SHAREDDISPLAY_H */
|
||||
Loading…
Add table
Add a link
Reference in a new issue