From 29f19b07a9ff75dfc465701050e418b7c493b0f8 Mon Sep 17 00:00:00 2001 From: bbedward Date: Wed, 17 Jun 2026 12:46:24 -0400 Subject: [PATCH] widgets: fix tooltip position mapping --- .../Modules/DankBar/Widgets/AppsDock.qml | 20 +++---- .../Modules/DankBar/Widgets/DiskUsage.qml | 9 +-- .../Modules/DankBar/Widgets/FocusedApp.qml | 10 +--- .../Modules/DankBar/Widgets/RunningApps.qml | 56 ++++++------------- quickshell/Modules/DankBar/Widgets/Vpn.qml | 13 ++--- quickshell/Modules/Dock/Dock.qml | 12 ++-- quickshell/Widgets/DankTooltip.qml | 10 +--- 7 files changed, 44 insertions(+), 86 deletions(-) diff --git a/quickshell/Modules/DankBar/Widgets/AppsDock.qml b/quickshell/Modules/DankBar/Widgets/AppsDock.qml index 71fd32e8..3749a15a 100644 --- a/quickshell/Modules/DankBar/Widgets/AppsDock.qml +++ b/quickshell/Modules/DankBar/Widgets/AppsDock.qml @@ -933,19 +933,17 @@ BasePill { tooltipLoader.active = true; if (tooltipLoader.item) { if (root.isVerticalOrientation) { - const globalPos = delegateItem.mapToGlobal(0, delegateItem.height / 2); - const screenX = root.parentScreen ? root.parentScreen.x : 0; - const screenY = root.parentScreen ? root.parentScreen.y : 0; + const localPos = delegateItem.mapToItem(null, 0, delegateItem.height / 2); const isLeft = root.axis?.edge === "left"; const tooltipX = isLeft ? (root.barThickness + root.barSpacing + Theme.spacingXS) : (root.parentScreen.width - root.barThickness - root.barSpacing - Theme.spacingXS); - const screenRelativeY = globalPos.y - screenY + root.minTooltipY; - tooltipLoader.item.show(appItem.tooltipText, screenX + tooltipX, screenRelativeY, root.parentScreen, isLeft, !isLeft); + const screenRelativeY = localPos.y + root.minTooltipY; + tooltipLoader.item.show(appItem.tooltipText, tooltipX, screenRelativeY, root.parentScreen, isLeft, !isLeft); } else { - const globalPos = delegateItem.mapToGlobal(delegateItem.width / 2, delegateItem.height); + const localPos = delegateItem.mapToItem(null, delegateItem.width / 2, delegateItem.height); const screenHeight = root.parentScreen ? root.parentScreen.height : Screen.height; const isBottom = root.axis?.edge === "bottom"; const tooltipY = isBottom ? (screenHeight - root.barThickness - root.barSpacing - Theme.spacingXS - 35) : (root.barThickness + root.barSpacing + Theme.spacingXS); - tooltipLoader.item.show(appItem.tooltipText, globalPos.x, tooltipY, root.parentScreen, false, false); + tooltipLoader.item.show(appItem.tooltipText, localPos.x, tooltipY, root.parentScreen, false, false); } } } @@ -967,14 +965,12 @@ BasePill { contextMenuLoader.active = true; if (contextMenuLoader.item) { - const globalPos = delegateItem.mapToGlobal(delegateItem.width / 2, delegateItem.height / 2); - const screenX = root.parentScreen ? root.parentScreen.x : 0; - const screenY = root.parentScreen ? root.parentScreen.y : 0; + const localPos = delegateItem.mapToItem(null, delegateItem.width / 2, delegateItem.height / 2); const isBarVertical = root.axis?.isVertical ?? false; const barEdge = root.axis?.edge ?? "top"; - let x = globalPos.x - screenX; - let y = globalPos.y - screenY; + let x = localPos.x; + let y = localPos.y; switch (barEdge) { case "bottom": diff --git a/quickshell/Modules/DankBar/Widgets/DiskUsage.qml b/quickshell/Modules/DankBar/Widgets/DiskUsage.qml index 5feac888..ac2e2ae4 100644 --- a/quickshell/Modules/DankBar/Widgets/DiskUsage.qml +++ b/quickshell/Modules/DankBar/Widgets/DiskUsage.qml @@ -276,15 +276,12 @@ BasePill { if (root.isVerticalOrientation && root.selectedMount) { tooltipLoader.active = true; if (tooltipLoader.item) { - const globalPos = mapToGlobal(width / 2, height / 2); + const localPos = mapToItem(null, width / 2, height / 2); const currentScreen = root.parentScreen || Screen; - const screenX = currentScreen ? currentScreen.x : 0; - const screenY = currentScreen ? currentScreen.y : 0; - const relativeY = globalPos.y - screenY; - const adjustedY = relativeY + root.minTooltipY; + const adjustedY = localPos.y + root.minTooltipY; const tooltipX = root.axis?.edge === "left" ? (root.barThickness + root.barSpacing + Theme.spacingXS) : (currentScreen.width - root.barThickness - root.barSpacing - Theme.spacingXS); const isLeft = root.axis?.edge === "left"; - tooltipLoader.item.show(root.selectedMount.mount, screenX + tooltipX, adjustedY, currentScreen, isLeft, !isLeft); + tooltipLoader.item.show(root.selectedMount.mount, tooltipX, adjustedY, currentScreen, isLeft, !isLeft); } } } diff --git a/quickshell/Modules/DankBar/Widgets/FocusedApp.qml b/quickshell/Modules/DankBar/Widgets/FocusedApp.qml index 76680a92..c6a67ec4 100644 --- a/quickshell/Modules/DankBar/Widgets/FocusedApp.qml +++ b/quickshell/Modules/DankBar/Widgets/FocusedApp.qml @@ -304,13 +304,9 @@ BasePill { if (root.isVerticalOrientation && activeWindow && activeWindow.appId && root.parentScreen) { tooltipLoader.active = true; if (tooltipLoader.item) { - const globalPos = mapToGlobal(width / 2, height / 2); + const localPos = mapToItem(null, width / 2, height / 2); const currentScreen = root.parentScreen; - const screenX = currentScreen ? currentScreen.x : 0; - const screenY = currentScreen ? currentScreen.y : 0; - const relativeY = globalPos.y - screenY; - // Add minTooltipY offset to account for top bar - const adjustedY = relativeY + root.minTooltipY; + const adjustedY = localPos.y + root.minTooltipY; const tooltipX = root.axis?.edge === "left" ? (Theme.barHeight + (barConfig?.spacing ?? 4) + Theme.spacingXS) : (currentScreen.width - Theme.barHeight - (barConfig?.spacing ?? 4) - Theme.spacingXS); const appName = Paths.getAppName(activeWindow.appId, activeDesktopEntry); @@ -318,7 +314,7 @@ BasePill { const tooltipText = appName + (title ? " • " + title : ""); const isLeft = root.axis?.edge === "left"; - tooltipLoader.item.show(tooltipText, screenX + tooltipX, adjustedY, currentScreen, isLeft, !isLeft); + tooltipLoader.item.show(tooltipText, tooltipX, adjustedY, currentScreen, isLeft, !isLeft); } } } diff --git a/quickshell/Modules/DankBar/Widgets/RunningApps.qml b/quickshell/Modules/DankBar/Widgets/RunningApps.qml index 8c67d6b8..08d79148 100644 --- a/quickshell/Modules/DankBar/Widgets/RunningApps.qml +++ b/quickshell/Modules/DankBar/Widgets/RunningApps.qml @@ -424,22 +424,16 @@ BasePill { windowContextMenuLoader.item.triggerBarThickness = root.barThickness; windowContextMenuLoader.item.triggerBarSpacing = root.barSpacing; if (root.isVerticalOrientation) { - const globalPos = delegateItem.mapToGlobal(delegateItem.width / 2, delegateItem.height / 2); - const screenX = root.parentScreen ? root.parentScreen.x : 0; - const screenY = root.parentScreen ? root.parentScreen.y : 0; - const relativeY = globalPos.y - screenY; - // Add minTooltipY offset to account for top bar - const adjustedY = relativeY + root.minTooltipY; + const localPos = delegateItem.mapToItem(null, delegateItem.width / 2, delegateItem.height / 2); + const adjustedY = localPos.y + root.minTooltipY; const xPos = root.axis?.edge === "left" ? (root.barThickness + root.barSpacing + Theme.spacingXS) : (root.parentScreen.width - root.barThickness - root.barSpacing - Theme.spacingXS); windowContextMenuLoader.item.showAt(xPos, adjustedY, true, root.axis?.edge); } else { - const globalPos = delegateItem.mapToGlobal(delegateItem.width / 2, 0); - const screenX = root.parentScreen ? root.parentScreen.x : 0; - const relativeX = globalPos.x - screenX; + const localPos = delegateItem.mapToItem(null, delegateItem.width / 2, 0); const screenHeight = root.parentScreen ? root.parentScreen.height : Screen.height; const isBottom = root.axis?.edge === "bottom"; const yPos = isBottom ? (screenHeight - root.barThickness - root.barSpacing - 32 - Theme.spacingXS) : (root.barThickness + root.barSpacing + Theme.spacingXS); - windowContextMenuLoader.item.showAt(relativeX, yPos, false, root.axis?.edge); + windowContextMenuLoader.item.showAt(localPos.x, yPos, false, root.axis?.edge); } } } else if (mouse.button === Qt.MiddleButton) { @@ -455,21 +449,17 @@ BasePill { tooltipLoader.active = true; if (tooltipLoader.item) { if (root.isVerticalOrientation) { - const globalPos = delegateItem.mapToGlobal(delegateItem.width / 2, delegateItem.height / 2); - const screenX = root.parentScreen ? root.parentScreen.x : 0; - const screenY = root.parentScreen ? root.parentScreen.y : 0; - const relativeY = globalPos.y - screenY; + const localPos = delegateItem.mapToItem(null, delegateItem.width / 2, delegateItem.height / 2); const tooltipX = root.axis?.edge === "left" ? (root.barThickness + root.barSpacing + Theme.spacingXS) : (root.parentScreen.width - root.barThickness - root.barSpacing - Theme.spacingXS); const isLeft = root.axis?.edge === "left"; - const adjustedY = relativeY + root.minTooltipY; - const finalX = screenX + tooltipX; - tooltipLoader.item.show(delegateItem.tooltipText, finalX, adjustedY, root.parentScreen, isLeft, !isLeft); + const adjustedY = localPos.y + root.minTooltipY; + tooltipLoader.item.show(delegateItem.tooltipText, tooltipX, adjustedY, root.parentScreen, isLeft, !isLeft); } else { - const globalPos = delegateItem.mapToGlobal(delegateItem.width / 2, delegateItem.height); + const localPos = delegateItem.mapToItem(null, delegateItem.width / 2, delegateItem.height); const screenHeight = root.parentScreen ? root.parentScreen.height : Screen.height; const isBottom = root.axis?.edge === "bottom"; const tooltipY = isBottom ? (screenHeight - root.barThickness - root.barSpacing - Theme.spacingXS - 35) : (root.barThickness + root.barSpacing + Theme.spacingXS); - tooltipLoader.item.show(delegateItem.tooltipText, globalPos.x, tooltipY, root.parentScreen, false, false); + tooltipLoader.item.show(delegateItem.tooltipText, localPos.x, tooltipY, root.parentScreen, false, false); } } } @@ -677,22 +667,16 @@ BasePill { windowContextMenuLoader.item.triggerBarThickness = root.barThickness; windowContextMenuLoader.item.triggerBarSpacing = root.barSpacing; if (root.isVerticalOrientation) { - const globalPos = delegateItem.mapToGlobal(delegateItem.width / 2, delegateItem.height / 2); - const screenX = root.parentScreen ? root.parentScreen.x : 0; - const screenY = root.parentScreen ? root.parentScreen.y : 0; - const relativeY = globalPos.y - screenY; - // Add minTooltipY offset to account for top bar - const adjustedY = relativeY + root.minTooltipY; + const localPos = delegateItem.mapToItem(null, delegateItem.width / 2, delegateItem.height / 2); + const adjustedY = localPos.y + root.minTooltipY; const xPos = root.axis?.edge === "left" ? (root.barThickness + root.barSpacing + Theme.spacingXS) : (root.parentScreen.width - root.barThickness - root.barSpacing - Theme.spacingXS); windowContextMenuLoader.item.showAt(xPos, adjustedY, true, root.axis?.edge); } else { - const globalPos = delegateItem.mapToGlobal(delegateItem.width / 2, 0); - const screenX = root.parentScreen ? root.parentScreen.x : 0; - const relativeX = globalPos.x - screenX; + const localPos = delegateItem.mapToItem(null, delegateItem.width / 2, 0); const screenHeight = root.parentScreen ? root.parentScreen.height : Screen.height; const isBottom = root.axis?.edge === "bottom"; const yPos = isBottom ? (screenHeight - root.barThickness - root.barSpacing - 32 - Theme.spacingXS) : (root.barThickness + root.barSpacing + Theme.spacingXS); - windowContextMenuLoader.item.showAt(relativeX, yPos, false, root.axis?.edge); + windowContextMenuLoader.item.showAt(localPos.x, yPos, false, root.axis?.edge); } } } else if (mouse.button === Qt.MiddleButton) { @@ -708,21 +692,17 @@ BasePill { tooltipLoader.active = true; if (tooltipLoader.item) { if (root.isVerticalOrientation) { - const globalPos = delegateItem.mapToGlobal(delegateItem.width / 2, delegateItem.height / 2); - const screenX = root.parentScreen ? root.parentScreen.x : 0; - const screenY = root.parentScreen ? root.parentScreen.y : 0; - const relativeY = globalPos.y - screenY; + const localPos = delegateItem.mapToItem(null, delegateItem.width / 2, delegateItem.height / 2); const tooltipX = root.axis?.edge === "left" ? (root.barThickness + root.barSpacing + Theme.spacingXS) : (root.parentScreen.width - root.barThickness - root.barSpacing - Theme.spacingXS); const isLeft = root.axis?.edge === "left"; - const adjustedY = relativeY + root.minTooltipY; - const finalX = screenX + tooltipX; - tooltipLoader.item.show(delegateItem.tooltipText, finalX, adjustedY, root.parentScreen, isLeft, !isLeft); + const adjustedY = localPos.y + root.minTooltipY; + tooltipLoader.item.show(delegateItem.tooltipText, tooltipX, adjustedY, root.parentScreen, isLeft, !isLeft); } else { - const globalPos = delegateItem.mapToGlobal(delegateItem.width / 2, delegateItem.height); + const localPos = delegateItem.mapToItem(null, delegateItem.width / 2, delegateItem.height); const screenHeight = root.parentScreen ? root.parentScreen.height : Screen.height; const isBottom = root.axis?.edge === "bottom"; const tooltipY = isBottom ? (screenHeight - root.barThickness - root.barSpacing - Theme.spacingXS - 35) : (root.barThickness + root.barSpacing + Theme.spacingXS); - tooltipLoader.item.show(delegateItem.tooltipText, globalPos.x, tooltipY, root.parentScreen, false, false); + tooltipLoader.item.show(delegateItem.tooltipText, localPos.x, tooltipY, root.parentScreen, false, false); } } } diff --git a/quickshell/Modules/DankBar/Widgets/Vpn.qml b/quickshell/Modules/DankBar/Widgets/Vpn.qml index fec33d0f..79a0a4f7 100644 --- a/quickshell/Modules/DankBar/Widgets/Vpn.qml +++ b/quickshell/Modules/DankBar/Widgets/Vpn.qml @@ -106,18 +106,15 @@ BasePill { } if (root.isVerticalOrientation) { - const globalPos = mapToGlobal(width / 2, height / 2); + const localPos = mapToItem(null, width / 2, height / 2); const currentScreen = root.parentScreen || Screen; - const screenX = currentScreen ? currentScreen.x : 0; - const screenY = currentScreen ? currentScreen.y : 0; - const relativeY = globalPos.y - screenY; - const adjustedY = relativeY + root.minTooltipY; + const adjustedY = localPos.y + root.minTooltipY; const tooltipX = root.axis?.edge === "left" ? (root.barThickness + root.barSpacing + Theme.spacingXS) : (currentScreen.width - root.barThickness - root.barSpacing - Theme.spacingXS); const isLeft = root.axis?.edge === "left"; - tooltipLoader.item.show(tooltipText, screenX + tooltipX, adjustedY, currentScreen, isLeft, !isLeft); + tooltipLoader.item.show(tooltipText, tooltipX, adjustedY, currentScreen, isLeft, !isLeft); } else { const isBottom = root.axis?.edge === "bottom"; - const globalPos = mapToGlobal(width / 2, 0); + const localPos = mapToItem(null, width / 2, 0); const currentScreen = root.parentScreen || Screen; let tooltipY; @@ -128,7 +125,7 @@ BasePill { tooltipY = root.barThickness + root.barSpacing + Theme.spacingXS; } - tooltipLoader.item.show(tooltipText, globalPos.x, tooltipY, currentScreen, false, false); + tooltipLoader.item.show(tooltipText, localPos.x, tooltipY, currentScreen, false, false); } } onExited: { diff --git a/quickshell/Modules/Dock/Dock.qml b/quickshell/Modules/Dock/Dock.qml index e302f598..6aacb7a7 100644 --- a/quickshell/Modules/Dock/Dock.qml +++ b/quickshell/Modules/Dock/Dock.qml @@ -511,13 +511,11 @@ Variants { if (!dock.hoveredButton || !dock.reveal || slideXAnimation.running || slideYAnimation.running) return; - const buttonGlobalPos = dock.hoveredButton.mapToGlobal(0, 0); + const buttonLocalPos = dock.hoveredButton.mapToItem(null, 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; const gap = Theme.spacingS; @@ -527,19 +525,19 @@ Variants { if (!dock.isVertical) { const isBottom = SettingsData.dockPosition === SettingsData.Position.Bottom; - const globalX = buttonGlobalPos.x + btnW / 2 + adjacentLeftBarWidth; + const tooltipX = buttonLocalPos.x + btnW / 2 + adjacentLeftBarWidth; const tooltipHeight = 32; const totalFromEdge = bgMargin + dockBackground.height + dock.borderThickness + gap; const screenRelativeY = isBottom ? (screenHeight - totalFromEdge - tooltipHeight) : totalFromEdge; - dockTooltip.show(tooltipText, globalX, screenRelativeY, dock.screen, false, false); + dockTooltip.show(tooltipText, tooltipX, screenRelativeY, dock.screen, false, false); return; } const isLeft = SettingsData.dockPosition === SettingsData.Position.Left; const screenWidth = dock.screen ? dock.screen.width : 0; const totalFromEdge = bgMargin + dockBackground.width + dock.borderThickness + gap; - const tooltipX = isLeft ? (screenX + totalFromEdge) : (screenX + screenWidth - totalFromEdge); - const screenRelativeY = buttonGlobalPos.y - screenY + btnH / 2 + adjacentTopBarHeight; + const tooltipX = isLeft ? totalFromEdge : (screenWidth - totalFromEdge); + const screenRelativeY = buttonLocalPos.y + btnH / 2 + adjacentTopBarHeight; dockTooltip.show(tooltipText, tooltipX, screenRelativeY, dock.screen, isLeft, !isLeft); } diff --git a/quickshell/Widgets/DankTooltip.qml b/quickshell/Widgets/DankTooltip.qml index 8cd1fd21..58f7b448 100644 --- a/quickshell/Widgets/DankTooltip.qml +++ b/quickshell/Widgets/DankTooltip.qml @@ -19,14 +19,8 @@ PanelWindow { function show(text, x, y, screen, leftAlign, rightAlign) { root.text = text; - if (screen) { - targetScreen = screen; - const screenX = screen.x || 0; - targetX = x - screenX; - } else { - targetScreen = null; - targetX = x; - } + targetScreen = screen ?? null; + targetX = x; targetY = y; alignLeft = leftAlign ?? false; alignRight = rightAlign ?? false;