mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-28 16:49:58 -06:00
GLInterface: Destroy GLWin
Everything is now safely tucked inside each individual GLInterface.
This commit is contained in:
@ -2,50 +2,61 @@
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "Common/Thread.h"
|
||||
#include "Core/Host.h"
|
||||
#include "DolphinWX/GLInterface/GLInterface.h"
|
||||
#include "DolphinWX/GLInterface/X11_Util.h"
|
||||
#include "VideoBackends/OGL/GLInterfaceBase.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
|
||||
void cX11Window::CreateXWindow(void)
|
||||
void cX11Window::Initialize(Display *_dpy)
|
||||
{
|
||||
dpy = _dpy;
|
||||
}
|
||||
|
||||
Window cX11Window::CreateXWindow(Window parent, XVisualInfo *vi)
|
||||
{
|
||||
XSetWindowAttributes attr;
|
||||
|
||||
colormap = XCreateColormap(dpy, parent, vi->visual, AllocNone);
|
||||
|
||||
// Setup window attributes
|
||||
GLWin.attr.colormap = XCreateColormap(GLWin.dpy,
|
||||
GLWin.parent, GLWin.vi->visual, AllocNone);
|
||||
GLWin.attr.background_pixel = BlackPixel(GLWin.dpy, GLWin.screen);
|
||||
GLWin.attr.border_pixel = 0;
|
||||
attr.colormap = colormap;
|
||||
attr.background_pixel = BlackPixel(dpy, 0);
|
||||
attr.border_pixel = 0;
|
||||
|
||||
// Create the window
|
||||
GLWin.win = XCreateWindow(GLWin.dpy, GLWin.parent,
|
||||
0, 0, 1, 1, 0,
|
||||
GLWin.vi->depth, InputOutput, GLWin.vi->visual,
|
||||
CWBorderPixel | CWBackPixel | CWColormap, &GLWin.attr);
|
||||
XSelectInput(GLWin.dpy, GLWin.parent, StructureNotifyMask);
|
||||
XMapWindow(GLWin.dpy, GLWin.win);
|
||||
XSync(GLWin.dpy, True);
|
||||
win = XCreateWindow(dpy, parent,
|
||||
0, 0, 1, 1, 0,
|
||||
vi->depth, InputOutput, vi->visual,
|
||||
CWBorderPixel | CWBackPixel | CWColormap, &attr);
|
||||
XSelectInput(dpy, parent, StructureNotifyMask);
|
||||
XMapWindow(dpy, win);
|
||||
XSync(dpy, True);
|
||||
|
||||
GLWin.xEventThread = std::thread(&cX11Window::XEventThread, this);
|
||||
xEventThread = std::thread(&cX11Window::XEventThread, this);
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
void cX11Window::DestroyXWindow(void)
|
||||
{
|
||||
XUnmapWindow(GLWin.dpy, GLWin.win);
|
||||
GLWin.win = 0;
|
||||
if (GLWin.xEventThread.joinable())
|
||||
GLWin.xEventThread.join();
|
||||
XFreeColormap(GLWin.dpy, GLWin.attr.colormap);
|
||||
XUnmapWindow(dpy, win);
|
||||
if (xEventThread.joinable())
|
||||
xEventThread.join();
|
||||
XFreeColormap(dpy, colormap);
|
||||
}
|
||||
|
||||
void cX11Window::XEventThread()
|
||||
{
|
||||
while (GLWin.win)
|
||||
while (win)
|
||||
{
|
||||
XEvent event;
|
||||
for (int num_events = XPending(GLWin.dpy); num_events > 0; num_events--)
|
||||
for (int num_events = XPending(dpy); num_events > 0; num_events--)
|
||||
{
|
||||
XNextEvent(GLWin.dpy, &event);
|
||||
XNextEvent(dpy, &event);
|
||||
switch (event.type) {
|
||||
case ConfigureNotify:
|
||||
XResizeWindow(GLWin.dpy, GLWin.win, event.xconfigure.width, event.xconfigure.height);
|
||||
XResizeWindow(dpy, win, event.xconfigure.width, event.xconfigure.height);
|
||||
GLInterface->SetBackBufferDimensions(event.xconfigure.width, event.xconfigure.height);
|
||||
break;
|
||||
default:
|
||||
|
Reference in New Issue
Block a user