From 571a9dabcdb6c1a20bda97010bbb6cb183f1dd0d Mon Sep 17 00:00:00 2001 From: bbedward Date: Thu, 1 Jan 2026 12:04:49 -0500 Subject: [PATCH] dock: fix tooltip positioning with adjacent bars --- quickshell/Modules/Dock/Dock.qml | 85 ++++++++++++++++++++++++-------- 1 file changed, 65 insertions(+), 20 deletions(-) diff --git a/quickshell/Modules/Dock/Dock.qml b/quickshell/Modules/Dock/Dock.qml index fd776a54..497ef829 100644 --- a/quickshell/Modules/Dock/Dock.qml +++ b/quickshell/Modules/Dock/Dock.qml @@ -35,6 +35,17 @@ Variants { readonly property real widgetHeight: SettingsData.dockIconSize readonly property real effectiveBarHeight: widgetHeight + SettingsData.dockSpacing * 2 + 10 + borderThickness * 2 + function getBarHeight(barConfig) { + if (!barConfig) + return 0; + const innerPadding = barConfig.innerPadding ?? 4; + const widgetThickness = Math.max(20, 26 + innerPadding * 0.6); + const barThickness = Math.max(widgetThickness + innerPadding + 4, Theme.barHeight - 4 - (8 - innerPadding)); + const spacing = barConfig.spacing ?? 4; + const bottomGap = barConfig.bottomGap ?? 0; + return barThickness + spacing + bottomGap; + } + readonly property real barSpacing: { const defaultBar = SettingsData.barConfigs[0] || SettingsData.getBarConfig("default"); if (!defaultBar) @@ -60,6 +71,36 @@ Variants { return 0; } + readonly property real adjacentTopBarHeight: { + if (!isVertical || autoHide) + return 0; + const screenName = dock.modelData?.name ?? ""; + const topBar = SettingsData.barConfigs.find(bc => { + if (!bc.enabled || bc.autoHide || !(bc.visible ?? true)) + return false; + if (bc.position !== SettingsData.Position.Top && bc.position !== 0) + return false; + const onThisScreen = bc.screenPreferences.length === 0 || bc.screenPreferences.includes("all") || bc.screenPreferences.includes(screenName); + return onThisScreen; + }); + return getBarHeight(topBar); + } + + readonly property real adjacentLeftBarWidth: { + if (isVertical || autoHide) + return 0; + const screenName = dock.modelData?.name ?? ""; + const leftBar = SettingsData.barConfigs.find(bc => { + if (!bc.enabled || bc.autoHide || !(bc.visible ?? true)) + return false; + if (bc.position !== SettingsData.Position.Left && bc.position !== 2) + return false; + const onThisScreen = bc.screenPreferences.length === 0 || bc.screenPreferences.includes("all") || bc.screenPreferences.includes(screenName); + return onThisScreen; + }); + return getBarHeight(leftBar); + } + readonly property real dockMargin: SettingsData.dockSpacing readonly property real positionSpacing: barSpacing + SettingsData.dockBottomGap + SettingsData.dockMargin readonly property real _dpr: (dock.screen && dock.screen.devicePixelRatio) ? dock.screen.devicePixelRatio : 1 @@ -186,27 +227,31 @@ Variants { function showTooltipForHoveredButton() { dockTooltip.hide(); - if (dock.hoveredButton && dock.reveal && !slideXAnimation.running && !slideYAnimation.running) { - const buttonGlobalPos = dock.hoveredButton.mapToGlobal(0, 0); - const tooltipText = dock.hoveredButton.tooltipText || ""; - if (tooltipText) { - const screenX = dock.screen ? (dock.screen.x || 0) : 0; - const screenY = dock.screen ? (dock.screen.y || 0) : 0; - const screenHeight = dock.screen ? dock.screen.height : 0; - if (!dock.isVertical) { - const isBottom = SettingsData.dockPosition === SettingsData.Position.Bottom; - const globalX = buttonGlobalPos.x + dock.hoveredButton.width / 2; - const screenRelativeY = isBottom ? (screenHeight - dock.effectiveBarHeight - SettingsData.dockSpacing - SettingsData.dockBottomGap - SettingsData.dockMargin - 35) : (buttonGlobalPos.y - screenY + dock.hoveredButton.height + Theme.spacingS); - dockTooltip.show(tooltipText, globalX, screenRelativeY, dock.screen, false, false); - } else { - const isLeft = SettingsData.dockPosition === SettingsData.Position.Left; - const tooltipOffset = dock.effectiveBarHeight + SettingsData.dockSpacing + SettingsData.dockMargin + Theme.spacingXS; - const tooltipX = isLeft ? tooltipOffset : (dock.screen.width - tooltipOffset); - const screenRelativeY = buttonGlobalPos.y - screenY + dock.hoveredButton.height / 2; - dockTooltip.show(tooltipText, screenX + tooltipX, screenRelativeY, dock.screen, isLeft, !isLeft); - } - } + if (!dock.hoveredButton || !dock.reveal || slideXAnimation.running || slideYAnimation.running) + return; + + const buttonGlobalPos = dock.hoveredButton.mapToGlobal(0, 0); + const tooltipText = dock.hoveredButton.tooltipText || ""; + if (!tooltipText) + return; + + const screenX = dock.screen ? (dock.screen.x || 0) : 0; + const screenY = dock.screen ? (dock.screen.y || 0) : 0; + const screenHeight = dock.screen ? dock.screen.height : 0; + + if (!dock.isVertical) { + const isBottom = SettingsData.dockPosition === SettingsData.Position.Bottom; + const globalX = buttonGlobalPos.x + dock.hoveredButton.width / 2 + adjacentLeftBarWidth; + const screenRelativeY = isBottom ? (screenHeight - dock.effectiveBarHeight - SettingsData.dockSpacing - SettingsData.dockBottomGap - SettingsData.dockMargin - barSpacing - 35) : (buttonGlobalPos.y - screenY + dock.hoveredButton.height + Theme.spacingS); + dockTooltip.show(tooltipText, globalX, screenRelativeY, dock.screen, false, false); + return; } + + const isLeft = SettingsData.dockPosition === SettingsData.Position.Left; + const tooltipOffset = dock.effectiveBarHeight + SettingsData.dockSpacing + SettingsData.dockMargin + barSpacing + Theme.spacingXS; + const tooltipX = isLeft ? tooltipOffset : (dock.screen.width - tooltipOffset); + const screenRelativeY = buttonGlobalPos.y - screenY + dock.hoveredButton.height / 2 + adjacentTopBarHeight; + dockTooltip.show(tooltipText, screenX + tooltipX, screenRelativeY, dock.screen, isLeft, !isLeft); } Connections {