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;
}
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))
{

View file

@ -11,6 +11,7 @@
#define YDEBUG
#include <wine/debug.h>
#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
}
}

View file

@ -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();

View file

@ -27,6 +27,8 @@
#ifndef __WINLOGON_MAIN_H__
#define __WINLOGON_MAIN_H__
//#define USE_GETLASTINPUTINFO
#define WIN32_NO_STATUS
#include <windows.h>
#include <userenv.h>
@ -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);