workaround for a bug where sometimes a background window steals the focus

This commit is contained in:
FunkyFr3sh 2018-06-10 23:25:30 +02:00
parent 1d83797a48
commit f5b661dc1b
2 changed files with 19 additions and 1 deletions

View file

@ -590,6 +590,24 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
return 0;
//workaround for a bug where sometimes a background window steals the focus
case WM_WINDOWPOSCHANGING:
{
if (ddraw->locked)
{
WINDOWPOS *pos = (WINDOWPOS *)lParam;
if (pos->flags == SWP_NOMOVE + SWP_NOSIZE)
{
mouse_unlock();
if (GetForegroundWindow() == ddraw->hWnd)
mouse_lock();
}
}
break;
}
case WM_MOUSELEAVE:
mouse_unlock();
return 0;