From 7ca8d8dfc7e9bf3b09f9cab929c98f9e607c298b Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Wed, 6 Aug 2014 00:44:21 -0400 Subject: [PATCH] Core: Don't pass through a reference to the window handle Now that MainNoGUI is properly architected and GLX doesn't need to sometimes craft its own windows sometimes which we have to thread back into MainNoGUI, we don't need to thread the window handle that GLX creates at all. This removes the reference to pass back here, and the g_pWindowHandle always be the same as the window returned by Host_GetRenderHandle(). A future cleanup could remove g_pWindowHandle entirely. --- Source/Core/Core/Core.cpp | 3 --- Source/Core/DolphinWX/GLInterface/AGL.cpp | 2 +- Source/Core/DolphinWX/GLInterface/AGL.h | 2 +- Source/Core/DolphinWX/GLInterface/EGL.cpp | 2 +- Source/Core/DolphinWX/GLInterface/EGL.h | 2 +- Source/Core/DolphinWX/GLInterface/GLX.cpp | 3 +-- Source/Core/DolphinWX/GLInterface/GLX.h | 2 +- Source/Core/DolphinWX/GLInterface/WGL.cpp | 2 +- Source/Core/DolphinWX/GLInterface/WGL.h | 2 +- Source/Core/DolphinWX/MainNoGUI.cpp | 11 ++++++++++- Source/Core/VideoBackends/D3D/VideoBackend.h | 2 +- Source/Core/VideoBackends/D3D/main.cpp | 2 +- Source/Core/VideoBackends/OGL/GLInterfaceBase.h | 2 +- Source/Core/VideoBackends/OGL/VideoBackend.h | 2 +- Source/Core/VideoBackends/OGL/main.cpp | 2 +- Source/Core/VideoBackends/Software/SWmain.cpp | 2 +- Source/Core/VideoBackends/Software/VideoBackend.h | 2 +- Source/Core/VideoCommon/VideoBackendBase.h | 2 +- 18 files changed, 26 insertions(+), 21 deletions(-) diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index b37ac0a3e6..16ae870ae8 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -208,9 +208,6 @@ bool Init() !!SConfig::GetInstance().m_SYSCONF->GetData("IPL.AR")); } - // g_pWindowHandle is first the m_Panel handle, - // then it is updated to the render window handle, - // within g_video_backend->Initialize() g_pWindowHandle = Host_GetRenderHandle(); // Start the emu thread diff --git a/Source/Core/DolphinWX/GLInterface/AGL.cpp b/Source/Core/DolphinWX/GLInterface/AGL.cpp index 1abb97019d..6f79a8bec0 100644 --- a/Source/Core/DolphinWX/GLInterface/AGL.cpp +++ b/Source/Core/DolphinWX/GLInterface/AGL.cpp @@ -16,7 +16,7 @@ void cInterfaceAGL::Swap() // Create rendering window. // Call browser: Core.cpp:EmuThread() > main.cpp:Video_Initialize() -bool cInterfaceAGL::Create(void *&window_handle) +bool cInterfaceAGL::Create(void *window_handle) { // FIXME: Get rid of the explicit use of wxPanel here. This shouldn't be necessary. GLWin.cocoaWin = reinterpret_cast(((wxPanel*)window_handle)->GetHandle()); diff --git a/Source/Core/DolphinWX/GLInterface/AGL.h b/Source/Core/DolphinWX/GLInterface/AGL.h index 490691338d..7def0dd2d2 100644 --- a/Source/Core/DolphinWX/GLInterface/AGL.h +++ b/Source/Core/DolphinWX/GLInterface/AGL.h @@ -14,7 +14,7 @@ class cInterfaceAGL : public cInterfaceBase { public: void Swap(); - bool Create(void *&window_handle); + bool Create(void *window_handle); bool MakeCurrent(); bool ClearCurrent(); void Shutdown(); diff --git a/Source/Core/DolphinWX/GLInterface/EGL.cpp b/Source/Core/DolphinWX/GLInterface/EGL.cpp index b36aed38a5..8c58e9432e 100644 --- a/Source/Core/DolphinWX/GLInterface/EGL.cpp +++ b/Source/Core/DolphinWX/GLInterface/EGL.cpp @@ -87,7 +87,7 @@ err_exit: // Create rendering window. // Call browser: Core.cpp:EmuThread() > main.cpp:Video_Initialize() -bool cInterfaceEGL::Create(void *&window_handle) +bool cInterfaceEGL::Create(void *window_handle) { const char *s; EGLint egl_major, egl_minor; diff --git a/Source/Core/DolphinWX/GLInterface/EGL.h b/Source/Core/DolphinWX/GLInterface/EGL.h index bcf5d8cd75..63772f192b 100644 --- a/Source/Core/DolphinWX/GLInterface/EGL.h +++ b/Source/Core/DolphinWX/GLInterface/EGL.h @@ -20,7 +20,7 @@ public: void SetMode(u32 mode) { s_opengl_mode = mode; } void UpdateFPSDisplay(const std::string& text); void* GetFuncAddress(const std::string& name); - bool Create(void *&window_handle); + bool Create(void *window_handle); bool MakeCurrent(); void Shutdown(); }; diff --git a/Source/Core/DolphinWX/GLInterface/GLX.cpp b/Source/Core/DolphinWX/GLInterface/GLX.cpp index c7eb3eb239..69c376f4f2 100644 --- a/Source/Core/DolphinWX/GLInterface/GLX.cpp +++ b/Source/Core/DolphinWX/GLInterface/GLX.cpp @@ -37,7 +37,7 @@ void cInterfaceGLX::Swap() // Create rendering window. // Call browser: Core.cpp:EmuThread() > main.cpp:Video_Initialize() -bool cInterfaceGLX::Create(void *&window_handle) +bool cInterfaceGLX::Create(void *window_handle) { int glxMajorVersion, glxMinorVersion; @@ -102,7 +102,6 @@ bool cInterfaceGLX::Create(void *&window_handle) } XWindow.CreateXWindow(); - window_handle = (void *)GLWin.win; return true; } diff --git a/Source/Core/DolphinWX/GLInterface/GLX.h b/Source/Core/DolphinWX/GLInterface/GLX.h index 1ded9ec331..f48e27de79 100644 --- a/Source/Core/DolphinWX/GLInterface/GLX.h +++ b/Source/Core/DolphinWX/GLInterface/GLX.h @@ -19,7 +19,7 @@ public: void Swap() override; void UpdateFPSDisplay(const std::string& text) override; void* GetFuncAddress(const std::string& name) override; - bool Create(void *&window_handle) override; + bool Create(void *window_handle); bool MakeCurrent() override; bool ClearCurrent() override; void Shutdown() override; diff --git a/Source/Core/DolphinWX/GLInterface/WGL.cpp b/Source/Core/DolphinWX/GLInterface/WGL.cpp index 39e18f9105..295d21a2bc 100644 --- a/Source/Core/DolphinWX/GLInterface/WGL.cpp +++ b/Source/Core/DolphinWX/GLInterface/WGL.cpp @@ -63,7 +63,7 @@ void cInterfaceWGL::UpdateFPSDisplay(const std::string& text) // Create rendering window. // Call browser: Core.cpp:EmuThread() > main.cpp:Video_Initialize() -bool cInterfaceWGL::Create(void *&window_handle) +bool cInterfaceWGL::Create(void *window_handle) { if (window_handle == nullptr) return false; diff --git a/Source/Core/DolphinWX/GLInterface/WGL.h b/Source/Core/DolphinWX/GLInterface/WGL.h index e3bea0b044..3c9c7373fa 100644 --- a/Source/Core/DolphinWX/GLInterface/WGL.h +++ b/Source/Core/DolphinWX/GLInterface/WGL.h @@ -14,7 +14,7 @@ public: void Swap(); void UpdateFPSDisplay(const std::string& text); void* GetFuncAddress(const std::string& name); - bool Create(void *&window_handle); + bool Create(void *window_handle); bool MakeCurrent(); bool ClearCurrent(); void Shutdown(); diff --git a/Source/Core/DolphinWX/MainNoGUI.cpp b/Source/Core/DolphinWX/MainNoGUI.cpp index 9231b3ef3a..cca5d6ffb8 100644 --- a/Source/Core/DolphinWX/MainNoGUI.cpp +++ b/Source/Core/DolphinWX/MainNoGUI.cpp @@ -31,6 +31,7 @@ class Platform { public: virtual void Init() = 0; + virtual void SetTitle(const std::string &title) = 0; virtual void MainLoop() = 0; virtual void Shutdown() = 0; virtual ~Platform() {}; @@ -58,7 +59,10 @@ void* Host_GetRenderHandle() return windowHandle; } -void Host_UpdateTitle(const std::string& title){}; +void Host_UpdateTitle(const std::string& title) +{ + platform->SetTitle(title); +} void Host_UpdateDisasmDialog(){} @@ -175,6 +179,11 @@ class PlatformX11 : public Platform } } + void SetTitle(const std::string &string) override + { + XStoreName(dpy, win, string.c_str()); + } + void MainLoop() override { bool fullscreen = SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen; diff --git a/Source/Core/VideoBackends/D3D/VideoBackend.h b/Source/Core/VideoBackends/D3D/VideoBackend.h index fd58ab1ff4..4f529ff9f0 100644 --- a/Source/Core/VideoBackends/D3D/VideoBackend.h +++ b/Source/Core/VideoBackends/D3D/VideoBackend.h @@ -8,7 +8,7 @@ namespace DX11 class VideoBackend : public VideoBackendHardware { - bool Initialize(void *&) override; + bool Initialize(void *) override; void Shutdown() override; std::string GetName() const override; diff --git a/Source/Core/VideoBackends/D3D/main.cpp b/Source/Core/VideoBackends/D3D/main.cpp index 42c492b793..4bbaa894d7 100644 --- a/Source/Core/VideoBackends/D3D/main.cpp +++ b/Source/Core/VideoBackends/D3D/main.cpp @@ -141,7 +141,7 @@ void VideoBackend::ShowConfig(void *hParent) Host_ShowVideoConfig(hParent, GetDisplayName(), "gfx_dx11"); } -bool VideoBackend::Initialize(void *&window_handle) +bool VideoBackend::Initialize(void *window_handle) { if (window_handle == nullptr) return false; diff --git a/Source/Core/VideoBackends/OGL/GLInterfaceBase.h b/Source/Core/VideoBackends/OGL/GLInterfaceBase.h index bfddeb0c70..70a4cf56e7 100644 --- a/Source/Core/VideoBackends/OGL/GLInterfaceBase.h +++ b/Source/Core/VideoBackends/OGL/GLInterfaceBase.h @@ -29,7 +29,7 @@ public: virtual void SetMode(u32 mode) { s_opengl_mode = GLInterfaceMode::MODE_OPENGL; } virtual u32 GetMode() { return s_opengl_mode; } virtual void* GetFuncAddress(const std::string& name) { return nullptr; } - virtual bool Create(void *&window_handle) { return true; } + virtual bool Create(void *window_handle) { return true; } virtual bool MakeCurrent() { return true; } virtual bool ClearCurrent() { return true; } virtual void Shutdown() {} diff --git a/Source/Core/VideoBackends/OGL/VideoBackend.h b/Source/Core/VideoBackends/OGL/VideoBackend.h index 3a8aed0dd4..ab043395f6 100644 --- a/Source/Core/VideoBackends/OGL/VideoBackend.h +++ b/Source/Core/VideoBackends/OGL/VideoBackend.h @@ -8,7 +8,7 @@ namespace OGL class VideoBackend : public VideoBackendHardware { - bool Initialize(void *&) override; + bool Initialize(void *) override; void Shutdown() override; std::string GetName() const override; diff --git a/Source/Core/VideoBackends/OGL/main.cpp b/Source/Core/VideoBackends/OGL/main.cpp index c40704d049..1a378eb74f 100644 --- a/Source/Core/VideoBackends/OGL/main.cpp +++ b/Source/Core/VideoBackends/OGL/main.cpp @@ -155,7 +155,7 @@ void VideoBackend::ShowConfig(void *_hParent) Host_ShowVideoConfig(_hParent, GetDisplayName(), "gfx_opengl"); } -bool VideoBackend::Initialize(void *&window_handle) +bool VideoBackend::Initialize(void *window_handle) { InitializeShared(); InitBackendInfo(); diff --git a/Source/Core/VideoBackends/Software/SWmain.cpp b/Source/Core/VideoBackends/Software/SWmain.cpp index 4892daeeee..4d4784b61d 100644 --- a/Source/Core/VideoBackends/Software/SWmain.cpp +++ b/Source/Core/VideoBackends/Software/SWmain.cpp @@ -71,7 +71,7 @@ void VideoSoftware::ShowConfig(void *hParent) Host_ShowVideoConfig(hParent, GetDisplayName(), "gfx_software"); } -bool VideoSoftware::Initialize(void *&window_handle) +bool VideoSoftware::Initialize(void *window_handle) { g_SWVideoConfig.Load((File::GetUserPath(D_CONFIG_IDX) + "gfx_software.ini").c_str()); diff --git a/Source/Core/VideoBackends/Software/VideoBackend.h b/Source/Core/VideoBackends/Software/VideoBackend.h index dbfe1c7cab..19c555632e 100644 --- a/Source/Core/VideoBackends/Software/VideoBackend.h +++ b/Source/Core/VideoBackends/Software/VideoBackend.h @@ -10,7 +10,7 @@ namespace SW class VideoSoftware : public VideoBackend { - bool Initialize(void *&) override; + bool Initialize(void *window_handle) override; void Shutdown() override; std::string GetName() const override; diff --git a/Source/Core/VideoCommon/VideoBackendBase.h b/Source/Core/VideoCommon/VideoBackendBase.h index 7bcbbfef0f..5c361e8115 100644 --- a/Source/Core/VideoCommon/VideoBackendBase.h +++ b/Source/Core/VideoCommon/VideoBackendBase.h @@ -72,7 +72,7 @@ public: virtual unsigned int PeekMessages() = 0; - virtual bool Initialize(void *&) = 0; + virtual bool Initialize(void *window_handle) = 0; virtual void Shutdown() = 0; virtual void RunLoop(bool enable) = 0;