JuceApplication::suspended JuceApplication::Resumed never called on Windows


#1

Suspend / Resume function only called on Android. I miss this functions for Windows ...

Windows  implementation/ dispatch seems easy. see below,

regards
  elli

 

windowProc(
                           HWND   hWnd,
                           UINT   uMsg,
                           WPARAM wParam,
                           LPARAM lParam
                        )

{

switch ( ulMsg )
{
  case WM_POWERBROADCAST:

    switch ( wParam )
    {
      case PBT_APMQUERYSUSPEND:
         maybe query

      case PBT_APMQUERYSUSPENDFAILED:
         signal resume

      case PBT_APMSUSPEND:
         signal suspend

     case PBT_APMRESUMESUSPEND:
       signal resume 

     case PBT_APMRESUMEAUTOMATIC:
         signal resume

...


#2

In juce_win32_Windowing.cpp:

//Somewhere within "LRESULT peerWindowProc (HWND h, UINT message, WPARAM wParam, LPARAM lParam)"
case WM_POWERBROADCAST:
                switch (wParam)
                {
                case PBT_APMSUSPEND:
                    if (JUCEApplicationBase* const app = JUCEApplicationBase::getInstance())
                        app->suspended();
                    break;
                case PBT_APMQUERYSUSPENDFAILED:
                case PBT_APMRESUMECRITICAL:
                case PBT_APMRESUMESUSPEND:
                case PBT_APMRESUMEAUTOMATIC:
                    if (JUCEApplicationBase* const app = JUCEApplicationBase::getInstance())
                        app->resumed();
                    break;
                default:
                    break;
                }
                break;

N.B.: Have only tested this in Windows 8.1. Windows XP and Vista may behave differently.


#3

Bumped for you, Elli, to test. Give 'er a whirl!


#4

Cool stuff, thanks Joel - will merge this when I get a moment!


#5

Thanks Jules!


#6

bump