From 838fc606c170fac112f7bb5971c2507b7b56d08a Mon Sep 17 00:00:00 2001 From: Yuhang Zhao Date: Thu, 25 May 2023 13:50:17 +0800 Subject: [PATCH] Windows QPA: introduce a way to disable redirection surface Why do we need this feature: to give user the possibility to explore different interesting graphics features (currently only compatible with D3D with the new FLIP model). Why do we need to modify QPA directly: touch this flag after the window has been created has no effect. It can only be used when we call CreateWindow(), so we can't add this flag through SetWindowLong(). However, Qt doesn't provide any public or private interface to control how Qt call CreateWindow(), and providing such interface is also dangerous. Using environment variable to control this behavior is the simplest solution and is commonly used inside Qt code base. Change-Id: I12440ed498d97cc17640e6c7498e42770b813737 Reviewed-by: Laszlo Agocs --- src/plugins/platforms/windows/qwindowswindow.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index aaa3933acd..b2b8e4bd05 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -834,6 +834,10 @@ void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flag // NOTE: WS_EX_TRANSPARENT flag can make mouse inputs fall through a layered window if (flagsIn & Qt::WindowTransparentForInput) exStyle |= WS_EX_LAYERED | WS_EX_TRANSPARENT; + + // Currently only compatible with D3D surfaces, use it with care. + if (qEnvironmentVariableIntValue("QT_QPA_DISABLE_REDIRECTION_SURFACE")) + exStyle |= WS_EX_NOREDIRECTIONBITMAP; } }