mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-01-11 06:43:56 +00:00
[client] spice: filter out duplicate X xinput events
This commit is contained in:
parent
62f59ce50d
commit
c99561c2ac
1 changed files with 24 additions and 9 deletions
|
@ -843,12 +843,15 @@ static void handleMouseRawEvent(double ex, double ey)
|
||||||
|
|
||||||
g_cursor.accX += ex;
|
g_cursor.accX += ex;
|
||||||
g_cursor.accY += ey;
|
g_cursor.accY += ey;
|
||||||
ex = floor(g_cursor.accX);
|
int x = floor(g_cursor.accX);
|
||||||
ey = floor(g_cursor.accY);
|
int y = floor(g_cursor.accY);
|
||||||
g_cursor.accX -= ex;
|
g_cursor.accX -= x;
|
||||||
g_cursor.accY -= ey;
|
g_cursor.accY -= y;
|
||||||
|
|
||||||
if (!spice_mouse_motion(ex, ey))
|
if (x == 0 && y == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!spice_mouse_motion(x, y))
|
||||||
DEBUG_ERROR("failed to send mouse motion message");
|
DEBUG_ERROR("failed to send mouse motion message");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1242,17 +1245,16 @@ int eventFilter(void * userdata, SDL_Event * event)
|
||||||
if (cookie->extension != g_XInputOp)
|
if (cookie->extension != g_XInputOp)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
XIDeviceEvent *device = cookie->data;
|
|
||||||
|
|
||||||
if (g_cursor.grab)
|
if (g_cursor.grab)
|
||||||
{
|
{
|
||||||
if (device->evtype != XI_RawMotion)
|
if (cookie->evtype != XI_RawMotion)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (g_state.ignoreInput)
|
if (g_state.ignoreInput)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
XIRawEvent *raw = cookie->data;
|
XIRawEvent *raw = cookie->data;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* true RAW mode, however the UX is pretty poor with it, perhaps
|
/* true RAW mode, however the UX is pretty poor with it, perhaps
|
||||||
* make this an option later? */
|
* make this an option later? */
|
||||||
|
@ -1262,6 +1264,7 @@ int eventFilter(void * userdata, SDL_Event * event)
|
||||||
#else
|
#else
|
||||||
/* select the active validators for the X & Y axis */
|
/* select the active validators for the X & Y axis */
|
||||||
double *valuator = raw->valuators.values;
|
double *valuator = raw->valuators.values;
|
||||||
|
double *value = raw->raw_values;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
double axis[2];
|
double axis[2];
|
||||||
for(int i = 0; i < raw->valuators.mask_len * 8; ++i)
|
for(int i = 0; i < raw->valuators.mask_len * 8; ++i)
|
||||||
|
@ -1272,17 +1275,29 @@ int eventFilter(void * userdata, SDL_Event * event)
|
||||||
if (count == 2)
|
if (count == 2)
|
||||||
break;
|
break;
|
||||||
++valuator;
|
++valuator;
|
||||||
|
++value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* filter out duplicate events */
|
||||||
|
static Time prev_time = 0;
|
||||||
|
static double prev_axis[2] = {0};
|
||||||
|
if (raw->time == prev_time && axis[0] == prev_axis[0] && axis[1] == prev_axis[1])
|
||||||
|
break;
|
||||||
|
prev_time = raw->time;
|
||||||
|
prev_axis[0] = axis[0];
|
||||||
|
prev_axis[1] = axis[1];
|
||||||
|
|
||||||
|
|
||||||
handleMouseRawEvent(axis[0], axis[1]);
|
handleMouseRawEvent(axis[0], axis[1]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (device->evtype != XI_Motion)
|
if (cookie->evtype != XI_Motion)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
XIDeviceEvent *device = cookie->data;
|
||||||
const int x = round(device->event_x);
|
const int x = round(device->event_x);
|
||||||
const int y = round(device->event_y);
|
const int y = round(device->event_y);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue