fix(bar): swallow right/middle on hot strip to avoid Qt context-menu SIGSEGV

This commit is contained in:
Lysec
2026-04-19 09:22:16 +02:00
parent b452772feb
commit ccb04bf01d
2 changed files with 51 additions and 5 deletions
+38 -5
View File
@@ -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
+13
View File
@@ -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)