summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/OGL/GLInterface/X11_Util.cpp
diff options
context:
space:
mode:
authorAugustin Cavalier <waddlesplash@gmail.com>2014-11-01 10:33:02 -0400
committerAugustin Cavalier <waddlesplash@gmail.com>2014-11-02 12:16:33 -0500
commit29593d403b7e0b2311241de868426ed285c7d97a (patch)
tree858bd8dbf27a6f1a0f88f79ee1b2430f8952e6e2 /Source/Core/VideoBackends/OGL/GLInterface/X11_Util.cpp
parent089e32ba7d7f48993fa0706f7b9f69a12bf7192a (diff)
Move GLInterface to the OGL VideoBackend's directory.
Diffstat (limited to 'Source/Core/VideoBackends/OGL/GLInterface/X11_Util.cpp')
-rw-r--r--Source/Core/VideoBackends/OGL/GLInterface/X11_Util.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/Source/Core/VideoBackends/OGL/GLInterface/X11_Util.cpp b/Source/Core/VideoBackends/OGL/GLInterface/X11_Util.cpp
new file mode 100644
index 0000000000..ffc48550bb
--- /dev/null
+++ b/Source/Core/VideoBackends/OGL/GLInterface/X11_Util.cpp
@@ -0,0 +1,75 @@
+// Copyright 2014 Dolphin Emulator Project
+// Licensed under GPLv2
+// Refer to the license.txt file included.
+
+#include "Common/Thread.h"
+#include "Core/Host.h"
+#include "VideoBackends/OGL/GLInterfaceBase.h"
+#include "VideoBackends/OGL/GLInterface/X11_Util.h"
+#include "VideoCommon/VideoConfig.h"
+
+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
+ attr.colormap = colormap;
+
+ XWindowAttributes attribs;
+ if (!XGetWindowAttributes(dpy, parent, &attribs))
+ {
+ ERROR_LOG(VIDEO, "Window attribute retrieval failed");
+ return 0;
+ }
+
+ // Create the window
+ win = XCreateWindow(dpy, parent,
+ 0, 0, attribs.width, attribs.height, 0,
+ vi->depth, InputOutput, vi->visual,
+ CWColormap, &attr);
+ XSelectInput(dpy, parent, StructureNotifyMask);
+ XMapWindow(dpy, win);
+ XSync(dpy, True);
+
+ xEventThread = std::thread(&cX11Window::XEventThread, this);
+
+ return win;
+}
+
+void cX11Window::DestroyXWindow(void)
+{
+ XUnmapWindow(dpy, win);
+ win = 0;
+ if (xEventThread.joinable())
+ xEventThread.join();
+ XFreeColormap(dpy, colormap);
+}
+
+void cX11Window::XEventThread()
+{
+ while (win)
+ {
+ XEvent event;
+ for (int num_events = XPending(dpy); num_events > 0; num_events--)
+ {
+ XNextEvent(dpy, &event);
+ switch (event.type)
+ {
+ case ConfigureNotify:
+ XResizeWindow(dpy, win, event.xconfigure.width, event.xconfigure.height);
+ GLInterface->SetBackBufferDimensions(event.xconfigure.width, event.xconfigure.height);
+ break;
+ default:
+ break;
+ }
+ }
+ Common::SleepCurrentThread(20);
+ }
+}