summaryrefslogtreecommitdiff
path: root/recipes/xorg-xserver/xserver-kdrive/xcalibrate_coords.patch
blob: 7f4ec09d6885fdf61ce90f59b66ed727ae2655b7 (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
---
 Xext/xcalibrate.c      |   47 ++++++++++++++++++++++++++++++++++++++++++++++-
 hw/kdrive/src/kdrive.h |    3 +++
 hw/kdrive/src/kinput.c |   12 ++++++++++++
 3 files changed, 61 insertions(+), 1 deletion(-)

Index: xorg-server-1.4/Xext/xcalibrate.c
===================================================================
--- xorg-server-1.4.orig/Xext/xcalibrate.c	2007-08-23 21:04:52.000000000 +0200
+++ xorg-server-1.4/Xext/xcalibrate.c	2007-09-06 23:27:40.000000000 +0200
@@ -164,7 +164,6 @@
   return (client->noClientException);
 }
 
-
 static int
 SProcXCalibrateSetRawMode (ClientPtr client)
 {
@@ -178,6 +177,47 @@
   return ProcXCalibrateSetRawMode(client);
 }
 
+static int
+ProcXCalibrateScreenToCoord (ClientPtr client)
+{
+  REQUEST(xXCalibrateScreenToCoordReq);
+  xXCalibrateScreenToCoordReply rep;
+
+  REQUEST_SIZE_MATCH (xXCalibrateScreenToCoordReq);
+
+  memset (&rep, 0, sizeof (rep));
+  rep.type = X_Reply;
+  rep.sequenceNumber = client->sequence;
+  rep.x = stuff->x;
+  rep.y = stuff->y;
+
+  KdScreenToPointerCoords(&rep.x, &rep.y);
+
+  if (client->swapped)
+    {
+      int n;
+
+      swaps (&rep.x, n);
+      swaps (&rep.y, n);
+    }
+  WriteToClient(client, sizeof (rep), (char *) &rep);
+  return (client->noClientException);
+}
+
+static int
+SProcXCalibrateScreenToCoord (ClientPtr client)
+{
+  REQUEST(xXCalibrateScreenToCoordReq);
+  int n;
+
+  REQUEST_SIZE_MATCH (xXCalibrateScreenToCoordReq);
+
+  swaps(&stuff->x, n);
+  swaps(&stuff->y, n);
+
+  return ProcXCalibrateScreenToCoord(client);
+}
+
 static void
 XCalibrateResetProc (ExtensionEntry *extEntry) 
 { 
@@ -192,6 +232,9 @@
         return ProcXCalibrateQueryVersion(client);
     case X_XCalibrateRawMode:
         return ProcXCalibrateSetRawMode(client);
+    case X_XCalibrateScreenToCoord:
+        return ProcXCalibrateScreenToCoord(client);
+
     default: break;
     }
 
@@ -211,6 +254,8 @@
         return SProcXCalibrateQueryVersion(client);
     case X_XCalibrateRawMode:
         return SProcXCalibrateSetRawMode(client);
+    case X_XCalibrateScreenToCoord:
+        return SProcXCalibrateScreenToCoord(client);
 
     default: break;
     }
Index: xorg-server-1.4/hw/kdrive/src/kdrive.h
===================================================================
--- xorg-server-1.4.orig/hw/kdrive/src/kdrive.h	2007-08-23 21:04:53.000000000 +0200
+++ xorg-server-1.4/hw/kdrive/src/kdrive.h	2007-09-06 23:28:50.000000000 +0200
@@ -848,6 +848,9 @@
 KdSetPointerMatrix (KdPointerMatrix *pointer);
 
 void
+KdScreenToPointerCoords (int *x, int *y);
+
+void
 KdComputePointerMatrix (KdPointerMatrix *pointer, Rotation randr, int width, int height);
     
 void
Index: xorg-server-1.4/hw/kdrive/src/kinput.c
===================================================================
--- xorg-server-1.4.orig/hw/kdrive/src/kinput.c	2007-08-23 21:04:53.000000000 +0200
+++ xorg-server-1.4/hw/kdrive/src/kinput.c	2007-09-06 23:30:54.000000000 +0200
@@ -592,6 +592,18 @@
 }
 
 void
+KdScreenToPointerCoords (int *x, int *y)
+{
+    int	(*m)[3] = kdPointerMatrix.matrix;
+    int div = m[0][1] * m[1][0] - m[1][1] * m[0][0];
+    int sx = *x;
+    int sy = *y;
+
+    *x = (m[0][1] * sy - m[0][1] * m[1][2] + m[1][1] * m[0][2] - m[1][1] * sx) / div;
+    *y = (m[1][0] * sx + m[0][0] * m[1][2] - m[1][0] * m[0][2] - m[0][0] * sy) / div;
+}
+
+void
 KdComputePointerMatrix (KdPointerMatrix *m, Rotation randr, int width,
                         int height)
 {