mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-01-22 20:57:06 +00:00
spice: scale mouse input based on host DPI information
This commit is contained in:
parent
7e4d323427
commit
a172d79f66
@ -154,10 +154,12 @@ static void updatePositionInfo()
|
|||||||
|
|
||||||
g_cursor.scale = (
|
g_cursor.scale = (
|
||||||
g_state.srcSize.y != g_state.dstRect.h ||
|
g_state.srcSize.y != g_state.dstRect.h ||
|
||||||
g_state.srcSize.x != g_state.dstRect.w);
|
g_state.srcSize.x != g_state.dstRect.w ||
|
||||||
|
g_state.mouseScalePercent != 100);
|
||||||
|
|
||||||
g_cursor.scaleX = (float)g_state.srcSize.y / (float)g_state.dstRect.h;
|
g_cursor.scaleX = (float)g_state.srcSize.y / (float)g_state.dstRect.h;
|
||||||
g_cursor.scaleY = (float)g_state.srcSize.x / (float)g_state.dstRect.w;
|
g_cursor.scaleY = (float)g_state.srcSize.x / (float)g_state.dstRect.w;
|
||||||
|
g_state.mouseScale = g_state.mouseScalePercent / 100.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
atomic_fetch_add(&g_state.lgrResize, 1);
|
atomic_fetch_add(&g_state.lgrResize, 1);
|
||||||
@ -510,6 +512,7 @@ static int frameThread(void * unused)
|
|||||||
if (params.autoResize)
|
if (params.autoResize)
|
||||||
SDL_SetWindowSize(g_state.window, lgrFormat.width, lgrFormat.height);
|
SDL_SetWindowSize(g_state.window, lgrFormat.width, lgrFormat.height);
|
||||||
|
|
||||||
|
g_state.mouseScalePercent = frame->mouseScalePercent;
|
||||||
updatePositionInfo();
|
updatePositionInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -933,8 +936,8 @@ static void handleMouseMoveEvent(int ex, int ey)
|
|||||||
|
|
||||||
if (g_cursor.scale && params.scaleMouseInput && !g_cursor.grab)
|
if (g_cursor.scale && params.scaleMouseInput && !g_cursor.grab)
|
||||||
{
|
{
|
||||||
g_cursor.accX += (float)delta.x * g_cursor.scaleX;
|
g_cursor.accX += (float)delta.x * g_cursor.scaleX / g_state.mouseScale;
|
||||||
g_cursor.accY += (float)delta.y * g_cursor.scaleY;
|
g_cursor.accY += (float)delta.y * g_cursor.scaleY / g_state.mouseScale;
|
||||||
delta.x = floor(g_cursor.accX);
|
delta.x = floor(g_cursor.accX);
|
||||||
delta.y = floor(g_cursor.accY);
|
delta.y = floor(g_cursor.accY);
|
||||||
g_cursor.accX -= delta.x;
|
g_cursor.accX -= delta.x;
|
||||||
|
@ -53,6 +53,8 @@ struct AppState
|
|||||||
SDL_Rect border;
|
SDL_Rect border;
|
||||||
SDL_Point srcSize;
|
SDL_Point srcSize;
|
||||||
LG_RendererRect dstRect;
|
LG_RendererRect dstRect;
|
||||||
|
float mouseScale;
|
||||||
|
uint32_t mouseScalePercent;
|
||||||
|
|
||||||
const LG_Renderer * lgr;
|
const LG_Renderer * lgr;
|
||||||
void * lgrData;
|
void * lgrData;
|
||||||
|
Loading…
Reference in New Issue
Block a user