[client] input: avoid reentrancy when realigning guest cursor

This prevents LGMP_ERR_QUEUE_FULL from happening with high polling rate
mice, which is caused by receiving many more mouse events while the
guest cursor warps, triggering more warps.
This commit is contained in:
Quantum 2022-01-15 00:00:34 -05:00 committed by Geoffrey McRae
parent 9c49dc6efd
commit 7c91c922e6
2 changed files with 14 additions and 3 deletions

View File

@ -421,6 +421,9 @@ void core_handleMouseNormal(double ex, double ey)
if (!g_cursor.guest.valid) if (!g_cursor.guest.valid)
return; return;
if (g_cursor.realigning)
return;
if (!core_inputEnabled()) if (!core_inputEnabled())
return; return;
@ -478,11 +481,15 @@ void core_handleMouseNormal(double ex, double ey)
else else
{ {
/* wait for the move request to be processed */ /* wait for the move request to be processed */
g_cursor.realigning = true;
do do
{ {
uint32_t hostSerial; uint32_t hostSerial;
if (lgmpClientGetSerial(g_state.pointerQueue, &hostSerial) != LGMP_OK) if (lgmpClientGetSerial(g_state.pointerQueue, &hostSerial) != LGMP_OK)
{
g_cursor.realigning = false;
return; return;
}
if (hostSerial >= setPosSerial) if (hostSerial >= setPosSerial)
break; break;
@ -494,6 +501,7 @@ void core_handleMouseNormal(double ex, double ey)
g_cursor.guest.x = msg.x; g_cursor.guest.x = msg.x;
g_cursor.guest.y = msg.y; g_cursor.guest.y = msg.y;
g_cursor.realign = false; g_cursor.realign = false;
g_cursor.realigning = false;
if (!g_cursor.inWindow) if (!g_cursor.inWindow)
return; return;

View File

@ -250,6 +250,9 @@ struct CursorState
/* true if the guest should be realigned to the host when next drawn */ /* true if the guest should be realigned to the host when next drawn */
bool realign; bool realign;
/* true if the guest is currently realigning to the host */
bool realigning;
/* true if the cursor needs re-drawing/updating */ /* true if the cursor needs re-drawing/updating */
bool redraw; bool redraw;