File 2000-window-heap.patch of Package kwin6
diff --git a/src/plugins/private/qml/WindowHeap.qml b/src/plugins/private/qml/WindowHeap.qml
index 25c5df512e34a229278f451e295cb5414f0298a4..b36aed499fc29bbc2e4049a9c913bdd5413378e2 100644
--- a/src/plugins/private/qml/WindowHeap.qml
+++ b/src/plugins/private/qml/WindowHeap.qml
@@ -7,6 +7,7 @@
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
@@ -46,7 +47,14 @@ FocusScope {
required property bool organized
readonly property bool effectiveOrganized: expoLayout.ready && organized
- property bool dragActive: false
+ property bool dragActive: {
+ for (let i = 0, n = windowsInstantiator.count; i < n; ++i) {
+ if (windowsInstantiator.objectAt(i).dragActive) {
+ return true;
+ }
+ }
+ return false;
+ }
signal activated()
@@ -129,6 +137,18 @@ 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
@@ -357,6 +377,7 @@ FocusScope {
if (!heap.focus) {
break;
}
+ case Qt.Key_Enter:
case Qt.Key_Return:
handled = false;
let selectedItem = null;
diff --git a/src/plugins/private/qml/WindowHeapDelegate.qml b/src/plugins/private/qml/WindowHeapDelegate.qml
index 45ed597552cf433c0c17b4b3f7646e032d9cb81b..a290a7b92768a3538924a5226e82b2571d8b2098 100644
--- a/src/plugins/private/qml/WindowHeapDelegate.qml
+++ b/src/plugins/private/qml/WindowHeapDelegate.qml
@@ -14,7 +14,6 @@ import org.kde.kwin as KWinComponents
import org.kde.kwin.private.effects
import org.kde.plasma.components 3.0 as PC3
import org.kde.plasma.extras as PlasmaExtras
-import org.kde.ksvg 1.0 as KSvg
ExpoCell {
id: thumb
@@ -65,6 +64,8 @@ ExpoCell {
property bool isReady: width !== 0 && height !== 0
+ readonly property bool dragActive: activeDragHandler.active || returnAnimation.running
+
function restoreDND(oldGlobalRect: rect) {
thumbSource.restoreDND(oldGlobalRect);
}
@@ -77,7 +78,7 @@ ExpoCell {
naturalWidth: thumb.window.width
naturalHeight: thumb.window.height
persistentKey: thumb.window.internalId
- bottomMargin: icon.height / 4 + (thumb.windowTitleVisible ? caption.height + Kirigami.Units.smallSpacing : 0) + Kirigami.Units.largeSpacing
+ bottomMargin: icon.height / 4 + (windowTitleVisible ? caption.height + caption.anchors.topMargin : 0)
Behavior on x {
enabled: thumb.isReady
@@ -113,8 +114,7 @@ ExpoCell {
parent: contentItemParent
visible: opacity > 0 && (!activeHidden || !initialHidden)
opacity: (1 - downGestureProgress) * (initialHidden ? partialActivationFactor : 1)
- z: (activeDragHandler.active || returnAnimation.running) ? 1000
- : thumb.window.stackingOrder * (presentOnCurrentDesktop ? 1 : 0.001)
+ z: thumb.dragActive ? 1000 : thumb.window.stackingOrder * (presentOnCurrentDesktop ? 1 : 0.001)
KWinComponents.WindowThumbnail {
id: thumbSource
@@ -161,20 +161,7 @@ ExpoCell {
thumb.windowHeap.deleteDND(thumb.window.internalId);
}
- // Not using FrameSvg hover element intentionally for stylistic reasons
- Rectangle {
- border.width: Kirigami.Units.largeSpacing
- border.color: Kirigami.Theme.highlightColor
- anchors.fill: parent
- anchors.margins: -border.width
- radius: Kirigami.Units.cornerRadius
- color: "transparent"
- visible: !thumb.windowHeap.dragActive && (hoverHandler.hovered || (thumb.selected && Window.window.activeFocusItem)) && windowHeap.effectiveOrganized
- }
-
- MouseArea {
- anchors.fill: parent
- acceptedButtons: Qt.NoButton
+ HoverHandler {
cursorShape: thumb.activeDragHandler.active ? Qt.ClosedHandCursor : Qt.ArrowCursor
}
ParallelAnimation {
@@ -237,25 +224,25 @@ ExpoCell {
anchors.horizontalCenter: thumbSource.horizontalCenter
anchors.verticalCenter: thumbSource.bottom
anchors.verticalCenterOffset: -Math.round(height / 4) * scale
- visible: !thumb.activeHidden && !activeDragHandler.active && !returnAnimation.running
+ visible: !thumb.activeHidden && !thumb.dragActive
PC3.Label {
id: caption
visible: thumb.windowTitleVisible
- width: thumb.width
+ width: Math.min(implicitWidth, thumb.width)
maximumLineCount: 1
anchors.top: parent.bottom
anchors.topMargin: Kirigami.Units.smallSpacing
anchors.horizontalCenter: parent.horizontalCenter
+ topPadding: Kirigami.Units.smallSpacing / 2
+ rightPadding: Kirigami.Units.largeSpacing
+ bottomPadding: topPadding
+ leftPadding: rightPadding
elide: Text.ElideRight
text: thumb.window.caption
- color: Kirigami.Theme.textColor
textFormat: Text.PlainText
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
background: Rectangle {
- anchors.centerIn: parent
- height: parent.contentHeight + Kirigami.Units.smallSpacing
- width: parent.contentWidth + Kirigami.Units.smallSpacing
+ border.width: 1
+ border.color: Kirigami.ColorUtils.linearInterpolation(color, Kirigami.Theme.textColor, Kirigami.Theme.frameContrast)
color: Kirigami.Theme.backgroundColor
radius: Kirigami.Units.cornerRadius
}
@@ -263,9 +250,17 @@ ExpoCell {
}
HoverHandler {
- id: hoverHandler
- onHoveredChanged: if (hovered !== selected) {
- thumb.windowHeap.resetSelected();
+ property point lastPosition
+ onHoveredChanged: {
+ if (!hovered && thumb.selected) {
+ thumb.windowHeap.resetSelected();
+ }
+ }
+ onPointChanged: {
+ if (!thumb.selected && lastPosition !== point.position) {
+ thumb.windowHeap.selectedIndex = thumb.index;
+ }
+ lastPosition = point.position;
}
}
@@ -292,7 +287,6 @@ ExpoCell {
// enabled: thumb.state !== "active-normal"
onActiveChanged: {
- thumb.windowHeap.dragActive = active;
if (active) {
thumb.activeDragHandler = this;
} else {
@@ -357,7 +351,7 @@ ExpoCell {
top: thumbSource.top
margins: Kirigami.Units.smallSpacing
}
- active: thumb.closeButtonVisible && (hoverHandler.hovered || Kirigami.Settings.tabletMode || Kirigami.Settings.hasTransientTouchInput) && thumb.window.closeable && !thumb.activeDragHandler.active && !returnAnimation.running
+ active: thumb.closeButtonVisible && (thumb.selected || Kirigami.Settings.tabletMode || Kirigami.Settings.hasTransientTouchInput) && thumb.window.closeable && !thumb.dragActive
sourceComponent: PC3.Button {
text: i18ndc("kwin", "@info:tooltip as in: 'close this window'", "Close window")