From 806990968dc13cd09903f247fb976b28067b52a6 Mon Sep 17 00:00:00 2001
From: spycrab <spycrab@users.noreply.github.com>
Date: Sat, 24 Mar 2018 16:40:47 +0100
Subject: [PATCH] Qt: Implement "Auto-Adjust Window Size"

---
 Source/Core/DolphinQt2/Host.cpp         | 3 +++
 Source/Core/DolphinQt2/RenderWidget.cpp | 7 +++++++
 2 files changed, 10 insertions(+)

diff --git a/Source/Core/DolphinQt2/Host.cpp b/Source/Core/DolphinQt2/Host.cpp
index a788a76af0..27af4c7a91 100644
--- a/Source/Core/DolphinQt2/Host.cpp
+++ b/Source/Core/DolphinQt2/Host.cpp
@@ -115,9 +115,12 @@ void Host_UpdateProgressDialog(const char* caption, int position, int total)
 void Host_UpdateMainFrame()
 {
 }
+
 void Host_RequestRenderWindowSize(int w, int h)
 {
+  emit Host::GetInstance()->RequestRenderSize(w, h);
 }
+
 bool Host_UINeedsControllerState()
 {
   return Settings::Instance().IsControllerStateNeeded();
diff --git a/Source/Core/DolphinQt2/RenderWidget.cpp b/Source/Core/DolphinQt2/RenderWidget.cpp
index 879f318ecf..ea2611fa15 100644
--- a/Source/Core/DolphinQt2/RenderWidget.cpp
+++ b/Source/Core/DolphinQt2/RenderWidget.cpp
@@ -5,6 +5,7 @@
 #include <QKeyEvent>
 #include <QTimer>
 
+#include "Core/ConfigManager.h"
 #include "DolphinQt2/Host.h"
 #include "DolphinQt2/RenderWidget.h"
 #include "DolphinQt2/Settings.h"
@@ -15,6 +16,12 @@ RenderWidget::RenderWidget(QWidget* parent) : QWidget(parent)
   setAttribute(Qt::WA_NoSystemBackground, true);
 
   connect(Host::GetInstance(), &Host::RequestTitle, this, &RenderWidget::setWindowTitle);
+  connect(Host::GetInstance(), &Host::RequestRenderSize, this, [this](int w, int h) {
+    if (!SConfig::GetInstance().bRenderWindowAutoSize || isFullScreen() || isMaximized())
+      return;
+
+    resize(w, h);
+  });
 
   // We have to use Qt::DirectConnection here because we don't want those signals to get queued
   // (which results in them not getting called)