diff --git a/kcms/touchpad/src/backends/kwin_wayland/kwinwaylandtouchpad.h b/kcms/touchpad/src/backends/kwin_wayland/kwinwaylandtouchpad.h --- a/kcms/touchpad/src/backends/kwin_wayland/kwinwaylandtouchpad.h +++ b/kcms/touchpad/src/backends/kwin_wayland/kwinwaylandtouchpad.h @@ -102,6 +102,15 @@ Q_PROPERTY(quint32 defaultScrollButton READ defaultScrollButton CONSTANT) Q_PROPERTY(quint32 scrollButton READ scrollButton WRITE setScrollButton NOTIFY scrollButtonChanged) + // Click Methods + Q_PROPERTY(bool supportsClickMethodAreas READ supportsClickMethodAreas CONSTANT) + Q_PROPERTY(bool defaultClickMethodAreas READ defaultClickMethodAreas CONSTANT) + Q_PROPERTY(bool clickMethodAreas READ isClickMethodAreas WRITE setClickMethodAreas NOTIFY clickMethodChanged) + + Q_PROPERTY(bool supportsClickMethodClickfinger READ supportsClickMethodClickfinger CONSTANT) + Q_PROPERTY(bool defaultClickMethodClickfinger READ defaultClickMethodClickfinger CONSTANT) + Q_PROPERTY(bool clickMethodClickfinger READ isClickMethodClickfinger WRITE setClickMethodClickfinger NOTIFY clickMethodChanged) + public: KWinWaylandTouchpad(QString dbusName); ~KWinWaylandTouchpad() override; @@ -328,6 +337,32 @@ void setScrollButton(quint32 button) { m_scrollButton.set(button); } + + bool supportsClickMethodAreas() const { + return m_supportsClickMethodAreas.val; + } + bool defaultClickMethodAreas() const { + return m_defaultClickMethodAreas.val; + } + bool isClickMethodAreas() const { + return m_clickMethodAreas.val; + } + void setClickMethodAreas(bool set) { + m_clickMethodAreas.set(set); + } + + bool supportsClickMethodClickfinger() const { + return m_supportsClickMethodClickfinger.val; + } + bool defaultClickMethodClickfinger() const { + return m_defaultClickMethodClickfinger.val; + } + bool isClickMethodClickfinger() const { + return m_clickMethodClickfinger.val; + } + void setClickMethodClickfinger(bool set) { + m_clickMethodClickfinger.set(set); + } Q_SIGNALS: void leftHandedChanged(); @@ -343,6 +378,7 @@ void naturalScrollChanged(); void scrollMethodChanged(); void scrollButtonChanged(); + void clickMethodChanged(); private: template @@ -451,6 +487,14 @@ Prop m_defaultScrollButton = Prop("defaultScrollButton"); Prop m_scrollButton = Prop("scrollButton"); + Prop m_supportsClickMethodAreas = Prop("supportsClickMethodAreas"); + Prop m_defaultClickMethodAreas = Prop("defaultClickMethodAreas"); + Prop m_clickMethodAreas = Prop("clickMethodAreas"); + + Prop m_supportsClickMethodClickfinger = Prop("supportsClickMethodClickfinger"); + Prop m_defaultClickMethodClickfinger = Prop("defaultClickMethodClickfinger"); + Prop m_clickMethodClickfinger = Prop("clickMethodClickfinger"); + QDBusInterface *m_iface; }; diff --git a/kcms/touchpad/src/backends/kwin_wayland/kwinwaylandtouchpad.cpp b/kcms/touchpad/src/backends/kwin_wayland/kwinwaylandtouchpad.cpp --- a/kcms/touchpad/src/backends/kwin_wayland/kwinwaylandtouchpad.cpp +++ b/kcms/touchpad/src/backends/kwin_wayland/kwinwaylandtouchpad.cpp @@ -123,6 +123,13 @@ success &= valueLoader(m_isScrollEdge); success &= valueLoader(m_isScrollOnButtonDown); success &= valueLoader(m_scrollButton); + // click methods + success &= valueLoader(m_supportsClickMethodAreas); + success &= valueLoader(m_supportsClickMethodClickfinger); + success &= valueLoader(m_defaultClickMethodAreas); + success &= valueLoader(m_defaultClickMethodClickfinger); + success &= valueLoader(m_clickMethodAreas); + success &= valueLoader(m_clickMethodClickfinger); return success; } @@ -148,6 +155,9 @@ m_isScrollEdge.set(m_scrollEdgeEnabledByDefault); m_isScrollOnButtonDown.set(m_scrollOnButtonDownEnabledByDefault); + m_clickMethodAreas.set(m_defaultClickMethodAreas); + m_clickMethodClickfinger.set(m_defaultClickMethodClickfinger); + return true; } @@ -173,7 +183,10 @@ << valueWriter(m_isScrollTwoFinger) << valueWriter(m_isScrollEdge) << valueWriter(m_isScrollOnButtonDown) - << valueWriter(m_scrollButton); + << valueWriter(m_scrollButton) + + << valueWriter(m_clickMethodAreas) + << valueWriter(m_clickMethodClickfinger); bool success = true; QString error_msg; @@ -212,7 +225,9 @@ m_isScrollTwoFinger.changed() || m_isScrollEdge.changed() || m_isScrollOnButtonDown.changed() || - m_scrollButton.changed(); + m_scrollButton.changed() || + m_clickMethodAreas.changed() || + m_clickMethodClickfinger.changed(); } template diff --git a/kcms/touchpad/src/kcm/libinput/main.qml b/kcms/touchpad/src/kcm/libinput/main.qml --- a/kcms/touchpad/src/kcm/libinput/main.qml +++ b/kcms/touchpad/src/kcm/libinput/main.qml @@ -74,6 +74,8 @@ multiTap.load() scrollMethod.load() naturalScroll.load() + rightClickMethod.load() + middleClickMethod.load() loading = false } @@ -219,6 +221,9 @@ touchpad.middleEmulation = checked root.changeSignal() } + loading = true + middleClickMethod.load() + loading = false } } @@ -562,5 +567,149 @@ delay: 1000 } } + + Item { + Kirigami.FormData.isSection: false + } + + Layouts.ColumnLayout { + Kirigami.FormData.label: i18nd("kcm_touchpad", "Right-click :") + Kirigami.FormData.buddyFor: rightClickMethodAreas + id: rightClickMethod + + spacing: Kirigami.Units.smallSpacing + + function load() { + visible = (touchpad.supportedButtons & Qt.LeftButton) + + if (!visible) { + rightClickMethodAreas.checked = false + rightClickMethodClickfinger.checked = false + return; + } + + rightClickMethodAreas.enabled = touchpad.supportsClickMethodAreas + rightClickMethodClickfinger.enabled = touchpad.supportsClickMethodClickfinger + + if (rightClickMethodAreas.enabled && touchpad.clickMethodAreas) { + rightClickMethodAreas.checked = true + } else if (rightClickMethodClickfinger.enabled && touchpad.clickMethodClickfinger) { + rightClickMethodClickfinger.checked = true + } + } + + function syncCurrent() { + if (enabled && !root.loading) { + touchpad.clickMethodAreas = rightClickMethodAreas.checked + touchpad.clickMethodClickfinger = rightClickMethodClickfinger.checked + root.changeSignal() + } + loading = true + middleClickMethod.load() + loading = false + } + + Controls.RadioButton { + id: rightClickMethodAreas + text: i18nd("kcm_touchpad", "Press bottom-right corner") + + hoverEnabled: true + Controls.ToolTip { + text: i18nd("kcm_touchpad", "Software enabled buttons will be added to bottom portion of your touchpad.") + visible: parent.hovered + delay: 1000 + } + } + + Controls.RadioButton { + id: rightClickMethodClickfinger + text: i18nd("kcm_touchpad", "Press anywhere with two fingers") + + hoverEnabled: true + Controls.ToolTip { + text: i18nd("kcm_touchpad", "Tap with two finger to enable right click.") + visible: parent.hovered + delay: 1000 + } + onCheckedChanged: rightClickMethod.syncCurrent() + } + } + + Item { + Kirigami.FormData.isSection: false + } + + Layouts.ColumnLayout { + Kirigami.FormData.label: i18nd("kcm_touchpad", "Middle-click: ") + Kirigami.FormData.buddyFor: middleSoftwareEmulation + id: middleClickMethod + + spacing: Kirigami.Units.smallSpacing + + function load() { + visible = rightClickMethod.visible + + if (!visible) { + enabled = false + return; + } + + enabled = touchpad.supportsMiddleEmulation + if (enabled && touchpad.middleEmulation) { + middleSoftwareEmulation.checked = true + } else { + noMiddleSoftwareEmulation.checked = true + } + } + + function syncCurrent() { + if (enabled && !root.loading) { + touchpad.middleEmulation = middleSoftwareEmulation.checked + root.changeSignal() + } + loading = true + middleEmulation.load() + loading = false + } + + Controls.RadioButton { + id: noMiddleSoftwareEmulation + text: i18nd("kcm_touchpad", "Press bottom-middle") + visible: rightClickMethodAreas.checked + hoverEnabled: true + Controls.ToolTip { + text: i18nd("kcm_touchpad", "Software enabled middle-button will be added to bottom portion of your touchpad.") + visible: parent.hovered + delay: 1000 + } + } + + Controls.RadioButton { + id: middleSoftwareEmulation + text: i18nd("kcm_touchpad", "Press bottom left and bottom right corners simultaneously") + visible: rightClickMethodAreas.checked + hoverEnabled: true + Controls.ToolTip { + text: i18nd("kcm_touchpad", "Clicking left and right button simultaneously sends middle button click.") + visible: parent.hovered + delay: 1000 + } + onCheckedChanged: middleClickMethod.syncCurrent() + } + + Controls.CheckBox { + id: clickfingerMiddleInfoBox + text: i18nd("kcm_touchpad", "Press anywhere with three fingers") + checked: true + enabled: false + visible: rightClickMethodClickfinger.checked + hoverEnabled: true + Controls.ToolTip { + text: i18nd("kcm_touchpad", "Press anywhere with three fingers.") + visible: parent.hovered + delay: 1000 + } + } + } } // END Kirigami.FormLayout } // END Kirigami.ScrollablePage