[client] spice: look for x11 warp completion events in key/btn events.

This commit is contained in:
Geoffrey McRae 2021-01-06 20:17:52 +11:00
parent 09e02b0613
commit 67022d664f

View File

@ -1060,6 +1060,23 @@ static void keyboardUngrab()
); );
} }
static bool processXWarp(const XEvent xe, int x, int y)
{
union WarpInfo * warp;
if (ll_peek_head(g_cursor.warpList, (void **)&warp) &&
xe.xany.serial == warp->serial)
{
ll_shift(g_cursor.warpList, NULL);
free(warp);
g_cursor.last.x = x;
g_cursor.last.y = y;
return true;
}
return false;
}
int eventFilter(void * userdata, SDL_Event * event) int eventFilter(void * userdata, SDL_Event * event)
{ {
switch(event->type) switch(event->type)
@ -1152,17 +1169,8 @@ int eventFilter(void * userdata, SDL_Event * event)
const int y = round(device->event_y); const int y = round(device->event_y);
/* detect and filter out warp events */ /* detect and filter out warp events */
union WarpInfo * warp; if (processXWarp(xe, x, y))
if (ll_peek_head(g_cursor.warpList, (void **)&warp) &&
xe.xany.serial == warp->serial)
{
ll_shift(g_cursor.warpList, NULL);
free(warp);
g_cursor.last.x = x;
g_cursor.last.y = y;
break; break;
}
handleMouseMoveEvent(x, y); handleMouseMoveEvent(x, y);
break; break;
@ -1174,53 +1182,38 @@ int eventFilter(void * userdata, SDL_Event * event)
case MotionNotify: case MotionNotify:
{ {
/* detect and filter out warp events */ /* detect and filter out warp events */
union WarpInfo * warp; if (processXWarp(xe, xe.xmotion.x, xe.xmotion.y))
if (ll_peek_head(g_cursor.warpList, (void **)&warp) &&
xe.xany.serial == warp->serial)
{
ll_shift(g_cursor.warpList, NULL);
free(warp);
g_cursor.last.x = xe.xmotion.x;
g_cursor.last.y = xe.xmotion.y;
break; break;
}
handleMouseMoveEvent(xe.xmotion.x, xe.xmotion.y); handleMouseMoveEvent(xe.xmotion.x, xe.xmotion.y);
break; break;
} }
/* key press/release events can be the end of a warp also */
case KeyPress:
case KeyRelease:
processXWarp(xe, xe.xkey.x, xe.xkey.y);
break;
/* button press/release events can be the end of a warp also */
case ButtonPress:
case ButtonRelease:
processXWarp(xe, xe.xbutton.x, xe.xbutton.y);
break;
case EnterNotify: case EnterNotify:
{ {
union WarpInfo * warp; processXWarp(xe, xe.xcrossing.x, xe.xcrossing.y);
if (ll_peek_head(g_cursor.warpList, (void **)&warp) &&
xe.xany.serial == warp->serial)
{
ll_shift(g_cursor.warpList, NULL);
free(warp);
}
g_cursor.last.x = xe.xcrossing.x;
g_cursor.last.y = xe.xcrossing.y;
handleWindowEnter(); handleWindowEnter();
break; break;
} }
case LeaveNotify: case LeaveNotify:
{ {
union WarpInfo * warp; processXWarp(xe, xe.xcrossing.x, xe.xcrossing.y);
if (ll_peek_head(g_cursor.warpList, (void **)&warp) &&
xe.xany.serial == warp->serial)
{
ll_shift(g_cursor.warpList, NULL);
free(warp);
}
if (xe.xcrossing.mode != NotifyNormal) if (xe.xcrossing.mode != NotifyNormal)
break; break;
g_cursor.last.x = xe.xcrossing.x;
g_cursor.last.y = xe.xcrossing.y;
handleWindowLeave(); handleWindowLeave();
break; break;
} }
@ -1243,6 +1236,7 @@ int eventFilter(void * userdata, SDL_Event * event)
keyboardUngrab(); keyboardUngrab();
break; break;
default: default:
{ {
union WarpInfo * warp; union WarpInfo * warp;