dix: mark motion events as emulated if we're scrolling from button press

The protocol requires that the emulated event is marked as such. So if a
driver with smooth scrolling axis sends legacy button events, the motion
event must be marked as emulated.

Pass the real type to emulate_scroll_button_events and create the events
accordingly. For real button press or relase events, only that event must be
generated since a release event will follow or a press event has already
occured, respectively. (This fixes a bug where we'd get two release events
for each legacy button event)

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
This commit is contained in:
Peter Hutterer 2011-10-05 12:08:31 +10:00
parent 82c60232c0
commit 2cb63180fa

View File

@ -1228,6 +1228,7 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
*
* @param events The pointer to the event list to fill the events
* @param dev The device to generate the events for
* @param type The real type of the event
* @param axis The axis number to generate events for
* @param mask State before this event in absolute coords
* @param[in,out] last Last scroll state posted in absolute coords (modified
@ -1239,6 +1240,7 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
static int
emulate_scroll_button_events(InternalEvent *events,
DeviceIntPtr dev,
int type,
int axis,
const ValuatorMask *mask,
ValuatorMask *last,
@ -1251,6 +1253,7 @@ emulate_scroll_button_events(InternalEvent *events,
int num_events = 0;
double total;
int b;
int flags = 0;
if (dev->valuator->axes[axis].scroll.type == SCROLL_TYPE_NONE)
return 0;
@ -1261,6 +1264,9 @@ emulate_scroll_button_events(InternalEvent *events,
ax = &dev->valuator->axes[axis];
incr = ax->scroll.increment;
if (type != ButtonPress && type != ButtonRelease)
flags |= POINTER_EMULATED;
if (!valuator_mask_isset(last, axis))
valuator_mask_set_double(last, axis, 0);
@ -1288,14 +1294,20 @@ emulate_scroll_button_events(InternalEvent *events,
*/
if (num_events + 4 < max_events)
{
nev_tmp = fill_pointer_events(events, dev, ButtonPress, b, ms,
POINTER_EMULATED, NULL);
events += nev_tmp;
num_events += nev_tmp;
nev_tmp = fill_pointer_events(events, dev, ButtonRelease, b, ms,
POINTER_EMULATED, NULL);
events += nev_tmp;
num_events += nev_tmp;
if (type != ButtonRelease)
{
nev_tmp = fill_pointer_events(events, dev, ButtonPress, b, ms,
flags, NULL);
events += nev_tmp;
num_events += nev_tmp;
}
if (type != ButtonPress)
{
nev_tmp = fill_pointer_events(events, dev, ButtonRelease, b, ms,
flags, NULL);
events += nev_tmp;
num_events += nev_tmp;
}
}
}
@ -1340,6 +1352,7 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
ValuatorMask mask;
ValuatorMask scroll;
int i;
int realtype = type;
/* refuse events from disabled devices */
if (!pDev->enabled)
@ -1392,6 +1405,7 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
valuator_mask_set_double(&mask, axis, val);
type = MotionNotify;
buttons = 0;
flags |= POINTER_EMULATED;
}
}
@ -1411,7 +1425,7 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
valuator_mask_set_double(&scroll, i, pDev->last.valuators[i]);
nev_tmp = emulate_scroll_button_events(events, pDev, i, &scroll,
nev_tmp = emulate_scroll_button_events(events, pDev, realtype, i, &scroll,
pDev->last.scroll, ms,
GetMaximumEventsNum() - num_events);
events += nev_tmp;