touchflow-gestures 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- touchflow_gestures-0.1.0/.github/workflows/ci.yml +30 -0
- touchflow_gestures-0.1.0/.github/workflows/publish.yml +25 -0
- touchflow_gestures-0.1.0/.gitignore +30 -0
- touchflow_gestures-0.1.0/PKG-INFO +32 -0
- touchflow_gestures-0.1.0/README.md +5 -0
- touchflow_gestures-0.1.0/docs/ARCHITECTURE.md +18 -0
- touchflow_gestures-0.1.0/docs/ROADMAP.md +22 -0
- touchflow_gestures-0.1.0/install.sh +105 -0
- touchflow_gestures-0.1.0/pyproject.toml +52 -0
- touchflow_gestures-0.1.0/tests/test_action_editor.py +174 -0
- touchflow_gestures-0.1.0/tests/test_conflict_detector.py +30 -0
- touchflow_gestures-0.1.0/tests/test_detector.py +77 -0
- touchflow_gestures-0.1.0/tests/test_fluid_springs.py +123 -0
- touchflow_gestures-0.1.0/tests/test_glass_theme.py +44 -0
- touchflow_gestures-0.1.0/tests/test_kwin_engine.py +102 -0
- touchflow_gestures-0.1.0/tests/test_profile_manager.py +89 -0
- touchflow_gestures-0.1.0/touch_flow/__init__.py +3 -0
- touchflow_gestures-0.1.0/touch_flow/backend/action_catalog.py +90 -0
- touchflow_gestures-0.1.0/touch_flow/backend/conflict_detector.py +198 -0
- touchflow_gestures-0.1.0/touch_flow/backend/detector.py +195 -0
- touchflow_gestures-0.1.0/touch_flow/backend/kwin_engine.py +180 -0
- touchflow_gestures-0.1.0/touch_flow/backend/presets.py +195 -0
- touchflow_gestures-0.1.0/touch_flow/backend/profile_manager.py +132 -0
- touchflow_gestures-0.1.0/touch_flow/backend/setup_manager.py +278 -0
- touchflow_gestures-0.1.0/touch_flow/gui/action_editor.py +142 -0
- touchflow_gestures-0.1.0/touch_flow/gui/audio_feedback.py +71 -0
- touchflow_gestures-0.1.0/touch_flow/gui/blur_effect.py +65 -0
- touchflow_gestures-0.1.0/touch_flow/gui/gesture_widgets.py +321 -0
- touchflow_gestures-0.1.0/touch_flow/gui/macos_theme.py +283 -0
- touchflow_gestures-0.1.0/touch_flow/gui/main_window.py +558 -0
- touchflow_gestures-0.1.0/touch_flow/gui/setup_wizard.py +176 -0
- touchflow_gestures-0.1.0/touch_flow/gui/touchpad_canvas.py +501 -0
- touchflow_gestures-0.1.0/touch_flow/main.py +164 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
- name: Set up Python
|
|
15
|
+
uses: actions/setup-python@v5
|
|
16
|
+
with:
|
|
17
|
+
python-version: "3.11"
|
|
18
|
+
- name: Install system dependencies for Qt and EGL
|
|
19
|
+
run: |
|
|
20
|
+
sudo apt-get update
|
|
21
|
+
sudo apt-get install -y libegl1 libgl1-mesa-dev libxkbcommon0 libdbus-1-3
|
|
22
|
+
- name: Install dependencies
|
|
23
|
+
run: |
|
|
24
|
+
python -m pip install --upgrade pip
|
|
25
|
+
pip install ".[dev]"
|
|
26
|
+
- name: Run pytest
|
|
27
|
+
env:
|
|
28
|
+
QT_QPA_PLATFORM: offscreen
|
|
29
|
+
run: |
|
|
30
|
+
pytest -v
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
pypi-publish:
|
|
10
|
+
name: Build and publish Python distribution to PyPI
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
permissions:
|
|
13
|
+
id-token: write
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- name: Set up Python
|
|
17
|
+
uses: actions/setup-python@v5
|
|
18
|
+
with:
|
|
19
|
+
python-version: "3.11"
|
|
20
|
+
- name: Install build
|
|
21
|
+
run: python -m pip install --upgrade pip build
|
|
22
|
+
- name: Build binary wheel and source tarball
|
|
23
|
+
run: python -m build
|
|
24
|
+
- name: Publish distribution to PyPI
|
|
25
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.py[cod]
|
|
3
|
+
*$py.class
|
|
4
|
+
*.so
|
|
5
|
+
.venv/
|
|
6
|
+
env/
|
|
7
|
+
build/
|
|
8
|
+
develop-eggs/
|
|
9
|
+
dist/
|
|
10
|
+
downloads/
|
|
11
|
+
eggs/
|
|
12
|
+
.eggs/
|
|
13
|
+
lib/
|
|
14
|
+
lib64/
|
|
15
|
+
parts/
|
|
16
|
+
sdist/
|
|
17
|
+
var/
|
|
18
|
+
wheels/
|
|
19
|
+
share/python-wheels/
|
|
20
|
+
*.egg-info/
|
|
21
|
+
.installed.cfg
|
|
22
|
+
*.egg
|
|
23
|
+
.pytest_cache/
|
|
24
|
+
.coverage
|
|
25
|
+
htmlcov/
|
|
26
|
+
.mypy_cache/
|
|
27
|
+
.ruff_cache/
|
|
28
|
+
*.swp
|
|
29
|
+
*.swo
|
|
30
|
+
*~
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: touchflow-gestures
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Universal, intuitive Linux multi-touch gesture manager supporting KDE Wayland, libinput, and X11
|
|
5
|
+
Project-URL: Homepage, https://github.com/rhn-ryan/TouchFlow
|
|
6
|
+
Project-URL: Repository, https://github.com/rhn-ryan/TouchFlow.git
|
|
7
|
+
Project-URL: Issues, https://github.com/rhn-ryan/TouchFlow/issues
|
|
8
|
+
Author-email: Rehan Mansoori <rhn-ryan@users.noreply.github.com>
|
|
9
|
+
License-Expression: GPL-3.0-or-later
|
|
10
|
+
Keywords: gestures,kde,kwin,libinput,linux,touchflow,touchpad,wayland
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: X11 Applications :: Qt
|
|
13
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
14
|
+
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
|
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Topic :: Desktop Environment
|
|
18
|
+
Classifier: Topic :: System :: Hardware
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Requires-Dist: pyside6>=6.5.0
|
|
21
|
+
Requires-Dist: pyyaml>=6.0
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest-qt>=4.4.0; extra == 'dev'
|
|
24
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
25
|
+
Requires-Dist: ruff>=0.4.0; extra == 'dev'
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# TouchFlow
|
|
29
|
+
|
|
30
|
+
Universal, modern, and intuitive multi-touch gesture manager for Linux desktops.
|
|
31
|
+
|
|
32
|
+
Supports KDE Wayland (KWin / InputActions), generic libinput, and X11 environments with unified configuration, visual touchpad preview, and customizable action bindings.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# TouchFlow Architecture Specification
|
|
2
|
+
|
|
3
|
+
## 1. System Architecture Overview
|
|
4
|
+
|
|
5
|
+
TouchFlow decouples gesture management into three distinct layers:
|
|
6
|
+
1. **Sensors & Platform Layer**: Hardware touchpad detection (`/proc/bus/input/devices`, `libinput`), environment detection (`XDG_CURRENT_DESKTOP`, `XDG_SESSION_TYPE`), and permission checks.
|
|
7
|
+
2. **Backend Engine Layer**: Interchangeable drivers for desktop environments (KDE KWin Wayland via `inputactions`, generic libinput user daemons, and legacy X11).
|
|
8
|
+
3. **Ergonomic Presentation Layer**: PySide6 user interface featuring real-time touchpad visualization, preset managers, conflict inspectors, and shortcut binders.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 2. Key Intelligent Differentiators
|
|
13
|
+
|
|
14
|
+
- **Zero-Friction Conflict Resolution**: Automatically detects rogue or overlapping services (Touchegg, libinput-gestures) and provides seamless 1-click mitigation.
|
|
15
|
+
- **Context & App Awareness**: Enables distinct gesture behaviors when specific applications are focused (e.g., web browser tab switching vs IDE workspace switching).
|
|
16
|
+
- **Interactive Live Playground**: Visualizes multi-touch tracking, swipe trajectories, and pinch dynamics on a simulated touchpad canvas.
|
|
17
|
+
- **Rootless & Secure**: Operates without granting unnecessary root permissions to the GUI; backend configs write to user-space standards with validated schemas.
|
|
18
|
+
- **Resilient Fallback Pipeline**: If a desktop-native backend is unavailable, it gracefully cascades to generic input simulation mechanisms.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# TouchFlow Implementation Roadmap
|
|
2
|
+
|
|
3
|
+
## Phase 1: Hardware & Desktop Environment Core
|
|
4
|
+
- [x] Workspace & Python environment initialization.
|
|
5
|
+
- [ ] Hardware touchpad detector (vendor, model, multi-touch capabilities).
|
|
6
|
+
- [ ] Desktop environment identifier (KDE Plasma 6 Wayland, GNOME, wlroots, X11).
|
|
7
|
+
- [ ] InputActions YAML configuration reader and writer.
|
|
8
|
+
|
|
9
|
+
## Phase 2: Conflict Diagnostics & Profile Engine
|
|
10
|
+
- [ ] Conflicting gesture daemon scanner (Touchegg, libinput-gestures).
|
|
11
|
+
- [ ] Profile manager with JSON/YAML serialization and atomic backups.
|
|
12
|
+
- [ ] Built-in gesture presets (macOS style, Windows 11 style, Tiling style).
|
|
13
|
+
|
|
14
|
+
## Phase 3: Ergonomic User Interface
|
|
15
|
+
- [ ] PySide6 modern card layout with dark/light theme integration.
|
|
16
|
+
- [ ] Real-time touchpad canvas with animated touch gestures.
|
|
17
|
+
- [ ] Action editor dialog with key recording and D-Bus action picker.
|
|
18
|
+
|
|
19
|
+
## Phase 4: App Awareness & Multi-Distro Hardening
|
|
20
|
+
- [ ] Active window tracker for per-app gesture profiles.
|
|
21
|
+
- [ ] Multi-distro compatibility testing (Arch, Fedora, Debian/Ubuntu).
|
|
22
|
+
- [ ] Automated pytest test suite covering parsers, detectors, and backend drivers.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
# TouchFlow Cross-Distro Installer & Dependency Resolver
|
|
5
|
+
# Supports Arch/EndeavourOS (pacman), Debian/Ubuntu (apt), and Fedora (dnf).
|
|
6
|
+
|
|
7
|
+
DRY_RUN=0
|
|
8
|
+
for arg in "$@"; do
|
|
9
|
+
case "$arg" in
|
|
10
|
+
--dry-run|--check)
|
|
11
|
+
DRY_RUN=1
|
|
12
|
+
;;
|
|
13
|
+
-h|--help)
|
|
14
|
+
echo "Usage: ./install.sh [--dry-run|--check]"
|
|
15
|
+
exit 0
|
|
16
|
+
;;
|
|
17
|
+
esac
|
|
18
|
+
done
|
|
19
|
+
|
|
20
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
21
|
+
VENV_DIR="${SCRIPT_DIR}/.venv"
|
|
22
|
+
LOCAL_BIN="${HOME}/.local/bin"
|
|
23
|
+
|
|
24
|
+
log() {
|
|
25
|
+
printf "[TouchFlow Setup] %s\n" "$1"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
run_cmd() {
|
|
29
|
+
if [[ "$DRY_RUN" -eq 1 ]]; then
|
|
30
|
+
printf "[DRY-RUN] %s\n" "$*"
|
|
31
|
+
else
|
|
32
|
+
"$@"
|
|
33
|
+
fi
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
detect_pkg_manager() {
|
|
37
|
+
if command -v pacman >/dev/null 2>&1; then
|
|
38
|
+
echo "pacman"
|
|
39
|
+
elif command -v apt-get >/dev/null 2>&1; then
|
|
40
|
+
echo "apt"
|
|
41
|
+
elif command -v dnf >/dev/null 2>&1; then
|
|
42
|
+
echo "dnf"
|
|
43
|
+
else
|
|
44
|
+
echo "unknown"
|
|
45
|
+
fi
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
PKG_MGR="$(detect_pkg_manager)"
|
|
49
|
+
log "Detected package manager: ${PKG_MGR}"
|
|
50
|
+
|
|
51
|
+
install_system_deps() {
|
|
52
|
+
case "$PKG_MGR" in
|
|
53
|
+
pacman)
|
|
54
|
+
log "Resolving Arch/EndeavourOS dependencies (python, PySide6, PyYAML, qt6-tools)..."
|
|
55
|
+
run_cmd sudo pacman -S --needed --noconfirm python python-pyside6 python-yaml qt6-tools
|
|
56
|
+
if ! pacman -Qi inputactions-kwin >/dev/null 2>&1; then
|
|
57
|
+
log "Note: For KDE Plasma 6 Wayland gestures, ensure 'inputactions-kwin' is installed (e.g., yay -S inputactions-kwin)."
|
|
58
|
+
fi
|
|
59
|
+
;;
|
|
60
|
+
apt)
|
|
61
|
+
log "Resolving Debian/Ubuntu dependencies..."
|
|
62
|
+
run_cmd sudo apt-get update
|
|
63
|
+
run_cmd sudo apt-get install -y python3 python3-venv python3-pyside6 python3-yaml qt6-tools-dev-tools
|
|
64
|
+
;;
|
|
65
|
+
dnf)
|
|
66
|
+
log "Resolving Fedora dependencies..."
|
|
67
|
+
run_cmd sudo dnf install -y python3 python3-pyside6 python3-pyyaml qt6-qttools
|
|
68
|
+
;;
|
|
69
|
+
*)
|
|
70
|
+
log "Unknown package manager; skipping distro packages and relying on Python venv."
|
|
71
|
+
;;
|
|
72
|
+
esac
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
install_python_env() {
|
|
76
|
+
if [[ ! -d "$VENV_DIR" ]]; then
|
|
77
|
+
log "Creating Python virtual environment at ${VENV_DIR}..."
|
|
78
|
+
run_cmd python3 -m venv --system-site-packages "$VENV_DIR"
|
|
79
|
+
fi
|
|
80
|
+
|
|
81
|
+
log "Installing TouchFlow into virtual environment..."
|
|
82
|
+
run_cmd "${VENV_DIR}/bin/pip" install --upgrade pip
|
|
83
|
+
run_cmd "${VENV_DIR}/bin/pip" install -e "$SCRIPT_DIR"
|
|
84
|
+
|
|
85
|
+
run_cmd mkdir -p "$LOCAL_BIN"
|
|
86
|
+
run_cmd ln -sf "${VENV_DIR}/bin/touch-flow" "${LOCAL_BIN}/touch-flow"
|
|
87
|
+
log "Linked executable to ${LOCAL_BIN}/touch-flow"
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
setup_desktop_integration() {
|
|
91
|
+
log "Installing XDG desktop entry, icon, and systemd user service..."
|
|
92
|
+
if [[ "$DRY_RUN" -eq 1 ]]; then
|
|
93
|
+
printf "[DRY-RUN] %s/bin/touch-flow --setup\n" "$VENV_DIR"
|
|
94
|
+
printf "[DRY-RUN] %s/bin/touch-flow --doctor\n" "$VENV_DIR"
|
|
95
|
+
else
|
|
96
|
+
"${VENV_DIR}/bin/touch-flow" --setup
|
|
97
|
+
"${VENV_DIR}/bin/touch-flow" --doctor || true
|
|
98
|
+
fi
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
install_system_deps
|
|
102
|
+
install_python_env
|
|
103
|
+
setup_desktop_integration
|
|
104
|
+
|
|
105
|
+
log "Installation complete! Launch TouchFlow from your application menu or run 'touch-flow'."
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "touchflow-gestures"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Universal, intuitive Linux multi-touch gesture manager supporting KDE Wayland, libinput, and X11"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "GPL-3.0-or-later"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Rehan Mansoori", email = "rhn-ryan@users.noreply.github.com" },
|
|
14
|
+
]
|
|
15
|
+
keywords = ["linux", "gestures", "touchpad", "libinput", "wayland", "kde", "kwin", "touchflow"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
|
+
"Environment :: X11 Applications :: Qt",
|
|
19
|
+
"Intended Audience :: End Users/Desktop",
|
|
20
|
+
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
|
|
21
|
+
"Operating System :: POSIX :: Linux",
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"Topic :: Desktop Environment",
|
|
24
|
+
"Topic :: System :: Hardware",
|
|
25
|
+
]
|
|
26
|
+
dependencies = [
|
|
27
|
+
"PySide6>=6.5.0",
|
|
28
|
+
"pyyaml>=6.0",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.optional-dependencies]
|
|
32
|
+
dev = [
|
|
33
|
+
"pytest>=8.0.0",
|
|
34
|
+
"pytest-qt>=4.4.0",
|
|
35
|
+
"ruff>=0.4.0",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.scripts]
|
|
39
|
+
touch-flow = "touch_flow.main:main"
|
|
40
|
+
|
|
41
|
+
[project.urls]
|
|
42
|
+
Homepage = "https://github.com/rhn-ryan/TouchFlow"
|
|
43
|
+
Repository = "https://github.com/rhn-ryan/TouchFlow.git"
|
|
44
|
+
Issues = "https://github.com/rhn-ryan/TouchFlow/issues"
|
|
45
|
+
|
|
46
|
+
[tool.hatch.build.targets.wheel]
|
|
47
|
+
packages = ["touch_flow"]
|
|
48
|
+
|
|
49
|
+
[tool.pytest.ini_options]
|
|
50
|
+
testpaths = ["tests"]
|
|
51
|
+
python_files = ["test_*.py"]
|
|
52
|
+
pythonpath = ["."]
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"""Tests for ActionEditorDialog and custom action integration in TouchFlowMainWindow."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
|
|
9
|
+
|
|
10
|
+
import pytest
|
|
11
|
+
from PySide6.QtWidgets import QApplication, QDialogButtonBox
|
|
12
|
+
|
|
13
|
+
from touch_flow.backend.action_catalog import ACTION_CATALOG, validate_action, validate_rules
|
|
14
|
+
from touch_flow.backend.kwin_engine import GestureAction, GestureRule, KWinInputActionsEngine
|
|
15
|
+
from touch_flow.backend.profile_manager import GestureProfile, ProfileManager
|
|
16
|
+
from touch_flow.gui.action_editor import ActionEditorDialog
|
|
17
|
+
from touch_flow.gui.gesture_widgets import AddGestureDialog
|
|
18
|
+
from touch_flow.gui.main_window import TouchFlowMainWindow
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@pytest.fixture(scope="module")
|
|
22
|
+
def qapp():
|
|
23
|
+
app = QApplication.instance()
|
|
24
|
+
if app is None:
|
|
25
|
+
app = QApplication([])
|
|
26
|
+
return app
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def test_action_editor_dialog_create_and_edit(qapp):
|
|
30
|
+
dlg = ActionEditorDialog("3-Finger Swipe Up")
|
|
31
|
+
ok_btn = dlg.button_box.button(QDialogButtonBox.Ok)
|
|
32
|
+
assert ok_btn is not None
|
|
33
|
+
assert ok_btn.isEnabled() is False
|
|
34
|
+
|
|
35
|
+
# Select Shell Command and enter target
|
|
36
|
+
cmd_idx = dlg.kind_combo.findData("command")
|
|
37
|
+
dlg.kind_combo.setCurrentIndex(cmd_idx)
|
|
38
|
+
dlg.target_input.setText(" /usr/bin/konsole ")
|
|
39
|
+
|
|
40
|
+
assert ok_btn.isEnabled() is True
|
|
41
|
+
assert dlg.get_action() == GestureAction(kind="command", target="/usr/bin/konsole")
|
|
42
|
+
|
|
43
|
+
# Pre-populated shortcut editing shows key_edit
|
|
44
|
+
dlg_shortcut = ActionEditorDialog(
|
|
45
|
+
"4-Finger Hold",
|
|
46
|
+
current_action=GestureAction(kind="shortcut", target="Ctrl+Alt+T"),
|
|
47
|
+
)
|
|
48
|
+
assert dlg_shortcut.kind_combo.currentData() == "shortcut"
|
|
49
|
+
assert dlg_shortcut.target_input.text() == "Ctrl+Alt+T"
|
|
50
|
+
assert dlg_shortcut.get_action() == GestureAction(kind="shortcut", target="Ctrl+Alt+T")
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def test_main_window_loads_and_collects_custom_actions(qapp, tmp_path: Path, monkeypatch):
|
|
54
|
+
cfg = tmp_path / "config.yaml"
|
|
55
|
+
profiles_dir = tmp_path / "profiles"
|
|
56
|
+
engine = KWinInputActionsEngine(config_path=cfg)
|
|
57
|
+
pm = ProfileManager(profiles_dir=profiles_dir, kwin_engine=engine)
|
|
58
|
+
|
|
59
|
+
custom_profile = GestureProfile(
|
|
60
|
+
name="Custom Test",
|
|
61
|
+
rules=[
|
|
62
|
+
GestureRule(
|
|
63
|
+
gesture_type="swipe",
|
|
64
|
+
fingers=3,
|
|
65
|
+
direction="up",
|
|
66
|
+
actions=[GestureAction(kind="command", target="kitty")],
|
|
67
|
+
),
|
|
68
|
+
GestureRule(
|
|
69
|
+
gesture_type="swipe",
|
|
70
|
+
fingers=4,
|
|
71
|
+
direction="right",
|
|
72
|
+
actions=[GestureAction(kind="dbus", target="org.kde.KWin /KWin org.kde.KWin.showOverview")],
|
|
73
|
+
),
|
|
74
|
+
],
|
|
75
|
+
)
|
|
76
|
+
assert pm.apply_profile(custom_profile, reload_compositor=False) is True
|
|
77
|
+
|
|
78
|
+
monkeypatch.setattr("touch_flow.gui.main_window.ProfileManager", lambda: pm)
|
|
79
|
+
window = TouchFlowMainWindow()
|
|
80
|
+
|
|
81
|
+
# Custom rules should be loaded into the combos and preserved on collection
|
|
82
|
+
assert window.rule_combos["3_swipe_up"].currentData() == ("command", "kitty")
|
|
83
|
+
assert window.rule_combos["4_swipe_right"].currentData() == (
|
|
84
|
+
"dbus",
|
|
85
|
+
"org.kde.KWin /KWin org.kde.KWin.showOverview",
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
collected = window._collect_rules_from_ui()
|
|
89
|
+
by_key = {
|
|
90
|
+
f"{r.fingers}_{r.gesture_type}" + (f"_{r.direction}" if r.direction else ""): r.actions[0]
|
|
91
|
+
for r in collected
|
|
92
|
+
}
|
|
93
|
+
assert by_key["3_swipe_up"] == GestureAction(kind="command", target="kitty")
|
|
94
|
+
assert by_key["4_swipe_right"] == GestureAction(
|
|
95
|
+
kind="dbus", target="org.kde.KWin /KWin org.kde.KWin.showOverview"
|
|
96
|
+
)
|
|
97
|
+
window.canvas.timer.stop()
|
|
98
|
+
window.close()
|
|
99
|
+
window.deleteLater()
|
|
100
|
+
qapp.processEvents()
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def test_action_catalog_and_validation():
|
|
104
|
+
for expected in (
|
|
105
|
+
"Window Controls",
|
|
106
|
+
"Workspace & Multitasking",
|
|
107
|
+
"Media & Audio",
|
|
108
|
+
"Browser Navigation",
|
|
109
|
+
):
|
|
110
|
+
assert expected in ACTION_CATALOG
|
|
111
|
+
assert len(ACTION_CATALOG[expected]) > 0
|
|
112
|
+
|
|
113
|
+
ok, _ = validate_action(GestureAction(kind="command", target="konsole"))
|
|
114
|
+
assert ok is True
|
|
115
|
+
|
|
116
|
+
bad_ok, msg = validate_action(GestureAction(kind="command", target=" "))
|
|
117
|
+
assert bad_ok is False
|
|
118
|
+
assert "empty" in msg.lower()
|
|
119
|
+
|
|
120
|
+
rules_ok, errors = validate_rules(
|
|
121
|
+
[
|
|
122
|
+
GestureRule(
|
|
123
|
+
gesture_type="swipe",
|
|
124
|
+
fingers=6,
|
|
125
|
+
direction="up",
|
|
126
|
+
actions=[GestureAction(kind="command", target="")],
|
|
127
|
+
)
|
|
128
|
+
]
|
|
129
|
+
)
|
|
130
|
+
assert rules_ok is False
|
|
131
|
+
assert len(errors) == 2
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def test_add_gesture_dialog_and_card_duplicate_delete(qapp, tmp_path: Path, monkeypatch):
|
|
135
|
+
# Test AddGestureDialog supports 2-5 fingers, dynamic directions, and instant flag
|
|
136
|
+
dlg = AddGestureDialog()
|
|
137
|
+
assert [dlg.fingers_combo.itemData(i) for i in range(dlg.fingers_combo.count())] == [2, 3, 4, 5]
|
|
138
|
+
|
|
139
|
+
dlg.fingers_combo.setCurrentIndex(dlg.fingers_combo.findData(5))
|
|
140
|
+
dlg.type_combo.setCurrentIndex(dlg.type_combo.findData("pinch"))
|
|
141
|
+
assert dlg.direction_combo.isEnabled() is True
|
|
142
|
+
assert dlg.direction_combo.findData("out") >= 0
|
|
143
|
+
assert dlg.direction_combo.findData("up") == -1
|
|
144
|
+
|
|
145
|
+
dlg.type_combo.setCurrentIndex(dlg.type_combo.findData("hold"))
|
|
146
|
+
assert dlg.direction_combo.isEnabled() is False
|
|
147
|
+
dlg.instant_checkbox.setChecked(True)
|
|
148
|
+
rule = dlg.get_rule()
|
|
149
|
+
assert rule.fingers == 5
|
|
150
|
+
assert rule.gesture_type == "hold"
|
|
151
|
+
assert rule.direction is None
|
|
152
|
+
assert rule.instant is True
|
|
153
|
+
|
|
154
|
+
# Test MainWindow duplicate & delete cards
|
|
155
|
+
cfg = tmp_path / "config.yaml"
|
|
156
|
+
engine = KWinInputActionsEngine(config_path=cfg)
|
|
157
|
+
pm = ProfileManager(profiles_dir=tmp_path / "profiles", kwin_engine=engine)
|
|
158
|
+
monkeypatch.setattr("touch_flow.gui.main_window.ProfileManager", lambda: pm)
|
|
159
|
+
|
|
160
|
+
window = TouchFlowMainWindow()
|
|
161
|
+
initial_count = len(window.rule_cards)
|
|
162
|
+
assert initial_count > 0
|
|
163
|
+
|
|
164
|
+
first_card = window.rule_cards[0]
|
|
165
|
+
window._on_duplicate_card(first_card)
|
|
166
|
+
assert len(window.rule_cards) == initial_count + 1
|
|
167
|
+
|
|
168
|
+
window._on_delete_card(window.rule_cards[1])
|
|
169
|
+
assert len(window.rule_cards) == initial_count
|
|
170
|
+
|
|
171
|
+
window.canvas.timer.stop()
|
|
172
|
+
window.close()
|
|
173
|
+
window.deleteLater()
|
|
174
|
+
qapp.processEvents()
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""Tests for ConflictDetector."""
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from touch_flow.backend.conflict_detector import ConflictDetector
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def test_conflict_detector_scan():
|
|
8
|
+
detector = ConflictDetector()
|
|
9
|
+
issues = detector.scan_all()
|
|
10
|
+
assert len(issues) >= 3
|
|
11
|
+
ids = [i.id for i in issues]
|
|
12
|
+
assert "touchegg" in ids
|
|
13
|
+
assert "libinput-gestures" in ids
|
|
14
|
+
assert "fusuma" in ids
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def test_neutralize_autostart_override(tmp_path: Path):
|
|
18
|
+
detector = ConflictDetector()
|
|
19
|
+
user_autostart = tmp_path / "touchegg.desktop"
|
|
20
|
+
|
|
21
|
+
# Mock the user_autostart path for touchegg
|
|
22
|
+
for d in detector.KNOWN_DAEMONS:
|
|
23
|
+
if d["id"] == "touchegg":
|
|
24
|
+
d["user_autostart"] = user_autostart
|
|
25
|
+
|
|
26
|
+
ok = detector.neutralize("touchegg")
|
|
27
|
+
assert ok is True
|
|
28
|
+
assert user_autostart.exists()
|
|
29
|
+
content = user_autostart.read_text(encoding="utf-8")
|
|
30
|
+
assert "Hidden=true" in content
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"""Tests for touchpad and desktop environment detectors."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from touch_flow.backend.detector import (
|
|
6
|
+
TouchpadDevice,
|
|
7
|
+
detect_desktop_environment,
|
|
8
|
+
detect_touchpads,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
SAMPLE_PROC_DEVICES = """
|
|
12
|
+
I: Bus=0011 Vendor=0001 Product=0001 Version=ab83
|
|
13
|
+
N: Name="AT Translated Set 2 keyboard"
|
|
14
|
+
P: Phys=isa0060/serio0/input0
|
|
15
|
+
S: Sysfs=/devices/platform/i8042/serio0/input/input0
|
|
16
|
+
U: Uniq=
|
|
17
|
+
H: Handlers=sysrq kbd event0
|
|
18
|
+
B: PROP=0
|
|
19
|
+
B: EV=120013
|
|
20
|
+
B: KEY=402000000 3803078f800d001 feffffdfffefffff fffffffffffffffe
|
|
21
|
+
B: MSC=10
|
|
22
|
+
B: LED=7
|
|
23
|
+
|
|
24
|
+
I: Bus=0018 Vendor=04f3 Product=307a Version=0100
|
|
25
|
+
N: Name="ELAN1203:00 04F3:307A Touchpad"
|
|
26
|
+
P: Phys=i2c-ELAN1203:00
|
|
27
|
+
S: Sysfs=/devices/pci0000:00/0000:00:15.0/i2c_designware.0/i2c-0/i2c-ELAN1203:00/0018:04F3:307A.0005/input/input16
|
|
28
|
+
U: Uniq=
|
|
29
|
+
H: Handlers=event11 mouse2
|
|
30
|
+
B: PROP=1
|
|
31
|
+
B: EV=1b
|
|
32
|
+
B: KEY=e520 30000 0 0 0 0
|
|
33
|
+
B: ABS=2e0800000000003
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def test_detect_touchpads_mock(tmp_path: Path):
|
|
38
|
+
mock_file = tmp_path / "devices"
|
|
39
|
+
mock_file.write_text(SAMPLE_PROC_DEVICES)
|
|
40
|
+
|
|
41
|
+
touchpads = detect_touchpads(mock_file)
|
|
42
|
+
assert len(touchpads) == 1
|
|
43
|
+
tp = touchpads[0]
|
|
44
|
+
assert tp.name == "ELAN1203:00 04F3:307A Touchpad"
|
|
45
|
+
assert tp.vendor == "04f3"
|
|
46
|
+
assert tp.product == "307a"
|
|
47
|
+
assert tp.event_node == "/dev/input/event11"
|
|
48
|
+
assert tp.is_touchpad is True
|
|
49
|
+
assert "pointer_device" in tp.capabilities
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def test_detect_touchpads_empty_or_missing(tmp_path: Path):
|
|
53
|
+
missing_file = tmp_path / "nonexistent"
|
|
54
|
+
assert detect_touchpads(missing_file) == []
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def test_detect_desktop_environment(monkeypatch):
|
|
58
|
+
monkeypatch.setenv("XDG_CURRENT_DESKTOP", "KDE")
|
|
59
|
+
monkeypatch.setenv("XDG_SESSION_DESKTOP", "KDE")
|
|
60
|
+
monkeypatch.setenv("XDG_SESSION_TYPE", "wayland")
|
|
61
|
+
env = detect_desktop_environment()
|
|
62
|
+
assert env.desktop == "KDE"
|
|
63
|
+
assert env.session_type == "wayland"
|
|
64
|
+
|
|
65
|
+
monkeypatch.setenv("XDG_CURRENT_DESKTOP", "GNOME")
|
|
66
|
+
monkeypatch.setenv("XDG_SESSION_DESKTOP", "gnome")
|
|
67
|
+
monkeypatch.setenv("XDG_SESSION_TYPE", "x11")
|
|
68
|
+
env_gnome = detect_desktop_environment()
|
|
69
|
+
assert env_gnome.desktop == "GNOME"
|
|
70
|
+
assert env_gnome.session_type == "x11"
|
|
71
|
+
|
|
72
|
+
for dt in ["Hyprland", "Sway", "XFCE", "Cinnamon"]:
|
|
73
|
+
monkeypatch.setenv("XDG_CURRENT_DESKTOP", dt)
|
|
74
|
+
monkeypatch.setenv("XDG_SESSION_DESKTOP", dt.lower())
|
|
75
|
+
monkeypatch.setenv("XDG_SESSION_TYPE", "wayland")
|
|
76
|
+
env_other = detect_desktop_environment()
|
|
77
|
+
assert env_other.desktop == dt
|