mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-14 01:58:25 +00:00
[client] fix mouse acceleration when in capture mode
SDL2 really doesn't do this well, instead I have implemented our own capture method that allows us to maintain better client/server cursor sync.
This commit is contained in:
parent
5b163063c3
commit
1341bf8fbd
@ -644,15 +644,35 @@ void spiceClipboardRequest(const SpiceDataType type)
|
|||||||
|
|
||||||
static void handleMouseMoveEvent(int ex, int ey)
|
static void handleMouseMoveEvent(int ex, int ey)
|
||||||
{
|
{
|
||||||
|
static bool wrapping = false;
|
||||||
|
static int wrapX, wrapY;
|
||||||
|
|
||||||
if (state.ignoreInput || !params.useSpiceInput)
|
if (state.ignoreInput || !params.useSpiceInput)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (state.serverMode)
|
if (state.serverMode)
|
||||||
{
|
{
|
||||||
/* get the screen center as SDL sees it */
|
if (wrapping)
|
||||||
SDL_GetWindowSize(state.window, &lastX, &lastY);
|
{
|
||||||
lastX /= 2;
|
if (ex == state.windowW / 2 && ey == state.windowH / 2)
|
||||||
lastY /= 2;
|
{
|
||||||
|
lastX += (state.windowW / 2) - wrapX;
|
||||||
|
lastY += (state.windowH / 2) - wrapY;
|
||||||
|
wrapping = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (
|
||||||
|
ex < 100 || ex > state.windowW - 100 ||
|
||||||
|
ey < 100 || ey > state.windowH - 100)
|
||||||
|
{
|
||||||
|
wrapping = true;
|
||||||
|
wrapX = ex;
|
||||||
|
wrapY = ey;
|
||||||
|
SDL_WarpMouseInWindow(state.window, state.windowW / 2, state.windowH / 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -814,7 +834,6 @@ int eventFilter(void * userdata, SDL_Event * event)
|
|||||||
{
|
{
|
||||||
state.serverMode = !state.serverMode;
|
state.serverMode = !state.serverMode;
|
||||||
spice_mouse_mode(state.serverMode);
|
spice_mouse_mode(state.serverMode);
|
||||||
SDL_SetRelativeMouseMode(state.serverMode);
|
|
||||||
SDL_SetWindowGrab(state.window, state.serverMode);
|
SDL_SetWindowGrab(state.window, state.serverMode);
|
||||||
DEBUG_INFO("Server Mode: %s", state.serverMode ? "on" : "off");
|
DEBUG_INFO("Server Mode: %s", state.serverMode ? "on" : "off");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user