Fix dock preview not showing up after first hover

This commit is contained in:
wbbwbwbwbwbb
2026-04-12 18:37:19 -07:00
committed by GitHub
parent e03cbfec91
commit dbcde24003
@@ -17,14 +17,20 @@ Item {
property real windowControlsHeight: 30 property real windowControlsHeight: 30
property real buttonPadding: 5 property real buttonPadding: 5
property Item lastHoveredButton property Item lastHoveredButton: null
property bool buttonHovered: false property bool buttonHovered: false
property bool requestDockShow: previewPopup.show property bool requestDockShow: previewPopup.show
Layout.fillHeight: true Layout.fillHeight: true
Layout.topMargin: Appearance.sizes.hyprlandGapsOut // why does this work Layout.topMargin: Appearance.sizes.hyprlandGapsOut
implicitWidth: listView.implicitWidth implicitWidth: listView.implicitWidth
function popupCenterXForButton(button) {
if (!button || !root.QsWindow)
return 0
return root.QsWindow.mapFromItem(button, button.width / 2, 0).x
}
StyledListView { StyledListView {
id: listView id: listView
spacing: 2 spacing: 2
@@ -56,37 +62,32 @@ Item {
PopupWindow { PopupWindow {
id: previewPopup id: previewPopup
property var appTopLevel: root.lastHoveredButton?.appToplevel property var appTopLevel: root.lastHoveredButton?.appToplevel
property bool allPreviewsReady: false
property bool shouldShow: (popupMouseArea.containsMouse || root.buttonHovered)
&& appTopLevel
&& appTopLevel.toplevels
&& appTopLevel.toplevels.length > 0
property bool show: false
property real cachedCenterX: 0
Connections { Connections {
target: root target: root
function onLastHoveredButtonChanged() { function onLastHoveredButtonChanged() {
previewPopup.allPreviewsReady = false; // Reset readiness when the hovered button changes if (root.lastHoveredButton && root.QsWindow)
} previewPopup.cachedCenterX = root.popupCenterXForButton(root.lastHoveredButton)
} }
function updatePreviewReadiness() { function onButtonHoveredChanged() {
for(var i = 0; i < previewRowLayout.children.length; i++) { if (root.buttonHovered && root.lastHoveredButton && root.QsWindow)
const view = previewRowLayout.children[i]; previewPopup.cachedCenterX = root.popupCenterXForButton(root.lastHoveredButton)
if (view.hasContent === false) { updateTimer.restart()
allPreviewsReady = false;
return;
}
} }
allPreviewsReady = true;
} }
property bool shouldShow: {
const hoverConditions = (popupMouseArea.containsMouse || root.buttonHovered)
return hoverConditions && allPreviewsReady;
}
property bool show: false
onShouldShowChanged: { onShouldShowChanged: {
if (shouldShow) { updateTimer.restart()
// show = true;
updateTimer.restart();
} else {
updateTimer.restart();
}
} }
Timer { Timer {
id: updateTimer id: updateTimer
interval: 100 interval: 100
@@ -94,14 +95,15 @@ Item {
previewPopup.show = previewPopup.shouldShow previewPopup.show = previewPopup.shouldShow
} }
} }
anchor { anchor {
window: root.QsWindow.window window: root.QsWindow.window
adjustment: PopupAdjustment.None adjustment: PopupAdjustment.None
gravity: Edges.Top | Edges.Right gravity: Edges.Top | Edges.Right
edges: Edges.Top | Edges.Left edges: Edges.Top | Edges.Left
} }
visible: popupBackground.visible
visible: popupBackground.opacity > 0
color: "transparent" color: "transparent"
implicitWidth: root.QsWindow.window?.width ?? 1 implicitWidth: root.QsWindow.window?.width ?? 1
implicitHeight: popupMouseArea.implicitHeight + root.windowControlsHeight + Appearance.sizes.elevationMargin * 2 implicitHeight: popupMouseArea.implicitHeight + root.windowControlsHeight + Appearance.sizes.elevationMargin * 2
@@ -112,10 +114,8 @@ Item {
implicitWidth: popupBackground.implicitWidth + Appearance.sizes.elevationMargin * 2 implicitWidth: popupBackground.implicitWidth + Appearance.sizes.elevationMargin * 2
implicitHeight: root.maxWindowPreviewHeight + root.windowControlsHeight + Appearance.sizes.elevationMargin * 2 implicitHeight: root.maxWindowPreviewHeight + root.windowControlsHeight + Appearance.sizes.elevationMargin * 2
hoverEnabled: true hoverEnabled: true
x: { x: previewPopup.cachedCenterX - width / 2
const itemCenter = root.QsWindow?.mapFromItem(root.lastHoveredButton, root.lastHoveredButton?.width / 2, 0);
return itemCenter.x - width / 2
}
StyledRectangularShadow { StyledRectangularShadow {
target: popupBackground target: popupBackground
opacity: previewPopup.show ? 1 : 0 opacity: previewPopup.show ? 1 : 0
@@ -124,6 +124,7 @@ Item {
animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this) animation: Appearance.animation.elementMoveFast.numberAnimation.createObject(this)
} }
} }
Rectangle { Rectangle {
id: popupBackground id: popupBackground
property real padding: 5 property real padding: 5
@@ -198,13 +199,10 @@ Item {
} }
ScreencopyView { ScreencopyView {
id: screencopyView id: screencopyView
captureSource: previewPopup ? windowButton.modelData : null captureSource: windowButton.modelData
live: true live: true
paintCursor: true paintCursor: true
constraintSize: Qt.size(root.maxWindowPreviewWidth, root.maxWindowPreviewHeight) constraintSize: Qt.size(root.maxWindowPreviewWidth, root.maxWindowPreviewHeight)
onHasContentChanged: {
previewPopup.updatePreviewReadiness();
}
layer.enabled: true layer.enabled: true
layer.effect: OpacityMask { layer.effect: OpacityMask {
maskSource: Rectangle { maskSource: Rectangle {