[client] mouse: dont leave the window if any mouse buttons are held

This commit is contained in:
Geoffrey McRae 2021-01-17 15:13:45 +11:00
parent bab7eba7f0
commit d22124519e
2 changed files with 11 additions and 0 deletions

View File

@ -1020,6 +1020,8 @@ void app_handleButtonPress(int button)
if (!app_inputEnabled() || !g_cursor.inView)
return;
g_cursor.buttons |= (1U << button);
if (!spice_mouse_press(button))
DEBUG_ERROR("SDL_MOUSEBUTTONDOWN: failed to send message");
}
@ -1029,6 +1031,8 @@ void app_handleButtonRelease(int button)
if (!app_inputEnabled())
return;
g_cursor.buttons &= ~(1U << button);
if (!spice_mouse_release(button))
DEBUG_ERROR("SDL_MOUSEBUTTONUP: failed to send message");
}
@ -1107,6 +1111,10 @@ void app_handleMouseNormal(double ex, double ey)
struct DoublePoint local;
guestCurToLocal(&local);
/* if any buttons are held we should not allow exit to happen */
if (g_cursor.buttons)
testExit = false;
/* check if the move would push the cursor outside the guest's viewport */
if (testExit && (
local.x + ex < g_state.dstRect.x ||

View File

@ -226,6 +226,9 @@ struct CursorState
/* the local position */
struct DoublePoint pos;
/* the button state */
unsigned int buttons;
/* the delta since last warp when in auto capture mode */
struct DoublePoint delta;