Skip to content

Conversation

@fly602
Copy link
Contributor

@fly602 fly602 commented Dec 26, 2025

This commit replaces the kernel file-based touchpad control mechanism with a udev-based solution. The main changes include:

  1. Removed dependency on /proc/uos/touchpad_switch kernel file
  2. Implemented udev rules to control touchpad via LIBINPUT_IGNORE_DEVICE environment variable
  3. Added udev monitor to track touchpad device changes in real-time
  4. Enhanced system touchpad integration with proper DBus property synchronization
  5. Improved channel handling in transient units to prevent blocking

The new approach uses udev rules to set LIBINPUT_IGNORE_DEVICE=1 for touchpad devices when disabled, which is more reliable and portable across different kernel versions. The system now properly monitors device changes and synchronizes touchpad state between user session and system level.

Log: Touchpad control now uses udev rules instead of kernel files

Influence:

  1. Test touchpad enable/disable functionality through settings
  2. Verify touchpad state persists after reboot
  3. Test touchpad hotplug detection (plug/unplug external touchpad)
  4. Verify touchpad toggle keyboard shortcuts work correctly
  5. Test touchpad behavior when mouse is connected/disconnected
  6. Check system logs for any udev-related errors

feat: 使用 udev 替代内核文件控制触控板
PMS: BUG-342407
本次提交将基于内核文件的触控板控制机制替换为基于 udev 的解决方案。主要变
更包括:

  1. 移除对 /proc/uos/touchpad_switch 内核文件的依赖
  2. 实现 udev 规则通过 LIBINPUT_IGNORE_DEVICE 环境变量控制触控板
  3. 添加 udev 监视器实时跟踪触控板设备变化
  4. 增强系统触控板集成,实现正确的 DBus 属性同步
  5. 改进瞬态单元中的通道处理以防止阻塞

新方法使用 udev 规则在禁用触控板时设置 LIBINPUT_IGNORE_DEVICE=1,这种方 法更可靠且可在不同内核版本间移植。系统现在能正确监控设备变化并在用户会话
和系统级别之间同步触控板状态。

Log: 触控板控制现在使用 udev 规则替代内核文件

Influence:

  1. 通过设置测试触控板启用/禁用功能
  2. 验证重启后触控板状态持久化
  3. 测试触控板热插拔检测(插拔外接触控板)
  4. 验证触控板切换键盘快捷键正常工作
  5. 测试连接/断开鼠标时的触控板行为
  6. 检查系统日志中是否有 udev 相关错误

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: fly602

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @fly602, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@fly602 fly602 force-pushed the master branch 4 times, most recently from 046f3f4 to fe1472c Compare December 26, 2025 05:18
This commit replaces the kernel file-based touchpad control mechanism
with a udev-based solution. The main changes include:
1. Removed dependency on /proc/uos/touchpad_switch kernel file
2. Implemented udev rules to control touchpad via LIBINPUT_IGNORE_DEVICE
environment variable
3. Added udev monitor to track touchpad device changes in real-time
4. Enhanced system touchpad integration with proper DBus property
synchronization
5. Improved channel handling in transient units to prevent blocking

The new approach uses udev rules to set LIBINPUT_IGNORE_DEVICE=1 for
touchpad devices when disabled, which is more reliable and portable
across different kernel versions. The system now properly monitors
device changes and synchronizes touchpad state between user session and
system level.

Log: Touchpad control now uses udev rules instead of kernel files

Influence:
1. Test touchpad enable/disable functionality through settings
2. Verify touchpad state persists after reboot
3. Test touchpad hotplug detection (plug/unplug external touchpad)
4. Verify touchpad toggle keyboard shortcuts work correctly
5. Test touchpad behavior when mouse is connected/disconnected
6. Check system logs for any udev-related errors

feat: 使用 udev 替代内核文件控制触控板

本次提交将基于内核文件的触控板控制机制替换为基于 udev 的解决方案。主要变
更包括:
1. 移除对 /proc/uos/touchpad_switch 内核文件的依赖
2. 实现 udev 规则通过 LIBINPUT_IGNORE_DEVICE 环境变量控制触控板
3. 添加 udev 监视器实时跟踪触控板设备变化
4. 增强系统触控板集成,实现正确的 DBus 属性同步
5. 改进瞬态单元中的通道处理以防止阻塞

新方法使用 udev 规则在禁用触控板时设置 LIBINPUT_IGNORE_DEVICE=1,这种方
法更可靠且可在不同内核版本间移植。系统现在能正确监控设备变化并在用户会话
和系统级别之间同步触控板状态。

Log: 触控板控制现在使用 udev 规则替代内核文件
PMS: BUG-342407
Influence:
1. 通过设置测试触控板启用/禁用功能
2. 验证重启后触控板状态持久化
3. 测试触控板热插拔检测(插拔外接触控板)
4. 验证触控板切换键盘快捷键正常工作
5. 测试连接/断开鼠标时的触控板行为
6. 检查系统日志中是否有 udev 相关错误
@deepin-ci-robot
Copy link

deepin pr auto review

我来对这个 diff 进行详细的代码审查:

  1. transientunit.go 改进:
  • 优点:将无缓冲 channel 改为有缓冲 channel (buffer=1),并使用 select 防止阻塞,这是很好的改进
  • 建议:可以考虑在 defer 函数中关闭 channel,以避免潜在的 goroutine 泄漏
  1. ifc.go 改进:
  • 优点:增加了错误处理和空指针检查
  • 问题:错误消息 "system touchpad is nul" 有拼写错误,应该是 "null"
  • 建议:应该在函数开始处就检查 sysTP 是否为 nil,避免不必要的操作
  1. inputdevices_dbusutil.go 改进:
  • 优点:增加了 TPAD_ENABLE 相关的属性设置和信号发送函数
  • 建议:函数命名可以更清晰,比如 setPropTPadEnable 可以改为 setPropTouchpadEnabled
  1. mouse.go 改进:
  • 优点:简化了条件判断,直接使用 TPadEnable 而不是通过 Get() 方法
  • 建议:建议添加注释说明为什么可以直接访问 TPadEnable
  1. touchpad.go 改进:
  • 优点:
    • 使用系统端触控板状态替代 dconfig 配置
    • 增加了设备状态监听
    • 改进了错误处理
  • 问题:
    • 部分代码重复,如设备状态检查
    • 某些函数过长,建议拆分
  • 建议:
    • 添加更多注释说明状态同步机制
    • 考虑将设备监听相关代码抽取到单独的文件
  1. libinput.go 改进:
  • 优点:将错误日志级别从 Error 改为 Warning,更合理
  • 建议:可以考虑添加更多日志级别,如 Debug
  1. system/inputdevices1/touchpad.go 改进:
  • 优点:
    • 使用 udev 规则替代 proc 文件系统
    • 增加了设备监听
    • 改进了错误处理
  • 问题:
    • 新增的 udev_monitor.go 文件代码量较大,建议进一步模块化
    • 部分函数职责不够单一
  • 建议:
    • 将 udev 相关操作封装成单独的包
    • 添加单元测试
    • 考虑添加配置选项来控制 udev 规则的行为
  1. system/keyevent1/manager.go 改进:
  • 优点:
    • 简化了触控板开关逻辑
    • 移除了文件系统操作
    • 改进了错误处理
  • 建议:
    • 可以考虑添加防抖机制,避免快速切换
    • 建议添加日志记录触控板状态变化

总体建议:

  1. 增加单元测试覆盖率
  2. 添加更多注释说明关键逻辑
  3. 考虑将一些通用功能抽取到公共包
  4. 统一错误处理方式
  5. 考虑添加性能监控和日志记录
  6. 建议进行代码审查,确保代码风格一致

这些改进总体上提高了代码的健壮性和可维护性,但还有一些可以优化的空间。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants