Skip to content

Commit

Permalink
feat: Xrecord add touch support.
Browse files Browse the repository at this point in the history
Xrecord add touch support.

Log: Xrecord add touch support.

Bug: https://pms.uniontech.com/zentao/bug-view-87450.html
  • Loading branch information
zy-seven authored and Zeno-sole committed Sep 26, 2024
1 parent c5fd05a commit b55f066
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 0 deletions.
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
xorg-server (2:21.1.10-1deepin2) unstable; urgency=medium

* Xrecord add touch support.

-- zhangyu <zhangyud@uniontech.com> Mon, 23 Sep 2024 17:24:26 +0800

xorg-server (2:21.1.10-1deepin1) unstable; urgency=medium

* add zx 709 mwv206 device id.
Expand Down
154 changes: 154 additions & 0 deletions debian/patches/feat-Xrecord-add-touch-support.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
From 640c51eb28f4946228dae408c83784ac8b5f4735 Mon Sep 17 00:00:00 2001
From: zhangyu <zhangyud@uniontech.com>
Date: Mon, 23 Sep 2024 17:22:47 +0800
Subject: [PATCH] feat: Xrecord add touch support.

Xrecord add touch support.

Log: Xrecord add touch support.

Bug: https://pms.uniontech.com/zentao/bug-view-87450.html
---
Xi/exevents.c | 13 +++++++
dix/eventconvert.c | 87 ++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 97 insertions(+), 3 deletions(-)

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 54ea11a..902e8e4 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1622,6 +1622,19 @@ ProcessTouchEvent(InternalEvent *ev, DeviceIntPtr dev)
else
ti = TouchFindByClientID(dev, touchid);

+ if (DeviceEventCallback) {
+ DeviceEventInfoRec eventinfo;
+ SpritePtr pSprite = dev->spriteInfo->sprite;
+
+ /* see comment in EnqueueEvents regarding the next three lines */
+ if (ev->any.type == ET_Motion)
+ ev->device_event.root = pSprite->hotPhys.pScreen->root->drawable.id;
+
+ eventinfo.device = dev;
+ eventinfo.event = ev;
+ CallCallbacks(&DeviceEventCallback, (void *) &eventinfo);
+ }
+
/* Active pointer grab */
if (emulate_pointer && dev->deviceGrab.grab && !dev->deviceGrab.fromPassiveGrab &&
(dev->deviceGrab.grab->grabtype == CORE ||
diff --git a/dix/eventconvert.c b/dix/eventconvert.c
index 53b8c79..b34b9c4 100644
--- a/dix/eventconvert.c
+++ b/dix/eventconvert.c
@@ -32,6 +32,18 @@
#include <dix-config.h>
#endif

+#ifndef TOUCHDOWN
+# define TOUCHDOWN (LASTEvent + 1)
+#endif
+
+#ifndef TOUCHMOTION
+# define TOUCHMOTION (LASTEvent + 2)
+#endif
+
+#ifndef TOUCHUP
+# define TOUCHUP (LASTEvent + 3)
+#endif
+
#include <stdint.h>
#include <X11/X.h>
#include <X11/extensions/XIproto.h>
@@ -159,9 +171,6 @@ EventToCore(InternalEvent *event, xEvent **core_out, int *count_out)
case ET_RawTouchBegin:
case ET_RawTouchUpdate:
case ET_RawTouchEnd:
- case ET_TouchBegin:
- case ET_TouchUpdate:
- case ET_TouchEnd:
case ET_TouchOwnership:
case ET_BarrierHit:
case ET_BarrierLeave:
@@ -173,6 +182,78 @@ EventToCore(InternalEvent *event, xEvent **core_out, int *count_out)
case ET_GestureSwipeEnd:
ret = BadMatch;
break;
+ case ET_TouchBegin:
+ {
+ DeviceEvent *e = &event->device_event;
+
+ if (e->detail.key > 0xFF) {
+ ret = BadMatch;
+ goto out;
+ }
+
+ core = calloc(1, sizeof(*core));
+ if (!core)
+ return BadAlloc;
+ count = 1;
+ core->u.u.type = TOUCHDOWN;
+ core->u.u.detail = e->detail.key & 0xFF;
+ core->u.keyButtonPointer.time = e->time;
+ core->u.keyButtonPointer.rootX = e->root_x;
+ core->u.keyButtonPointer.rootY = e->root_y;
+ core->u.keyButtonPointer.state = e->corestate;
+ core->u.keyButtonPointer.root = e->root;
+ EventSetKeyRepeatFlag(core, (e->type == ET_KeyPress && e->key_repeat));
+ ret = Success;
+ }
+ break;
+ case ET_TouchUpdate:
+ {
+ DeviceEvent *e = &event->device_event;
+
+ if (e->detail.key > 0xFF) {
+ ret = BadMatch;
+ goto out;
+ }
+
+ core = calloc(1, sizeof(*core));
+ if (!core)
+ return BadAlloc;
+ count = 1;
+ core->u.u.type = TOUCHMOTION;
+ core->u.u.detail = e->detail.key & 0xFF;
+ core->u.keyButtonPointer.time = e->time;
+ core->u.keyButtonPointer.rootX = e->root_x;
+ core->u.keyButtonPointer.rootY = e->root_y;
+ core->u.keyButtonPointer.state = e->corestate;
+ core->u.keyButtonPointer.root = e->root;
+ EventSetKeyRepeatFlag(core, (e->type == ET_KeyPress && e->key_repeat));
+ ret = Success;
+ }
+ break;
+ case ET_TouchEnd:
+ {
+ DeviceEvent *e = &event->device_event;
+
+ if (e->detail.key > 0xFF) {
+ ret = BadMatch;
+ goto out;
+ }
+
+ core = calloc(1, sizeof(*core));
+ if (!core)
+ return BadAlloc;
+ count = 1;
+ core->u.u.type = TOUCHUP;
+ core->u.u.detail = e->detail.key & 0xFF;
+ core->u.keyButtonPointer.time = e->time;
+ core->u.keyButtonPointer.rootX = e->root_x;
+ core->u.keyButtonPointer.rootY = e->root_y;
+ core->u.keyButtonPointer.state = e->corestate;
+ core->u.keyButtonPointer.root = e->root;
+ EventSetKeyRepeatFlag(core, (e->type == ET_KeyPress && e->key_repeat));
+ ret = Success;
+ }
+ break;
default:
/* XXX: */
ErrorF("[dix] EventToCore: Not implemented yet \n");
--
2.20.1

1 change: 1 addition & 0 deletions debian/patches/series
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
06_use-intel-only-on-pre-gen4.diff
07_use-modesetting-driver-by-default-on-GeForce.diff
add-device-id.patch
feat-Xrecord-add-touch-support.patch

0 comments on commit b55f066

Please sign in to comment.