Commit 8571c648 authored by Peter Hutterer's avatar Peter Hutterer
Browse files

Xext: if a root window is given in XTestFakeInput, move to that



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's avatarPeter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard's avatarKeith Packard <keithp@keithp.com>
parent 9fd6cb89
......@@ -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;
......
......@@ -820,24 +820,30 @@ accelPointer(DeviceIntPtr dev, ValuatorMask *valuators, CARD32 ms)
* device's coordinate range.
*
* @param dev The device to scale for.
* @param[in, out] mask The mask in desktop coordinates, modified in place
* @param[in, out] mask The mask in desktop/screen 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/desktop 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);
......
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment