From 655b7ee99887f807e0b3285fbe6e10d5410c6c5a Mon Sep 17 00:00:00 2001 From: Pavel Artsishevsky Date: Tue, 1 Nov 2022 23:23:54 +0300 Subject: [PATCH 1/2] Use more updated window state values Signed-off-by: Pavel Artsishevsky --- src/decoration/qgnomeplatformdecoration.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/decoration/qgnomeplatformdecoration.cpp b/src/decoration/qgnomeplatformdecoration.cpp index a31e7df..98510ae 100644 --- a/src/decoration/qgnomeplatformdecoration.cpp +++ b/src/decoration/qgnomeplatformdecoration.cpp @@ -372,7 +372,7 @@ void QGnomePlatformDecoration::paint(QPaintDevice *device) // * * // ******************************** QPainterPath borderRect; - if (!(window()->windowStates() & Qt::WindowMaximized)) { + if (!(waylandWindow()->windowStates() & Qt::WindowMaximized)) { borderRect.addRoundedRect(0, 0, surfaceRect.width(), margins().top() + 8, 10, 10); p.fillPath(borderRect.simplified(), borderColor); } @@ -390,7 +390,7 @@ void QGnomePlatformDecoration::paint(QPaintDevice *device) // * * // ******************************** QPainterPath roundedRect; - if ((window()->windowStates() & Qt::WindowMaximized)) { + if ((waylandWindow()->windowStates() & Qt::WindowMaximized)) { roundedRect.addRect(0, 0, surfaceRect.width(), margins().top() + 8); } else { roundedRect @@ -414,7 +414,7 @@ void QGnomePlatformDecoration::paint(QPaintDevice *device) // *| |* // *------------------------------* // ******************************** - if (!(window()->windowStates() & Qt::WindowMaximized)) { + if (!(waylandWindow()->windowStates() & Qt::WindowMaximized)) { QPainterPath borderPath; // Left borderPath.addRect(0, margins().top(), margins().left(), surfaceRect.height() - margins().top() - WINDOW_BORDER_WIDTH); @@ -499,7 +499,7 @@ void QGnomePlatformDecoration::paint(QPaintDevice *device) if (GnomeSettings::getInstance().titlebarButtons().testFlag(GnomeSettings::getInstance().MaximizeButton)) { renderButton(&p, maximizeButtonRect(), - (window()->windowStates() & Qt::WindowMaximized) ? Adwaita::ButtonType::ButtonRestore : Adwaita::ButtonType::ButtonMaximize, + (waylandWindow()->windowStates() & Qt::WindowMaximized) ? Adwaita::ButtonType::ButtonRestore : Adwaita::ButtonType::ButtonMaximize, m_maximizeButtonHovered && active, m_clicking == Button::Maximize || m_clicking == Button::Restore); } From 6a9b70063804ec2c3958f7a61f1780c47fa787c6 Mon Sep 17 00:00:00 2001 From: Pavel Artsishevsky Date: Tue, 1 Nov 2022 23:25:53 +0300 Subject: [PATCH 2/2] Fix build and behavior w/o DECORATION_SHADOWS_SUPPORT enabled Signed-off-by: Pavel Artsishevsky --- src/decoration/qgnomeplatformdecoration.cpp | 17 ++++------------- src/decoration/qgnomeplatformdecoration.h | 4 ---- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/decoration/qgnomeplatformdecoration.cpp b/src/decoration/qgnomeplatformdecoration.cpp index 98510ae..b01595b 100644 --- a/src/decoration/qgnomeplatformdecoration.cpp +++ b/src/decoration/qgnomeplatformdecoration.cpp @@ -64,7 +64,11 @@ #define BUTTON_WIDTH 28 // Decoration sizing +#ifdef DECORATION_SHADOWS_SUPPORT // Qt 6.2.0+ or patched QtWayland #define SHADOWS_WIDTH 10 +#else +#define SHADOWS_WIDTH 0 +#endif #define TITLEBAR_HEIGHT 37 #define WINDOW_BORDER_WIDTH 1 @@ -141,7 +145,6 @@ QRectF QGnomePlatformDecoration::minimizeButtonRect() const } } -#ifdef DECORATION_SHADOWS_SUPPORT // Qt 6.2.0+ or patched QtWayland QMargins QGnomePlatformDecoration::margins(MarginsType marginsType) const { const bool maximized = waylandWindow()->windowStates() & Qt::WindowMaximized; @@ -179,18 +182,6 @@ QMargins QGnomePlatformDecoration::margins(MarginsType marginsType) const return QMargins(tiledLeft ? 0 : SHADOWS_WIDTH, tiledTop ? 0 : SHADOWS_WIDTH, tiledRight ? 0 : SHADOWS_WIDTH, tiledBottom ? 0 : SHADOWS_WIDTH); } } -#else -QMargins QGnomePlatformDecoration::margins() const -{ - if ((window()->windowStates() & Qt::WindowMaximized)) { - return QMargins(0, TITLEBAR_HEIGHT, 0, 0); - } - - return QMargins(WINDOW_BORDER_WIDTH, // Left - TITLEBAR_HEIGHT + WINDOW_BORDER_WIDTH, // Top - WINDOW_BORDER_WIDTH, // Right - WINDOW_BORDER_WIDTH); // Bottom -#endif } void QGnomePlatformDecoration::paint(QPaintDevice *device) diff --git a/src/decoration/qgnomeplatformdecoration.h b/src/decoration/qgnomeplatformdecoration.h index 2877f0e..bc9c0cd 100644 --- a/src/decoration/qgnomeplatformdecoration.h +++ b/src/decoration/qgnomeplatformdecoration.h @@ -46,11 +46,7 @@ class QGnomePlatformDecoration : public QWaylandAbstractDecoration virtual ~QGnomePlatformDecoration() override = default; protected: -#ifdef DECORATION_SHADOWS_SUPPORT // Qt 6.2.0+ or patched QtWayland QMargins margins(MarginsType marginsType = Full) const override; -#else - QMargins margins() const override; -#endif void paint(QPaintDevice *device) override; bool handleMouse(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override; #if QT_VERSION >= 0x060000