diff --git a/src/main.c b/src/main.c index c09eecd..942ab15 100644 --- a/src/main.c +++ b/src/main.c @@ -1189,6 +1189,28 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) break; + //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; + case WM_ACTIVATE: if (wParam == WA_ACTIVE || wParam == WA_CLICKACTIVE) { @@ -1230,28 +1252,6 @@ 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; - case WM_ACTIVATEAPP: /* C&C and RA stop drawing when they receive this with FALSE wParam, disable in windowed mode */ if (ddraw->windowed || ddraw->noactivateapp)