From 630a10a05867df04ad49b02a76b0a98f212dec35 Mon Sep 17 00:00:00 2001 From: fuleyi Date: Sun, 20 Sep 2026 09:33:09 +0800 Subject: [PATCH] fix: touchpad FN key only shows OSD, no double toggle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Remove direct DBus TPadEnable toggling from dde-shortcut-tool 2. Keep OSD display (TouchpadToggle/TouchpadOn/TouchpadOff) only 3. Actual touchpad switch is handled by the system keyevent service, avoiding double-toggle that inverted the CC switch state Log: FN touchpad shortcut no longer toggles state twice; control center switch stays in sync Influence: 1. On a laptop with touchpad, press FN touchpad hotkey, verify touchpad toggles exactly once and OSD shows correct icon 2. Check control center touchpad switch matches actual touchpad state after each FN press 3. Verify touchpad enable/disable still works from control center itself fix: 触控板FN快捷键仅显示OSD,不再重复切换状态 1. 移除 dde-shortcut-tool 中直接通过 DBus 切换 TPadEnable 的逻辑 2. 保留 OSD 显示(TouchpadToggle/TouchpadOn/TouchpadOff) 3. 实际开关由系统 keyevent 服务处理,避免双重切换导致 控制中心开关状态与实际相反 Log: 触控板FN快捷键不再重复切换状态,控制中心开关保持同步 Influence: 1. 在带触控板的笔记本上按 FN 触控板快捷键,验证触控板仅切换 一次且 OSD 图标正确 2. 每次按 FN 后检查控制中心触控板开关与实际状态一致 3. 验证从控制中心直接开关触控板仍正常工作 PMS: BUG-377717 --- .../dde-shortcut-tool/touchpadcontroller.cpp | 101 +----------------- .../dde-shortcut-tool/touchpadcontroller.h | 6 +- 2 files changed, 6 insertions(+), 101 deletions(-) diff --git a/src/plugin-qt/shortcut/tools/dde-shortcut-tool/touchpadcontroller.cpp b/src/plugin-qt/shortcut/tools/dde-shortcut-tool/touchpadcontroller.cpp index 0369f930..c01a6c3e 100644 --- a/src/plugin-qt/shortcut/tools/dde-shortcut-tool/touchpadcontroller.cpp +++ b/src/plugin-qt/shortcut/tools/dde-shortcut-tool/touchpadcontroller.cpp @@ -6,33 +6,11 @@ #include #include -#include #include -TouchPadController::TouchPadController(QObject *parent) +TouchPadController::TouchPadController(QObject *parent) : BaseController(parent) - , m_touchpadInterface(nullptr) { - // Connect to touchpad service - using same path and interface as Go version - m_touchpadInterface = new QDBusInterface( - "org.deepin.dde.InputDevices1", - "/org/deepin/dde/InputDevice1/TouchPad", - "org.deepin.dde.InputDevice1.TouchPad", - QDBusConnection::sessionBus(), - this - ); - - if (!m_touchpadInterface->isValid()) { - qWarning() << "Failed to connect to TouchPad service:" - << m_touchpadInterface->lastError().message(); - } -} - -TouchPadController::~TouchPadController() -{ - if (m_touchpadInterface) { - delete m_touchpadInterface; - } } QStringList TouchPadController::commandActions() @@ -81,87 +59,18 @@ QString TouchPadController::actionHelp(const QString &action) const bool TouchPadController::toggle() { - if (!m_touchpadInterface || !m_touchpadInterface->isValid()) { - qDebug() << "Touchpad interface not available"; - return false; - } - - // Check if touchpad exists (following Go version logic) - QVariant existVariant = m_touchpadInterface->property("Exist"); - if (!existVariant.isValid()) { - qWarning() << "Failed to get touchpad exist state"; - return false; - } - - bool exist = existVariant.toBool(); - if (!exist) { - qDebug() << "Touchpad does not exist"; - return true; // Return success (nil in Go version) - } - - // Check if HandleTouchPadToggle is enabled (following Go version logic) - // Note: Currently assumes true, corresponds to globalConfig.HandleTouchPadToggle in Go version - bool handleTouchPadToggle = true; // TODO: Read from config file - - if (handleTouchPadToggle) { - // Get current state using TPadEnable property (Go version property name) - QVariant enabledVariant = m_touchpadInterface->property("TPadEnable"); - if (!enabledVariant.isValid()) { - qWarning() << "Failed to get touchpad TPadEnable state"; - return false; - } - - bool currentEnabled = enabledVariant.toBool(); - - // Set new state - bool success = m_touchpadInterface->setProperty("TPadEnable", !currentEnabled); - if (!success) { - qWarning() << "Failed to set touchpad TPadEnable state"; - return false; - } - - qDebug() << "Toggled touchpad TPadEnable from" << currentEnabled << "to" << !currentEnabled; - } - - // Toggle always shows TouchpadToggle OSD (Go version logic) + // The shortcut only shows the OSD; the actual touchpad switch is handled + // elsewhere (e.g. the system keyevent service). showOSD("TouchpadToggle"); - return true; } bool TouchPadController::setEnabled(bool enabled) { - if (!m_touchpadInterface || !m_touchpadInterface->isValid()) { - qDebug() << "Touchpad interface not available"; - return false; - } - - // Check if touchpad exists (following Go version logic) - QVariant existVariant = m_touchpadInterface->property("Exist"); - if (!existVariant.isValid()) { - qWarning() << "Failed to get touchpad exist state"; - return false; - } - - bool exist = existVariant.toBool(); - if (!exist) { - qDebug() << "Touchpad does not exist"; - return true; // Return success (nil in Go version) - } - - // Set state using TPadEnable property (Go version logic) - bool success = m_touchpadInterface->setProperty("TPadEnable", enabled); - if (!success) { - qWarning() << "Failed to set touchpad TPadEnable state"; - return false; - } - - qDebug() << "Set touchpad TPadEnable:" << enabled; - - // Show corresponding OSD (Go version logic) + // The shortcut only shows the OSD; the actual touchpad switch is handled + // elsewhere (e.g. the system keyevent service). QString osd = enabled ? "TouchpadOn" : "TouchpadOff"; showOSD(osd); - return true; } diff --git a/src/plugin-qt/shortcut/tools/dde-shortcut-tool/touchpadcontroller.h b/src/plugin-qt/shortcut/tools/dde-shortcut-tool/touchpadcontroller.h index 974e6791..b0d15558 100644 --- a/src/plugin-qt/shortcut/tools/dde-shortcut-tool/touchpadcontroller.h +++ b/src/plugin-qt/shortcut/tools/dde-shortcut-tool/touchpadcontroller.h @@ -9,14 +9,12 @@ #include -class QDBusInterface; - class TouchPadController : public BaseController { Q_OBJECT public: explicit TouchPadController(QObject *parent = nullptr); - ~TouchPadController() override; + ~TouchPadController() override = default; static QString commandName() { return "touchpad"; } static QStringList commandActions(); @@ -32,8 +30,6 @@ class TouchPadController : public BaseController bool toggle(); bool setEnabled(bool enabled); void showOSD(const QString &signal); - - QDBusInterface *m_touchpadInterface; }; #endif