From 8dcf1980fe705b95d38772f6017fce402f113ce8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Sat, 9 Sep 2006 17:10:42 +0000 Subject: [PATCH] Set 2nd stage setup to language selected in registry Try to use GetLastInputInfo API instead of a keyboard/mouse hook for screensaver (not enabled yet) svn path=/trunk/; revision=23998 --- reactos/base/system/winlogon/sas.c | 6 ++-- reactos/base/system/winlogon/screensaver.c | 39 +++++++++++++++++++++- reactos/base/system/winlogon/winlogon.c | 3 ++ reactos/base/system/winlogon/winlogon.h | 10 ++++++ 4 files changed, 54 insertions(+), 4 deletions(-) diff --git a/reactos/base/system/winlogon/sas.c b/reactos/base/system/winlogon/sas.c index 12669287574..00068eaa14d 100644 --- a/reactos/base/system/winlogon/sas.c +++ b/reactos/base/system/winlogon/sas.c @@ -94,13 +94,12 @@ SetDefaultLanguage( goto cleanup; } - Value = HeapAlloc(GetProcessHeap(), 0, dwSize + sizeof(UNICODE_NULL)); + Value = HeapAlloc(GetProcessHeap(), 0, dwSize); if (!Value) { TRACE("HeapAlloc() failed\n"); goto cleanup; } - Value[dwSize / sizeof(WCHAR)] = UNICODE_NULL; rc = RegQueryValueExW( hKey, ValueName, @@ -115,7 +114,8 @@ SetDefaultLanguage( } /* Convert Value to a Lcid */ - RtlInitUnicodeString(&ValueString, Value); + ValueString.Length = ValueString.MaximumLength = dwSize; + ValueString.Buffer = Value; Status = RtlUnicodeStringToInteger(&ValueString, 16, &Lcid); if (!NT_SUCCESS(Status)) { diff --git a/reactos/base/system/winlogon/screensaver.c b/reactos/base/system/winlogon/screensaver.c index 62febd804d4..329fe9f8fab 100644 --- a/reactos/base/system/winlogon/screensaver.c +++ b/reactos/base/system/winlogon/screensaver.c @@ -11,6 +11,7 @@ #define YDEBUG #include +#ifndef USE_GETLASTINPUTINFO static LRESULT CALLBACK KeyboardActivityProc( IN INT nCode, @@ -30,6 +31,7 @@ MouseActivityProc( InterlockedExchange((LONG*)&WLSession->LastActivity, ((PMSLLHOOKSTRUCT)lParam)->time); return CallNextHookEx(NULL, nCode, wParam, lParam); } +#endif static VOID LoadScreenSaverParameters( @@ -65,7 +67,12 @@ ScreenSaverThreadMain( { PWLSESSION Session = (PWLSESSION)lpParameter; HANDLE HandleArray[3]; - DWORD LastActivity, TimeToWait; +#ifdef USE_GETLASTINPUTINFO + LASTINPUTINFO lastInputInfo; +#else + DWORD LastActivity; +#endif + DWORD TimeToWait; DWORD Timeout; /* Timeout before screen saver starts, in milliseconds */ DWORD ret; @@ -88,12 +95,26 @@ ScreenSaverThreadMain( LoadScreenSaverParameters(&Timeout); +#ifndef USE_GETLASTINPUTINFO InterlockedExchange((LONG*)&Session->LastActivity, GetTickCount()); +#else + lastInputInfo.cbSize = sizeof(LASTINPUTINFO); +#endif for (;;) { /* See the time of last activity and calculate a timeout */ +#ifndef USE_GETLASTINPUTINFO LastActivity = InterlockedCompareExchange((LONG*)&Session->LastActivity, 0, 0); TimeToWait = Timeout - (GetTickCount() - LastActivity); +#else + if (GetLastInputInfo(&lastInputInfo)) + TimeToWait = Timeout - (GetTickCount() - lastInputInfo.dwTime); + else + { + WARN("GetLastInputInfo() failed with error %lu\n", GetLastError()); + TimeToWait = 10; /* Try again in 10 ms */ + } +#endif if (TimeToWait > Timeout) { /* GetTickCount() got back to 0 */ @@ -108,9 +129,19 @@ ScreenSaverThreadMain( LoadScreenSaverParameters(&Timeout); /* Check if we didn't had recent activity */ +#ifndef USE_GETLASTINPUTINFO LastActivity = InterlockedCompareExchange((LONG*)&Session->LastActivity, 0, 0); if (LastActivity + Timeout > GetTickCount()) continue; +#else + if (!GetLastInputInfo(&lastInputInfo)) + { + WARN("GetLastInputInfo() failed with error %lu\n", GetLastError()); + continue; + } + if (lastInputInfo.dwTime + Timeout > GetTickCount()) + continue; +#endif /* Run screen saver */ PostMessageW(Session->SASWindow, WLX_WM_SAS, WLX_SAS_TYPE_SCRNSVR_TIMEOUT, 0); @@ -129,10 +160,12 @@ cleanup: RevertToSelf(); if (Session->hUserActivity) CloseHandle(Session->hUserActivity); +#ifndef USE_GETLASTINPUTINFO if (Session->KeyboardHook) UnhookWindowsHookEx(Session->KeyboardHook); if (Session->MouseHook) UnhookWindowsHookEx(Session->MouseHook); +#endif CloseHandle(Session->hEndOfScreenSaverThread); CloseHandle(Session->hScreenSaverParametersChanged); return 0; @@ -147,6 +180,7 @@ InitializeScreenSaver( FIXME("Disabling screen saver due to numerous bugs in ReactOS (see r23540)!\n"); return TRUE; +#ifndef USE_GETLASTINPUTINFO /* Register hooks to detect keyboard and mouse activity */ Session->KeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardActivityProc, hAppInstance, 0); if (!Session->KeyboardHook) @@ -160,6 +194,7 @@ InitializeScreenSaver( ERR("WL: Unable to register mouse hook\n"); return FALSE; } +#endif if (!(Session->hScreenSaverParametersChanged = CreateEventW(NULL, FALSE, FALSE, NULL))) { @@ -264,6 +299,8 @@ cleanup: else { PostMessageW(Session->SASWindow, WLX_WM_SAS, WLX_SAS_TYPE_SCRNSVR_ACTIVITY, 0); +#ifndef USE_GETLASTINPUTINFO InterlockedExchange((LONG*)&Session->LastActivity, GetTickCount()); +#endif } } diff --git a/reactos/base/system/winlogon/winlogon.c b/reactos/base/system/winlogon/winlogon.c index c0896e980cc..245720c9227 100644 --- a/reactos/base/system/winlogon/winlogon.c +++ b/reactos/base/system/winlogon/winlogon.c @@ -406,6 +406,9 @@ WinMain( { TRACE("WL: Setup mode detected\n"); + /* Set locale */ + SetDefaultLanguage(FALSE); + /* Run setup and reboot when done */ SwitchDesktop(WLSession->ApplicationDesktop); RunSetup(); diff --git a/reactos/base/system/winlogon/winlogon.h b/reactos/base/system/winlogon/winlogon.h index 4bcaa421c8a..6487484cdf7 100644 --- a/reactos/base/system/winlogon/winlogon.h +++ b/reactos/base/system/winlogon/winlogon.h @@ -27,6 +27,8 @@ #ifndef __WINLOGON_MAIN_H__ #define __WINLOGON_MAIN_H__ +//#define USE_GETLASTINPUTINFO + #define WIN32_NO_STATUS #include #include @@ -137,12 +139,16 @@ typedef struct _WLSESSION DWORD DialogTimeout; /* Timeout for dialog boxes, in seconds */ /* Screen-saver informations */ +#ifndef USE_GETLASTINPUTINFO HHOOK KeyboardHook; HHOOK MouseHook; +#endif HANDLE hEndOfScreenSaverThread; HANDLE hScreenSaverParametersChanged; HANDLE hUserActivity; +#ifndef USE_GETLASTINPUTINFO DWORD LastActivity; +#endif /* Logon informations */ DWORD Options; @@ -171,6 +177,10 @@ UpdatePerUserSystemParameters(DWORD dwUnknown, DWORD dwReserved); /* sas.c */ +BOOL +SetDefaultLanguage( + IN BOOL UserProfile); + BOOL InitializeSAS( IN OUT PWLSESSION Session);