From 466f0038653b746845c45b35691dd49b61e6a9c8 Mon Sep 17 00:00:00 2001 From: Wang Chuan Date: Mon, 22 Jan 2024 20:41:31 +0800 Subject: [PATCH] rhi: d3d: Ensure dcomp content does not obscure child windows According to the documentation for DirectComposition, there are four layers associated with each window: 1. The contents drawn directly to the window handle (this is the bottommost layer). 2. An optional DirectComposition visual tree. 3. The contents of all child windows, if any. 4. Another optional DirectComposition visual tree (this is the topmost layer). Creating an IDCompositionTarget as the topmost layer can cause the DirectComposition content to cover all child windows. This results in child windows becoming invisible, which is particularly problematic when a user embeds an external window into a QML-created round rectangle window. Fixes: QTBUG-121403 Change-Id: I6807ea578276a9518b57afea1c21ca89239deeaf Reviewed-by: Laszlo Agocs --- src/gui/rhi/qrhid3d11.cpp | 2 +- src/gui/rhi/qrhid3d12.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index 54e94bf2f3f..d10303316ce 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -5051,7 +5051,7 @@ bool QD3D11SwapChain::createOrResize() if (m_flags.testFlag(SurfaceHasPreMulAlpha) || m_flags.testFlag(SurfaceHasNonPreMulAlpha)) { if (!rhiD->useLegacySwapchainModel && rhiD->ensureDirectCompositionDevice()) { if (!dcompTarget) { - hr = rhiD->dcompDevice->CreateTargetForHwnd(hwnd, true, &dcompTarget); + hr = rhiD->dcompDevice->CreateTargetForHwnd(hwnd, false, &dcompTarget); if (FAILED(hr)) { qWarning("Failed to create Direct Compsition target for the window: %s", qPrintable(QSystemError::windowsComString(hr))); diff --git a/src/gui/rhi/qrhid3d12.cpp b/src/gui/rhi/qrhid3d12.cpp index 745e55d76e8..2909152d4a1 100644 --- a/src/gui/rhi/qrhid3d12.cpp +++ b/src/gui/rhi/qrhid3d12.cpp @@ -6229,7 +6229,7 @@ bool QD3D12SwapChain::createOrResize() if (m_flags.testFlag(SurfaceHasPreMulAlpha) || m_flags.testFlag(SurfaceHasNonPreMulAlpha)) { if (rhiD->ensureDirectCompositionDevice()) { if (!dcompTarget) { - hr = rhiD->dcompDevice->CreateTargetForHwnd(hwnd, true, &dcompTarget); + hr = rhiD->dcompDevice->CreateTargetForHwnd(hwnd, false, &dcompTarget); if (FAILED(hr)) { qWarning("Failed to create Direct Compsition target for the window: %s", qPrintable(QSystemError::windowsComString(hr)));