effects/overview: Use Kirigami.ScenePosition

This makes the WindowHeap more robust to layout changes. Currently, the
main issue with it is that thumbnails will be misplaced if the heap's
scene position changes.

Kirigami.ScenePosition automagically keeps track of the item's scene pos.
This commit is contained in:
Vlad Zahorodnii 2021-08-19 11:06:51 +03:00
parent ba0f5981bf
commit 66d74f4398

View file

@ -5,6 +5,7 @@
*/ */
import QtQuick 2.12 import QtQuick 2.12
import org.kde.kirigami 2.12 as Kirigami
import org.kde.kwin 3.0 as KWinComponents import org.kde.kwin 3.0 as KWinComponents
import org.kde.kwin.private.overview 1.0 import org.kde.kwin.private.overview 1.0
import org.kde.plasma.components 3.0 as PC3 import org.kde.plasma.components 3.0 as PC3
@ -31,9 +32,6 @@ FocusScope {
focus: true focus: true
spacing: PlasmaCore.Units.largeSpacing spacing: PlasmaCore.Units.largeSpacing
// This assumes that the position of the WindowHeap is static.
readonly property point scenePosition: mapToItem(null, 0, 0)
Repeater { Repeater {
id: windowsRepeater id: windowsRepeater
@ -62,8 +60,8 @@ FocusScope {
ExpoCell { ExpoCell {
id: cell id: cell
layout: expoLayout layout: expoLayout
naturalX: thumb.client.x - targetScreen.geometry.x - expoLayout.scenePosition.x naturalX: thumb.client.x - targetScreen.geometry.x - expoLayout.Kirigami.ScenePosition.x
naturalY: thumb.client.y - targetScreen.geometry.y - expoLayout.scenePosition.y naturalY: thumb.client.y - targetScreen.geometry.y - expoLayout.Kirigami.ScenePosition.y
naturalWidth: thumb.client.width naturalWidth: thumb.client.width
naturalHeight: thumb.client.height naturalHeight: thumb.client.height
persistentKey: thumb.client.internalId persistentKey: thumb.client.internalId
@ -74,8 +72,8 @@ FocusScope {
name: "initial" name: "initial"
PropertyChanges { PropertyChanges {
target: thumb target: thumb
x: thumb.client.x - targetScreen.geometry.x - expoLayout.scenePosition.x x: thumb.client.x - targetScreen.geometry.x - expoLayout.Kirigami.ScenePosition.x
y: thumb.client.y - targetScreen.geometry.y - expoLayout.scenePosition.y y: thumb.client.y - targetScreen.geometry.y - expoLayout.Kirigami.ScenePosition.y
width: thumb.client.width width: thumb.client.width
height: thumb.client.height height: thumb.client.height
} }