GLX: Remove evdpy / dpy split
Move to one display. There's no reason to have two displays here -- the comment stated that one should touch GLX and one should touch window events, and that they should be touched from different threads, but the current code wasn't this careful. Just use one Display connection.
This commit is contained in:
parent
12f073c56b
commit
e3a9ba30e3
|
@ -33,9 +33,7 @@ typedef struct {
|
||||||
int screen;
|
int screen;
|
||||||
Window win;
|
Window win;
|
||||||
Window parent;
|
Window parent;
|
||||||
// dpy used for glx stuff, evdpy for window events etc.
|
Display *dpy;
|
||||||
// evdpy is to be used by XEventThread only
|
|
||||||
Display *dpy, *evdpy;
|
|
||||||
XVisualInfo *vi;
|
XVisualInfo *vi;
|
||||||
XSetWindowAttributes attr;
|
XSetWindowAttributes attr;
|
||||||
std::thread xEventThread;
|
std::thread xEventThread;
|
||||||
|
|
|
@ -15,7 +15,7 @@ static PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI = nullptr;
|
||||||
// Show the current FPS
|
// Show the current FPS
|
||||||
void cInterfaceGLX::UpdateFPSDisplay(const std::string& text)
|
void cInterfaceGLX::UpdateFPSDisplay(const std::string& text)
|
||||||
{
|
{
|
||||||
XStoreName(GLWin.evdpy, GLWin.win, text.c_str());
|
XStoreName(GLWin.dpy, GLWin.win, text.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void cInterfaceGLX::SwapInterval(int Interval)
|
void cInterfaceGLX::SwapInterval(int Interval)
|
||||||
|
@ -65,7 +65,6 @@ bool cInterfaceGLX::Create(void *&window_handle)
|
||||||
None };
|
None };
|
||||||
|
|
||||||
GLWin.dpy = XOpenDisplay(nullptr);
|
GLWin.dpy = XOpenDisplay(nullptr);
|
||||||
GLWin.evdpy = XOpenDisplay(nullptr);
|
|
||||||
GLWin.parent = (Window)window_handle;
|
GLWin.parent = (Window)window_handle;
|
||||||
GLWin.screen = DefaultScreen(GLWin.dpy);
|
GLWin.screen = DefaultScreen(GLWin.dpy);
|
||||||
if (GLWin.parent == 0)
|
if (GLWin.parent == 0)
|
||||||
|
@ -134,7 +133,6 @@ void cInterfaceGLX::Shutdown()
|
||||||
{
|
{
|
||||||
glXDestroyContext(GLWin.dpy, GLWin.ctx);
|
glXDestroyContext(GLWin.dpy, GLWin.ctx);
|
||||||
XCloseDisplay(GLWin.dpy);
|
XCloseDisplay(GLWin.dpy);
|
||||||
XCloseDisplay(GLWin.evdpy);
|
|
||||||
GLWin.ctx = nullptr;
|
GLWin.ctx = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,33 +11,33 @@ void cX11Window::CreateXWindow(void)
|
||||||
Atom wmProtocols[1];
|
Atom wmProtocols[1];
|
||||||
|
|
||||||
// Setup window attributes
|
// Setup window attributes
|
||||||
GLWin.attr.colormap = XCreateColormap(GLWin.evdpy,
|
GLWin.attr.colormap = XCreateColormap(GLWin.dpy,
|
||||||
GLWin.parent, GLWin.vi->visual, AllocNone);
|
GLWin.parent, GLWin.vi->visual, AllocNone);
|
||||||
GLWin.attr.event_mask = KeyPressMask | StructureNotifyMask | FocusChangeMask;
|
GLWin.attr.event_mask = KeyPressMask | StructureNotifyMask | FocusChangeMask;
|
||||||
GLWin.attr.background_pixel = BlackPixel(GLWin.evdpy, GLWin.screen);
|
GLWin.attr.background_pixel = BlackPixel(GLWin.dpy, GLWin.screen);
|
||||||
GLWin.attr.border_pixel = 0;
|
GLWin.attr.border_pixel = 0;
|
||||||
|
|
||||||
// Create the window
|
// Create the window
|
||||||
GLWin.win = XCreateWindow(GLWin.evdpy, GLWin.parent,
|
GLWin.win = XCreateWindow(GLWin.dpy, GLWin.parent,
|
||||||
0, 0, 1, 1, 0,
|
0, 0, 1, 1, 0,
|
||||||
GLWin.vi->depth, InputOutput, GLWin.vi->visual,
|
GLWin.vi->depth, InputOutput, GLWin.vi->visual,
|
||||||
CWBorderPixel | CWBackPixel | CWColormap | CWEventMask, &GLWin.attr);
|
CWBorderPixel | CWBackPixel | CWColormap | CWEventMask, &GLWin.attr);
|
||||||
wmProtocols[0] = XInternAtom(GLWin.evdpy, "WM_DELETE_WINDOW", True);
|
wmProtocols[0] = XInternAtom(GLWin.dpy, "WM_DELETE_WINDOW", True);
|
||||||
XSetWMProtocols(GLWin.evdpy, GLWin.win, wmProtocols, 1);
|
XSetWMProtocols(GLWin.dpy, GLWin.win, wmProtocols, 1);
|
||||||
XSetStandardProperties(GLWin.evdpy, GLWin.win, "GPU", "GPU", None, nullptr, 0, nullptr);
|
XSetStandardProperties(GLWin.dpy, GLWin.win, "GPU", "GPU", None, nullptr, 0, nullptr);
|
||||||
XMapRaised(GLWin.evdpy, GLWin.win);
|
XMapRaised(GLWin.dpy, GLWin.win);
|
||||||
XSync(GLWin.evdpy, True);
|
XSync(GLWin.dpy, True);
|
||||||
|
|
||||||
GLWin.xEventThread = std::thread(&cX11Window::XEventThread, this);
|
GLWin.xEventThread = std::thread(&cX11Window::XEventThread, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cX11Window::DestroyXWindow(void)
|
void cX11Window::DestroyXWindow(void)
|
||||||
{
|
{
|
||||||
XUnmapWindow(GLWin.evdpy, GLWin.win);
|
XUnmapWindow(GLWin.dpy, GLWin.win);
|
||||||
GLWin.win = 0;
|
GLWin.win = 0;
|
||||||
if (GLWin.xEventThread.joinable())
|
if (GLWin.xEventThread.joinable())
|
||||||
GLWin.xEventThread.join();
|
GLWin.xEventThread.join();
|
||||||
XFreeColormap(GLWin.evdpy, GLWin.attr.colormap);
|
XFreeColormap(GLWin.dpy, GLWin.attr.colormap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cX11Window::XEventThread()
|
void cX11Window::XEventThread()
|
||||||
|
@ -45,16 +45,16 @@ void cX11Window::XEventThread()
|
||||||
while (GLWin.win)
|
while (GLWin.win)
|
||||||
{
|
{
|
||||||
XEvent event;
|
XEvent event;
|
||||||
for (int num_events = XPending(GLWin.evdpy); num_events > 0; num_events--)
|
for (int num_events = XPending(GLWin.dpy); num_events > 0; num_events--)
|
||||||
{
|
{
|
||||||
XNextEvent(GLWin.evdpy, &event);
|
XNextEvent(GLWin.dpy, &event);
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case ConfigureNotify:
|
case ConfigureNotify:
|
||||||
GLInterface->SetBackBufferDimensions(event.xconfigure.width, event.xconfigure.height);
|
GLInterface->SetBackBufferDimensions(event.xconfigure.width, event.xconfigure.height);
|
||||||
break;
|
break;
|
||||||
case ClientMessage:
|
case ClientMessage:
|
||||||
if ((unsigned long) event.xclient.data.l[0] ==
|
if ((unsigned long) event.xclient.data.l[0] ==
|
||||||
XInternAtom(GLWin.evdpy, "WM_DELETE_WINDOW", False))
|
XInternAtom(GLWin.dpy, "WM_DELETE_WINDOW", False))
|
||||||
Host_Message(WM_USER_STOP);
|
Host_Message(WM_USER_STOP);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue