summaryrefslogtreecommitdiff
path: root/recipes/xorg-xserver/xserver-kdrive/xcalibrate-new-input-world-order.patch
blob: 2cc9e60d8da5f5205f7d49d30894cb3e89d6305a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
CRUDE HACK ALERT: this patch adds a new device control (DEVICE_RAWEVENT) 
which cannot be exported in the protocol because the xDeviceRaweventCtl 
carries a C pointer to the tslib event hook. For lack of a better idea,
I added this to get the event hook pointer from Xext/xcalibrate.c into
tslib.c, where the now-private _raw_event_hook and _raw_event_closure
pointers are manipulated instead of, like before, in the Xcalibrate 
extension itself.

Index: xorg-server-1.4/Xext/xcalibrate.c
===================================================================
--- xorg-server-1.4.orig/Xext/xcalibrate.c	2007-09-08 13:22:55.000000000 +0200
+++ xorg-server-1.4/Xext/xcalibrate.c	2007-09-08 16:03:17.000000000 +0200
@@ -33,14 +33,14 @@
 #include "os.h"
 #include "dixstruct.h"
 #include "extnsionst.h"
+#include "inputstr.h"				/* for inputInfo */
 #include "swaprep.h"
 
+#include <X11/extensions/XI.h>			/* for XI_TOUCHSCREEN */
+#include <X11/extensions/XIproto.h>		/* for xDeviceCtl */
 #include <X11/extensions/xcalibrateproto.h>
 #include <X11/extensions/xcalibratewire.h>
 
-extern void (*tslib_raw_event_hook)(int x, int y, int pressure, void *closure);
-extern void *tslib_raw_event_closure;
-
 static CARD8	XCalibrateReqCode;
 int		XCalibrateEventBase;
 int		XCalibrateReqBase;
@@ -64,6 +64,31 @@
     WriteEventsToClient (pClient, 1, (xEvent *) &ev);
 }
 
+#define DEVICE_RAWEVENT 6
+typedef struct {
+    CARD16          control B16;
+    CARD16          length  B16;
+    void           *hook;
+} xDeviceRaweventCtl;
+
+static void
+xcalibrate_set_event_hook (void *hook, ClientPtr client)
+{
+  DeviceIntPtr devtmp;
+  Atom xiclass;
+  xDeviceRaweventCtl rawevent;
+
+  rawevent.control = DEVICE_RAWEVENT;
+  rawevent.length = sizeof(rawevent);
+  rawevent.hook = hook;
+
+  xiclass = MakeAtom(XI_TOUCHSCREEN, strlen(XI_TOUCHSCREEN), 1);
+
+  for (devtmp = inputInfo.devices; devtmp; devtmp = devtmp->next)
+    if (devtmp->type == xiclass)
+      ChangeDeviceControl(client, devtmp, (xDeviceCtl *) &rawevent);
+}
+
 static int
 ProcXCalibrateQueryVersion (ClientPtr client)
 {
@@ -124,8 +149,7 @@
 	{
 	  /* Start calibrating.  */
 	  xcalibrate_client = client;
-	  tslib_raw_event_hook = xcalibrate_event_hook;
-	  tslib_raw_event_closure = client;
+	  xcalibrate_set_event_hook(xcalibrate_event_hook, client);
 	  rep.status = GrabSuccess;
 	}
       else
@@ -139,8 +163,7 @@
 	{
 	  /* Stop calibrating.  */
 	  xcalibrate_client = NULL;
-	  tslib_raw_event_hook = NULL;
-	  tslib_raw_event_closure = NULL;
+	  xcalibrate_set_event_hook(NULL, NULL);
 	  rep.status = GrabSuccess;
 
 	  /* Cycle input off and on to reload configuration.  */
@@ -277,8 +300,7 @@
       {
 	/* Stop calibrating.  */
 	xcalibrate_client = NULL;
-	tslib_raw_event_hook = NULL;
-	tslib_raw_event_closure = NULL;
+	xcalibrate_set_event_hook(NULL, NULL);
       }
 }
 
Index: xorg-server-1.4/hw/kdrive/linux/tslib.c
===================================================================
--- xorg-server-1.4.orig/hw/kdrive/linux/tslib.c	2007-09-08 14:46:41.000000000 +0200
+++ xorg-server-1.4/hw/kdrive/linux/tslib.c	2007-09-08 16:10:57.000000000 +0200
@@ -56,6 +56,13 @@
     int phys_screen;
 };
 
+void
+tslib_set_raw_event_hook(KdPointerInfo *pi, void *hook, void *closure)
+{
+	struct TslibPrivate *private = pi->driverPrivate;
+	private->raw_event_hook = hook;
+	private->raw_event_closure = closure;
+}
 
 static void
 TsRead (int fd, void *closure)
Index: xorg-server-1.4/hw/kdrive/src/kinput.c
===================================================================
--- xorg-server-1.4.orig/hw/kdrive/src/kinput.c	2007-09-08 14:45:01.000000000 +0200
+++ xorg-server-1.4/hw/kdrive/src/kinput.c	2007-09-08 16:09:32.000000000 +0200
@@ -2389,10 +2389,19 @@
     return BadMatch;
 }
 
+#define DEVICE_RAWEVENT 6
+typedef struct {
+    CARD16          control B16;
+    CARD16          length  B16;
+    void           *hook;
+} xDeviceRaweventCtl;
+
 int
 ChangeDeviceControl(register ClientPtr client, DeviceIntPtr pDev,
                         xDeviceCtl *control)
 {
+    KdPointerInfo *pi;
+
     switch (control->control) {
     case DEVICE_RESOLUTION:
         /* FIXME do something more intelligent here */
@@ -2406,6 +2415,24 @@
     case DEVICE_ENABLE:
         return Success;
 
+    case DEVICE_RAWEVENT:
+        if (!pDev)
+	    return BadImplementation;
+
+        for (pi = kdPointers; pi; pi = pi->next) {
+            if (pi->dixdev && pi->dixdev->id == pDev->id)
+                break;
+        }
+
+        if (!pi || !pi->dixdev || pi->dixdev->id != pDev->id) {
+            ErrorF("[ChangeDeviceControl] Failed to find pointer for device %d!\n",
+                   pDev->id);
+            return BadImplementation;
+        }
+
+        tslib_set_raw_event_hook(pi, ((xDeviceRaweventCtl *)control)->hook, client);
+	return Success;
+
     default:
         return BadMatch;
     }