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 <laszlo.agocs@qt.io>
This commit is contained in:
Wang Chuan 2024-01-22 20:41:31 +08:00
parent ec849cd269
commit 466f003865
2 changed files with 2 additions and 2 deletions

View File

@ -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)));

View File

@ -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)));