Skip to content

Commit 50e8d64

Browse files
MyLeeJiEundeepin-bot[bot]
authored andcommitted
fix: simulate right-click on tray item long press
1. Add sendRightClickForSurface method to synthesize right-click events via Wayland seat for tray surfaces 2. Expose shellSurface property in PluginSurface for QML access 3. Handle long press in ShellSurfaceItemProxy TapHandler to trigger right-click on tray items 4. Handle long press in PanelTrayItem MouseArea and prevent normal click from firing after long press Log: Simulate right-click mouse events on tray items when long-pressed via touch input fix: 托盘项长按模拟右键点击 1. 新增 sendRightClickForSurface 方法,通过 Wayland seat 向托盘 表面发送右键点击事件 2. 在 PluginSurface 中暴露 shellSurface 属性供 QML 访问 3. 在 ShellSurfaceItemProxy 的 TapHandler 中处理长按,触发 托盘项右键点击 4. 在 PanelTrayItem 的 MouseArea 中处理长按并防止长按结束后 误触发普通点击 Log: 在触控长按托盘项时模拟右键点击鼠标事件 PMS: BUG-364527
1 parent 0faf4a7 commit 50e8d64

5 files changed

Lines changed: 45 additions & 1 deletion

File tree

panels/dock/DockCompositor.qml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ Item {
2323
function notifyXEmbedWindowMoveResult(wid, success) {
2424
pluginManager.notifyXEmbedWindowMoveResult(wid, success)
2525
}
26+
function sendRightClickForSurface() {
27+
pluginManager.sendRightClickForSurface()
28+
}
2629

2730
property ListModel trayPluginSurfaces: ListModel {}
2831
property ListModel quickPluginSurfaces: ListModel {}

panels/dock/pluginmanagerextension.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,3 +1008,17 @@ void PluginManager::onTextInputSurfaceEnabled(QWaylandSurface *surface)
10081008
}
10091009
}
10101010
}
1011+
1012+
void PluginManager::sendRightClickForSurface()
1013+
{
1014+
QWaylandCompositor *compositor = qobject_cast<QWaylandCompositor *>(extensionContainer());
1015+
if (!compositor)
1016+
return;
1017+
1018+
QWaylandSeat *seat = compositor->defaultSeat();
1019+
if (!seat)
1020+
return;
1021+
1022+
seat->sendMousePressEvent(Qt::RightButton);
1023+
seat->sendMouseReleaseEvent(Qt::RightButton);
1024+
}

panels/dock/pluginmanagerextension_p.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ class PluginManager : public QWaylandCompositorExtensionTemplate<PluginManager>,
7373
// result: true = success, false = error
7474
Q_INVOKABLE void notifyXEmbedWindowMoveResult(uint32_t wid, bool result);
7575

76+
// Called from QML to synthesize a right-click (mouse press + release)
77+
// on the given Wayland surface, e.g. on long press from touch input
78+
Q_INVOKABLE void sendRightClickForSurface();
79+
7680
uint32_t dockPosition() const;
7781
void setDockPosition(uint32_t dockPosition);
7882

panels/dock/tray/ShellSurfaceItemProxy.qml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ Item {
5252
}
5353
TapHandler {
5454
id: tapHandler
55+
onLongPressed: {
56+
if (tapHandler.point.device.type === PointerDevice.TouchScreen) {
57+
DockCompositor.sendRightClickForSurface()
58+
}
59+
}
5560
}
5661

5762
onVisibleChanged: function () {

panels/dock/tray/quickpanel/PanelTrayItem.qml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,24 @@ Control {
116116
MouseArea {
117117
id: mouseHandler
118118
anchors.fill: parent
119-
onClicked: root.clicked()
119+
onPressed: function (mouse) {
120+
longPressTriggered = false
121+
isTouchSource = (mouse.source !== Qt.MouseEventNotSynthesized)
122+
}
123+
onPressAndHold: {
124+
if (isTouchSource) {
125+
longPressTriggered = true
126+
DockCompositor.sendRightClickForSurface()
127+
}
128+
}
129+
onClicked: {
130+
if (!longPressTriggered) {
131+
root.clicked()
132+
}
133+
longPressTriggered = false
134+
}
135+
136+
property bool longPressTriggered: false
137+
property bool isTouchSource: false
120138
}
121139
}

0 commit comments

Comments
 (0)