Make mouse foreground window check more reliable
This commit is contained in:
parent
1db3c97f09
commit
a34644439e
@ -261,6 +261,8 @@ void GraphicsCaptureSource::EndCapture()
|
|||||||
captureCheckInterval = -1.0f;
|
captureCheckInterval = -1.0f;
|
||||||
hwndCapture = NULL;
|
hwndCapture = NULL;
|
||||||
targetProcessID = 0;
|
targetProcessID = 0;
|
||||||
|
foregroundPID = 0;
|
||||||
|
foregroundCheckCount = 0;
|
||||||
|
|
||||||
if(warningID)
|
if(warningID)
|
||||||
{
|
{
|
||||||
@ -726,7 +728,14 @@ void GraphicsCaptureSource::Render(const Vect2 &pos, const Vect2 &size)
|
|||||||
//----------------------------------------------------------
|
//----------------------------------------------------------
|
||||||
// draw mouse
|
// draw mouse
|
||||||
|
|
||||||
if(bMouseCaptured && cursorTexture && GetForegroundWindow() == hwndCapture)
|
if (!foregroundCheckCount)
|
||||||
|
{
|
||||||
|
//only check for foreground window every 10 frames since this involves two syscalls
|
||||||
|
GetWindowThreadProcessId(GetForegroundWindow(), &foregroundPID);
|
||||||
|
foregroundCheckCount = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(bMouseCaptured && cursorTexture && foregroundPID == targetProcessID)
|
||||||
{
|
{
|
||||||
Vect2 newCursorPos = Vect2(float(cursorPos.x-xHotspot), float(cursorPos.y-xHotspot));
|
Vect2 newCursorPos = Vect2(float(cursorPos.x-xHotspot), float(cursorPos.y-xHotspot));
|
||||||
Vect2 newCursorSize = Vect2(float(cursorTexture->Width()), float(cursorTexture->Height()));
|
Vect2 newCursorSize = Vect2(float(cursorTexture->Width()), float(cursorTexture->Height()));
|
||||||
@ -748,6 +757,8 @@ void GraphicsCaptureSource::Render(const Vect2 &pos, const Vect2 &size)
|
|||||||
|
|
||||||
DrawSprite(cursorTexture, 0xFFFFFFFF, newCursorPos.x, newCursorPos.y, newCursorPos.x+newCursorSize.x, newCursorPos.y+newCursorSize.y);
|
DrawSprite(cursorTexture, 0xFFFFFFFF, newCursorPos.x, newCursorPos.y, newCursorPos.x+newCursorSize.x, newCursorPos.y+newCursorSize.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foregroundCheckCount--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lastShader)
|
if(lastShader)
|
||||||
|
@ -53,6 +53,9 @@ class GraphicsCaptureSource : public ImageSource
|
|||||||
|
|
||||||
float captureCheckInterval;
|
float captureCheckInterval;
|
||||||
|
|
||||||
|
DWORD foregroundPID;
|
||||||
|
DWORD foregroundCheckCount;
|
||||||
|
|
||||||
void NewCapture();
|
void NewCapture();
|
||||||
void EndCapture();
|
void EndCapture();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user