From df070fef5dcf20181f10704a69168322e90cb71c Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 29 Oct 2012 18:33:50 +0100 Subject: [PATCH] Xi: put the state into the event _before_ updating the device state (#56558) The emulated motion event that happens before TouchBegin/ButtonPress should contain no buttons set in the mask, as it virtually happens at a time when the button is not yet pressed. This is known to confuse GTK+ and Abiword to different degrees, as enclosing button press/release events are expected around changes in the button mask. Likewise, the emulated press and release events must include the state from before the touch event was processed. Co-authored-by: Carlos Garnacho Signed-off-by: Peter Hutterer --- Xi/exevents.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Xi/exevents.c b/Xi/exevents.c index 7625c1f..401e9a5 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -1400,7 +1400,6 @@ DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent motion, button; InternalEvent *ptrev = &motion; int nevents; - DeviceIntPtr kbd; /* We don't deliver pointer events to non-owners */ if (!TouchResourceIsOwner(ti, listener->listener)) @@ -1412,10 +1411,6 @@ DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, if (nevents > 1) ptrev = &button; - kbd = GetMaster(dev, KEYBOARD_OR_FLOAT); - event_set_state(dev, kbd, &ptrev->device_event); - ptrev->device_event.corestate = event_get_corestate(dev, kbd); - if (grab) { /* this side-steps the usual activation mechansims, but... */ if (ev->any.type == ET_TouchBegin && !dev->deviceGrab.grab) @@ -1558,6 +1553,7 @@ ProcessTouchEvent(InternalEvent *ev, DeviceIntPtr dev) uint32_t touchid; int type = ev->any.type; int emulate_pointer = ! !(ev->device_event.flags & TOUCH_POINTER_EMULATED); + DeviceIntPtr kbd; if (!t) return; @@ -1567,9 +1563,6 @@ ProcessTouchEvent(InternalEvent *ev, DeviceIntPtr dev) else touchid = ev->device_event.touchid; - if (emulate_pointer) - UpdateDeviceState(dev, &ev->device_event); - if (type == ET_TouchBegin) { ti = TouchBeginTouch(dev, ev->device_event.sourceid, touchid, emulate_pointer); @@ -1616,9 +1609,17 @@ ProcessTouchEvent(InternalEvent *ev, DeviceIntPtr dev) * events which _only_ emulate motion just work normally */ if (emulate_pointer && ev->any.type != ET_TouchUpdate) DeliverEmulatedMotionEvent(dev, ti, ev); + if (emulate_pointer && IsMaster(dev)) CheckMotion(&ev->device_event, dev); + kbd = GetMaster(dev, KEYBOARD_OR_FLOAT); + event_set_state(dev, kbd, &ev->device_event); + ev->device_event.corestate = event_get_corestate(dev, kbd); + + if (emulate_pointer) + UpdateDeviceState(dev, &ev->device_event); + /* Make sure we have a valid window trace for event delivery; must be * called after event type mutation. Touch end events are always processed * in order to end touch records. */ -- 1.7.11.7