Commit bab85038 authored by Alexandre Julliard's avatar Alexandre Julliard

winex11: Merge consecutive RawMotion events.

parent da9922b4
......@@ -246,6 +246,46 @@ enum event_merge_action
};
/***********************************************************************
* 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
*
* Try to merge 2 consecutive 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
......
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