From 7390ae28e467e31d38deffbea6cd1de5a12fc2fe Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Sun, 25 May 2025 20:33:37 -0700 Subject: [PATCH] widgets/cliprect: override parent's implicit size instead of wrapper Adding implicitSize to margin wrappers broke implicit sizing of ClippingWrapperRectangle. --- src/widgets/CMakeLists.txt | 1 + src/widgets/ClippingWrapperRectangle.qml | 15 ++++++--------- src/widgets/ClippingWrapperRectangleInternal.qml | 7 +++++++ 3 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 src/widgets/ClippingWrapperRectangleInternal.qml diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index e5f213eb..ec1dd4f0 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -14,6 +14,7 @@ qt_add_qml_module(quickshell-widgets WrapperMouseArea.qml WrapperRectangle.qml ClippingWrapperRectangle.qml + ClippingWrapperRectangleInternal.qml ) qt6_add_shaders(quickshell-widgets "widgets-cliprect" diff --git a/src/widgets/ClippingWrapperRectangle.qml b/src/widgets/ClippingWrapperRectangle.qml index f338d2cf..d12bd156 100644 --- a/src/widgets/ClippingWrapperRectangle.qml +++ b/src/widgets/ClippingWrapperRectangle.qml @@ -11,7 +11,7 @@ import QtQuick /// > @@Item.height or @@Item.anchors on the child item, as they are used /// > by WrapperItem to position it. Instead set @@Item.implicitWidth and /// > @@Item.implicitHeight. -ClippingRectangle { +ClippingWrapperRectangleInternal { id: root /// The default for @@topMargin, @@bottomMargin, @@leftMargin and @@rightMargin. @@ -54,13 +54,10 @@ ClippingRectangle { /// See @@WrapperManager.child for details. property alias child: manager.child - implicitWidth: root.contentItem.implicitWidth + (root.contentInsideBorder ? root.border.width * 2 : 0) - implicitHeight: root.contentItem.implicitHeight + (root.contentInsideBorder ? root.border.width * 2 : 0) + border.width: 0 - resources: [ - MarginWrapperManager { - id: manager - wrapper: root.contentItem - } - ] + __implicitWidthInternal: root.contentItem.implicitWidth + (root.contentInsideBorder ? root.border.width * 2 : 0) + __implicitHeightInternal: root.contentItem.implicitHeight + (root.contentInsideBorder ? root.border.width * 2 : 0) + + MarginWrapperManager { id: manager } } diff --git a/src/widgets/ClippingWrapperRectangleInternal.qml b/src/widgets/ClippingWrapperRectangleInternal.qml new file mode 100644 index 00000000..4bd67873 --- /dev/null +++ b/src/widgets/ClippingWrapperRectangleInternal.qml @@ -0,0 +1,7 @@ +import QtQuick + +ClippingRectangle { + id: root + property alias __implicitWidthInternal: root.implicitWidth + property alias __implicitHeightInternal: root.implicitHeight +}