Skip to content

Commit 2c2921f

Browse files
fly602deepin-bot[bot]
authored andcommitted
fix: disable context menu on right click
1. Remove right-click and touch long-press context menu behavior from the windowed icon delegate. 2. Simplify input handling in IconItemDelegate by consolidating interactions into MouseArea events and removing the extra TapHandler- based menu/click logic. 3. Keep left-click activation behavior intact, while allowing right- button events to be received without triggering duplicated or unintended handling paths. 4. Preserve drag image generation only for left-button press when drag- and-drop is enabled. 5. Adjust launcher item input handling to use TapHandler for mouse buttons and a separate touchscreen TapHandler for tap activation, avoiding the previous event-order issue noted in the comment. 6. These changes were necessary to match the updated interaction requirement that right mouse click and touchscreen long press should no longer show a context menu, while also reducing conflicting event processing between MouseArea and TapHandler. Influence: 1. Verify left-click on an icon still opens or activates the target item normally. 2. Verify right-click on a windowed icon does not show a context menu and does not trigger unintended actions. 3. Verify long-press on a touchscreen icon does not show a context menu. 4. Verify drag-and-drop still works correctly when pressing and dragging with the left mouse button. 5. Verify launcher toggling still works with mouse left-click. 6. Verify launcher toggling still works with touchscreen tap. 7. Regression test mixed input scenarios to ensure MouseArea and TapHandler no longer produce duplicate triggers or incorrect state changes. fix: 禁用右键上下文菜单弹出 1. 移除窗口模式图标代理中的右键和触控长按上下文菜单行为。 2. 简化 IconItemDelegate 的输入处理逻辑,将交互集中到 MouseArea 事件中, 并移除额外基于 TapHandler 的菜单/点击处理逻辑。 3. 保持左键激活行为不变,同时允许接收右键事件,但避免触发重复或非预期的 处理路径。 4. 仅在启用拖拽时的左键按下场景下保留拖拽预览图生成逻辑。 5. 调整 launcheritem 的输入处理,改为使用 TapHandler 处理鼠标按键,并增 加独立的触摸屏 TapHandler 处理点击激活,以规避注释中提到的事件顺序问题。 6. 这些修改是为了满足新的交互要求:鼠标右键和触控屏长按都不再弹出右键菜 单,同时减少 MouseArea 与 TapHandler 并存时的事件冲突。 Influence: 1. 验证左键点击图标后仍能正常打开或激活目标项。 2. 验证右键点击窗口模式图标时不会弹出右键菜单,且不会触发非预期操作。 3. 验证触控屏长按图标时不会弹出右键菜单。 4. 验证使用鼠标左键按下并拖动时,拖拽功能仍然正常。 5. 验证使用鼠标左键点击时,启动器开关功能仍然正常。 6. 验证使用触控屏点击时,启动器开关功能仍然正常。 7. 回归测试混合输入场景,确保 MouseArea 与 TapHandler 不会再产生重复触发 或状态异常。 PMS: BUG-358827 Change-Id: I29e423fa5fa40dd3165417118756d3b143a5fb2d
1 parent 1abad99 commit 2c2921f

2 files changed

Lines changed: 25 additions & 53 deletions

File tree

qml/windowed/IconItemDelegate.qml

Lines changed: 10 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -49,48 +49,27 @@ Control {
4949
id: mouseArea
5050
anchors.fill: parent
5151
hoverEnabled: false
52-
acceptedButtons: Qt.LeftButton
5352
enabled: true
53+
acceptedButtons: Qt.LeftButton | Qt.RightButton
5454
drag.target: root.dndEnabled ? root : null
55-
56-
// 记录是否是触摸长按导致的,防止在 onClicked 中重复处理
57-
property bool isTouchLongPressed: false
58-
59-
TapHandler {
60-
acceptedDevices: PointerDevice.TouchScreen
61-
gesturePolicy: TapHandler.DragThreshold
62-
onLongPressed: {
63-
mouseArea.isTouchLongPressed = true
64-
root.menuTriggered()
65-
}
66-
}
67-
6855
onPressed: function (mouse) {
69-
if (mouse.button !== Qt.LeftButton) {
70-
mouse.accepted = false
71-
return
72-
}
73-
isTouchLongPressed = false
74-
if (root.dndEnabled) {
56+
if (mouse.button === Qt.LeftButton && root.dndEnabled) {
7557
appIcon.grabToImage(function(result) {
7658
root.Drag.imageSource = result.url;
7759
})
7860
}
7961
}
80-
onClicked: function(mouse) {
81-
if (isTouchLongPressed) {
82-
isTouchLongPressed = false
83-
return
84-
}
85-
86-
if (mouse.button !== Qt.LeftButton) {
87-
return
88-
}
89-
90-
if (!drag.active) {
62+
onPressAndHold: function (mouse) {
63+
root.menuTriggered()
64+
}
65+
onClicked: function (mouse) {
66+
if (mouse.button === Qt.LeftButton) {
9167
root.itemClicked()
68+
} else if (mouse.button === Qt.RightButton) {
69+
root.menuTriggered()
9270
}
9371
}
72+
9473
}
9574
contentItem: Column {
9675
anchors.fill: parent
@@ -154,21 +133,6 @@ Control {
154133
}
155134
background: DebugBounding { }
156135

157-
TapHandler {
158-
acceptedButtons: Qt.RightButton
159-
onTapped: {
160-
root.menuTriggered()
161-
}
162-
}
163-
164-
TapHandler {
165-
acceptedButtons: Qt.LeftButton
166-
gesturePolicy: TapHandler.WithinBounds
167-
onTapped: {
168-
root.itemClicked()
169-
}
170-
}
171-
172136
Keys.onSpacePressed: {
173137
root.itemClicked()
174138
}

shell-launcher-applet/package/launcheritem.qml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -379,17 +379,25 @@ AppletItem {
379379
}
380380
}
381381

382-
// FIXME: The TapHandler receives the event after visibleChange, which causes the state to be inverted after synchronization,
383-
// causing the launchpad to be displayed again. However, the MouseArea receives the event before visibleChange.
384-
MouseArea {
385-
id: mouseHandler
386-
anchors.fill: parent
387-
onClicked: function (mouse) {
388-
if (mouse.button === Qt.LeftButton) {
382+
TapHandler {
383+
id: tapHandler
384+
acceptedButtons: Qt.LeftButton | Qt.RightButton
385+
gesturePolicy: TapHandler.WithinBounds
386+
onTapped: function (eventPoint, buttons) {
387+
if (buttons === Qt.LeftButton) {
389388
toggleLauncher()
390389
}
391390
}
392391
}
392+
393+
TapHandler {
394+
acceptedButtons: Qt.NoButton
395+
acceptedDevices: PointerDevice.TouchScreen
396+
gesturePolicy: TapHandler.WithinBounds
397+
onTapped: function (eventPoint, buttons) {
398+
toggleLauncher()
399+
}
400+
}
393401
HoverHandler {
394402
onHoveredChanged: {
395403
if (hovered) {

0 commit comments

Comments
 (0)