feat: Add support for modifying the plugin popup cursor shape via the…#1434
feat: Add support for modifying the plugin popup cursor shape via the…#1434yixinshark wants to merge 1 commit intolinuxdeepin:masterfrom
Conversation
Reviewer's GuideAdds protocol and implementation support for plugin popups to request cursor shape changes, plumbing the request from the Wayland plugin manager extension through to the QML shell surface proxy and exposing it as a cursorShape property with bounds checking. Sequence diagram for plugin popup cursor shape update flowsequenceDiagram
actor PluginClient
participant WaylandPluginProtocol
participant PluginPopup
participant ShellSurfaceItemProxy_qml as ShellSurfaceItemProxy
participant HoverHandler_qml as HoverHandler
PluginClient->>WaylandPluginProtocol: plugin_popup_set_cursor(cursor_shape)
WaylandPluginProtocol->>PluginPopup: plugin_popup_set_cursor(resource, cursor_shape)
PluginPopup->>PluginPopup: plugin_popup_set_cursor(resource, cursor_shape)
PluginPopup-->>ShellSurfaceItemProxy_qml: cursorShapeRequested(cursor_shape)
ShellSurfaceItemProxy_qml->>ShellSurfaceItemProxy_qml: onCursorShapeRequested(cursor_shape)
ShellSurfaceItemProxy_qml->>ShellSurfaceItemProxy_qml: validate cursor_shape range 0-21,24,25
alt cursor_shape out of range
ShellSurfaceItemProxy_qml->>ShellSurfaceItemProxy_qml: root.cursorShape = Qt.ArrowCursor
else cursor_shape in range
ShellSurfaceItemProxy_qml->>ShellSurfaceItemProxy_qml: root.cursorShape = cursor_shape
end
ShellSurfaceItemProxy_qml->>HoverHandler_qml: cursorShape = root.cursorShape
Class diagram for PluginPopup and ShellSurfaceItemProxy cursor shape supportclassDiagram
class PluginPopup {
+plugin_popup_source_size(resource: Resource, width: int32_t, height: int32_t)
+plugin_popup_set_cursor(resource: Resource, cursor_shape: int32_t)
+plugin_popup_destroy_resource(resource: Resource)
+plugin_popup_destroy(resource: Resource)
+cursorShapeRequested(cursorShape: int)
-m_manager: PluginManager*
}
class ShellSurfaceItemProxy {
+inputEventsEnabled: bool
+hovered: bool
+pressed: bool
+cursorShape: int
+onCursorShapeRequested(cursorShape: int)
}
class HoverHandler_qml {
+hovered: bool
+cursorShape: int
}
ShellSurfaceItemProxy --> HoverHandler_qml: sets cursorShape
PluginPopup --> ShellSurfaceItemProxy: emits cursorShapeRequested
Flow diagram for cursorShape bounds checking in ShellSurfaceItemProxyflowchart TD
A[onCursorShapeRequested cursorShape param received] --> B[Check if cursorShape < 0 or cursorShape > 25]
B -->|yes| C[Set root.cursorShape to Qt.ArrowCursor]
B -->|no| D[Set root.cursorShape to cursorShape]
C --> E[HoverHandler.cursorShape uses root.cursorShape]
D --> E[HoverHandler.cursorShape uses root.cursorShape]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The
onCursorShapeRequestedhandler inShellSurfaceItemProxy.qmlis currently just a standalone function; unless it is explicitly connected to thePluginPopup::cursorShapeRequestedsignal elsewhere, this callback will never run—consider wiring the signal to this handler or using aConnectionsobject in the QML to make the linkage explicit. - The
console.log("onCursorShapeRequested:", cursorShape)in QML will spam logs on every cursor update; consider removing it or guarding it behind a runtime debug flag to avoid excessive logging in normal operation.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `onCursorShapeRequested` handler in `ShellSurfaceItemProxy.qml` is currently just a standalone function; unless it is explicitly connected to the `PluginPopup::cursorShapeRequested` signal elsewhere, this callback will never run—consider wiring the signal to this handler or using a `Connections` object in the QML to make the linkage explicit.
- The `console.log("onCursorShapeRequested:", cursorShape)` in QML will spam logs on every cursor update; consider removing it or guarding it behind a runtime debug flag to avoid excessive logging in normal operation.
## Individual Comments
### Comment 1
<location> `panels/dock/tray/ShellSurfaceItemProxy.qml:117-122` </location>
<code_context>
})
}
+
+ function onCursorShapeRequested(cursorShape)
+ {
+ console.log("onCursorShapeRequested:", cursorShape)
+ // Qt::CursorShape range is 0-21, plus 24 (BitmapCursor) and 25 (CustomCursor).
+ // We set a default if the value is out of logical bounds.
+ if (cursorShape < 0 || cursorShape > 25) {
+ root.cursorShape = Qt.ArrowCursor
+ } else {
</code_context>
<issue_to_address>
**issue (bug_risk):** The cursorShape bounds check lets invalid enum values 22 and 23 through.
The check only filters values < 0 or > 25, so 22 and 23 are still accepted even though the comment marks them as invalid. If Wayland ever sends 22 or 23, this could cause undefined cursor behavior. Please tighten the condition to only accept 0–21, 24, and 25 (e.g. `if ((cursorShape >= 0 && cursorShape <= 21) || cursorShape == 24 || cursorShape == 25)`), or map any other value to a safe default.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
linuxdeepin/dde-tray-loader#424 |
… protocol. add support in plugin-manager-v1.xml Log: Add support for modifying the plugin popup cursor shape via the protocol.
a8691e7 to
1447b43
Compare
deepin pr auto review这段代码主要实现了在 Wayland 协议下,插件弹窗(PluginPopup)支持动态设置鼠标光标形状的功能。整体来看,代码逻辑清晰,能够实现预期功能。但在代码质量、健壮性和安全性方面,仍有改进空间。 以下是详细的审查意见和改进建议: 1. 依赖版本控制 (
|
| void yChanged(); | ||
| void heightChanged(); | ||
| void widthChanged(); | ||
| void cursorShapeRequested(int cursorShape); |
There was a problem hiding this comment.
这里要不要再加个cursorShape属性,导出到qml中,
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, yixinshark The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
TAG Bot New tag: 2.0.29 |
There was a problem hiding this comment.
Pull request overview
This PR adds support for plugin popups to request cursor shape changes via the Wayland protocol. The feature allows plugins to communicate their desired cursor shape to the compositor, which then updates the UI accordingly.
Changes:
- Added protocol support for cursor shape requests in plugin popups
- Implemented cursor shape handling in the QML UI layer with validation
- Updated dependency version to require protocol support in dde-tray-loader-dev
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| panels/dock/tray/ShellSurfaceItemProxy.qml | Added cursorShape property and signal handler to process cursor shape requests from plugins |
| panels/dock/pluginmanagerextension_p.h | Declared new protocol method and signal for cursor shape requests |
| panels/dock/pluginmanagerextension.cpp | Implemented plugin_popup_set_cursor to emit cursorShapeRequested signal |
| debian/control | Updated dde-tray-loader-dev dependency to require version > 2.0.24 for protocol support |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (cursorShape < 0 || cursorShape > 25) { | ||
| root.cursorShape = Qt.ArrowCursor | ||
| } else { | ||
| root.cursorShape = cursorShape | ||
| } |
There was a problem hiding this comment.
The validation logic allows cursor shape values 22 and 23, which are not valid Qt cursor shapes. According to the comment on line 120-121, Qt::CursorShape has values 0-21, then 24-25, with a gap at 22-23. The validation should explicitly exclude these invalid values to prevent potential rendering issues. Consider checking if the value is in the valid ranges: (cursorShape >= 0 && cursorShape <= 21) || cursorShape == 24 || cursorShape == 25.
… protocol.
add support in plugin-manager-v1.xml
Log: Add support for modifying the plugin popup cursor shape via the protocol.
Summary by Sourcery
Add protocol and UI support for plugin popups to request and update the cursor shape.
New Features: