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
This commit is contained in:
Hervé Poussineau 2006-09-09 17:10:42 +00:00
parent 52d59f6a4f
commit 8dcf1980fe
4 changed files with 54 additions and 4 deletions

View file

@ -94,13 +94,12 @@ SetDefaultLanguage(
goto cleanup; goto cleanup;
} }
Value = HeapAlloc(GetProcessHeap(), 0, dwSize + sizeof(UNICODE_NULL)); Value = HeapAlloc(GetProcessHeap(), 0, dwSize);
if (!Value) if (!Value)
{ {
TRACE("HeapAlloc() failed\n"); TRACE("HeapAlloc() failed\n");
goto cleanup; goto cleanup;
} }
Value[dwSize / sizeof(WCHAR)] = UNICODE_NULL;
rc = RegQueryValueExW( rc = RegQueryValueExW(
hKey, hKey,
ValueName, ValueName,
@ -115,7 +114,8 @@ SetDefaultLanguage(
} }
/* Convert Value to a Lcid */ /* Convert Value to a Lcid */
RtlInitUnicodeString(&ValueString, Value); ValueString.Length = ValueString.MaximumLength = dwSize;
ValueString.Buffer = Value;
Status = RtlUnicodeStringToInteger(&ValueString, 16, &Lcid); Status = RtlUnicodeStringToInteger(&ValueString, 16, &Lcid);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {

View file

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

View file

@ -406,6 +406,9 @@ WinMain(
{ {
TRACE("WL: Setup mode detected\n"); TRACE("WL: Setup mode detected\n");
/* Set locale */
SetDefaultLanguage(FALSE);
/* Run setup and reboot when done */ /* Run setup and reboot when done */
SwitchDesktop(WLSession->ApplicationDesktop); SwitchDesktop(WLSession->ApplicationDesktop);
RunSetup(); RunSetup();

View file

@ -27,6 +27,8 @@
#ifndef __WINLOGON_MAIN_H__ #ifndef __WINLOGON_MAIN_H__
#define __WINLOGON_MAIN_H__ #define __WINLOGON_MAIN_H__
//#define USE_GETLASTINPUTINFO
#define WIN32_NO_STATUS #define WIN32_NO_STATUS
#include <windows.h> #include <windows.h>
#include <userenv.h> #include <userenv.h>
@ -137,12 +139,16 @@ typedef struct _WLSESSION
DWORD DialogTimeout; /* Timeout for dialog boxes, in seconds */ DWORD DialogTimeout; /* Timeout for dialog boxes, in seconds */
/* Screen-saver informations */ /* Screen-saver informations */
#ifndef USE_GETLASTINPUTINFO
HHOOK KeyboardHook; HHOOK KeyboardHook;
HHOOK MouseHook; HHOOK MouseHook;
#endif
HANDLE hEndOfScreenSaverThread; HANDLE hEndOfScreenSaverThread;
HANDLE hScreenSaverParametersChanged; HANDLE hScreenSaverParametersChanged;
HANDLE hUserActivity; HANDLE hUserActivity;
#ifndef USE_GETLASTINPUTINFO
DWORD LastActivity; DWORD LastActivity;
#endif
/* Logon informations */ /* Logon informations */
DWORD Options; DWORD Options;
@ -171,6 +177,10 @@ UpdatePerUserSystemParameters(DWORD dwUnknown,
DWORD dwReserved); DWORD dwReserved);
/* sas.c */ /* sas.c */
BOOL
SetDefaultLanguage(
IN BOOL UserProfile);
BOOL BOOL
InitializeSAS( InitializeSAS(
IN OUT PWLSESSION Session); IN OUT PWLSESSION Session);