fix previous fix
[openwrt/svn-archive/archive.git] / Xorg / driver / xf86-input-tslib / patches / 015-add-randr-support.patch
1 commit b80f653bf33ed0ec23223a9877068cba97850ed1
2 Author: Lars-Peter Clausen <lars@metafoo.de>
3 Date: Wed Feb 18 23:08:14 2009 +0100
4
5 Transform touchscreen coordinates according to randr rotation.
6
7 diff --git a/src/tslib.c b/src/tslib.c
8 index 3eba078..6091006 100644
9 --- a/src/tslib.c
10 +++ b/src/tslib.c
11 @@ -48,6 +48,7 @@
12 #include <exevents.h> /* Needed for InitValuator/Proximity stuff */
13 #include <X11/keysym.h>
14 #include <mipointer.h>
15 +#include <randrstr.h>
16
17 #include <tslib.h>
18
19 @@ -128,6 +129,8 @@ static void ReadInput (LocalDevicePtr local)
20 struct ts_sample samp;
21 int ret;
22 int x,y;
23 + ScrnInfoPtr pScrn = xf86Screens[priv->screen_num];
24 + Rotation rotation = rrGetScrPriv (pScrn->pScreen) ? RRGetRotation(pScrn->pScreen) : RR_Rotate_0;
25
26 ret = ts_read(priv->ts, &samp, 1);
27
28 @@ -154,6 +157,23 @@ static void ReadInput (LocalDevicePtr local)
29 default: break;
30 }
31
32 + tmp_x = samp.x;
33 +
34 + switch(rotation) {
35 + case RR_Rotate_90:
36 + samp.x = (priv->height - samp.y - 1) * priv->width / priv->height;
37 + samp.y = tmp_x * priv->height / priv->width;
38 + break;
39 + case RR_Rotate_180:
40 + samp.x = priv->width - samp.x - 1;
41 + samp.y = priv->height - samp.y - 1;
42 + break;
43 + case RR_Rotate_270:
44 + samp.x = samp.y * priv->width / priv->height;
45 + samp.y = (priv->width - tmp_x - 1) * priv->height / priv->width;
46 + break;
47 + }
48 +
49 priv->lastx = samp.x;
50 priv->lasty = samp.y;
51 x = samp.x;