Add geminux-touchd multi-touch gesture daemon and st wheel scrollback
This commit is contained in:
1 parent
9db15e30ce
commit
ba7b86e570
16 files changed
+877
-13
No files matched your search
@@ -11,10 +11,12 @@ import tempfile
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
DAEMON_DIR = os.path.join(BASE_DIR, "src", "geminux-daemons")
|
||||
POLICY_C = os.path.join(DAEMON_DIR, "geminux-power-policy.c")
|
||||
GESTURE_C = os.path.join(DAEMON_DIR, "geminux-touch-gesture.c")
|
||||
|
||||
DAEMON_FILES = {
|
||||
"geminux-powerd.c": "epoll_wait",
|
||||
"geminux-statusd.c": "epoll_wait",
|
||||
"geminux-touchd.c": "epoll_wait",
|
||||
"geminux-ccci-daemon.c": "epoll_wait",
|
||||
"geminux-modem-ctl.c": "epoll_wait",
|
||||
"geminux-bt-obex.c": "g_main_loop_run",
|
||||
@@ -25,6 +27,104 @@ C_TEST = r"""
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include "geminux-power-policy.h"
|
||||
#include "geminux-touch-gesture.h"
|
||||
|
||||
static int count_decision(const geminux_gesture_action_t *a, int mode) {
|
||||
int c = 0;
|
||||
for (int i = 0; i < a->decision_count; i++) {
|
||||
if (a->decisions[i].allow_mode == mode) c++;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
static void test_touch_gestures(void) {
|
||||
geminux_gesture_state_t gs;
|
||||
geminux_gesture_action_t act;
|
||||
|
||||
/* 1. 1-finger tap -> REJECT passthrough, no synthetic click */
|
||||
geminux_gesture_init(&gs, true);
|
||||
geminux_gesture_on_begin(&gs, 2, 100, 500.0, 400.0, 0, &act);
|
||||
assert(gs.phase == GESTURE_PENDING_1F);
|
||||
assert(act.decision_count == 0);
|
||||
assert(act.next_timer_ms == GEMINUX_LONGPRESS_MS);
|
||||
geminux_gesture_on_end(&gs, 2, 100, 504.0, 403.0, 90, &act);
|
||||
assert(act.decision_count == 1);
|
||||
assert(act.decisions[0].devid == 2 && act.decisions[0].touchid == 100);
|
||||
assert(act.decisions[0].allow_mode == GEMINUX_ALLOW_REJECT);
|
||||
assert(act.click_button == 0);
|
||||
assert(gs.phase == GESTURE_IDLE);
|
||||
|
||||
/* 2. 1-finger drag -> held during 45ms grace, REJECTed on timer */
|
||||
geminux_gesture_init(&gs, true);
|
||||
geminux_gesture_on_begin(&gs, 2, 101, 500.0, 400.0, 1000, &act);
|
||||
geminux_gesture_on_update(&gs, 2, 101, 550.0, 400.0, 1020, &act);
|
||||
assert(gs.phase == GESTURE_PENDING_1F);
|
||||
assert(act.decision_count == 0);
|
||||
assert(act.next_timer_ms == 25);
|
||||
geminux_gesture_on_timer(&gs, 1045, &act);
|
||||
assert(gs.phase == GESTURE_PASSTHROUGH_1F);
|
||||
assert(count_decision(&act, GEMINUX_ALLOW_REJECT) == 1);
|
||||
geminux_gesture_on_end(&gs, 2, 101, 600.0, 400.0, 1150, &act);
|
||||
assert(act.click_button == 0);
|
||||
assert(gs.phase == GESTURE_IDLE);
|
||||
|
||||
/* 3. 1-finger 500ms stationary hold -> ACCEPT + Button3 right-click */
|
||||
geminux_gesture_init(&gs, true);
|
||||
geminux_gesture_on_begin(&gs, 2, 102, 700.0, 300.0, 2000, &act);
|
||||
geminux_gesture_on_timer(&gs, 2500, &act);
|
||||
assert(gs.phase == GESTURE_ACCEPTED_1F_HOLD);
|
||||
assert(count_decision(&act, GEMINUX_ALLOW_ACCEPT) == 1);
|
||||
assert(act.click_button == 3);
|
||||
geminux_gesture_on_end(&gs, 2, 102, 705.0, 302.0, 2600, &act);
|
||||
assert(act.click_button == 0);
|
||||
assert(gs.phase == GESTURE_IDLE);
|
||||
|
||||
/* 4. 2-finger tap -> ACCEPT both + Button3 right-click on release */
|
||||
geminux_gesture_init(&gs, true);
|
||||
geminux_gesture_on_begin(&gs, 2, 201, 600.0, 400.0, 3000, &act);
|
||||
geminux_gesture_on_begin(&gs, 2, 202, 680.0, 410.0, 3015, &act);
|
||||
assert(gs.phase == GESTURE_ACCEPTED_MULTI);
|
||||
assert(count_decision(&act, GEMINUX_ALLOW_ACCEPT) == 2);
|
||||
assert(act.next_timer_ms == 0);
|
||||
geminux_gesture_on_end(&gs, 2, 201, 604.0, 402.0, 3110, &act);
|
||||
assert(act.click_button == 0);
|
||||
geminux_gesture_on_end(&gs, 2, 202, 684.0, 412.0, 3120, &act);
|
||||
assert(act.click_button == 3);
|
||||
assert(gs.phase == GESTURE_IDLE);
|
||||
|
||||
/* 5. 3-finger tap -> ACCEPT all 3 + Button2 middle-click on release */
|
||||
geminux_gesture_init(&gs, true);
|
||||
geminux_gesture_on_begin(&gs, 2, 301, 500.0, 400.0, 4000, &act);
|
||||
geminux_gesture_on_begin(&gs, 2, 302, 600.0, 400.0, 4010, &act);
|
||||
assert(count_decision(&act, GEMINUX_ALLOW_ACCEPT) == 2);
|
||||
geminux_gesture_on_begin(&gs, 2, 303, 700.0, 400.0, 4025, &act);
|
||||
assert(count_decision(&act, GEMINUX_ALLOW_ACCEPT) == 1);
|
||||
geminux_gesture_on_end(&gs, 2, 301, 505.0, 402.0, 4120, &act);
|
||||
geminux_gesture_on_end(&gs, 2, 302, 605.0, 402.0, 4135, &act);
|
||||
assert(act.click_button == 0);
|
||||
geminux_gesture_on_end(&gs, 2, 303, 705.0, 402.0, 4150, &act);
|
||||
assert(act.click_button == 2);
|
||||
assert(gs.phase == GESTURE_IDLE);
|
||||
|
||||
/* 6. 2-finger drag -> natural vertical & horizontal scroll ticks, no tap click */
|
||||
int total_v = 0, total_h = 0;
|
||||
geminux_gesture_init(&gs, true);
|
||||
geminux_gesture_on_begin(&gs, 2, 401, 600.0, 300.0, 5000, &act);
|
||||
geminux_gesture_on_begin(&gs, 2, 402, 680.0, 300.0, 5010, &act);
|
||||
geminux_gesture_on_update(&gs, 2, 401, 730.0, 410.0, 5080, &act);
|
||||
total_v += act.wheel_v;
|
||||
total_h += act.wheel_h;
|
||||
geminux_gesture_on_update(&gs, 2, 402, 810.0, 410.0, 5081, &act);
|
||||
total_v += act.wheel_v;
|
||||
total_h += act.wheel_h;
|
||||
assert(gs.scrolled);
|
||||
assert(total_v == 2);
|
||||
assert(total_h == 2);
|
||||
geminux_gesture_on_end(&gs, 2, 401, 730.0, 410.0, 5140, &act);
|
||||
geminux_gesture_on_end(&gs, 2, 402, 810.0, 410.0, 5150, &act);
|
||||
assert(act.click_button == 0);
|
||||
assert(gs.phase == GESTURE_IDLE);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
geminux_power_policy_t pol;
|
||||
@@ -63,6 +163,8 @@ int main(void) {
|
||||
assert(strcmp(perf.governor, "schedutil") == 0);
|
||||
assert(perf.a72_online);
|
||||
assert(perf.suspend_timeout_s == 0);
|
||||
|
||||
test_touch_gestures();
|
||||
return 0;
|
||||
}
|
||||
"""
|
||||
@@ -89,7 +191,7 @@ def main():
|
||||
if gcc:
|
||||
subprocess.run(
|
||||
[gcc, "-std=c11", "-Wall", "-Wextra", "-Werror",
|
||||
"-I", DAEMON_DIR, src, POLICY_C, "-o", bin_path],
|
||||
"-I", DAEMON_DIR, src, POLICY_C, GESTURE_C, "-lm", "-o", bin_path],
|
||||
check=True,
|
||||
)
|
||||
subprocess.run([bin_path], check=True)
|
||||
@@ -100,11 +202,12 @@ def main():
|
||||
"apk add --no-cache build-base >/dev/null && "
|
||||
"gcc -std=c11 -Wall -Wextra -Werror -I/geminux/src/geminux-daemons "
|
||||
"/work/test_power.c /geminux/src/geminux-daemons/geminux-power-policy.c "
|
||||
"/geminux/src/geminux-daemons/geminux-touch-gesture.c -lm "
|
||||
"-o /work/test_power && /work/test_power"],
|
||||
check=True,
|
||||
)
|
||||
|
||||
print("[PASS] Zero-poll daemon loops and power/lid policy verified")
|
||||
print("[PASS] Zero-poll daemon loops, power/lid policy, and touch gestures verified")
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user