File 2005-better-overview-effect.patch of Package kwin6

diff --git a/src/plugins/overview/qml/main.qml b/src/plugins/overview/qml/main.qml
index ab2323771110f34b19fb11e2d42caaef4421f2b4..ac0e3178f9e7807dad6da2be21ae2a0fac52d076 100644
--- a/src/plugins/overview/qml/main.qml
+++ b/src/plugins/overview/qml/main.qml
@@ -130,7 +130,7 @@ FocusScope {
         if (effect.searchText !== "") return false;
         let currentIndex = 0
         for (let i = 0; i < allDesktopHeaps.count; i++) {
-            if (allDesktopHeaps.itemAt(i).current) {
+            if (allDesktopHeaps.itemAt(i).selected) {
                 currentIndex = i;
                 break;
             }
@@ -169,9 +169,13 @@ FocusScope {
         }
         let newIndex = y * container.columns + x;
 
-        KWinComponents.Workspace.currentDesktop = allDesktopHeaps.itemAt(newIndex).desktop
-        allDesktopHeaps.itemAt(newIndex).nestedHeap.focus = true
-        allDesktopHeaps.itemAt(newIndex).selectLastItem(invertedDirection);
+        const newItem = allDesktopHeaps.itemAt(newIndex);
+        allDesktopHeaps.selectedHeap = newItem.nestedHeap;
+        if (container.state === "overview") {
+            KWinComponents.Workspace.currentDesktop = newItem.desktop;
+        }
+        newItem.selectLastItem(invertedDirection);
+
         return true;
     }
 
@@ -182,10 +186,6 @@ FocusScope {
             } else {
                 effect.deactivate();
             }
-        } else if (event.key === Qt.Key_Plus || event.key === Qt.Key_Equal) {
-            desktopModel.create(desktopModel.rowCount());
-        } else if (event.key === Qt.Key_Minus) {
-            desktopModel.remove(desktopModel.rowCount() - 1);
         } else if (event.key >= Qt.Key_F1 && event.key <= Qt.Key_F12) {
             const desktopId = event.key - Qt.Key_F1;
             if (desktopId < allDesktopHeaps.count) {
@@ -228,13 +228,8 @@ FocusScope {
                     effect.activateView(view)
                 }
             }
-        } else if (event.key === Qt.Key_Return || event.key === Qt.Key_Space) {
-            for (let i = 0; i < allDesktopHeaps.count; i++) {
-                if (allDesktopHeaps.itemAt(i).current) {
-                    switchTo(allDesktopHeaps.itemAt(i).desktop)
-                    break;
-                }
-            }
+        } else if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return || event.key === Qt.Key_Space) {
+            switchTo(allDesktopHeaps.selectedHeap.parent.desktop);
         }
     }
     Keys.priority: Keys.AfterItem
@@ -275,6 +270,7 @@ FocusScope {
         anchors.top: parent.top
         anchors.topMargin: Kirigami.Units.largeSpacing
         height: searchField.height + 1 * Kirigami.Units.largeSpacing
+        visible: container.state !== "grid"
 
         PlasmaExtras.SearchField {
             id: searchField
@@ -372,6 +368,7 @@ FocusScope {
 
             property Item currentHeap
             property Item currentBackgroundItem
+            property Item selectedHeap: currentHeap
 
             Item {
                 id: mainBackground
@@ -393,6 +390,7 @@ FocusScope {
                 required property QtObject desktop
                 required property int index
                 readonly property bool current: KWinComponents.Workspace.currentDesktop === desktop
+                readonly property bool selected: allDesktopHeaps.selectedHeap === heap
                 readonly property bool nearCurrent: Math.abs(deltaColumn) <= 1 && Math.abs(deltaRow) <= 1
                 readonly property var nestedHeap: heap
 
@@ -503,10 +501,24 @@ FocusScope {
                             yOffset: 3
                         }
 
-                        property var borderWidth: desktopHover.hovered ? Kirigami.Units.largeSpacing : (mainBackground.current ? Kirigami.Units.smallSpacing : 0);
-                        property var borderColor: desktopHover.hovered ? Kirigami.Theme.focusColor : (mainBackground.current ? Kirigami.Theme.highlightColor : "transparent")
-                        border.width: gridVal == 1 ? borderWidth : 0
-                        border.color: gridVal == 1 ? borderColor : "transparent"
+                        border.color: Kirigami.Theme.highlightColor
+                        border.width: {
+                            if (container.state === "grid") {
+                                if (mainBackground.selected) {
+                                    return Kirigami.Units.largeSpacing;
+                                }
+                                if (mainBackground.current) {
+                                    return Kirigami.Units.smallSpacing;
+                                }
+                            }
+                            return 0;
+                        }
+
+                        Behavior on border.width {
+                            NumberAnimation {
+                                duration: effect.animationDuration
+                            }
+                        }
                     }
 
                     DropArea {
@@ -568,7 +580,13 @@ FocusScope {
                     }
 
                     HoverHandler {
-                        id: desktopHover
+                        property point lastPosition
+                        onPointChanged: {
+                            if (!mainBackground.selected && lastPosition !== point.position) {
+                                allDesktopHeaps.selectedHeap = heap;
+                            }
+                            lastPosition = point.position;
+                        }
                     }
                 }
 
@@ -592,14 +610,13 @@ FocusScope {
                     Drag.hotSpot: Qt.point(width * 0.5, height * 0.5)
                     Drag.keys: ["kwin-desktop"]
 
-                    focus: current
                     padding: Kirigami.Units.largeSpacing
                     animationDuration: effect.animationDuration
                     animationEnabled:  (gridVal !== 0 || mainBackground.current) && organized
                     organized: container.state !== "initial"
                     dndManagerStore: desktopGrid.dndManagerStore
                     Keys.priority: Keys.AfterItem
-                    Keys.forwardTo: [searchResults, searchField]
+                    Keys.forwardTo: container.state === "overview" ? [searchResults, searchField] : []
                     model: KWinComponents.WindowFilterModel {
                         activity: KWinComponents.Workspace.currentActivity
                         desktop: mainBackground.desktop
@@ -639,6 +656,13 @@ FocusScope {
                     }
 
                     onActivated: effect.deactivate()
+
+                    onSelectedIndexChanged: {
+                        if (selectedIndex !== -1) {
+                            allDesktopHeaps.selectedHeap = this;
+                            focus = true;
+                        }
+                    }
                 }
 
                 onCurrentChanged: {
@@ -647,6 +671,15 @@ FocusScope {
                         allDesktopHeaps.currentBackgroundItem = mainBackground;
                     }
                 }
+
+                onSelectedChanged: {
+                    if (mainBackground.selected) {
+                        heap.focus = true;
+                    } else {
+                        heap.resetSelected();
+                    }
+                }
+
                 Component.onCompleted: {
                     if (current) {
                         allDesktopHeaps.currentHeap = heap;
@@ -654,10 +687,14 @@ FocusScope {
                     }
                     startTimer.running = true
                 }
-            }
 
+                Component.onDestruction: {
+                    if (selected) {
+                        allDesktopHeaps.selectedHeap = allDesktopHeaps.currentHeap;
+                    }
+                }
+            }
         }
-
     }
 
     Loader {
diff --git a/src/plugins/private/qml/WindowHeap.qml b/src/plugins/private/qml/WindowHeap.qml
index 57e5df5a4579ee28cd149c8caad6679936fb39c1..56413b8d5129e6490910eddffbb40b1b66e0bbd6 100644
--- a/src/plugins/private/qml/WindowHeap.qml
+++ b/src/plugins/private/qml/WindowHeap.qml
@@ -7,7 +7,6 @@
 
 import QtQuick
 import QtQuick.Window
-import org.kde.plasma.extras as PlasmaExtras
 import org.kde.kirigami as Kirigami
 import org.kde.kwin as KWinComponents
 import org.kde.kwin.private.effects
@@ -137,18 +136,6 @@ FocusScope {
 
         placementMode: width >= height ? ExpoLayout.Rows : ExpoLayout.Columns
 
-        PlasmaExtras.Highlight {
-            readonly property Item selectedItem: windowsInstantiator.objectAt(heap.selectedIndex)
-
-            anchors.fill: parent == expoLayout ? null : parent
-            anchors.margins: -Kirigami.Units.largeSpacing
-            anchors.bottomMargin: -(selectedItem?.bottomMargin ?? 0) + anchors.margins
-            parent: selectedItem?.contentItem ?? expoLayout
-            hovered: true
-            z: -1
-            visible: selectedItem && !selectedItem.gestureInProgress && !selectedItem.dragActive && heap.effectiveOrganized && Window.window.activeFocusItem
-        }
-
         Instantiator {
             id: windowsInstantiator
 
@@ -374,32 +361,14 @@ FocusScope {
             heap.focus = true;
             break;
         case Qt.Key_Space:
-            if (!heap.focus) {
+            if (!activeFocus) {
                 break;
             }
         case Qt.Key_Enter:
         case Qt.Key_Return:
-            handled = false;
-            let selectedItem = null;
             if (selectedIndex !== -1) {
-                selectedItem = windowsInstantiator.objectAt(selectedIndex);
-            } else {
-                // If the window heap has only one visible window, activate it.
-                for (let i = 0; i < windowsInstantiator.count; ++i) {
-                    const candidateItem = windowsInstantiator.objectAt(i);
-                    if (candidateItem.activeHidden) {
-                        continue;
-                    } else if (selectedItem) {
-                        selectedItem = null;
-                        break;
-                    }
-                    selectedItem = candidateItem;
-                }
-            }
-            if (selectedItem) {
                 handled = true;
-                KWinComponents.Workspace.activeWindow = selectedItem.window;
-                activated();
+                activateIndex(selectedIndex);
             }
             break;
         default:
diff --git a/src/plugins/private/qml/WindowHeapDelegate.qml b/src/plugins/private/qml/WindowHeapDelegate.qml
index a290a7b92768a3538924a5226e82b2571d8b2098..263c880dfd3515cc77371a0a92f9a6c1b4f06bf4 100644
--- a/src/plugins/private/qml/WindowHeapDelegate.qml
+++ b/src/plugins/private/qml/WindowHeapDelegate.qml
@@ -161,6 +161,24 @@ ExpoCell {
                 thumb.windowHeap.deleteDND(thumb.window.internalId);
             }
 
+            // Not using FrameSvg hover element intentionally for stylistic reasons
+            Rectangle {
+                anchors.fill: parent
+                anchors.margins: -Kirigami.Units.largeSpacing
+                anchors.bottomMargin: -thumb.bottomMargin + anchors.margins
+                radius: Kirigami.Units.cornerRadius
+                color: Kirigami.Theme.highlightColor
+                z: -1
+                opacity: thumb.selected && !thumb.gestureInProgress && !thumb.dragActive && windowHeap.effectiveOrganized && Window.activeFocusItem ? 0.8 : 0
+                visible: opacity > 0
+
+                Behavior on opacity {
+                    NumberAnimation {
+                        duration: thumb.windowHeap.animationDuration
+                    }
+                }
+            }
+
             HoverHandler {
                 cursorShape: thumb.activeDragHandler.active ? Qt.ClosedHandCursor : Qt.ArrowCursor
             }
diff --git a/src/plugins/windowview/qml/main.qml b/src/plugins/windowview/qml/main.qml
index 5ef33cfd846fad9325d6eafd00c7478c1915f847..ce390e2a087014fef8b1b0bc8f9fc1f746c74449 100644
--- a/src/plugins/windowview/qml/main.qml
+++ b/src/plugins/windowview/qml/main.qml
@@ -60,6 +60,21 @@ Item {
             effect.activateView(view)
         }
     }
+    Keys.onPressed: (event) => {
+        switch (event.key) {
+        case Qt.Key_Enter:
+        case Qt.Key_Return:
+        case Qt.Key_Space:
+            if (heap.selectedIndex !== -1) {
+                heap.activateIndex(heap.selectedIndex);
+            } else {
+                effect.deactivate(container.effect.animationDuration);
+            }
+            break;
+        default:
+            break;
+        }
+    }
 
     KWinComponents.DesktopBackground {
         activity: KWinComponents.Workspace.currentActivity
@@ -137,7 +152,7 @@ Item {
             }
             Keys.priority: Keys.AfterItem
             Keys.forwardTo: heap
-            Keys.onPressed: {
+            Keys.onPressed: (event) => {
                 switch (event.key) {
                 case Qt.Key_Down:
                     heap.forceActiveFocus();
@@ -153,12 +168,6 @@ Item {
                     break;
                 }
             }
-            Keys.onEnterPressed: {
-                heap.forceActiveFocus();
-                if (heap.count === 1) {
-                    heap.activateCurrentClient();
-                }
-            }
         }
         WindowHeap {
             id: heap
openSUSE Build Service is sponsored by