2014-02-17 10:18:15 +00:00
|
|
|
// Copyright 2014 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2012-12-26 18:12:26 +00:00
|
|
|
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Core/Host.h"
|
|
|
|
#include "DolphinWX/GLInterface/GLInterface.h"
|
|
|
|
#include "VideoCommon/VideoConfig.h"
|
2012-12-26 18:12:26 +00:00
|
|
|
|
|
|
|
void cX11Window::CreateXWindow(void)
|
|
|
|
{
|
|
|
|
// Setup window attributes
|
2014-08-06 03:44:25 +00:00
|
|
|
GLWin.attr.colormap = XCreateColormap(GLWin.dpy,
|
2012-12-26 18:12:26 +00:00
|
|
|
GLWin.parent, GLWin.vi->visual, AllocNone);
|
2014-08-06 03:44:25 +00:00
|
|
|
GLWin.attr.background_pixel = BlackPixel(GLWin.dpy, GLWin.screen);
|
2012-12-26 18:12:26 +00:00
|
|
|
GLWin.attr.border_pixel = 0;
|
|
|
|
|
|
|
|
// Create the window
|
2014-08-06 03:44:25 +00:00
|
|
|
GLWin.win = XCreateWindow(GLWin.dpy, GLWin.parent,
|
2014-08-05 09:31:28 +00:00
|
|
|
0, 0, 1, 1, 0,
|
2012-12-26 18:12:26 +00:00
|
|
|
GLWin.vi->depth, InputOutput, GLWin.vi->visual,
|
2014-08-07 02:22:13 +00:00
|
|
|
CWBorderPixel | CWBackPixel | CWColormap, &GLWin.attr);
|
|
|
|
XSelectInput(GLWin.dpy, GLWin.parent, StructureNotifyMask);
|
2014-08-06 18:58:34 +00:00
|
|
|
XMapWindow(GLWin.dpy, GLWin.win);
|
2014-08-06 03:44:25 +00:00
|
|
|
XSync(GLWin.dpy, True);
|
2012-12-26 18:12:26 +00:00
|
|
|
|
|
|
|
GLWin.xEventThread = std::thread(&cX11Window::XEventThread, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cX11Window::DestroyXWindow(void)
|
|
|
|
{
|
2014-08-06 03:44:25 +00:00
|
|
|
XUnmapWindow(GLWin.dpy, GLWin.win);
|
2012-12-26 18:12:26 +00:00
|
|
|
GLWin.win = 0;
|
|
|
|
if (GLWin.xEventThread.joinable())
|
|
|
|
GLWin.xEventThread.join();
|
2014-08-06 03:44:25 +00:00
|
|
|
XFreeColormap(GLWin.dpy, GLWin.attr.colormap);
|
2012-12-26 18:12:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void cX11Window::XEventThread()
|
|
|
|
{
|
|
|
|
while (GLWin.win)
|
|
|
|
{
|
|
|
|
XEvent event;
|
2014-08-06 03:44:25 +00:00
|
|
|
for (int num_events = XPending(GLWin.dpy); num_events > 0; num_events--)
|
2012-12-26 18:12:26 +00:00
|
|
|
{
|
2014-08-06 03:44:25 +00:00
|
|
|
XNextEvent(GLWin.dpy, &event);
|
2014-03-10 11:30:55 +00:00
|
|
|
switch (event.type) {
|
2012-12-26 18:12:26 +00:00
|
|
|
case ConfigureNotify:
|
2014-08-07 02:22:13 +00:00
|
|
|
XResizeWindow(GLWin.dpy, GLWin.win, event.xconfigure.width, event.xconfigure.height);
|
2013-07-21 05:02:10 +00:00
|
|
|
GLInterface->SetBackBufferDimensions(event.xconfigure.width, event.xconfigure.height);
|
2012-12-26 18:12:26 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Common::SleepCurrentThread(20);
|
|
|
|
}
|
|
|
|
}
|