From 76182bbeb8ab1e8de64773adb5c8d6fde7b70e2b Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sun, 17 Jan 2021 10:44:30 +1100 Subject: [PATCH] [client] mouse: do not send mouse updates to the guest if not focused --- client/src/main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/client/src/main.c b/client/src/main.c index ac51370a..f99d8a7e 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -958,6 +958,10 @@ void app_handleMouseGrabbed(double ex, double ey) { int x, y; + /* do not pass mouse events to the guest if we do not have focus */ + if (!g_state.focused) + return; + if (params.rawMouse && !g_cursor.useScale) { /* raw unscaled input are always round numbers */ @@ -987,6 +991,10 @@ static void guestCurToLocal(struct DoublePoint *local) void app_handleMouseNormal(double ex, double ey) { + /* do not pass mouse events to the guest if we do not have focus */ + if (!g_state.focused) + return; + // prevent cursor handling outside of capture if the position is not known if (!g_cursor.guest.valid) return; @@ -1115,6 +1123,10 @@ void app_handleMouseNormal(double ex, double ey) // capture mode. void app_handleMouseBasic() { + /* do not pass mouse events to the guest if we do not have focus */ + if (!g_state.focused) + return; + const bool inView = g_cursor.pos.x >= g_state.dstRect.x && g_cursor.pos.x < g_state.dstRect.x + g_state.dstRect.w &&