1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-08-04 04:28:30 -04:00

dbar/notifications: fix right click context menu position and add middle

click to DnD

(cherry picked from commit 1f94c3cbd4)
This commit is contained in:
bbedward
2026-07-26 14:51:51 -04:00
parent a64bd80cc9
commit 6c27b92445
2 changed files with 33 additions and 35 deletions
@@ -31,14 +31,16 @@ PanelWindow {
}
property point anchorPos: Qt.point(0, 0)
property string anchorEdge: "top"
property bool isVertical: false
property string edge: "top"
visible: false
function showAt(x, y, targetScreen, edge) {
function showAt(x, y, vertical, barEdge, targetScreen) {
if (targetScreen)
root.screen = targetScreen;
anchorPos = Qt.point(x, y);
anchorEdge = edge || "top";
isVertical = vertical ?? false;
edge = barEdge ?? "top";
visible = true;
}
@@ -66,21 +68,19 @@ PanelWindow {
visible: root.visible
x: {
const left = 10;
const right = root.width - width - 10;
const want = root.anchorPos.x - width / 2;
return Math.max(left, Math.min(right, want));
if (root.isVertical) {
if (root.edge === "left")
return Math.min(root.width - width - 10, root.anchorPos.x);
return Math.max(10, root.anchorPos.x - width);
}
return Math.max(10, Math.min(root.width - width - 10, root.anchorPos.x - width / 2));
}
y: {
switch (root.anchorEdge) {
case "bottom":
return Math.max(10, root.anchorPos.y - height);
case "left":
case "right":
if (root.isVertical)
return Math.max(10, Math.min(root.height - height - 10, root.anchorPos.y - height / 2));
default:
return Math.min(root.height - height - 10, root.anchorPos.y);
}
if (root.edge === "bottom")
return Math.max(10, root.anchorPos.y - height);
return Math.min(root.height - height - 10, root.anchorPos.y);
}
onDismissed: root.closeMenu()