diff --git a/modules/Backlight.qml b/modules/Backlight.qml index 396ee85..0973603 100644 --- a/modules/Backlight.qml +++ b/modules/Backlight.qml @@ -99,7 +99,7 @@ M.BarSection { id: hoverPanel showPanel: root._showPanel screen: QsWindow.window?.screen ?? null - anchorX: root.mapToGlobal(root.width / 2, 0).x - (QsWindow.window?.screen?.x ?? 0) + anchorItem: root accentColor: root.accentColor panelNamespace: "nova-backlight" contentWidth: 200 diff --git a/modules/HoverPanel.qml b/modules/HoverPanel.qml index 3ac7640..01a68d5 100644 --- a/modules/HoverPanel.qml +++ b/modules/HoverPanel.qml @@ -9,7 +9,7 @@ PanelWindow { id: root required property bool showPanel - required property real anchorX + required property Item anchorItem required property color accentColor property string panelNamespace: "nova-panel" property real contentWidth: 220 @@ -31,7 +31,6 @@ PanelWindow { anchors.left: true margins.top: 0 - margins.left: Math.max(0, Math.min(Math.round(anchorX - contentWidth / 2), (screen?.width ?? 1920) - contentWidth)) implicitWidth: panelContent.width implicitHeight: panelContent.height @@ -44,8 +43,16 @@ PanelWindow { } } + function _updatePosition() { + const pt = anchorItem.mapToGlobal(anchorItem.width / 2, 0); + const scr = screen; + const sw = scr?.width ?? 1920; + margins.left = Math.max(0, Math.min(Math.round(pt.x - (scr?.x ?? 0) - contentWidth / 2), sw - contentWidth)); + } + onShowPanelChanged: { if (showPanel) { + _updatePosition(); _winVisible = true; hideAnim.stop(); showAnim.start(); diff --git a/modules/Mpris.qml b/modules/Mpris.qml index 4cf8907..e3295d0 100644 --- a/modules/Mpris.qml +++ b/modules/Mpris.qml @@ -99,7 +99,7 @@ M.BarSection { id: hoverPanel showPanel: root._showPanel screen: QsWindow.window?.screen ?? null - anchorX: root.mapToGlobal(root.width / 2, 0).x - (QsWindow.window?.screen?.x ?? 0) + anchorItem: root accentColor: root.accentColor panelNamespace: "nova-mpris" contentWidth: 280 diff --git a/modules/Volume.qml b/modules/Volume.qml index 982a8a6..c75abe5 100644 --- a/modules/Volume.qml +++ b/modules/Volume.qml @@ -109,7 +109,7 @@ M.BarSection { id: hoverPanel showPanel: root._showPanel screen: QsWindow.window?.screen ?? null - anchorX: root.mapToGlobal(root.width / 2, 0).x - (QsWindow.window?.screen?.x ?? 0) + anchorItem: root accentColor: root.accentColor panelNamespace: "nova-volume" contentWidth: 220