[PATCH 3/3] Xext: if a root window is given in XTestFakeInput, move to that
Peter Hutterer
peter.hutterer at who-t.net
Wed Jan 30 18:57:01 PST 2013
For absolute events, if the client specifies a screen number offset the
coordinates by that. And add a new flag so we know when _not_ to add the
screen offset in GPE.
Without this offset and the flag, GPE would simply add the offset of the
current screen if POINTER_SCREEN is set.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
Xext/xtest.c | 10 +++++++++-
dix/getevents.c | 16 +++++++++++-----
include/input.h | 1 +
3 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/Xext/xtest.c b/Xext/xtest.c
index 209bbdd..0a854f3 100644
--- a/Xext/xtest.c
+++ b/Xext/xtest.c
@@ -305,7 +305,7 @@ ProcXTestFakeInput(ClientPtr client)
numValuators = 2;
firstValuator = 0;
if (ev->u.u.detail == xFalse)
- flags = POINTER_ABSOLUTE | POINTER_SCREEN;
+ flags = POINTER_ABSOLUTE | POINTER_DESKTOP;
break;
default:
client->errorValue = ev->u.u.type;
@@ -376,6 +376,14 @@ ProcXTestFakeInput(ClientPtr client)
client->errorValue = ev->u.keyButtonPointer.root;
return BadValue;
}
+
+ /* Add the root window's offset to the valuators */
+ if ((flags & POINTER_ABSOLUTE) && firstValuator <= 1 && numValuators > 0) {
+ if (firstValuator == 0)
+ valuators[0] += root->drawable.pScreen->x;
+ if (firstValuator < 2 && firstValuator + numValuators > 1)
+ valuators[1 - firstValuator] += root->drawable.pScreen->y;
+ }
}
if (ev->u.u.detail != xTrue && ev->u.u.detail != xFalse) {
client->errorValue = ev->u.u.detail;
diff --git a/dix/getevents.c b/dix/getevents.c
index 8fe54d7..9d9df21 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -822,22 +822,28 @@ accelPointer(DeviceIntPtr dev, ValuatorMask *valuators, CARD32 ms)
* @param dev The device to scale for.
* @param[in, out] mask The mask in desktop coordinates, modified in place
* to contain device coordinate range.
+ * @param flags If POINTER_SCREEN is set, mask is in per-screen coordinates.
+ * Otherwise, mask is in desktop coords.
*/
static void
-scale_from_screen(DeviceIntPtr dev, ValuatorMask *mask)
+scale_from_screen(DeviceIntPtr dev, ValuatorMask *mask, int flags)
{
double scaled;
ScreenPtr scr = miPointerGetScreen(dev);
if (valuator_mask_isset(mask, 0)) {
- scaled = valuator_mask_get_double(mask, 0) + scr->x;
+ scaled = valuator_mask_get_double(mask, 0);
+ if (flags & POINTER_SCREEN)
+ scaled += scr->x;
scaled = rescaleValuatorAxis(scaled,
NULL, dev->valuator->axes + 0,
screenInfo.x, screenInfo.width);
valuator_mask_set_double(mask, 0, scaled);
}
if (valuator_mask_isset(mask, 1)) {
- scaled = valuator_mask_get_double(mask, 1) + scr->y;
+ scaled = valuator_mask_get_double(mask, 1);
+ if (flags & POINTER_SCREEN)
+ scaled += scr->y;
scaled = rescaleValuatorAxis(scaled,
NULL, dev->valuator->axes + 1,
screenInfo.y, screenInfo.height);
@@ -1363,10 +1369,10 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
/* valuators are in driver-native format (rel or abs) */
if (flags & POINTER_ABSOLUTE) {
- if (flags & POINTER_SCREEN) { /* valuators are in screen coords */
+ if (flags & (POINTER_SCREEN | POINTER_DESKTOP)) { /* valuators are in screen coords */
sx = valuator_mask_get(&mask, 0);
sy = valuator_mask_get(&mask, 1);
- scale_from_screen(pDev, &mask);
+ scale_from_screen(pDev, &mask, flags);
}
transformAbsolute(pDev, &mask);
diff --git a/include/input.h b/include/input.h
index f53ed99..7b5ab94 100644
--- a/include/input.h
+++ b/include/input.h
@@ -69,6 +69,7 @@ SOFTWARE.
#define POINTER_SCREEN (1 << 4) /* Data in screen coordinates */
#define POINTER_NORAW (1 << 5) /* Don't generate RawEvents */
#define POINTER_EMULATED (1 << 6) /* Event was emulated from another event */
+#define POINTER_DESKTOP (1 << 7) /* Data in desktop coordinates */
/* GetTouchEvent flags */
#define TOUCH_ACCEPT (1 << 0)
--
1.8.1
More information about the xorg-devel
mailing list