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:
@@ -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)
|
||||||
|
anchorPos = Qt.point(targetX, relativeY + root.height / 2)
|
||||||
} else {
|
} else {
|
||||||
const popupX = effectiveBarThickness + SettingsData.dankBarSpacing + Theme.popupDistance
|
let targetY = root.isAtBottom
|
||||||
targetX = screen.width - popupX
|
? screen.height - (effectiveBarThickness + SettingsData.dankBarSpacing + SettingsData.dankBarBottomGap + Theme.popupDistance)
|
||||||
}
|
: effectiveBarThickness + SettingsData.dankBarSpacing + SettingsData.dankBarBottomGap + Theme.popupDistance
|
||||||
anchorPos = Qt.point(targetX, relativeY + menuRoot.anchorItem.height / 2)
|
anchorPos = Qt.point(relativeX + root.width / 2, targetY)
|
||||||
} else {
|
|
||||||
let targetY
|
|
||||||
if (menuRoot.isAtBottom) {
|
|
||||||
const popupY = effectiveBarThickness + SettingsData.dankBarSpacing + SettingsData.dankBarBottomGap + Theme.popupDistance
|
|
||||||
targetY = screen.height - popupY
|
|
||||||
} else {
|
|
||||||
targetY = effectiveBarThickness + SettingsData.dankBarSpacing + SettingsData.dankBarBottomGap + Theme.popupDistance
|
|
||||||
}
|
|
||||||
anchorPos = Qt.point(relativeX + menuRoot.anchorItem.width / 2, targetY)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user