[client] spice: fix loss of click/focus on resize

This commit is contained in:
Geoffrey McRae 2021-01-09 18:41:02 +11:00
parent c9f41ea69e
commit 21ba14f629

View file

@ -84,6 +84,9 @@ struct CursorState g_cursor;
// this structure is initialized in config.c
struct AppParams params = { 0 };
static void setGrab(bool enable);
static void setGrabQuiet(bool enable);
static void handleMouseGrabbed(double ex, double ey);
static void handleMouseNormal(double ex, double ey);
@ -1093,7 +1096,17 @@ static void handleResizeEvent(unsigned int w, unsigned int h)
updatePositionInfo();
if (inputEnabled())
{
/* if the window is moved/resized causing a loss of focus while grabbed, it
* makes it impossible to re-focus the window, so we quietly re-enter
* capture if we were already in it */
if (g_cursor.grab)
{
setGrabQuiet(false);
setGrabQuiet(true);
}
alignToGuest();
}
}
static void handleWindowLeave()
@ -1151,6 +1164,16 @@ static void keyboardUngrab()
}
static void setGrab(bool enable)
{
setGrabQuiet(enable);
app_alert(
g_cursor.grab ? LG_ALERT_SUCCESS : LG_ALERT_WARNING,
g_cursor.grab ? "Capture Enabled" : "Capture Disabled"
);
}
static void setGrabQuiet(bool enable)
{
/* we always do this so that at init the cursor is in the right state */
if (params.captureInputOnly && params.hideMouse)
@ -1205,11 +1228,6 @@ static void setGrab(bool enable)
if (g_cursor.grab)
g_cursor.inView = true;
app_alert(
g_cursor.grab ? LG_ALERT_SUCCESS : LG_ALERT_WARNING,
g_cursor.grab ? "Capture Enabled" : "Capture Disabled"
);
}
int eventFilter(void * userdata, SDL_Event * event)