[client] spice: fix errant keyboard grab/ungrab behaviour

This commit is contained in:
Geoffrey McRae 2021-01-30 12:01:20 +11:00
parent bbfe5aea37
commit e951aaad2d

View File

@ -152,16 +152,11 @@ void app_handleFocusEvent(bool focused)
if (!app_inputEnabled()) if (!app_inputEnabled())
return; return;
if (params.grabKeyboardOnFocus)
{
if (focused)
g_state.ds->grabKeyboard();
else
g_state.ds->ungrabKeyboard();
}
if (!focused) if (!focused)
{
setGrabQuiet(false);
setCursorInView(false); setCursorInView(false);
}
g_cursor.realign = true; g_cursor.realign = true;
g_state.ds->realignPointer(); g_state.ds->realignPointer();
@ -1013,6 +1008,9 @@ static void setCursorInView(bool enable)
if (warpSupport && !params.captureInputOnly) if (warpSupport && !params.captureInputOnly)
g_state.ds->grabPointer(); g_state.ds->grabPointer();
if (params.grabKeyboardOnFocus)
g_state.ds->grabKeyboard();
} }
else else
{ {
@ -1022,7 +1020,7 @@ static void setCursorInView(bool enable)
if (warpSupport) if (warpSupport)
g_state.ds->ungrabPointer(); g_state.ds->ungrabPointer();
setGrabQuiet(false); g_state.ds->ungrabKeyboard();
} }
g_cursor.warpState = WARP_STATE_ON; g_cursor.warpState = WARP_STATE_ON;
@ -1562,8 +1560,7 @@ static void setGrabQuiet(bool enable)
{ {
if (params.grabKeyboard) if (params.grabKeyboard)
{ {
if (!g_state.focused || !params.grabKeyboardOnFocus || if (!g_state.focused || params.captureInputOnly)
params.captureInputOnly)
g_state.ds->ungrabKeyboard(); g_state.ds->ungrabKeyboard();
} }