From ccb04bf01dc69f21a456dcbd5920cb91f3f39e95 Mon Sep 17 00:00:00 2001 From: Lysec Date: Sun, 19 Apr 2026 09:22:16 +0200 Subject: [PATCH] fix(bar): swallow right/middle on hot strip to avoid Qt context-menu SIGSEGV --- Modules/Bar/Bar.qml | 43 +++++++++++++++++++++++---- Modules/MainScreen/BarTriggerZone.qml | 13 ++++++++ 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/Modules/Bar/Bar.qml b/Modules/Bar/Bar.qml index 51eac97ac..7d5df0861 100644 --- a/Modules/Bar/Bar.qml +++ b/Modules/Bar/Bar.qml @@ -412,7 +412,10 @@ Item { MouseArea { anchors.fill: parent acceptedButtons: Qt.RightButton | Qt.MiddleButton - enabled: bar.barRightClickAction !== "none" || Settings.data.bar.middleClickAction !== "none" + // Keep enabled even when actions are "none" so we still swallow right/middle on + // empty bar gaps. Otherwise Qt Quick's context-menu path can crash on Wayland + // (QQuickDeliveryAgentPrivate::contextMenuTargets / mapToScene). + enabled: true hoverEnabled: false preventStealing: true onClicked: mouse => { @@ -420,12 +423,14 @@ Item { if (bar.isPointOverWidget(mouse.x, mouse.y)) return; bar.handleEmptyBarClick(bar.barRightClickAction, Settings.data.bar.rightClickFollowMouse, Settings.data.bar.rightClickCommand, mouse); + mouse.accepted = true; return; } if (mouse.button === Qt.MiddleButton) { if (bar.isPointOverWidget(mouse.x, mouse.y)) return; bar.handleEmptyBarClick(Settings.data.bar.middleClickAction || "none", Settings.data.bar.middleClickFollowMouse, Settings.data.bar.middleClickCommand, mouse); + mouse.accepted = true; return; } } @@ -518,7 +523,14 @@ Item { height: Style.marginS x: 0 y: 0 - onClicked: root.triggerFirstWidgetInSection("left") + acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton + onClicked: function (mouse) { + if (mouse.button !== Qt.LeftButton) { + mouse.accepted = true; + return; + } + root.triggerFirstWidgetInSection("left"); + } } // Bottom edge hot corner - triggers last widget in right (bottom) section @@ -527,7 +539,14 @@ Item { height: Style.marginS x: 0 anchors.bottom: parent.bottom - onClicked: root.triggerLastWidgetInSection("right") + acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton + onClicked: function (mouse) { + if (mouse.button !== Qt.LeftButton) { + mouse.accepted = true; + return; + } + root.triggerLastWidgetInSection("right"); + } } // Calculate margin to center widgets vertically within the bar height @@ -625,7 +644,14 @@ Item { height: parent.height x: 0 y: 0 - onClicked: root.triggerFirstWidgetInSection("left") + acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton + onClicked: function (mouse) { + if (mouse.button !== Qt.LeftButton) { + mouse.accepted = true; + return; + } + root.triggerFirstWidgetInSection("left"); + } } // Right edge hot corner - triggers last widget in right section @@ -634,7 +660,14 @@ Item { height: parent.height anchors.right: parent.right y: 0 - onClicked: root.triggerLastWidgetInSection("right") + acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton + onClicked: function (mouse) { + if (mouse.button !== Qt.LeftButton) { + mouse.accepted = true; + return; + } + root.triggerLastWidgetInSection("right"); + } } // Calculate margin to center widgets horizontally within the bar height diff --git a/Modules/MainScreen/BarTriggerZone.qml b/Modules/MainScreen/BarTriggerZone.qml index b7a9cd58b..caf80d0f1 100644 --- a/Modules/MainScreen/BarTriggerZone.qml +++ b/Modules/MainScreen/BarTriggerZone.qml @@ -45,6 +45,19 @@ PanelWindow { id: triggerArea anchors.fill: parent hoverEnabled: true + // Default MouseArea only accepts left; right/middle would fall through to Qt Quick's + // Wayland context-menu delivery, which can SIGSEGV in contextMenuTargets/mapToScene. + acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton + + onPressed: function (mouse) { + if (mouse.button === Qt.RightButton || mouse.button === Qt.MiddleButton) + mouse.accepted = true; + } + + onClicked: function (mouse) { + if (mouse.button === Qt.RightButton || mouse.button === Qt.MiddleButton) + mouse.accepted = true; + } onEntered: { if (root.isBeingDestroyed)