2014-02-17 05:18:15 -05:00
|
|
|
// Copyright 2014 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2012-12-26 12:12:26 -06:00
|
|
|
|
2014-02-17 05:18:15 -05:00
|
|
|
#include "Core/Host.h"
|
|
|
|
#include "DolphinWX/GLInterface/GLInterface.h"
|
|
|
|
#include "VideoCommon/VideoConfig.h"
|
2012-12-26 12:12:26 -06:00
|
|
|
|
|
|
|
void cX11Window::CreateXWindow(void)
|
|
|
|
{
|
|
|
|
Atom wmProtocols[1];
|
|
|
|
|
|
|
|
// Setup window attributes
|
|
|
|
GLWin.attr.colormap = XCreateColormap(GLWin.evdpy,
|
|
|
|
GLWin.parent, GLWin.vi->visual, AllocNone);
|
|
|
|
GLWin.attr.event_mask = KeyPressMask | StructureNotifyMask | FocusChangeMask;
|
|
|
|
GLWin.attr.background_pixel = BlackPixel(GLWin.evdpy, GLWin.screen);
|
|
|
|
GLWin.attr.border_pixel = 0;
|
|
|
|
|
|
|
|
// Create the window
|
|
|
|
GLWin.win = XCreateWindow(GLWin.evdpy, GLWin.parent,
|
2014-08-05 05:31:28 -04:00
|
|
|
0, 0, 1, 1, 0,
|
2012-12-26 12:12:26 -06:00
|
|
|
GLWin.vi->depth, InputOutput, GLWin.vi->visual,
|
|
|
|
CWBorderPixel | CWBackPixel | CWColormap | CWEventMask, &GLWin.attr);
|
|
|
|
wmProtocols[0] = XInternAtom(GLWin.evdpy, "WM_DELETE_WINDOW", True);
|
|
|
|
XSetWMProtocols(GLWin.evdpy, GLWin.win, wmProtocols, 1);
|
2014-03-09 21:14:26 +01:00
|
|
|
XSetStandardProperties(GLWin.evdpy, GLWin.win, "GPU", "GPU", None, nullptr, 0, nullptr);
|
2012-12-26 12:12:26 -06:00
|
|
|
XMapRaised(GLWin.evdpy, GLWin.win);
|
|
|
|
XSync(GLWin.evdpy, True);
|
|
|
|
|
|
|
|
GLWin.xEventThread = std::thread(&cX11Window::XEventThread, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cX11Window::DestroyXWindow(void)
|
|
|
|
{
|
2013-04-25 23:41:45 -05:00
|
|
|
XUnmapWindow(GLWin.evdpy, GLWin.win);
|
2012-12-26 12:12:26 -06:00
|
|
|
GLWin.win = 0;
|
|
|
|
if (GLWin.xEventThread.joinable())
|
|
|
|
GLWin.xEventThread.join();
|
|
|
|
XFreeColormap(GLWin.evdpy, GLWin.attr.colormap);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cX11Window::XEventThread()
|
|
|
|
{
|
|
|
|
while (GLWin.win)
|
|
|
|
{
|
|
|
|
XEvent event;
|
2013-04-25 23:41:45 -05:00
|
|
|
for (int num_events = XPending(GLWin.evdpy); num_events > 0; num_events--)
|
2012-12-26 12:12:26 -06:00
|
|
|
{
|
2013-04-25 23:41:45 -05:00
|
|
|
XNextEvent(GLWin.evdpy, &event);
|
2014-03-11 00:30:55 +13:00
|
|
|
switch (event.type) {
|
2012-12-26 12:12:26 -06:00
|
|
|
case ConfigureNotify:
|
2013-07-21 01:02:10 -04:00
|
|
|
GLInterface->SetBackBufferDimensions(event.xconfigure.width, event.xconfigure.height);
|
2012-12-26 12:12:26 -06:00
|
|
|
break;
|
|
|
|
case ClientMessage:
|
|
|
|
if ((unsigned long) event.xclient.data.l[0] ==
|
2013-04-25 23:41:45 -05:00
|
|
|
XInternAtom(GLWin.evdpy, "WM_DELETE_WINDOW", False))
|
2012-12-26 12:12:26 -06:00
|
|
|
Host_Message(WM_USER_STOP);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Common::SleepCurrentThread(20);
|
|
|
|
}
|
|
|
|
}
|