Author: greatlrd
Date: Fri Jul 7 20:22:46 2006
New Revision: 22900
URL:
http://svn.reactos.org/svn/reactos?rev=22900&view=rev
Log:
Change in the auto screen saver startup code in win32k
1. Fixing allot better sync for the timeout counter
2. Change the hard code value to 30 sec instead for 15 sec
3. The start of screen saver are 30.0 sec to 30.9 sec for
we can not start on exactly on the x.0 sec but betwin
Modified:
trunk/reactos/subsystems/win32/win32k/ntuser/input.c
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 20:22:46 2006
@@ -41,6 +41,8 @@
static HANDLE ScreenSaverThreadHandle;
static CLIENT_ID ScreenSaverThreadId;
+static LARGE_INTEGER MouseInputCurrentTime;
+static LARGE_INTEGER KeyboardInputCurrentTime;
static HANDLE MouseDeviceHandle;
static HANDLE MouseThreadHandle;
@@ -50,7 +52,6 @@
static HANDLE KeyboardDeviceHandle;
static KEVENT InputThreadsStart;
static BOOLEAN InputThreadsRunning = FALSE;
-static BOOLEAN ScreenSaverRunning = FALSE;
PUSER_MESSAGE_QUEUE pmPrimitiveMessageQueue = 0;
/* FUNCTIONS *****************************************************************/
@@ -157,10 +158,24 @@
{
KEVENT Event;
LARGE_INTEGER Timeout;
+ LARGE_INTEGER DelayTimer;
+ LARGE_INTEGER CurrentTime;
+ LARGE_INTEGER DiffTimeMouse;
+ LARGE_INTEGER DiffTimeKeyboard;
+ LARGE_INTEGER OldTimeMouse;
+ LARGE_INTEGER OldTimeKeyboard;
NTSTATUS Status;
-
+
KeSetPriorityThread(&PsGetCurrentThread()->Tcb,
LOW_REALTIME_PRIORITY + 3);
+
+ KeQuerySystemTime(&MouseInputCurrentTime);
+ KeQuerySystemTime(&KeyboardInputCurrentTime);
+
+ OldTimeMouse.QuadPart = MouseInputCurrentTime.QuadPart;
+ OldTimeKeyboard.QuadPart = MouseInputCurrentTime.QuadPart;
+
+ DelayTimer.QuadPart = -10000000LL; /* 1 second timeout */
for(;;)
{
@@ -172,17 +187,17 @@
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 */
+
+ /* 30 second timeout This value should be read from register */
+ Timeout.QuadPart = 300000000LL;
+
KeInitializeEvent(&Event, NotificationEvent, FALSE);
- Status = KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE,
&Timeout);
+ Status = KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE,
&DelayTimer);
if(Status == STATUS_ALERTED && !InputThreadsRunning)
{
@@ -193,18 +208,31 @@
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 );
- }
+
+ KeQuerySystemTime(&CurrentTime);
+ DiffTimeMouse.QuadPart = CurrentTime.QuadPart - MouseInputCurrentTime.QuadPart;
+ DiffTimeKeyboard.QuadPart = CurrentTime.QuadPart - KeyboardInputCurrentTime.QuadPart;
+
+ if ( DiffTimeMouse.QuadPart >= Timeout.QuadPart &&
+ DiffTimeKeyboard.QuadPart >= Timeout.QuadPart &&
+ OldTimeMouse.QuadPart != MouseInputCurrentTime.QuadPart &&
+ OldTimeKeyboard.QuadPart != MouseInputCurrentTime.QuadPart)
+ {
+ DPRINT1("Keyboard and Mouse TimeOut Starting Screen Saver ...\n");
+ DPRINT1("Keyboard Timeout counter was
%I64d\n",DiffTimeKeyboard.QuadPart);
+ DPRINT1("Mouse Timeout counter was
%I64d\n",DiffTimeMouse.QuadPart);
+
+ CSR_API_MESSAGE Request;
+
+ OldTimeMouse.QuadPart = MouseInputCurrentTime.QuadPart;
+ OldTimeKeyboard.QuadPart = MouseInputCurrentTime.QuadPart;
+
+ 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");
}
@@ -286,8 +314,8 @@
}
DPRINT("MouseEvent\n");
- ScreenSaverRunning = FALSE;
-
+ KeQuerySystemTime(&MouseInputCurrentTime);
+
UserEnterExclusive();
ProcessMouseInputData(&MouseInput, Iosb.Information /
sizeof(MOUSE_INPUT_DATA));
@@ -596,7 +624,7 @@
return; //(Status);
}
- ScreenSaverRunning = FALSE;
+ KeQuerySystemTime(&KeyboardInputCurrentTime);
/* Update modifier state */
fsModifiers = IntKeyboardGetModifiers(&KeyInput);
@@ -845,7 +873,7 @@
InitInputImpl(VOID)
{
NTSTATUS Status;
-
+
KeInitializeEvent(&InputThreadsStart, NotificationEvent, FALSE);
Status = PsCreateSystemThread(&KeyboardThreadHandle,