Skip to content

Commit fc12bbe

Browse files
committed
fix: prevent touchscreen right-click context menu
Modified notification view delegate to check for touchscreen device type before showing context menu on right-click. Added PointerDevice.TouchScreen type check to both TapHandler instances in the DelegateChooser. The previous implementation would trigger context menu on right-click gestures from touchscreen devices, which was unintended behavior. Touchscreen right-clicks are typically long-press gestures that should not open the same context menu as mouse right-clicks. This change ensures context menus only appear when using mouse input devices. Influence: 1. Test right-click with mouse on notification items - context menu should appear 2. Test long-press/touch gestures on touchscreen devices - context menu should not appear 3. Verify regular left-click functionality remains unchanged 4. Test touchscreen interactions with other gestures to ensure no regression PMS: BUG-355017
1 parent 79ee98f commit fc12bbe

File tree

6 files changed

+52
-14
lines changed

6 files changed

+52
-14
lines changed

panels/notification/center/GroupNotify.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ NotifyItem {
106106
onClicked: function () {
107107
console.log("group setting", root.appName)
108108
let pos = mapToItem(root, Qt.point(width / 2, height))
109-
root.setting(pos)
109+
root.setting(pos, false)
110110
}
111111
}
112112
AnimationSettingButton {

panels/notification/center/NotifySettingMenu.qml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,35 @@ Menu {
1313
closePolicy: Popup.CloseOnPressOutside | Popup.CloseOnEscape
1414
modal: true
1515

16-
function toggle()
16+
Timer {
17+
id: closePolicyTimer
18+
interval: 1000
19+
onTriggered: {
20+
if (root.visible) {
21+
root.closePolicy = Popup.CloseOnPressOutside | Popup.CloseOnEscape
22+
}
23+
}
24+
}
25+
26+
function toggle(isTouch)
1727
{
1828
if (!visible) {
1929
console.log("Open menu")
30+
if (isTouch) {
31+
closePolicy = Popup.CloseOnEscape
32+
}
2033
open()
34+
if (isTouch) {
35+
closePolicyTimer.restart()
36+
}
2137
} else {
2238
console.log("Close menu")
2339
close()
2440
}
2541
}
42+
43+
onClosed: {
44+
closePolicyTimer.stop()
45+
closePolicy = Popup.CloseOnPressOutside | Popup.CloseOnEscape
46+
}
2647
}

panels/notification/center/NotifyView.qml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ Control {
128128
id: notifyDelegate
129129
notifyModel: root.notifyModel
130130
view: view
131-
onSetting: function (pos, params) {
131+
onSetting: function (pos, params, isTouch) {
132132
let appName = params.appName
133133
let pinned = params.pinned
134134
notifySetting.x = pos.x - notifySetting.width / 2
@@ -137,7 +137,7 @@ Control {
137137
notifySetting.pinned = pinned
138138

139139
console.log("setting", appName, pinned)
140-
notifySetting.toggle();
140+
notifySetting.toggle(isTouch);
141141
}
142142
}
143143
add: Transition {

panels/notification/center/NotifyViewDelegate.qml

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ DelegateChooser {
1414
required property NotifyModel notifyModel
1515
required property Item view
1616

17-
signal setting(var pos, var params)
17+
signal setting(var pos, var params, bool isTouch)
1818

1919
role: "type"
2020

@@ -74,12 +74,12 @@ DelegateChooser {
7474
root.view.requestFocusOnExpand(collapseIndex)
7575
}
7676

77-
onSetting: function (pos) {
77+
onSetting: function (pos, isTouch) {
7878
let tmp = mapToItem(root.view, pos)
7979
root.setting(tmp, {
8080
appName: model.appName,
8181
pinned: model.pinned
82-
})
82+
}, isTouch)
8383
}
8484
onRemove: function () {
8585
console.log("remove group", model.appName)
@@ -116,18 +116,20 @@ DelegateChooser {
116116
acceptedButtons: Qt.RightButton
117117
onPressedChanged: function () {
118118
if (pressed) {
119+
if (point.device.type === PointerDevice.TouchScreen)
120+
return
119121
let pos = point.position
120-
setting(pos)
122+
setting(pos, false)
121123
}
122124
}
123125
}
124126

125-
onSetting: function (pos) {
127+
onSetting: function (pos, isTouch) {
126128
let tmp = mapToItem(root.view, pos)
127129
root.setting(tmp, {
128130
appName: model.appName,
129131
pinned: model.pinned
130-
})
132+
}, isTouch)
131133
}
132134
onRemove: function () {
133135
console.log("remove normal", model.id)
@@ -201,12 +203,26 @@ DelegateChooser {
201203
acceptedButtons: Qt.RightButton
202204
onPressedChanged: function () {
203205
if (pressed) {
206+
if (point.device.type === PointerDevice.TouchScreen)
207+
return
204208
let pos = point.position
205-
setting(pos)
209+
setting(pos, false)
206210
}
207211
}
208212
}
209213

214+
TapHandler {
215+
acceptedDevices: PointerDevice.TouchScreen
216+
onTapped: {
217+
overlapNotify.forceActiveFocus()
218+
overlapNotify.expand()
219+
}
220+
onLongPressed: {
221+
let pos = point.position
222+
setting(pos, true)
223+
}
224+
}
225+
210226
onExpand: function ()
211227
{
212228
console.log("expand")
@@ -215,12 +231,12 @@ DelegateChooser {
215231
root.view.jiggleUpdate()
216232
root.view.requestFocusOnExpand(expandIndex + 1)
217233
}
218-
onSetting: function (pos) {
234+
onSetting: function (pos, isTouch) {
219235
let tmp = mapToItem(root.view, pos)
220236
root.setting(tmp, {
221237
appName: model.appName,
222238
pinned: model.pinned
223-
})
239+
}, isTouch)
224240
}
225241
onRemove: function () {
226242
console.log("remove overlap", model.appName)

panels/notification/center/OverlapNotify.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ NotifyItem {
187187
TapHandler {
188188
enabled: !root.enableDismissed
189189
acceptedButtons: Qt.LeftButton
190+
acceptedDevices: PointerDevice.Mouse
190191
onTapped: {
191192
root.forceActiveFocus()
192193
root.expand()

panels/notification/plugin/NotifyItem.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ FocusScope {
3636

3737
signal remove()
3838
signal dismiss()
39-
signal setting(var pos)
39+
signal setting(var pos, bool isTouch)
4040
signal actionInvoked(var actionId)
4141
signal linkActivated(var link)
4242

0 commit comments

Comments
 (0)