diff --git a/Modules/Bar/Extras/BarPillHorizontal.qml b/Modules/Bar/Extras/BarPillHorizontal.qml index bddd8dec7..1d3a4967c 100644 --- a/Modules/Bar/Extras/BarPillHorizontal.qml +++ b/Modules/Bar/Extras/BarPillHorizontal.qml @@ -255,7 +255,7 @@ Item { onEntered: { hovered = true; root.entered(); - TooltipService.show(screen, pill, root.tooltipText, BarService.getTooltipDirection(), Style.tooltipDelayLong); + TooltipService.show(pill, root.tooltipText, BarService.getTooltipDirection(), Style.tooltipDelayLong); if (forceClose) { return; } diff --git a/Modules/Bar/Extras/BarPillVertical.qml b/Modules/Bar/Extras/BarPillVertical.qml index d36256e29..6ac176861 100644 --- a/Modules/Bar/Extras/BarPillVertical.qml +++ b/Modules/Bar/Extras/BarPillVertical.qml @@ -297,7 +297,7 @@ Item { onEntered: { hovered = true; root.entered(); - TooltipService.show(screen, pill, root.tooltipText, BarService.getTooltipDirection(), Style.tooltipDelayLong); + TooltipService.show(pill, root.tooltipText, BarService.getTooltipDirection(), Style.tooltipDelayLong); if (forceClose) { return; } diff --git a/Modules/Bar/Widgets/ActiveWindow.qml b/Modules/Bar/Widgets/ActiveWindow.qml index a8b49b004..6daaf743c 100644 --- a/Modules/Bar/Widgets/ActiveWindow.qml +++ b/Modules/Bar/Widgets/ActiveWindow.qml @@ -412,7 +412,7 @@ Item { acceptedButtons: Qt.LeftButton onEntered: { if ((windowTitle !== "") && isVerticalBar || (scrollingMode === "never")) { - TooltipService.show(screen, root, windowTitle, BarService.getTooltipDirection()); + TooltipService.show(root, windowTitle, BarService.getTooltipDirection()); } } onExited: { diff --git a/Modules/Bar/Widgets/Clock.qml b/Modules/Bar/Widgets/Clock.qml index 5e5205b47..09ab56b33 100644 --- a/Modules/Bar/Widgets/Clock.qml +++ b/Modules/Bar/Widgets/Clock.qml @@ -122,7 +122,7 @@ Rectangle { hoverEnabled: true onEntered: { if (!PanelService.getPanel("calendarPanel", screen)?.active) { - TooltipService.show(screen, root, I18n.tr("clock.tooltip"), BarService.getTooltipDirection()); + TooltipService.show(root, I18n.tr("clock.tooltip"), BarService.getTooltipDirection()); } } onExited: { diff --git a/Modules/Bar/Widgets/MediaMini.qml b/Modules/Bar/Widgets/MediaMini.qml index 4483c3e78..859ae4af6 100644 --- a/Modules/Bar/Widgets/MediaMini.qml +++ b/Modules/Bar/Widgets/MediaMini.qml @@ -484,7 +484,7 @@ Item { onEntered: { var textToShow = hasActivePlayer ? tooltipText : placeholderText; if ((textToShow !== "") && isVerticalBar || (scrollingMode === "never")) { - TooltipService.show(screen, root, textToShow, BarService.getTooltipDirection()); + TooltipService.show(root, textToShow, BarService.getTooltipDirection()); } } onExited: { diff --git a/Modules/Bar/Widgets/SystemMonitor.qml b/Modules/Bar/Widgets/SystemMonitor.qml index a154a4ff6..330d0ab2e 100644 --- a/Modules/Bar/Widgets/SystemMonitor.qml +++ b/Modules/Bar/Widgets/SystemMonitor.qml @@ -524,7 +524,7 @@ Rectangle { anchors.fill: parent hoverEnabled: true onEntered: { - TooltipService.show(screen, diskContent, diskPath, BarService.getTooltipDirection()); + TooltipService.show(diskContent, diskPath, BarService.getTooltipDirection()); } onExited: { TooltipService.hide(); diff --git a/Modules/Bar/Widgets/Taskbar.qml b/Modules/Bar/Widgets/Taskbar.qml index e8e30adb7..d541052d5 100644 --- a/Modules/Bar/Widgets/Taskbar.qml +++ b/Modules/Bar/Widgets/Taskbar.qml @@ -177,7 +177,7 @@ Rectangle { } } } - onEntered: TooltipService.show(screen, taskbarItem, taskbarItem.modelData.title || taskbarItem.modelData.appId || "Unknown app.", BarService.getTooltipDirection()) + onEntered: TooltipService.show(taskbarItem, taskbarItem.modelData.title || taskbarItem.modelData.appId || "Unknown app.", BarService.getTooltipDirection()) onExited: TooltipService.hide() } } diff --git a/Modules/Bar/Widgets/TaskbarGrouped.qml b/Modules/Bar/Widgets/TaskbarGrouped.qml index f519df666..dd0b5b4c3 100644 --- a/Modules/Bar/Widgets/TaskbarGrouped.qml +++ b/Modules/Bar/Widgets/TaskbarGrouped.qml @@ -306,7 +306,7 @@ Item { } onEntered: { taskbarItem.itemHovered = true; - TooltipService.show(screen, taskbarItem, model.title || model.appId || "Unknown app.", BarService.getTooltipDirection()); + TooltipService.show(taskbarItem, model.title || model.appId || "Unknown app.", BarService.getTooltipDirection()); } onExited: { taskbarItem.itemHovered = false; diff --git a/Modules/Bar/Widgets/Tray.qml b/Modules/Bar/Widgets/Tray.qml index a3915b4c2..dfd98feec 100644 --- a/Modules/Bar/Widgets/Tray.qml +++ b/Modules/Bar/Widgets/Tray.qml @@ -379,7 +379,7 @@ Rectangle { if (popupMenuWindow) { popupMenuWindow.close(); } - TooltipService.show(screen, trayIcon, modelData.tooltipTitle || modelData.name || modelData.id || "Tray Item", BarService.getTooltipDirection()); + TooltipService.show(trayIcon, modelData.tooltipTitle || modelData.name || modelData.id || "Tray Item", BarService.getTooltipDirection()); } onExited: TooltipService.hide() } diff --git a/Modules/Dock/Dock.qml b/Modules/Dock/Dock.qml index 91686e7bf..e68ed433f 100644 --- a/Modules/Dock/Dock.qml +++ b/Modules/Dock/Dock.qml @@ -500,7 +500,7 @@ Loader { const appName = appButton.appTitle || appButton.appId || "Unknown"; const tooltipText = appName.length > 40 ? appName.substring(0, 37) + "..." : appName; if (!contextMenu.visible) { - TooltipService.show(screen, appButton, tooltipText, "top"); + TooltipService.show(appButton, tooltipText, "top"); } if (autoHide) { showTimer.stop(); diff --git a/Modules/Panels/Calendar/CalendarPanel.qml b/Modules/Panels/Calendar/CalendarPanel.qml index b78ceb5fa..e661b9cb9 100644 --- a/Modules/Panels/Calendar/CalendarPanel.qml +++ b/Modules/Panels/Calendar/CalendarPanel.qml @@ -617,7 +617,7 @@ SmartPanel { return `${startFormatted}-${endFormatted} ${event.summary}`; } }).join('\n'); - TooltipService.show(screen, parent, summaries, "auto", Style.tooltipDelay, Settings.data.ui.fontFixed); + TooltipService.show(parent, summaries, "auto", Style.tooltipDelay, Settings.data.ui.fontFixed); } } diff --git a/Modules/Panels/Settings/Bar/WidgetSettings/CustomButtonSettings.qml b/Modules/Panels/Settings/Bar/WidgetSettings/CustomButtonSettings.qml index 7f94fa466..dfbebd810 100644 --- a/Modules/Panels/Settings/Bar/WidgetSettings/CustomButtonSettings.qml +++ b/Modules/Panels/Settings/Bar/WidgetSettings/CustomButtonSettings.qml @@ -82,7 +82,7 @@ ColumnLayout { enabled: !valueTextStream Layout.alignment: Qt.AlignRight | Qt.AlignBottom Layout.bottomMargin: Style.marginS - onEntered: TooltipService.show(screen, leftClickUpdateText, I18n.tr("bar.widget-settings.custom-button.left-click.update-text"), "auto") + onEntered: TooltipService.show(leftClickUpdateText, I18n.tr("bar.widget-settings.custom-button.left-click.update-text"), "auto") onExited: TooltipService.hide() checked: widgetData?.leftClickUpdateText ?? widgetMetadata.leftClickUpdateText onToggled: isChecked => checked = isChecked @@ -106,7 +106,7 @@ ColumnLayout { enabled: !valueTextStream Layout.alignment: Qt.AlignRight | Qt.AlignBottom Layout.bottomMargin: Style.marginS - onEntered: TooltipService.show(screen, rightClickUpdateText, I18n.tr("bar.widget-settings.custom-button.right-click.update-text"), "auto") + onEntered: TooltipService.show(rightClickUpdateText, I18n.tr("bar.widget-settings.custom-button.right-click.update-text"), "auto") onExited: TooltipService.hide() checked: widgetData?.rightClickUpdateText ?? widgetMetadata.rightClickUpdateText onToggled: isChecked => checked = isChecked @@ -130,7 +130,7 @@ ColumnLayout { enabled: !valueTextStream Layout.alignment: Qt.AlignRight | Qt.AlignBottom Layout.bottomMargin: Style.marginS - onEntered: TooltipService.show(screen, middleClickUpdateText, I18n.tr("bar.widget-settings.custom-button.middle-click.update-text"), "auto") + onEntered: TooltipService.show(middleClickUpdateText, I18n.tr("bar.widget-settings.custom-button.middle-click.update-text"), "auto") onExited: TooltipService.hide() checked: widgetData?.middleClickUpdateText ?? widgetMetadata.middleClickUpdateText onToggled: isChecked => checked = isChecked diff --git a/Modules/Panels/Tray/TrayDrawerPanel.qml b/Modules/Panels/Tray/TrayDrawerPanel.qml index e0a0e995e..b7898a977 100644 --- a/Modules/Panels/Tray/TrayDrawerPanel.qml +++ b/Modules/Panels/Tray/TrayDrawerPanel.qml @@ -235,7 +235,7 @@ SmartPanel { if (popupMenuWindow) { popupMenuWindow.close(); } - TooltipService.show(screen, trayIcon, modelData.tooltipTitle || modelData.name || modelData.id || "Tray Item", BarService.getTooltipDirection()); + TooltipService.show(trayIcon, modelData.tooltipTitle || modelData.name || modelData.id || "Tray Item", BarService.getTooltipDirection()); } onExited: TooltipService.hide() } diff --git a/Modules/Tooltip/Tooltip.qml b/Modules/Tooltip/Tooltip.qml index b982ff1fc..75dca2943 100644 --- a/Modules/Tooltip/Tooltip.qml +++ b/Modules/Tooltip/Tooltip.qml @@ -1,5 +1,4 @@ import QtQuick -// import QtQuick.Layouts import Quickshell import qs.Commons import qs.Widgets @@ -7,9 +6,6 @@ import qs.Widgets PopupWindow { id: root - property int screenWidth: 0 - property int screenHeight: 0 - property string text: "" property string direction: "auto" // "auto", "left", "right", "top", "bottom" property int margin: Style.marginXS // distance from target @@ -26,8 +22,9 @@ PopupWindow { property real anchorX: 0 property real anchorY: 0 property bool isPositioned: false - property bool pendingShow: false property bool animatingOut: true + property int screenWidth: 1920 + property int screenHeight: 1080 visible: false color: Color.transparent @@ -108,11 +105,9 @@ PopupWindow { } // Function to show tooltip - function show(screen, target, tipText, customDirection, showDelay, fontFamily) { - if (!screen || !target || !tipText || tipText === "") + function show(target, tipText, customDirection, showDelay, fontFamily) { + if (!target || !tipText || tipText === "") return; - root.screenWidth = screen.width; - root.screenHeight = screen.height; root.delay = showDelay; @@ -128,9 +123,32 @@ PopupWindow { } // Set properties - targetItem = target; text = tipText; - pendingShow = true; + targetItem = target; + + // Find the correct screen dimensions based on target's global position + // Respect all screens positionning + const targetGlobal = target.mapToGlobal(target.width / 2, target.height / 2); + let foundScreen = false; + for (let i = 0; i < Quickshell.screens.length; i++) { + const s = Quickshell.screens[i]; + if (targetGlobal.x >= s.x && targetGlobal.x < s.x + s.width && targetGlobal.y >= s.y && targetGlobal.y < s.y + s.height) { + screenWidth = s.width; + screenHeight = s.height; + foundScreen = true; + break; + } + } + if (!foundScreen) { + Logger.w("Tooltip", "No screen found for target position!"); + } + + // Initialize animation state (hidden) + tooltipContainer.opacity = 0.0; + tooltipContainer.scale = root.animationScale; + + // Start show timer (will position and then make visible) + showTimer.start(); if (customDirection !== undefined) { direction = customDirection; @@ -139,17 +157,16 @@ PopupWindow { } tooltipText.family = fontFamily ? fontFamily : Settings.data.ui.fontDefault; - - // Start show timer - showTimer.start(); } // Function to position and display the tooltip function positionAndShow() { - if (!targetItem || !targetItem.parent || !pendingShow) { + if (!targetItem || !targetItem.parent) { return; } + console.log(screenWidth, screenHeight); + // Calculate tooltip dimensions const tipWidth = Math.min(tooltipText.implicitWidth + (padding * 2), maxWidth); root.implicitWidth = tipWidth; @@ -256,35 +273,20 @@ PopupWindow { } } - // Apply position + // Apply position first (before making visible) anchorX = newAnchorX; anchorY = newAnchorY; isPositioned = true; - pendingShow = false; - // Show tooltip and start animation - visible = true; - - // Initialize animation state - tooltipContainer.opacity = 0.0; - tooltipContainer.scale = animationScale; - - // Start show animation + // Now make visible and start animation + root.visible = true; showAnimation.start(); - - // Force anchor update after showing - Qt.callLater(() => { - if (root.anchor && root.visible) { - root.anchor.updateAnchor(); - } - }); } // Function to hide tooltip function hide() { // Stop show timer if it's running showTimer.stop(); - pendingShow = false; // Stop hide timer if it's running hideTimer.stop(); @@ -307,7 +309,6 @@ PopupWindow { function completeHide() { visible = false; animatingOut = false; - pendingShow = false; text = ""; isPositioned = false; tooltipContainer.opacity = 1.0; @@ -320,7 +321,6 @@ PopupWindow { hideTimer.stop(); showAnimation.stop(); hideAnimation.stop(); - pendingShow = false; animatingOut = false; completeHide(); } @@ -345,8 +345,8 @@ PopupWindow { const globalX = targetGlobal.x + anchorX; if (globalX < 0) { anchorX = -targetGlobal.x + margin; - } else if (globalX + tipWidth > screenWidth) { - anchorX = screenWidth - targetGlobal.x - tipWidth - margin; + } else if (globalX + tipWidth > root.screen.width) { + anchorX = root.screen.width - targetGlobal.x - tipWidth - margin; } // Force anchor update @@ -368,7 +368,6 @@ PopupWindow { // Clear all state visible = false; - pendingShow = false; animatingOut = false; text = ""; isPositioned = false; diff --git a/Services/UI/TooltipService.qml b/Services/UI/TooltipService.qml index a1ab7c613..75d096f91 100644 --- a/Services/UI/TooltipService.qml +++ b/Services/UI/TooltipService.qml @@ -15,13 +15,13 @@ Singleton { Tooltip {} } - function show(screen, target, text, direction, delay, fontFamily) { + function show(target, text, direction, delay, fontFamily) { if (!Settings.data.ui.tooltipsEnabled) { return; } // Don't create if no text - if (!screen || !target || !text) { + if (!target || !text) { Logger.i("Tooltip", "No target or text"); return; } @@ -78,7 +78,7 @@ Singleton { }); // Show the tooltip - newTooltip.show(screen, target, text, direction || "auto", delay || Style.tooltipDelay, fontFamily); + newTooltip.show(target, text, direction || "auto", delay || Style.tooltipDelay, fontFamily); return newTooltip; } else { diff --git a/Widgets/NButton.qml b/Widgets/NButton.qml index 193baf7dd..e98502421 100644 --- a/Widgets/NButton.qml +++ b/Widgets/NButton.qml @@ -144,7 +144,7 @@ Rectangle { root.hovered = true; root.entered(); if (tooltipText) { - TooltipService.show(screen, root, root.tooltipText); + TooltipService.show(root, root.tooltipText); } } onExited: { diff --git a/Widgets/NIconButton.qml b/Widgets/NIconButton.qml index fc862cf8d..4e8404f39 100644 --- a/Widgets/NIconButton.qml +++ b/Widgets/NIconButton.qml @@ -83,7 +83,7 @@ Rectangle { onEntered: { hovering = root.enabled ? true : false; if (tooltipText) { - TooltipService.show(screen, parent, tooltipText, tooltipDirection); + TooltipService.show(parent, tooltipText, tooltipDirection); } root.entered(); } diff --git a/Widgets/NIconButtonHot.qml b/Widgets/NIconButtonHot.qml index 4d916655e..eb50c1159 100644 --- a/Widgets/NIconButtonHot.qml +++ b/Widgets/NIconButtonHot.qml @@ -119,7 +119,7 @@ Rectangle { onEntered: { hovering = root.enabled ? true : false; if (tooltipText) { - TooltipService.show(screen, parent, tooltipText, tooltipDirection); + TooltipService.show(parent, tooltipText, tooltipDirection); } root.entered(); } diff --git a/Widgets/NSlider.qml b/Widgets/NSlider.qml index 25aebf80a..dc028c757 100644 --- a/Widgets/NSlider.qml +++ b/Widgets/NSlider.qml @@ -117,7 +117,7 @@ Slider { onEntered: { root.hovering = true; if (root.tooltipText) { - TooltipService.show(screen, knob, root.tooltipText, root.tooltipDirection); + TooltipService.show(knob, root.tooltipText, root.tooltipDirection); } }