mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-25 23:41:19 +01:00
e7471958e4
We now have two cases: the GLX window is parented into a frame, or it's parented into the MainNoGUI host. In both cases, the GLX window should be locked to the size of the parent, so just sync it up based on that.
58 lines
1.6 KiB
C++
58 lines
1.6 KiB
C++
// Copyright 2014 Dolphin Emulator Project
|
|
// Licensed under GPLv2
|
|
// Refer to the license.txt file included.
|
|
|
|
#include "Core/Host.h"
|
|
#include "DolphinWX/GLInterface/GLInterface.h"
|
|
#include "VideoCommon/VideoConfig.h"
|
|
|
|
void cX11Window::CreateXWindow(void)
|
|
{
|
|
// 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;
|
|
|
|
// 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);
|
|
|
|
GLWin.xEventThread = std::thread(&cX11Window::XEventThread, this);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
void cX11Window::XEventThread()
|
|
{
|
|
while (GLWin.win)
|
|
{
|
|
XEvent event;
|
|
for (int num_events = XPending(GLWin.dpy); num_events > 0; num_events--)
|
|
{
|
|
XNextEvent(GLWin.dpy, &event);
|
|
switch (event.type) {
|
|
case ConfigureNotify:
|
|
XResizeWindow(GLWin.dpy, GLWin.win, event.xconfigure.width, event.xconfigure.height);
|
|
GLInterface->SetBackBufferDimensions(event.xconfigure.width, event.xconfigure.height);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
Common::SleepCurrentThread(20);
|
|
}
|
|
}
|