From 9996ff08bd1c577e7ba8c36a6e65e84a739df9af Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 15 Nov 2024 16:56:59 +0000 Subject: [PATCH] effects/overview: Properly map the windowHeap geometry In https://invent.kde.org/plasma/kwin/-/merge_requests/6747 the comparison with window heap geometry was done with the heap x/y/width/height properties to detect if the drop was done off the heap, but this is wrong, because in Overview window heaps are positioned with Translation transforms, so we need to properly mapping its geometry with mapToItem which is transforms aware (cherry picked from commit 31c4b8ac555289309341b03bf813b4ac45d2e12d) 31c4b8ac effects/overview: Properly map the windowHeap geometry Co-authored-by: Marco Martin --- src/plugins/private/qml/WindowHeapDelegate.qml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/plugins/private/qml/WindowHeapDelegate.qml b/src/plugins/private/qml/WindowHeapDelegate.qml index a92ac7a7c7..fee45b6c64 100644 --- a/src/plugins/private/qml/WindowHeapDelegate.qml +++ b/src/plugins/private/qml/WindowHeapDelegate.qml @@ -149,6 +149,9 @@ ExpoCell { } function restoreDND(oldGlobalRect: rect) { const newGlobalRect = mapFromItem(null, oldGlobalRect); + // We need proper mapping for the heap geometry becuase they are positioned with + // translation transformations + const heapRect = thumb.windowHeap.mapToItem(null, Qt.size(thumb.windowHeap.width, thumb.windowHeap.height)); // Disable bindings returnAnimation.active = true; x = newGlobalRect.x; @@ -159,10 +162,10 @@ ExpoCell { returnAnimation.restart(); // If we dropped on another desktop, don't make the window fly off the screen - if (newGlobalRect.x < thumb.windowHeap.x || - newGlobalRect.y < thumb.windowHeap.y || - thumb.windowHeap.x + thumb.windowHeap.width < newGlobalRect.x + newGlobalRect.width || - thumb.windowHeap.y + thumb.windowHeap.height < newGlobalRect.y + newGlobalRect.height) { + if (oldGlobalRect.x < heapRect.x || + oldGlobalRect.y < heapRect.y || + heapRect.x + heapRect.width < oldGlobalRect.x + oldGlobalRect.width || + heapRect.y + heapRect.height < oldGlobalRect.y + oldGlobalRect.height) { returnAnimation.complete(); } }