diff --git a/lib/arch/CArchMiscWindows.cpp b/lib/arch/CArchMiscWindows.cpp index e2fb2dce..1cda6ff3 100644 --- a/lib/arch/CArchMiscWindows.cpp +++ b/lib/arch/CArchMiscWindows.cpp @@ -414,3 +414,26 @@ CArchMiscWindows::dummySetThreadExecutionState(DWORD) // do nothing return 0; } + +void +CArchMiscWindows::wakeupDisplay() +{ + // We can't use ::setThreadExecutionState here because it sets + // ES_CONTINUOUS, which we don't want. + + if (s_stes == NULL) { + HINSTANCE kernel = LoadLibrary("kernel32.dll"); + if (kernel != NULL) { + s_stes = reinterpret_cast(GetProcAddress(kernel, + "SetThreadExecutionState")); + } + if (s_stes == NULL) { + s_stes = &CArchMiscWindows::dummySetThreadExecutionState; + } + } + + s_stes(ES_DISPLAY_REQUIRED); + + // restore the original execution states + setThreadExecutionState(s_busyState); +} \ No newline at end of file diff --git a/lib/arch/CArchMiscWindows.h b/lib/arch/CArchMiscWindows.h index 95a1d136..5260eaeb 100644 --- a/lib/arch/CArchMiscWindows.h +++ b/lib/arch/CArchMiscWindows.h @@ -161,6 +161,9 @@ public: //! Enable power saving static void removeBusyState(DWORD busyModes); + //! Briefly interrupt power saving + static void wakeupDisplay(); + private: //! Open and return a registry key, closing the parent key static HKEY openKey(HKEY parent, const TCHAR* child, bool create); diff --git a/lib/platform/CMSWindowsScreen.cpp b/lib/platform/CMSWindowsScreen.cpp index b000b477..786c1158 100644 --- a/lib/platform/CMSWindowsScreen.cpp +++ b/lib/platform/CMSWindowsScreen.cpp @@ -263,6 +263,16 @@ CMSWindowsScreen::enter() // all messages prior to now are invalid nextMark(); + } else { + // Entering a secondary screen. Ensure that no screensaver is active + // and that the screen is not in powersave mode. + CArchMiscWindows::wakeupDisplay(); + + if(m_screensaver != NULL && m_screensaverActive) + { + m_screensaver->deactivate(); + m_screensaverActive = 0; + } } // now on screen