diff --git a/Modules/Dock/Dock.qml b/Modules/Dock/Dock.qml index d99fdd5e..b23c90bc 100644 --- a/Modules/Dock/Dock.qml +++ b/Modules/Dock/Dock.qml @@ -482,7 +482,9 @@ Variants { anyAppHovered = true const appName = appButton.appTitle || appButton.appId || "Unknown" const tooltipText = appName.length > 40 ? appName.substring(0, 37) + "..." : appName - TooltipService.show(Screen, appButton, tooltipText, "top") + if (!contextMenu.visible) { + TooltipService.show(Screen, appButton, tooltipText, "top") + } if (autoHide) { showTimer.stop() hideTimer.stop() @@ -508,7 +510,7 @@ Variants { // Close any other existing context menu first root.closeAllContextMenus() // Hide tooltip when showing context menu - TooltipService.hide() + TooltipService.hideImmediately() contextMenu.show(appButton, modelData.toplevel || modelData) return } diff --git a/Modules/Dock/DockMenu.qml b/Modules/Dock/DockMenu.qml index 73c3dcf4..255e3b9d 100644 --- a/Modules/Dock/DockMenu.qml +++ b/Modules/Dock/DockMenu.qml @@ -16,6 +16,7 @@ PopupWindow { property real scaling: 1.0 property bool hovered: menuMouseArea.containsMouse property var onAppClosed: null // Callback function for when an app is closed + property bool canAutoClose: false // Track which menu item is hovered property int hoveredItem: -1 // -1: none, otherwise the index of the item in `items` @@ -24,7 +25,7 @@ PopupWindow { signal requestClose - implicitWidth: 160 * scaling + implicitWidth: Math.max(160 * scaling, contextMenuColumn.implicitWidth) implicitHeight: contextMenuColumn.implicitHeight + (Style.marginM * scaling * 2) color: Color.transparent visible: false @@ -128,6 +129,8 @@ PopupWindow { toplevel = toplevelData initItems() visible = true + canAutoClose = false + gracePeriodTimer.restart() } function hide() { @@ -179,6 +182,19 @@ PopupWindow { root.requestClose() } + // Short delay to ignore spurious events + Timer { + id: gracePeriodTimer + interval: 1500 + repeat: false + onTriggered: { + root.canAutoClose = true + if (!menuMouseArea.containsMouse) { + closeTimer.start() + } + } + } + Timer { id: closeTimer interval: 500 @@ -209,7 +225,10 @@ PopupWindow { onExited: { root.hoveredItem = -1 - closeTimer.start() + if (root.canAutoClose) { + // Only close if grace period has passed + closeTimer.start() + } } onPositionChanged: mouse => {