mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-12-23 14:03:40 +00:00
[client] don't attempt to align to the guest with invalid pos data
This commit is contained in:
parent
1da24af6ee
commit
b2ac2980d5
@ -132,6 +132,7 @@ void app_updateCursorPos(double x, double y)
|
|||||||
{
|
{
|
||||||
g_cursor.pos.x = x;
|
g_cursor.pos.x = x;
|
||||||
g_cursor.pos.y = y;
|
g_cursor.pos.y = y;
|
||||||
|
g_cursor.valid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void app_handleFocusEvent(bool focused)
|
void app_handleFocusEvent(bool focused)
|
||||||
@ -258,6 +259,12 @@ static void updatePositionInfo(void)
|
|||||||
g_cursor.scale.y = (float)srcW / (float)g_state.dstRect.w;
|
g_cursor.scale.y = (float)srcW / (float)g_state.dstRect.w;
|
||||||
g_cursor.dpiScale = g_cursor.guest.dpiScale / 100.0f;
|
g_cursor.dpiScale = g_cursor.guest.dpiScale / 100.0f;
|
||||||
|
|
||||||
|
if (!g_state.posInfoValid)
|
||||||
|
{
|
||||||
|
g_state.posInfoValid = true;
|
||||||
|
alignToGuest();
|
||||||
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
atomic_fetch_add(&g_state.lgrResize, 1);
|
atomic_fetch_add(&g_state.lgrResize, 1);
|
||||||
}
|
}
|
||||||
@ -1166,8 +1173,11 @@ static void rotatePoint(struct DoublePoint *point)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void guestCurToLocal(struct DoublePoint *local)
|
static bool guestCurToLocal(struct DoublePoint *local)
|
||||||
{
|
{
|
||||||
|
if (!g_cursor.guest.valid || !g_state.posInfoValid)
|
||||||
|
return false;
|
||||||
|
|
||||||
const struct DoublePoint point =
|
const struct DoublePoint point =
|
||||||
{
|
{
|
||||||
.x = g_cursor.guest.x + g_cursor.guest.hx,
|
.x = g_cursor.guest.x + g_cursor.guest.hx,
|
||||||
@ -1200,6 +1210,8 @@ static void guestCurToLocal(struct DoublePoint *local)
|
|||||||
point.x / g_cursor.scale.x;
|
point.x / g_cursor.scale.x;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static void localCurToGuest(struct DoublePoint *guest)
|
inline static void localCurToGuest(struct DoublePoint *guest)
|
||||||
@ -1561,7 +1573,7 @@ int eventFilter(void * userdata, SDL_Event * event)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
struct DoublePoint local;
|
struct DoublePoint local;
|
||||||
guestCurToLocal(&local);
|
if (guestCurToLocal(&local))
|
||||||
warpPointer(round(local.x), round(local.y), false);
|
warpPointer(round(local.x), round(local.y), false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,8 @@ struct AppState
|
|||||||
SDL_Rect border;
|
SDL_Rect border;
|
||||||
SDL_Point srcSize;
|
SDL_Point srcSize;
|
||||||
LG_RendererRect dstRect;
|
LG_RendererRect dstRect;
|
||||||
|
bool posInfoValid;
|
||||||
|
bool alignToGuest;
|
||||||
|
|
||||||
const LG_Renderer * lgr;
|
const LG_Renderer * lgr;
|
||||||
void * lgrData;
|
void * lgrData;
|
||||||
@ -229,6 +231,9 @@ struct CursorState
|
|||||||
/* the local position */
|
/* the local position */
|
||||||
struct DoublePoint pos;
|
struct DoublePoint pos;
|
||||||
|
|
||||||
|
/* true if the position is valid */
|
||||||
|
bool valid;
|
||||||
|
|
||||||
/* the button state */
|
/* the button state */
|
||||||
unsigned int buttons;
|
unsigned int buttons;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user