Windows QPA: also consider child windows for setting WS_EX_LAYERED
Child windows on Windows cannot have a frame, so checking only for Qt::FramelessWindowHint is not sufficient. Add an additional check to see if the window is a native child (has the WS_CHILD flag). Change-Id: Ib5cbec0f6157da687a5585e12a6c4c6935919538 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit f56fc425f9a103ed71697314196649641ef3691c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
a0981f1341
commit
5c0dea4760
@ -468,14 +468,21 @@ static bool shouldShowMaximizeButton(const QWindow *w, Qt::WindowFlags flags)
|
||||
w->maximumSize() == QSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX);
|
||||
}
|
||||
|
||||
bool QWindowsWindow::hasNoNativeFrame(HWND hwnd, Qt::WindowFlags flags)
|
||||
{
|
||||
const LONG_PTR style = GetWindowLongPtr(hwnd, GWL_STYLE);
|
||||
return (style & WS_CHILD) || (flags & Qt::FramelessWindowHint);
|
||||
}
|
||||
|
||||
// Set the WS_EX_LAYERED flag on a HWND if required. This is required for
|
||||
// translucent backgrounds, not fully opaque windows and for
|
||||
// Qt::WindowTransparentForInput (in combination with WS_EX_TRANSPARENT).
|
||||
bool QWindowsWindow::setWindowLayered(HWND hwnd, Qt::WindowFlags flags, bool hasAlpha, qreal opacity)
|
||||
{
|
||||
const LONG_PTR exStyle = GetWindowLongPtr(hwnd, GWL_EXSTYLE);
|
||||
// Native children are frameless by nature, so check for that as well.
|
||||
const bool needsLayered = (flags & Qt::WindowTransparentForInput)
|
||||
|| (hasAlpha && (flags & Qt::FramelessWindowHint)) || opacity < 1.0;
|
||||
|| (hasAlpha && hasNoNativeFrame(hwnd, flags)) || opacity < 1.0;
|
||||
const bool isLayered = (exStyle & WS_EX_LAYERED);
|
||||
if (needsLayered != isLayered) {
|
||||
if (needsLayered) {
|
||||
@ -491,7 +498,7 @@ static void setWindowOpacity(HWND hwnd, Qt::WindowFlags flags, bool hasAlpha, bo
|
||||
{
|
||||
if (QWindowsWindow::setWindowLayered(hwnd, flags, hasAlpha, level)) {
|
||||
const BYTE alpha = BYTE(qRound(255.0 * level));
|
||||
if (hasAlpha && !accelerated && (flags & Qt::FramelessWindowHint)) {
|
||||
if (hasAlpha && !accelerated && QWindowsWindow::hasNoNativeFrame(hwnd, flags)) {
|
||||
// Non-GL windows with alpha: Use blend function to update.
|
||||
BLENDFUNCTION blend = {AC_SRC_OVER, 0, alpha, AC_SRC_ALPHA};
|
||||
UpdateLayeredWindow(hwnd, nullptr, nullptr, nullptr, nullptr, nullptr, 0, &blend, ULW_ALPHA);
|
||||
|
@ -305,6 +305,7 @@ public:
|
||||
static inline void *userDataOf(HWND hwnd);
|
||||
static inline void setUserDataOf(HWND hwnd, void *ud);
|
||||
|
||||
static bool hasNoNativeFrame(HWND hwnd, Qt::WindowFlags flags);
|
||||
static bool setWindowLayered(HWND hwnd, Qt::WindowFlags flags, bool hasAlpha, qreal opacity);
|
||||
bool isLayered() const;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user