From ee4ba6815a7146d9ec395d9de7fbd0c2a991d955 Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Sat, 10 Dec 2022 21:40:21 -0500 Subject: [PATCH] homescreen: Fix binding loops caused by plasmoid changing dimensions --- .../mobileshell/qml/homescreen/HomeScreen.qml | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/components/mobileshell/qml/homescreen/HomeScreen.qml b/components/mobileshell/qml/homescreen/HomeScreen.qml index c61c981b..3a3e3d51 100644 --- a/components/mobileshell/qml/homescreen/HomeScreen.qml +++ b/components/mobileshell/qml/homescreen/HomeScreen.qml @@ -49,10 +49,26 @@ Item { /** * Margins for the homescreen, taking panels into account. */ - readonly property real topMargin: plasmoid.availableScreenRect.y - readonly property real bottomMargin: root.height - (plasmoid.availableScreenRect.y + plasmoid.availableScreenRect.height) - readonly property real leftMargin: plasmoid.availableScreenRect.x - readonly property real rightMargin: root.width - (plasmoid.availableScreenRect.x + plasmoid.availableScreenRect.width) + property real topMargin + property real bottomMargin + property real leftMargin + property real rightMargin + + function evaluateMargins() { + topMargin = plasmoid.availableScreenRect.y + bottomMargin = root.height - (plasmoid.availableScreenRect.y + plasmoid.availableScreenRect.height) + leftMargin = plasmoid.availableScreenRect.x + rightMargin = root.width - (plasmoid.availableScreenRect.x + plasmoid.availableScreenRect.width) + } + + Connections { + target: plasmoid + + // avoid binding loops with root.height and root.width changing along with the availableScreenRect + function onAvailableScreenRectChanged() { + Qt.callLater(() => root.evaluateMargins()); + } + } //BEGIN API implementation @@ -105,6 +121,9 @@ Item { //END API implementation Component.onCompleted: { + // determine the margins used + evaluateMargins(); + // set API variables if (plasmoid.screen == 0) { MobileShellState.HomeScreenControls.taskSwitcher = taskSwitcher;