Revert "[client] core: realign in the enter/focus handlers if possible"

This reverts commit 17617cc421.
This commit is contained in:
Geoffrey McRae 2021-08-19 23:19:59 +10:00
parent 17617cc421
commit c246b4a719
3 changed files with 41 additions and 47 deletions

View File

@ -112,7 +112,7 @@ void app_handleFocusEvent(bool focused)
g_state.ds->minimize(); g_state.ds->minimize();
} }
core_setGuestCursorPos(); g_cursor.realign = true;
g_state.ds->realignPointer(); g_state.ds->realignPointer();
} }
@ -124,7 +124,7 @@ void app_handleEnterEvent(bool entered)
if (!core_inputEnabled()) if (!core_inputEnabled())
return; return;
core_setGuestCursorPos(); g_cursor.realign = true;
} }
else else
{ {

View File

@ -314,46 +314,6 @@ void core_stopFrameThread(void)
g_state.frameThread = NULL; g_state.frameThread = NULL;
} }
void core_setGuestCursorPos(void)
{
struct DoublePoint guest;
util_localCurToGuest(&guest);
if (!(g_state.kvmfrFeatures & KVMFR_FEATURE_SETCURSORPOS))
{
g_cursor.realign = true;
return;
}
const KVMFRSetCursorPos msg = {
.msg.type = KVMFR_MESSAGE_SETCURSORPOS,
.x = round(guest.x),
.y = round(guest.y)
};
uint32_t setPosSerial;
if (lgmpClientSendData(g_state.pointerQueue,
&msg, sizeof(msg), &setPosSerial) != LGMP_OK)
return;
/* wait for the move request to be processed */
do
{
uint32_t hostSerial;
if (lgmpClientGetSerial(g_state.pointerQueue, &hostSerial) != LGMP_OK)
return;
if (hostSerial >= setPosSerial)
break;
g_state.ds->wait(1);
}
while(app_isRunning());
g_cursor.guest.x = msg.x;
g_cursor.guest.y = msg.y;
}
void core_handleGuestMouseUpdate(void) void core_handleGuestMouseUpdate(void)
{ {
struct DoublePoint localPos; struct DoublePoint localPos;
@ -430,7 +390,7 @@ void core_handleMouseNormal(double ex, double ey)
const bool inView = isInView(); const bool inView = isInView();
core_setCursorInView(inView); core_setCursorInView(inView);
if (inView) if (inView)
core_setGuestCursorPos(); g_cursor.realign = true;
} }
/* nothing to do if we are outside the viewport */ /* nothing to do if we are outside the viewport */
@ -451,9 +411,44 @@ void core_handleMouseNormal(double ex, double ey)
struct DoublePoint guest; struct DoublePoint guest;
util_localCurToGuest(&guest); util_localCurToGuest(&guest);
/* add the difference to the offset */ if (g_state.kvmfrFeatures & KVMFR_FEATURE_SETCURSORPOS)
ex += guest.x - (g_cursor.guest.x + g_cursor.guest.hx); {
ey += guest.y - (g_cursor.guest.y + g_cursor.guest.hy); const KVMFRSetCursorPos msg = {
.msg.type = KVMFR_MESSAGE_SETCURSORPOS,
.x = round(guest.x),
.y = round(guest.y)
};
uint32_t setPosSerial;
if (lgmpClientSendData(g_state.pointerQueue,
&msg, sizeof(msg), &setPosSerial) == LGMP_OK)
{
/* wait for the move request to be processed */
do
{
uint32_t hostSerial;
if (lgmpClientGetSerial(g_state.pointerQueue, &hostSerial) != LGMP_OK)
return;
if (hostSerial >= setPosSerial)
break;
g_state.ds->wait(1);
}
while(app_isRunning());
g_cursor.guest.x = msg.x;
g_cursor.guest.y = msg.y;
g_cursor.realign = false;
return;
}
}
else
{
/* add the difference to the offset */
ex += guest.x - (g_cursor.guest.x + g_cursor.guest.hx);
ey += guest.y - (g_cursor.guest.y + g_cursor.guest.hy);
}
g_cursor.realign = false; g_cursor.realign = false;

View File

@ -33,7 +33,6 @@ void core_alignToGuest(void);
bool core_isValidPointerPos(int x, int y); bool core_isValidPointerPos(int x, int y);
bool core_startFrameThread(void); bool core_startFrameThread(void);
void core_stopFrameThread(void); void core_stopFrameThread(void);
void core_setGuestCursorPos(void);
void core_handleGuestMouseUpdate(void); void core_handleGuestMouseUpdate(void);
void core_handleMouseGrabbed(double ex, double ey); void core_handleMouseGrabbed(double ex, double ey);
void core_handleMouseNormal(double ex, double ey); void core_handleMouseNormal(double ex, double ey);