[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

@ -898,6 +898,8 @@ static void handleMouseNormal(double ex, double ey)
g_cursor.pos.y < g_state.dstRect.y + g_state.dstRect.h; g_cursor.pos.y < g_state.dstRect.y + g_state.dstRect.h;
if (inView) if (inView)
{
if (g_state.focused)
{ {
/* the cursor moved in, enable grab mode */ /* the cursor moved in, enable grab mode */
g_cursor.inView = true; g_cursor.inView = true;
@ -913,6 +915,7 @@ static void handleMouseNormal(double ex, double ey)
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;