Only one thing opens a connection, the low level window. Anything depending on it can check directly if it is open or not. A native X11 loading window would probably use it as well and we wouldn't want to close and reopen the Display. hmm.
This commit is contained in:
@@ -2,9 +2,6 @@
|
|||||||
#include "X11Helper.h"
|
#include "X11Helper.h"
|
||||||
#include "RageLog.h"
|
#include "RageLog.h"
|
||||||
|
|
||||||
// Number of subsystems using the X connection:
|
|
||||||
static int g_iRefCount = 0;
|
|
||||||
|
|
||||||
Display *X11Helper::Dpy = NULL;
|
Display *X11Helper::Dpy = NULL;
|
||||||
Window X11Helper::Win = None;
|
Window X11Helper::Win = None;
|
||||||
|
|
||||||
@@ -13,35 +10,28 @@ static int FatalCallback( Display* );
|
|||||||
|
|
||||||
bool X11Helper::OpenXConnection()
|
bool X11Helper::OpenXConnection()
|
||||||
{
|
{
|
||||||
if( g_iRefCount == 0 )
|
DEBUG_ASSERT( Dpy == NULL && Win == None );
|
||||||
{
|
Dpy = XOpenDisplay(0);
|
||||||
Dpy = XOpenDisplay(0);
|
if( Dpy == NULL )
|
||||||
if( Dpy == NULL )
|
return false;
|
||||||
return false;
|
|
||||||
|
|
||||||
XSetIOErrorHandler( FatalCallback );
|
XSetIOErrorHandler( FatalCallback );
|
||||||
XSetErrorHandler( ErrorCallback );
|
XSetErrorHandler( ErrorCallback );
|
||||||
}
|
|
||||||
g_iRefCount++;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void X11Helper::CloseXConnection()
|
void X11Helper::CloseXConnection()
|
||||||
{
|
{
|
||||||
g_iRefCount--;
|
// The window should have been shut down
|
||||||
|
DEBUG_ASSERT( Dpy != NULL );
|
||||||
if( g_iRefCount == 0 )
|
DEBUG_ASSERT( Win == None );
|
||||||
{
|
XCloseDisplay( Dpy );
|
||||||
// The window should have been shut down
|
Dpy = NULL;
|
||||||
DEBUG_ASSERT( Win == None );
|
|
||||||
XCloseDisplay( Dpy );
|
|
||||||
Dpy = NULL; // For sanity's sake
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool X11Helper::MakeWindow( Window &win, int screenNum, int depth, Visual *visual, int width, int height, bool overrideRedirect )
|
bool X11Helper::MakeWindow( Window &win, int screenNum, int depth, Visual *visual, int width, int height, bool overrideRedirect )
|
||||||
{
|
{
|
||||||
if( g_iRefCount == 0 )
|
if( !Dpy || !Win )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
XSetWindowAttributes winAttribs;
|
XSetWindowAttributes winAttribs;
|
||||||
|
|||||||
Reference in New Issue
Block a user