From 3846d0c2cdc6dae3a9b8956a75ff2ae02e1a6eeb Mon Sep 17 00:00:00 2001
From: Alexander Orzechowski <alex@ozal.ski>
Date: Mon, 3 Apr 2023 13:56:39 +0300
Subject: [PATCH] RenderWidget: Set WA_DontCreateNativeAncestors

Some windowing systems like wayland are designed to show hardware accellerated
surfaces as subsurfaces and not native windows.
---
 src/citra_qt/bootmanager.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp
index 3cb1c904d..0dc51b1b9 100644
--- a/src/citra_qt/bootmanager.cpp
+++ b/src/citra_qt/bootmanager.cpp
@@ -41,6 +41,8 @@
 #include <qpa/qplatformnativeinterface.h>
 #endif
 
+static Frontend::WindowSystemType GetWindowSystemType();
+
 EmuThread::EmuThread(Frontend::GraphicsContext& core_context) : core_context(core_context) {}
 
 EmuThread::~EmuThread() = default;
@@ -243,6 +245,9 @@ public:
         : RenderWidget(parent), is_secondary(is_secondary) {
         setAttribute(Qt::WA_NativeWindow);
         setAttribute(Qt::WA_PaintOnScreen);
+        if (GetWindowSystemType() == Frontend::WindowSystemType::Wayland) {
+            setAttribute(Qt::WA_DontCreateNativeAncestors);
+        }
         windowHandle()->setSurfaceType(QWindow::OpenGLSurface);
     }