-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Xrecord add touch support. Log: Xrecord add touch support. Bug: https://pms.uniontech.com/zentao/bug-view-87450.html
- Loading branch information
Showing
3 changed files
with
161 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters