mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-22 05:27:20 +00:00
[host] nvfbc: avoid recreating mouse hook and 1x1 window
The mouse hook code is very fragile, and we would like to avoid unhooking and re-hooking as much as possible. After this commit, this is done only once, and the hook and 1x1 window is only destroyed upon exit. This, of course, comes with the downside of the slight performance penalty if the guest machine is used directly while the host is running and the client is not running.
This commit is contained in:
parent
1b48ac842a
commit
ff0a859ceb
@ -61,6 +61,9 @@ struct iface
|
|||||||
|
|
||||||
int mouseX, mouseY, mouseHotX, mouseHotY;
|
int mouseX, mouseY, mouseHotX, mouseHotY;
|
||||||
bool mouseVisible, hasMousePosition;
|
bool mouseVisible, hasMousePosition;
|
||||||
|
|
||||||
|
bool mouseHookCreated;
|
||||||
|
bool forceCompositionCreated;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct iface * this = NULL;
|
static struct iface * this = NULL;
|
||||||
@ -188,12 +191,21 @@ static bool nvfbc_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->cursorEvents[0] = lgCreateEvent(true, 10);
|
this->cursorEvents[0] = lgCreateEvent(true, 10);
|
||||||
mouseHook_install(on_mouseMove);
|
|
||||||
|
|
||||||
if (this->seperateCursor)
|
if (this->seperateCursor)
|
||||||
this->cursorEvents[1] = lgWrapEvent(event);
|
this->cursorEvents[1] = lgWrapEvent(event);
|
||||||
|
|
||||||
|
if (!this->mouseHookCreated)
|
||||||
|
{
|
||||||
|
mouseHook_install(on_mouseMove);
|
||||||
|
this->mouseHookCreated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this->forceCompositionCreated)
|
||||||
|
{
|
||||||
dwmForceComposition();
|
dwmForceComposition();
|
||||||
|
this->forceCompositionCreated = true;
|
||||||
|
}
|
||||||
|
|
||||||
DEBUG_INFO("Cursor mode : %s", this->seperateCursor ? "decoupled" : "integrated");
|
DEBUG_INFO("Cursor mode : %s", this->seperateCursor ? "decoupled" : "integrated");
|
||||||
|
|
||||||
@ -226,9 +238,6 @@ static void nvfbc_stop(void)
|
|||||||
|
|
||||||
static bool nvfbc_deinit(void)
|
static bool nvfbc_deinit(void)
|
||||||
{
|
{
|
||||||
mouseHook_remove();
|
|
||||||
dwmUnforceComposition();
|
|
||||||
|
|
||||||
if (this->cursorEvents[0])
|
if (this->cursorEvents[0])
|
||||||
{
|
{
|
||||||
lgFreeEvent(this->cursorEvents[0]);
|
lgFreeEvent(this->cursorEvents[0]);
|
||||||
@ -249,6 +258,12 @@ static void nvfbc_free(void)
|
|||||||
if (this->frameEvent)
|
if (this->frameEvent)
|
||||||
lgFreeEvent(this->frameEvent);
|
lgFreeEvent(this->frameEvent);
|
||||||
|
|
||||||
|
if (this->mouseHookCreated)
|
||||||
|
mouseHook_remove();
|
||||||
|
|
||||||
|
if (this->forceCompositionCreated)
|
||||||
|
dwmUnforceComposition();
|
||||||
|
|
||||||
free(this);
|
free(this);
|
||||||
this = NULL;
|
this = NULL;
|
||||||
NvFBCFree();
|
NvFBCFree();
|
||||||
|
Loading…
Reference in New Issue
Block a user