From e101ffce1d9260fd3481f1c7c4dacf07218b3078 Mon Sep 17 00:00:00 2001 From: Jan Grulich Date: Tue, 23 Feb 2021 08:30:04 +0100 Subject: [PATCH] Decorations: add new argument to margins() to allow exclude shadows We can already have shadows to be part of decoration margins, but we need a way to also get size of shadow margins itself, because they should be ignored for the purposes of aligning, placing and constraining windows. This change breaks API/ABI compatibility of QWaylandAbstractDecoration plugin, however, as stated in the header file, it is a subject of change and its API is not meant to be stable. Alternatively we can make this a separate method. Change-Id: Ib2c9982e16c4acb13a83757e6371022c0a89b74e Reviewed-by: David Edmundson Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../wayland/plugins/decorations/bradient/main.cpp | 7 +++++-- .../platforms/wayland/qwaylandabstractdecoration_p.h | 9 ++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/wayland/plugins/decorations/bradient/main.cpp b/src/plugins/platforms/wayland/plugins/decorations/bradient/main.cpp index daae9fcb3b5..b273a58ff41 100644 --- a/src/plugins/platforms/wayland/plugins/decorations/bradient/main.cpp +++ b/src/plugins/platforms/wayland/plugins/decorations/bradient/main.cpp @@ -73,7 +73,7 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandBradientDecoration : public QWaylandAbstra public: QWaylandBradientDecoration(); protected: - QMargins margins() const override; + QMargins margins(MarginsType marginsType = Full) const override; void paint(QPaintDevice *device) override; bool handleMouse(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global,Qt::MouseButtons b,Qt::KeyboardModifiers mods) override; bool handleTouch(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global, Qt::TouchPointState state, Qt::KeyboardModifiers mods) override; @@ -130,8 +130,11 @@ QRectF QWaylandBradientDecoration::minimizeButtonRect() const (margins().top() - BUTTON_WIDTH) / 2, BUTTON_WIDTH, BUTTON_WIDTH); } -QMargins QWaylandBradientDecoration::margins() const +QMargins QWaylandBradientDecoration::margins(MarginsType marginsType) const { + if (marginsType == ShadowsOnly) + return QMargins(); + return QMargins(3, 30, 3, 3); } diff --git a/src/plugins/platforms/wayland/qwaylandabstractdecoration_p.h b/src/plugins/platforms/wayland/qwaylandabstractdecoration_p.h index 81c8e1771cb..61cbde77e90 100644 --- a/src/plugins/platforms/wayland/qwaylandabstractdecoration_p.h +++ b/src/plugins/platforms/wayland/qwaylandabstractdecoration_p.h @@ -82,6 +82,12 @@ class Q_WAYLAND_CLIENT_EXPORT QWaylandAbstractDecoration : public QObject Q_OBJECT Q_DECLARE_PRIVATE(QWaylandAbstractDecoration) public: + enum MarginsType { + Full, + ShadowsExcluded, + ShadowsOnly + }; + QWaylandAbstractDecoration(); ~QWaylandAbstractDecoration() override; @@ -91,7 +97,8 @@ public: void update(); bool isDirty() const; - virtual QMargins margins() const = 0; + virtual QMargins margins(MarginsType marginsType = Full) const = 0; + QWindow *window() const; const QImage &contentImage();