Quote: "We need something that catches when a Windows or Mac app is losing focus."
I'm not sure if this is what you need but for Nexus, I modified the Core.cpp file so that the game pauses when it loses focus. I'm sure with a little adaption, you could use this method to catch the pause and do something, but personally I just pause the game and sort everything out afterwards when GetResumed() fires. The modifications I made were as follows.
1. Add
under globals for core
2. In the WM_ACTIVATE case, replace with the following code
// if being made inactive and currently we are topmost temporarily remove topmost until we are active again.
if ( LOWORD(wParam) != WA_INACTIVE )
{
gamePaused = false;
if ( g_bShouldBeTopMost ) ::SetWindowPos( g_hWnd, HWND_TOPMOST, 0,0,0,0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSENDCHANGING | SWP_NOSIZE );
agk::Resumed();
}
else
{
gamePaused = true;
agk::MouseLeftButton( 0, 0 );
agk::MouseRightButton( 0, 0 );
agk::MouseMiddleButton( 0, 0 );
if ( g_bShouldBeTopMost ) ::SetWindowPos( g_hWnd, HWND_NOTOPMOST, 0,0,0,0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSENDCHANGING | SWP_NOSIZE );
}
agk::WindowMoved();
return DefWindowProc(hWnd, message, wParam, lParam);
3. Set the line with App.Loop() to
if (!agk::IsCapturingImage() && !gamePaused) bExitLoop = App.Loop();
I hope that helps.