Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR extends touchpad initialization logic to support PS-type mouse devices that behave like touchpads, refines the libinput usage detection, updates copyright years, and refreshes key module dependencies. Sequence diagram for NewTouchpadFromDevInfo initialization with PS mouse supportsequenceDiagram
actor Caller
participant TouchpadPkg as TouchpadPackage
participant DevInfo as DeviceInfo
participant Utils as Utils
Caller->>TouchpadPkg: NewTouchpadFromDevInfo(dev)
alt dev is nil or (dev.Type not DevTypeTouchpad and not DevTypeMouse)
TouchpadPkg-->>Caller: error Not a touchpad device
else dev.Type is DevTypeTouchpad or DevTypeMouse
TouchpadPkg->>Utils: IsPropertyExist(dev.Id, libinputPropTapEnabled)
Utils-->>TouchpadPkg: isLibinputUsed
alt not isLibinputUsed and dev.Type is DevTypeMouse
TouchpadPkg->>Utils: IsPropertyExist(dev.Id, libinputPropButtonScrollingButton)
Utils-->>TouchpadPkg: isLibinputUsedUpdated
end
TouchpadPkg-->>Caller: *Touchpad with isLibinputUsed
end
Class diagram for Touchpad and DeviceInfo with updated initializationclassDiagram
class DeviceInfo {
int32 Id
string Name
int Type
}
class Touchpad {
int32 Id
string Name
bool isLibinputUsed
+NewTouchpad(id int32) Touchpad, error
+NewTouchpadFromDevInfo(dev *DeviceInfo) Touchpad, error
}
class Utils {
+IsPropertyExist(deviceId int32, property string) bool
}
class DevType {
<<enumeration>>
DevTypeTouchpad
DevTypeMouse
}
class LibinputProperties {
<<static>>
libinputPropTapEnabled
libinputPropButtonScrollingButton
}
DeviceInfo --> DevType : has
Touchpad --> DeviceInfo : constructed_from
Touchpad --> Utils : uses
Touchpad --> LibinputProperties : checks_properties
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:
- In
NewTouchpadFromDevInfo, the error branch still dereferencesdeveven when it may be nil (dev == nil || ...), so split the nil check and return early to avoid a potential panic. - Since
DevTypeMouseis now accepted, consider adjusting the error message inNewTouchpadFromDevInfo("Not a touchpad device") to better reflect the broader set of supported device types for easier debugging.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `NewTouchpadFromDevInfo`, the error branch still dereferences `dev` even when it may be nil (`dev == nil || ...`), so split the nil check and return early to avoid a potential panic.
- Since `DevTypeMouse` is now accepted, consider adjusting the error message in `NewTouchpadFromDevInfo` ("Not a touchpad device") to better reflect the broader set of supported device types for easier debugging.
## Individual Comments
### Comment 1
<location path="dxinput/touchpad.go" line_range="56-57" />
<code_context>
func NewTouchpadFromDevInfo(dev *DeviceInfo) (*Touchpad, error) {
- if dev == nil || dev.Type != DevTypeTouchpad {
- return nil, fmt.Errorf("Not a touchpad device(%d - %s)", dev.Id, dev.Name)
+ if dev == nil || (dev.Type != DevTypeTouchpad && dev.Type != DevTypeMouse) {
+ return nil, fmt.Errorf("Not a touchpad device(%d - %s), type: %v", dev.Id, dev.Name, dev.Type)
+ }
+
</code_context>
<issue_to_address>
**issue (bug_risk):** Guard clause dereferences dev when it may be nil, leading to a potential panic.
Because `dev` can be nil in this branch, formatting the error string still dereferences `dev.Id`, `dev.Name`, and `dev.Type`, which will panic. Please handle the `dev == nil` case separately (e.g., with a simpler error) or only build the detailed error when `dev != nil`.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
适配PS鼠标类型的触控板 Log: PMS: BUG-352421 Influence: 输入设备-触控板
deepin pr auto review这段代码主要是对触摸板( 1. 代码逻辑审查变更点:
2. 代码质量与规范
3. 代码性能
4. 代码安全
5. 依赖管理
总结与建议
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: fly602, mhduiy 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 |
适配PS鼠标类型的触控板
Log:
PMS: BUG-352421
Influence: 输入设备-触控板
Summary by Sourcery
Extend touchpad handling to support PS-type mouse touchpads and update related dependencies.
New Features:
Bug Fixes:
Enhancements: