Author: greatlrd
Date: Fri Jul 7 00:42:45 2006
New Revision: 22896
URL:
http://svn.reactos.org/svn/reactos?rev=22896&view=rev
Log:
Commit my autostart code for screen saver for now it is hardcode to 15 sec timeout
Modified:
trunk/reactos/subsystems/win32/csrss/win32csr/conio.c
trunk/reactos/subsystems/win32/win32k/ntuser/input.c
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/conio.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/conio.c (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/conio.c Fri Jul 7 00:42:45 2006
@@ -3301,8 +3301,6 @@
return Request->Status = STATUS_SUCCESS;
}
-static BOOL ScreenSaverRunning = FALSE;
-
CSR_API(CsrStartScreenSaver)
{
@@ -3337,33 +3335,27 @@
add the code here as w3seek recomandete
*/
- if (ScreenSaverRunning == FALSE)
- {
-
- RegOpenKeyExW(HKEY_CURRENT_USER, L"Control Panel\\Desktop", 0,
KEY_ALL_ACCESS, &hKey);
- result = RegQueryValueExW(hKey, L"SCRNSAVE.EXE", 0, &varType,
(LPBYTE)szBuffer, &bufferSize);
- if(result == ERROR_SUCCESS)
- {
- swprintf(szCmdline, L"%s /s",szBuffer);
- DPRINT1("CsrStartScreenSaver : OK %S\n",szCmdline);
- ZeroMemory( &si, sizeof(si) );
- si.cb = sizeof(si);
- ZeroMemory( &pi, sizeof(pi) );
- ScreenSaverRunning = TRUE;
- if(CreateProcessW( NULL, szCmdline, NULL, NULL, FALSE, 0,
NULL,NULL,&si, &pi ))
- {
-
- CloseHandle( pi.hProcess );
- CloseHandle( pi.hThread );
- ScreenSaverRunning = FALSE;
- }
- }
- else
- {
- DPRINT1("CsrStartScreenSaver : FAIL %S\n",szBuffer);
- }
- RegCloseKey(hKey);
- }
+
+ RegOpenKeyExW(HKEY_CURRENT_USER, L"Control Panel\\Desktop", 0,
KEY_ALL_ACCESS, &hKey);
+ result = RegQueryValueExW(hKey, L"SCRNSAVE.EXE", 0, &varType,
(LPBYTE)szBuffer, &bufferSize);
+ if(result == ERROR_SUCCESS)
+ {
+ swprintf(szCmdline, L"%s /s",szBuffer);
+ DPRINT1("CsrStartScreenSaver : OK %S\n",szCmdline);
+ ZeroMemory( &si, sizeof(si) );
+ si.cb = sizeof(si);
+ ZeroMemory( &pi, sizeof(pi) );
+ if(CreateProcessW( NULL, szCmdline, NULL, NULL, FALSE, 0,
NULL,NULL,&si, &pi ))
+ {
+ CloseHandle( pi.hProcess );
+ CloseHandle( pi.hThread );
+ }
+ }
+ else
+ {
+ DPRINT1("CsrStartScreenSaver : FAIL %S\n",szBuffer);
+ }
+ RegCloseKey(hKey);
}
return Request->Status = STATUS_SUCCESS;
}
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/input.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/ntuser/input.c (original)
+++ trunk/reactos/subsystems/win32/win32k/ntuser/input.c Fri Jul 7 00:42:45 2006
@@ -39,6 +39,9 @@
/* GLOBALS *******************************************************************/
+static HANDLE ScreenSaverThreadHandle;
+static CLIENT_ID ScreenSaverThreadId;
+
static HANDLE MouseDeviceHandle;
static HANDLE MouseThreadHandle;
static CLIENT_ID MouseThreadId;
@@ -47,6 +50,7 @@
static HANDLE KeyboardDeviceHandle;
static KEVENT InputThreadsStart;
static BOOLEAN InputThreadsRunning = FALSE;
+static BOOLEAN ScreenSaverRunning = FALSE;
PUSER_MESSAGE_QUEUE pmPrimitiveMessageQueue = 0;
/* FUNCTIONS *****************************************************************/
@@ -147,6 +151,65 @@
SendMouseEvent(mi);
}
+
+VOID STDCALL
+ScreenSaverThreadMain(PVOID StartContext)
+{
+ KEVENT Event;
+ LARGE_INTEGER Timeout;
+ NTSTATUS Status;
+
+ KeSetPriorityThread(&PsGetCurrentThread()->Tcb,
+ LOW_REALTIME_PRIORITY + 3);
+
+ for(;;)
+ {
+ DPRINT("Screen Saver auto start Thread Waiting for start event\n");
+ Status = KeWaitForSingleObject(&InputThreadsStart,
+ 0,
+ KernelMode,
+ TRUE,
+ NULL);
+ DPRINT("Screen Saver auto start Thread Starting...\n");
+ while(InputThreadsRunning)
+ {
+ NTSTATUS OldStatus;
+ /* FIXME
+ 1. read timeout value from reg
+ 2. read timeout value from spi msg
+ */
+ OldStatus = STATUS_SUCCESS;
+
+ Timeout.QuadPart = -150000000LL; /* 15 second timeout */
+ KeInitializeEvent(&Event, NotificationEvent, FALSE);
+ Status = KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE,
&Timeout);
+
+ if(Status == STATUS_ALERTED && !InputThreadsRunning)
+ {
+ break;
+ }
+ if(!NT_SUCCESS(Status))
+ {
+ DPRINT1("Win32K: Failed to read from Screen Saver auto
thread.\n");
+ return; //(Status);
+ }
+
+
+ if ((Status == STATUS_TIMEOUT) && (ScreenSaverRunning == FALSE))
+ {
+ DPRINT1("Keyboard and Mouse TimeOut Starting Screen Saver...\n");
+ CSR_API_MESSAGE Request;
+ ScreenSaverRunning = TRUE;
+ CsrInit();
+ Request.Type = MAKE_CSR_API(START_SCREEN_SAVER, CSR_GUI);
+ Request.Data.StartScreenSaver.Start = TRUE;
+ co_CsrNotifyScreenSaver(&Request );
+ }
+ }
+ DPRINT("Screen Saver auto start Thread Stopped...\n");
+ }
+}
+
VOID STDCALL
MouseThreadMain(PVOID StartContext)
@@ -223,6 +286,8 @@
}
DPRINT("MouseEvent\n");
+ ScreenSaverRunning = FALSE;
+
UserEnterExclusive();
ProcessMouseInputData(&MouseInput, Iosb.Information /
sizeof(MOUSE_INPUT_DATA));
@@ -491,7 +556,7 @@
HWND hWnd;
int id;
- DPRINT("KeyInput @ %08x\n", &KeyInput);
+ DPRINT("KeyInput @ %08x\n", &KeyInput);
Status = NtReadFile (KeyboardDeviceHandle,
NULL,
@@ -530,6 +595,8 @@
DPRINT1("Win32K: Failed to read from keyboard.\n");
return; //(Status);
}
+
+ ScreenSaverRunning = FALSE;
/* Update modifier state */
fsModifiers = IntKeyboardGetModifiers(&KeyInput);
@@ -809,6 +876,19 @@
DPRINT1("Win32K: Failed to create mouse thread.\n");
}
+ Status = PsCreateSystemThread(&ScreenSaverThreadHandle,
+ THREAD_ALL_ACCESS,
+ NULL,
+ NULL,
+ &ScreenSaverThreadId,
+ ScreenSaverThreadMain,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Win32K: Failed to create ScreenSaver auto start thread.\n");
+ }
+
+
return STATUS_SUCCESS;
}