Merge pull request #6312 from spycrab/qt_vulkan_resize

Qt: Fix render window resize bug
This commit is contained in:
Stenzek 2018-01-21 12:06:55 +10:00 committed by GitHub
commit 6a002a4938
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 1 deletions

View File

@ -2,12 +2,15 @@
// Licensed under GPLv2+ // Licensed under GPLv2+
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "DolphinQt2/Host.h"
#include <QAbstractEventDispatcher> #include <QAbstractEventDispatcher>
#include <QApplication> #include <QApplication>
#include "Common/Common.h" #include "Common/Common.h"
#include "Core/ConfigManager.h"
#include "Core/Host.h" #include "Core/Host.h"
#include "DolphinQt2/Host.h" #include "VideoCommon/RenderBase.h"
Host::Host() = default; Host::Host() = default;
@ -47,6 +50,12 @@ void Host::SetRenderFullscreen(bool fullscreen)
m_render_fullscreen = fullscreen; m_render_fullscreen = fullscreen;
} }
void Host::UpdateSurface()
{
if (g_renderer)
g_renderer->ChangeSurface(GetRenderHandle());
}
void Host_Message(int id) void Host_Message(int id)
{ {
if (id == WM_USER_STOP) if (id == WM_USER_STOP)

View File

@ -26,6 +26,7 @@ public:
void SetRenderHandle(void* handle); void SetRenderHandle(void* handle);
void SetRenderFocus(bool focus); void SetRenderFocus(bool focus);
void SetRenderFullscreen(bool fullscreen); void SetRenderFullscreen(bool fullscreen);
void UpdateSurface();
signals: signals:
void RequestTitle(const QString& title); void RequestTitle(const QString& title);

View File

@ -22,6 +22,8 @@ RenderWidget::RenderWidget(QWidget* parent) : QWidget(parent)
Qt::DirectConnection); Qt::DirectConnection);
connect(this, &RenderWidget::HandleChanged, Host::GetInstance(), &Host::SetRenderHandle, connect(this, &RenderWidget::HandleChanged, Host::GetInstance(), &Host::SetRenderHandle,
Qt::DirectConnection); Qt::DirectConnection);
connect(this, &RenderWidget::SizeChanged, Host::GetInstance(), &Host::UpdateSurface,
Qt::DirectConnection);
emit HandleChanged((void*)winId()); emit HandleChanged((void*)winId());
@ -75,6 +77,9 @@ bool RenderWidget::event(QEvent* event)
case QEvent::WindowDeactivate: case QEvent::WindowDeactivate:
Host::GetInstance()->SetRenderFocus(false); Host::GetInstance()->SetRenderFocus(false);
break; break;
case QEvent::Resize:
emit SizeChanged();
break;
case QEvent::WindowStateChange: case QEvent::WindowStateChange:
emit StateChanged(isFullScreen()); emit StateChanged(isFullScreen());
break; break;

View File

@ -23,6 +23,7 @@ signals:
void Closed(); void Closed();
void HandleChanged(void* handle); void HandleChanged(void* handle);
void StateChanged(bool fullscreen); void StateChanged(bool fullscreen);
void SizeChanged();
private: private:
void HandleCursorTimer(); void HandleCursorTimer();