1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-07 22:15:38 -05:00

systemtray: fix menu positioning

This commit is contained in:
bbedward
2025-11-12 22:21:02 -05:00
parent a6b059b30d
commit 5490a230bd

View File

@@ -716,12 +716,12 @@ Item {
} }
function updatePosition() { function updatePosition() {
if (!menuRoot.anchorItem || !menuRoot.trayItem) { if (!root.parentWindow) {
anchorPos = Qt.point(screen.width / 2, screen.height / 2) anchorPos = Qt.point(screen.width / 2, screen.height / 2)
return return
} }
const globalPos = menuRoot.anchorItem.mapToGlobal(0, 0) const globalPos = root.mapToGlobal(0, 0)
const screenX = screen.x || 0 const screenX = screen.x || 0
const screenY = screen.y || 0 const screenY = screen.y || 0
const relativeX = globalPos.x - screenX const relativeX = globalPos.x - screenX
@@ -730,25 +730,17 @@ Item {
const widgetThickness = Math.max(20, 26 + SettingsData.dankBarInnerPadding * 0.6) const widgetThickness = Math.max(20, 26 + SettingsData.dankBarInnerPadding * 0.6)
const effectiveBarThickness = Math.max(widgetThickness + SettingsData.dankBarInnerPadding + 4, Theme.barHeight - 4 - (8 - SettingsData.dankBarInnerPadding)) const effectiveBarThickness = Math.max(widgetThickness + SettingsData.dankBarInnerPadding + 4, Theme.barHeight - 4 - (8 - SettingsData.dankBarInnerPadding))
if (menuRoot.isVertical) { if (root.isVertical) {
const edge = menuRoot.axis?.edge const edge = root.axis?.edge
let targetX let targetX = edge === "left"
if (edge === "left") { ? effectiveBarThickness + SettingsData.dankBarSpacing + Theme.popupDistance
targetX = effectiveBarThickness + SettingsData.dankBarSpacing + Theme.popupDistance : screen.width - (effectiveBarThickness + SettingsData.dankBarSpacing + Theme.popupDistance)
} else { anchorPos = Qt.point(targetX, relativeY + root.height / 2)
const popupX = effectiveBarThickness + SettingsData.dankBarSpacing + Theme.popupDistance
targetX = screen.width - popupX
}
anchorPos = Qt.point(targetX, relativeY + menuRoot.anchorItem.height / 2)
} else { } else {
let targetY let targetY = root.isAtBottom
if (menuRoot.isAtBottom) { ? screen.height - (effectiveBarThickness + SettingsData.dankBarSpacing + SettingsData.dankBarBottomGap + Theme.popupDistance)
const popupY = effectiveBarThickness + SettingsData.dankBarSpacing + SettingsData.dankBarBottomGap + Theme.popupDistance : effectiveBarThickness + SettingsData.dankBarSpacing + SettingsData.dankBarBottomGap + Theme.popupDistance
targetY = screen.height - popupY anchorPos = Qt.point(relativeX + root.width / 2, targetY)
} else {
targetY = effectiveBarThickness + SettingsData.dankBarSpacing + SettingsData.dankBarBottomGap + Theme.popupDistance
}
anchorPos = Qt.point(relativeX + menuRoot.anchorItem.width / 2, targetY)
} }
} }