winex11: Merge consecutive RawMotion events.

This commit is contained in:
Alexandre Julliard 2011-04-27 16:00:50 +02:00
parent da9922b40d
commit bab850389a
1 changed files with 44 additions and 0 deletions

View File

@ -245,6 +245,46 @@ enum event_merge_action
MERGE_IGNORE /* ignore the new event, keep the old one */
};
/***********************************************************************
* merge_raw_motion_events
*/
#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
static enum event_merge_action merge_raw_motion_events( XIRawEvent *prev, XIRawEvent *next )
{
int i, j, k;
unsigned char mask;
if (!prev->valuators.mask_len) return MERGE_HANDLE;
if (!next->valuators.mask_len) return MERGE_HANDLE;
mask = prev->valuators.mask[0] | next->valuators.mask[0];
if (mask == next->valuators.mask[0]) /* keep next */
{
for (i = j = k = 0; i < 8; i++)
{
if (XIMaskIsSet( prev->valuators.mask, i ))
next->valuators.values[j] += prev->valuators.values[k++];
if (XIMaskIsSet( next->valuators.mask, i )) j++;
}
TRACE( "merging duplicate GenericEvent\n" );
return MERGE_DISCARD;
}
if (mask == prev->valuators.mask[0]) /* keep prev */
{
for (i = j = k = 0; i < 8; i++)
{
if (XIMaskIsSet( next->valuators.mask, i ))
prev->valuators.values[j] += next->valuators.values[k++];
if (XIMaskIsSet( prev->valuators.mask, i )) j++;
}
TRACE( "merging duplicate GenericEvent\n" );
return MERGE_IGNORE;
}
/* can't merge events with disjoint masks */
return MERGE_HANDLE;
}
#endif
/***********************************************************************
* merge_events
*
@ -289,6 +329,10 @@ static enum event_merge_action merge_events( XEvent *prev, XEvent *next )
return MERGE_IGNORE;
}
break;
case GenericEvent:
if (next->xcookie.extension != xinput2_opcode) break;
if (next->xcookie.evtype != XI_RawMotion) break;
return merge_raw_motion_events( prev->xcookie.data, next->xcookie.data );
}
break;
#endif