From 0dd7f6f5ea816db6dbaf9d7ed424ddb8a58e0847 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Wed, 6 Aug 2014 22:11:50 -0400 Subject: [PATCH] MainNoGUI: Supply a window in Host_GetRenderHandle Our existing code was relying on the GLX backend to create the GLX window properly, and for the rest of the code to patch that up, sort of. If we rely on Host_GetRenderHandle() returning a valid window, we can do a lot better about this. Create a simple window inside MainNoGUI to make this happen. --- Source/Core/DolphinWX/GLInterface/GLX.cpp | 2 -- .../Core/DolphinWX/GLInterface/X11_Util.cpp | 3 +-- Source/Core/DolphinWX/MainNoGUI.cpp | 20 ++++++++++++++----- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Source/Core/DolphinWX/GLInterface/GLX.cpp b/Source/Core/DolphinWX/GLInterface/GLX.cpp index 022efda2cb..c7eb3eb239 100644 --- a/Source/Core/DolphinWX/GLInterface/GLX.cpp +++ b/Source/Core/DolphinWX/GLInterface/GLX.cpp @@ -67,8 +67,6 @@ bool cInterfaceGLX::Create(void *&window_handle) GLWin.dpy = XOpenDisplay(nullptr); GLWin.parent = (Window)window_handle; GLWin.screen = DefaultScreen(GLWin.dpy); - if (GLWin.parent == 0) - GLWin.parent = RootWindow(GLWin.dpy, GLWin.screen); glXQueryVersion(GLWin.dpy, &glxMajorVersion, &glxMinorVersion); NOTICE_LOG(VIDEO, "glX-Version %d.%d", glxMajorVersion, glxMinorVersion); diff --git a/Source/Core/DolphinWX/GLInterface/X11_Util.cpp b/Source/Core/DolphinWX/GLInterface/X11_Util.cpp index b460c19b2e..610fd67949 100644 --- a/Source/Core/DolphinWX/GLInterface/X11_Util.cpp +++ b/Source/Core/DolphinWX/GLInterface/X11_Util.cpp @@ -13,7 +13,7 @@ void cX11Window::CreateXWindow(void) // Setup window attributes GLWin.attr.colormap = XCreateColormap(GLWin.dpy, GLWin.parent, GLWin.vi->visual, AllocNone); - GLWin.attr.event_mask = KeyPressMask | StructureNotifyMask | FocusChangeMask; + GLWin.attr.event_mask = StructureNotifyMask; GLWin.attr.background_pixel = BlackPixel(GLWin.dpy, GLWin.screen); GLWin.attr.border_pixel = 0; @@ -24,7 +24,6 @@ void cX11Window::CreateXWindow(void) CWBorderPixel | CWBackPixel | CWColormap | CWEventMask, &GLWin.attr); wmProtocols[0] = XInternAtom(GLWin.dpy, "WM_DELETE_WINDOW", True); XSetWMProtocols(GLWin.dpy, GLWin.win, wmProtocols, 1); - XSetStandardProperties(GLWin.dpy, GLWin.win, "GPU", "GPU", None, nullptr, 0, nullptr); XMapRaised(GLWin.dpy, GLWin.win); XSync(GLWin.dpy, True); diff --git a/Source/Core/DolphinWX/MainNoGUI.cpp b/Source/Core/DolphinWX/MainNoGUI.cpp index 4f8d98d110..74e9cc00a0 100644 --- a/Source/Core/DolphinWX/MainNoGUI.cpp +++ b/Source/Core/DolphinWX/MainNoGUI.cpp @@ -52,9 +52,10 @@ void Host_Message(int Id) } } +void* windowHandle; void* Host_GetRenderHandle() { - return nullptr; + return windowHandle; } void Host_UpdateTitle(const std::string& title){}; @@ -129,6 +130,7 @@ void Host_ShowVideoConfig(void*, const std::string&, const std::string&) {} class PlatformX11 : public Platform { Display *dpy; + Window win; Cursor blankCursor = None; #if defined(HAVE_XRANDR) && HAVE_XRANDR X11Utils::XRRConfiguration *XRRConfig; @@ -138,12 +140,17 @@ class PlatformX11 : public Platform { XInitThreads(); dpy = XOpenDisplay(NULL); - } - void MainLoop() override - { - Window win = (Window)Core::GetWindowHandle(); + win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), + SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowXPos, + SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowYPos, + SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowWidth, + SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowHeight, + 0, 0, BlackPixel(dpy, 0)); XSelectInput(dpy, win, KeyPressMask | FocusChangeMask); + XMapRaised(dpy, win); + XFlush(dpy); + windowHandle = (void *) win; if (SConfig::GetInstance().m_LocalCoreStartupParameter.bDisableScreenSaver) X11Utils::InhibitScreensaver(dpy, win, true); @@ -163,7 +170,10 @@ class PlatformX11 : public Platform XFreePixmap (dpy, Blank); XDefineCursor(dpy, win, blankCursor); } + } + void MainLoop() override + { bool fullscreen = SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen; if (fullscreen)