mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-10 08:38:20 +00:00
[client] core: realign in the enter/focus handlers if possible
This commit is contained in:
parent
e1a4401ffa
commit
17617cc421
@ -112,7 +112,7 @@ void app_handleFocusEvent(bool focused)
|
||||
g_state.ds->minimize();
|
||||
}
|
||||
|
||||
g_cursor.realign = true;
|
||||
core_setGuestCursorPos();
|
||||
g_state.ds->realignPointer();
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ void app_handleEnterEvent(bool entered)
|
||||
if (!core_inputEnabled())
|
||||
return;
|
||||
|
||||
g_cursor.realign = true;
|
||||
core_setGuestCursorPos();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -314,6 +314,46 @@ void core_stopFrameThread(void)
|
||||
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)
|
||||
{
|
||||
struct DoublePoint localPos;
|
||||
@ -390,7 +430,7 @@ void core_handleMouseNormal(double ex, double ey)
|
||||
const bool inView = isInView();
|
||||
core_setCursorInView(inView);
|
||||
if (inView)
|
||||
g_cursor.realign = true;
|
||||
core_setGuestCursorPos();
|
||||
}
|
||||
|
||||
/* nothing to do if we are outside the viewport */
|
||||
@ -411,44 +451,9 @@ void core_handleMouseNormal(double ex, double ey)
|
||||
struct DoublePoint guest;
|
||||
util_localCurToGuest(&guest);
|
||||
|
||||
if (g_state.kvmfrFeatures & KVMFR_FEATURE_SETCURSORPOS)
|
||||
{
|
||||
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);
|
||||
}
|
||||
/* 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;
|
||||
|
||||
|
@ -33,6 +33,7 @@ void core_alignToGuest(void);
|
||||
bool core_isValidPointerPos(int x, int y);
|
||||
bool core_startFrameThread(void);
|
||||
void core_stopFrameThread(void);
|
||||
void core_setGuestCursorPos(void);
|
||||
void core_handleGuestMouseUpdate(void);
|
||||
void core_handleMouseGrabbed(double ex, double ey);
|
||||
void core_handleMouseNormal(double ex, double ey);
|
||||
|
Loading…
Reference in New Issue
Block a user