[client] spice: don't grab the keyboard input unless we are focused

This commit is contained in:
Geoffrey McRae 2021-01-08 20:26:32 +11:00
parent f352463d19
commit 59ea957d0d
2 changed files with 21 additions and 13 deletions

View File

@ -899,20 +899,23 @@ static void handleMouseNormal(double ex, double ey)
if (inView) if (inView)
{ {
/* the cursor moved in, enable grab mode */ if (g_state.focused)
g_cursor.inView = true; {
g_cursor.warpState = WARP_STATE_ON; /* the cursor moved in, enable grab mode */
g_cursor.inView = true;
g_cursor.warpState = WARP_STATE_ON;
XGrabPointer( XGrabPointer(
g_state.wminfo.info.x11.display, g_state.wminfo.info.x11.display,
g_state.wminfo.info.x11.window, g_state.wminfo.info.x11.window,
true, true,
None, None,
GrabModeAsync, GrabModeAsync,
GrabModeAsync, GrabModeAsync,
g_state.wminfo.info.x11.window, g_state.wminfo.info.x11.window,
None, None,
CurrentTime); CurrentTime);
}
struct DoublePoint guest = struct DoublePoint guest =
{ {
@ -1314,6 +1317,8 @@ int eventFilter(void * userdata, SDL_Event * event)
} }
case FocusIn: case FocusIn:
g_state.focused = true;
if (!params.useSpiceInput) if (!params.useSpiceInput)
break; break;
@ -1323,6 +1328,8 @@ int eventFilter(void * userdata, SDL_Event * event)
break; break;
case FocusOut: case FocusOut:
g_state.focused = false;
if (!params.useSpiceInput) if (!params.useSpiceInput)
break; break;

View File

@ -50,6 +50,7 @@ struct AppState
SDL_Point windowPos; SDL_Point windowPos;
int windowW, windowH; int windowW, windowH;
int windowCX, windowCY; int windowCX, windowCY;
bool focused;
SDL_Rect border; SDL_Rect border;
SDL_Point srcSize; SDL_Point srcSize;
LG_RendererRect dstRect; LG_RendererRect dstRect;