From ba820693f10018470642ca2aa9e7553fdc8f1ae3 Mon Sep 17 00:00:00 2001 From: Pavel Artsishevsky Date: Mon, 2 Jan 2023 11:45:20 +0300 Subject: [PATCH] Fix regression in rendering titlebar on vanilla Qt (#126) Don't use `window()->windowStates()` for checking active window state on vanilla Qt5, this works only on Qt6 or with KDE's patchset for Qt5. Fixes #125 Signed-off-by: Pavel Artsishevsky Signed-off-by: Pavel Artsishevsky --- src/decoration/qgnomeplatformdecoration.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/decoration/qgnomeplatformdecoration.cpp b/src/decoration/qgnomeplatformdecoration.cpp index 87b6463..ae75d15 100644 --- a/src/decoration/qgnomeplatformdecoration.cpp +++ b/src/decoration/qgnomeplatformdecoration.cpp @@ -195,14 +195,14 @@ QMargins QGnomePlatformDecoration::margins() const void QGnomePlatformDecoration::paint(QPaintDevice *device) { - Qt::WindowStates windowStates; #ifdef DECORATION_SHADOWS_SUPPORT // Qt 6.2.0+ or patched QtWayland - windowStates = waylandWindow()->windowStates(); + const Qt::WindowStates windowStates = waylandWindow()->windowStates(); + const bool active = windowStates & Qt::WindowActive; #else - windowStates = window()->windowStates(); + const Qt::WindowStates windowStates = window()->windowStates(); + const bool active = window()->handle()->isActive(); #endif - const bool active = windowStates & Qt::WindowActive; const QRect surfaceRect = windowContentGeometry(); const QColor borderColor = active ? m_borderColor : m_borderInactiveColor; @@ -783,14 +783,14 @@ void QGnomePlatformDecoration::processMouseRight(QWaylandInputDevice *inputDevic void QGnomePlatformDecoration::renderButton(QPainter *painter, const QRectF &rect, Adwaita::ButtonType button, bool renderFrame, bool sunken) { - Qt::WindowStates windowStates; #ifdef DECORATION_SHADOWS_SUPPORT // Qt 6.2.0+ or patched QtWayland - windowStates = waylandWindow()->windowStates(); + const Qt::WindowStates windowStates = waylandWindow()->windowStates(); + const bool active = windowStates & Qt::WindowActive; #else - windowStates = window()->windowStates(); + const Qt::WindowStates windowStates = window()->windowStates(); + const bool active = window()->handle()->isActive(); #endif - const bool active = windowStates & Qt::WindowActive; Adwaita::StyleOptions decorationButtonStyle(painter, QRect()); decorationButtonStyle.setColor(active ? m_foregroundColor : m_foregroundInactiveColor);