diff --git a/quickshell/Modules/DankBar/Widgets/NotificationCenterButton.qml b/quickshell/Modules/DankBar/Widgets/NotificationCenterButton.qml index e86490716..bbc18237c 100644 --- a/quickshell/Modules/DankBar/Widgets/NotificationCenterButton.qml +++ b/quickshell/Modules/DankBar/Widgets/NotificationCenterButton.qml @@ -35,44 +35,42 @@ BasePill { } } - onRightClicked: (rx, ry) => { + onRightClicked: { const screen = root.parentScreen || Screen; if (!screen) return; - const globalPos = root.visualContent.mapToItem(null, 0, 0); + const isVertical = root.axis?.isVertical ?? false; const edge = root.axis?.edge ?? "top"; const gap = Math.max(Theme.spacingXS, root.barSpacing ?? Theme.spacingXS); const barOffset = root.barThickness + root.barSpacing + gap; + const localPos = root.visualContent.mapToItem(null, root.visualContent.width / 2, root.visualContent.height / 2); let anchorX; let anchorY; - let anchorEdge; if (isVertical) { - anchorY = globalPos.y - (screen.y || 0) + root.visualContent.height / 2; - if (edge === "left") { - anchorX = barOffset; - anchorEdge = "top"; - } else { - anchorX = screen.width - barOffset; - anchorEdge = "top"; - } + anchorX = edge === "left" ? barOffset : screen.width - barOffset; + anchorY = localPos.y; } else { - anchorX = globalPos.x - (screen.x || 0) + root.visualContent.width / 2; - if (edge === "bottom") { - anchorY = screen.height - barOffset; - anchorEdge = "bottom"; - } else { - anchorY = barOffset; - anchorEdge = "top"; - } + anchorX = localPos.x; + anchorY = edge === "bottom" ? screen.height - barOffset : barOffset; } dndPopupLoader.active = true; const popup = dndPopupLoader.item; if (!popup) return; - popup.showAt(anchorX, anchorY, screen, anchorEdge); + + popup.showAt(anchorX, anchorY, isVertical, edge, screen); + } + + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.MiddleButton + onPressed: mouse => { + root.triggerRipple(this, mouse.x, mouse.y); + SessionData.setDoNotDisturb(!SessionData.doNotDisturb); + } } Loader { diff --git a/quickshell/Modules/Notifications/Center/DndDurationPopup.qml b/quickshell/Modules/Notifications/Center/DndDurationPopup.qml index cb2c4d7f3..e13b34de4 100644 --- a/quickshell/Modules/Notifications/Center/DndDurationPopup.qml +++ b/quickshell/Modules/Notifications/Center/DndDurationPopup.qml @@ -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()