From e951aaad2dbdae00ff5f122fde2e76b3401d0c92 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sat, 30 Jan 2021 12:01:20 +1100 Subject: [PATCH] [client] spice: fix errant keyboard grab/ungrab behaviour --- client/src/main.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/client/src/main.c b/client/src/main.c index a13282c3..1b996584 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -152,16 +152,11 @@ void app_handleFocusEvent(bool focused) if (!app_inputEnabled()) return; - if (params.grabKeyboardOnFocus) - { - if (focused) - g_state.ds->grabKeyboard(); - else - g_state.ds->ungrabKeyboard(); - } - if (!focused) + { + setGrabQuiet(false); setCursorInView(false); + } g_cursor.realign = true; g_state.ds->realignPointer(); @@ -1013,6 +1008,9 @@ static void setCursorInView(bool enable) if (warpSupport && !params.captureInputOnly) g_state.ds->grabPointer(); + + if (params.grabKeyboardOnFocus) + g_state.ds->grabKeyboard(); } else { @@ -1022,7 +1020,7 @@ static void setCursorInView(bool enable) if (warpSupport) g_state.ds->ungrabPointer(); - setGrabQuiet(false); + g_state.ds->ungrabKeyboard(); } g_cursor.warpState = WARP_STATE_ON; @@ -1562,8 +1560,7 @@ static void setGrabQuiet(bool enable) { if (params.grabKeyboard) { - if (!g_state.focused || !params.grabKeyboardOnFocus || - params.captureInputOnly) + if (!g_state.focused || params.captureInputOnly) g_state.ds->ungrabKeyboard(); }