mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-12 20:27:53 +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
1 changed files with 20 additions and 5 deletions
|
@ -61,6 +61,9 @@ struct iface
|
|||
|
||||
int mouseX, mouseY, mouseHotX, mouseHotY;
|
||||
bool mouseVisible, hasMousePosition;
|
||||
|
||||
bool mouseHookCreated;
|
||||
bool forceCompositionCreated;
|
||||
};
|
||||
|
||||
static struct iface * this = NULL;
|
||||
|
@ -188,12 +191,21 @@ static bool nvfbc_init(void)
|
|||
}
|
||||
|
||||
this->cursorEvents[0] = lgCreateEvent(true, 10);
|
||||
mouseHook_install(on_mouseMove);
|
||||
|
||||
if (this->seperateCursor)
|
||||
this->cursorEvents[1] = lgWrapEvent(event);
|
||||
|
||||
dwmForceComposition();
|
||||
if (!this->mouseHookCreated)
|
||||
{
|
||||
mouseHook_install(on_mouseMove);
|
||||
this->mouseHookCreated = true;
|
||||
}
|
||||
|
||||
if (!this->forceCompositionCreated)
|
||||
{
|
||||
dwmForceComposition();
|
||||
this->forceCompositionCreated = true;
|
||||
}
|
||||
|
||||
DEBUG_INFO("Cursor mode : %s", this->seperateCursor ? "decoupled" : "integrated");
|
||||
|
||||
|
@ -226,9 +238,6 @@ static void nvfbc_stop(void)
|
|||
|
||||
static bool nvfbc_deinit(void)
|
||||
{
|
||||
mouseHook_remove();
|
||||
dwmUnforceComposition();
|
||||
|
||||
if (this->cursorEvents[0])
|
||||
{
|
||||
lgFreeEvent(this->cursorEvents[0]);
|
||||
|
@ -249,6 +258,12 @@ static void nvfbc_free(void)
|
|||
if (this->frameEvent)
|
||||
lgFreeEvent(this->frameEvent);
|
||||
|
||||
if (this->mouseHookCreated)
|
||||
mouseHook_remove();
|
||||
|
||||
if (this->forceCompositionCreated)
|
||||
dwmUnforceComposition();
|
||||
|
||||
free(this);
|
||||
this = NULL;
|
||||
NvFBCFree();
|
||||
|
|
Loading…
Reference in a new issue