summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@openedhand.com>2008-01-08 12:12:06 +0100
committerDodji Seketeli <dodji@openedhand.com>2008-01-08 12:31:47 +0100
commitc31aead0fe9fe424120ce221cd9f76cb6d29a5b5 (patch)
treed5ad9bdf02e5de7f8d1f5e5b3ea155645962bd93
parent30375cd6d1439a3390b41714fe116aecc94743ca (diff)
[Kdrive] make XCalibrate 'orientation aware'
-rw-r--r--Xext/xcalibrate.c47
-rw-r--r--hw/kdrive/src/kdrive.h5
-rw-r--r--hw/kdrive/src/kinput.c12
3 files changed, 62 insertions, 2 deletions
diff --git a/Xext/xcalibrate.c b/Xext/xcalibrate.c
index 97ef3dc38..3fe2bdc5c 100644
--- a/Xext/xcalibrate.c
+++ b/Xext/xcalibrate.c
@@ -164,7 +164,6 @@ ProcXCalibrateSetRawMode (ClientPtr client)
return (client->noClientException);
}
-
static int
SProcXCalibrateSetRawMode (ClientPtr client)
{
@@ -178,6 +177,47 @@ SProcXCalibrateSetRawMode (ClientPtr client)
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 @@ ProcXCalibrateDispatch (ClientPtr client)
return ProcXCalibrateQueryVersion(client);
case X_XCalibrateRawMode:
return ProcXCalibrateSetRawMode(client);
+ case X_XCalibrateScreenToCoord:
+ return ProcXCalibrateScreenToCoord(client);
+
default: break;
}
@@ -211,6 +254,8 @@ SProcXCalibrateDispatch (ClientPtr client)
return SProcXCalibrateQueryVersion(client);
case X_XCalibrateRawMode:
return SProcXCalibrateSetRawMode(client);
+ case X_XCalibrateScreenToCoord:
+ return SProcXCalibrateScreenToCoord(client);
default: break;
}
diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h
index 8722ba303..4e04b59f7 100644
--- a/hw/kdrive/src/kdrive.h
+++ b/hw/kdrive/src/kdrive.h
@@ -832,7 +832,10 @@ KdSetPointerMatrix (KdPointerMatrix *pointer);
void
KdComputePointerMatrix (KdPointerMatrix *pointer, Rotation randr, int width, int height);
-
+
+void
+KdScreenToPointerCoords (int *x, int *y);
+
void
KdBlockHandler (int screen,
pointer blockData,
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 6c247c185..df73942e7 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -631,6 +631,18 @@ KdComputePointerMatrix (KdPointerMatrix *m, Rotation randr, int width,
}
}
+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;
+}
+
static void
KdKbdCtrl (DeviceIntPtr pDevice, KeybdCtrl *ctrl)
{