#define YDEBUG\r
#include <wine/debug.h>\r
\r
+#ifndef USE_GETLASTINPUTINFO\r
static LRESULT CALLBACK\r
KeyboardActivityProc(\r
IN INT nCode,\r
InterlockedExchange((LONG*)&WLSession->LastActivity, ((PMSLLHOOKSTRUCT)lParam)->time);\r
return CallNextHookEx(NULL, nCode, wParam, lParam);\r
}\r
+#endif\r
\r
static VOID\r
LoadScreenSaverParameters(\r
{\r
PWLSESSION Session = (PWLSESSION)lpParameter;\r
HANDLE HandleArray[3];\r
- DWORD LastActivity, TimeToWait;\r
+#ifdef USE_GETLASTINPUTINFO\r
+ LASTINPUTINFO lastInputInfo;\r
+#else\r
+ DWORD LastActivity;\r
+#endif\r
+ DWORD TimeToWait;\r
DWORD Timeout; /* Timeout before screen saver starts, in milliseconds */\r
DWORD ret;\r
\r
\r
LoadScreenSaverParameters(&Timeout);\r
\r
+#ifndef USE_GETLASTINPUTINFO\r
InterlockedExchange((LONG*)&Session->LastActivity, GetTickCount());\r
+#else\r
+ lastInputInfo.cbSize = sizeof(LASTINPUTINFO);\r
+#endif\r
for (;;)\r
{\r
/* See the time of last activity and calculate a timeout */\r
+#ifndef USE_GETLASTINPUTINFO\r
LastActivity = InterlockedCompareExchange((LONG*)&Session->LastActivity, 0, 0);\r
TimeToWait = Timeout - (GetTickCount() - LastActivity);\r
+#else\r
+ if (GetLastInputInfo(&lastInputInfo))\r
+ TimeToWait = Timeout - (GetTickCount() - lastInputInfo.dwTime);\r
+ else\r
+ {\r
+ WARN("GetLastInputInfo() failed with error %lu\n", GetLastError());\r
+ TimeToWait = 10; /* Try again in 10 ms */\r
+ }\r
+#endif\r
if (TimeToWait > Timeout)\r
{\r
/* GetTickCount() got back to 0 */\r
LoadScreenSaverParameters(&Timeout);\r
\r
/* Check if we didn't had recent activity */\r
+#ifndef USE_GETLASTINPUTINFO\r
LastActivity = InterlockedCompareExchange((LONG*)&Session->LastActivity, 0, 0);\r
if (LastActivity + Timeout > GetTickCount())\r
continue;\r
+#else\r
+ if (!GetLastInputInfo(&lastInputInfo))\r
+ {\r
+ WARN("GetLastInputInfo() failed with error %lu\n", GetLastError());\r
+ continue;\r
+ }\r
+ if (lastInputInfo.dwTime + Timeout > GetTickCount())\r
+ continue;\r
+#endif\r
\r
/* Run screen saver */\r
PostMessageW(Session->SASWindow, WLX_WM_SAS, WLX_SAS_TYPE_SCRNSVR_TIMEOUT, 0);\r
RevertToSelf();\r
if (Session->hUserActivity)\r
CloseHandle(Session->hUserActivity);\r
+#ifndef USE_GETLASTINPUTINFO\r
if (Session->KeyboardHook)\r
UnhookWindowsHookEx(Session->KeyboardHook);\r
if (Session->MouseHook)\r
UnhookWindowsHookEx(Session->MouseHook);\r
+#endif\r
CloseHandle(Session->hEndOfScreenSaverThread);\r
CloseHandle(Session->hScreenSaverParametersChanged);\r
return 0;\r
FIXME("Disabling screen saver due to numerous bugs in ReactOS (see r23540)!\n");\r
return TRUE;\r
\r
+#ifndef USE_GETLASTINPUTINFO\r
/* Register hooks to detect keyboard and mouse activity */\r
Session->KeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardActivityProc, hAppInstance, 0);\r
if (!Session->KeyboardHook)\r
ERR("WL: Unable to register mouse hook\n");\r
return FALSE;\r
}\r
+#endif\r
\r
if (!(Session->hScreenSaverParametersChanged = CreateEventW(NULL, FALSE, FALSE, NULL)))\r
{\r
else\r
{\r
PostMessageW(Session->SASWindow, WLX_WM_SAS, WLX_SAS_TYPE_SCRNSVR_ACTIVITY, 0);\r
+#ifndef USE_GETLASTINPUTINFO\r
InterlockedExchange((LONG*)&Session->LastActivity, GetTickCount());\r
+#endif\r
}\r
}\r