Skip to content

Conversation

@waterlovemelon
Copy link
Contributor

有些厂商系统,未默认设置触控点击属性,致使greeter界面点击无效

Log: 修复greeter触控点击异常异常问题
Bug: https://pms.uniontech.com/task-view-368567.html Influence: 触控屏
Change-Id: I3ed0d90831ac8f849937982ba47e46bad8258e6f (cherry picked from commit ebb83b33e62ac41d4428977d1055755bd2d46696)

有些厂商系统,未默认设置触控点击属性,致使greeter界面点击无效

Log: 修复greeter触控点击异常异常问题
Bug: https://pms.uniontech.com/task-view-368567.html
Influence: 触控屏
Change-Id: I3ed0d90831ac8f849937982ba47e46bad8258e6f
(cherry picked from commit ebb83b33e62ac41d4428977d1055755bd2d46696)
deepin-ci-robot added a commit to linuxdeepin/dde-session-shell-snipe that referenced this pull request Jul 17, 2025
Synchronize source files from linuxdeepin/dde-session-shell.

Source-pull-request: linuxdeepin/dde-session-shell#28
@deepin-ci-robot
Copy link

deepin pr auto review

代码审查意见如下:

  1. 代码可读性

    • dbus_values_get_stringsdbus_values_get_bool函数中,使用grep -oPawk命令来提取和转换字符串,这种做法虽然有效,但不够直观。建议使用更明确的正则表达式来提高代码的可读性。
    • device_handle函数中,dbus_touchpad变量名不够直观,建议使用更具描述性的变量名,如dbus_touchpad_value
  2. 错误处理

    • device_handle函数中,没有对dbus-send命令的执行结果进行检查。如果命令执行失败,可能会导致后续逻辑错误。建议添加错误处理机制,例如检查命令的退出状态码。
  3. 性能优化

    • for循环中,每次迭代都会创建一个新的字符串变量path,这可能会导致不必要的内存分配。建议在循环外部预先创建好path变量,并在循环中直接使用。
  4. 安全性

    • dbus-send命令中,直接使用外部输入input变量,可能会导致命令注入攻击。建议对输入进行适当的验证和清理。
  5. 代码重复

    • dbus_values_get_stringsdbus_values_get_bool函数中的正则表达式和命令行工具可以合并,以减少代码重复。
  6. 注释

    • 函数dbus_values_get_stringsdbus_values_get_bool缺少注释说明函数的用途和参数说明。

综合以上意见,改进后的代码可能如下:

#在满足条件下,设置tapToClick=true
#解析dbus信息输出
dbus_values_get_strings(){
    local input="$1"
    echo "$input" | grep -oP 'string \K".*?"' | tr -d '"'
}

dbus_values_get_bool(){
    local input="$1"
    echo "$input" | grep -oP 'boolean \K(true|false)'
}

#判断并设置设备属性
device_handle(){
    local input="$1"
    local dbus_touchpad_value=$(dbus-send --session --print-reply --dest=org.kde.KWin $input org.freedesktop.DBus.Properties.Get string:"org.kde.KWin.InputDevice" string:"touchpad" 2>/dev/null)
    if [ $? -ne 0 ]; then
        echo "Failed to get touchpad property for $input"
        return 1
    fi

    local touchpad=$(dbus_values_get_bool "$dbus_touchpad_value")
    if [ "$touchpad" = "true" ]; then
        dbus-send --session --dest=org.kde.KWin "$input" org.freedesktop.DBus.Properties.Set string:"org.kde.KWin.InputDevice" string:"tapToClick" variant:boolean:true 2>/dev/null
        if [ $? -ne 0 ]; then
            echo "Failed to set tapToClick property for $input"
            return 1
        fi
    fi
}

#获取设备列表
dbus_devices=$(dbus-send --session --print-reply --dest=org.kde.KWin /org/kde/KWin/InputDevice org.freedesktop.DBus.Properties.Get string:"org.kde.KWin.InputDeviceManager" string:"devicesSysNames" 2>/dev/null)
if [ $? -ne 0 ]; then
    echo "Failed to get devices list"
    exit 1
fi

devices_strings=$(dbus_values_get_strings "$dbus_devices")

#遍历设备列表
device_path="/org/kde/KWin/InputDevice/"
for dev in $devices_strings; do
    path="${device_path}${dev}"
    device_handle "$path"
done

以上改进包括错误处理、性能优化、安全性增强和代码可读性的提升。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: waterlovemelon, yixinshark

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

@waterlovemelon
Copy link
Contributor Author

/merge

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Jul 17, 2025

This pr cannot be merged! (status: unstable)

@waterlovemelon
Copy link
Contributor Author

/forcemerge

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Jul 17, 2025

This pr force merged! (status: unstable)

@deepin-bot deepin-bot bot merged commit bc7259f into linuxdeepin:master Jul 17, 2025
14 of 15 checks passed
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.

3 participants