From e3b9b100e1aaa6684a73b040c9635ddc9084486f Mon Sep 17 00:00:00 2001 From: James Tabor Date: Wed, 14 Jan 2009 02:02:26 +0000 Subject: [PATCH] - Added stubs to timers, tooling up to change over to handled timers. This is related to just about everything. From Carets to window positions. svn path=/trunk/; revision=38752 --- .../subsystems/win32/win32k/include/timer.h | 2 + .../subsystems/win32/win32k/ntuser/object.c | 9 +- .../subsystems/win32/win32k/ntuser/timer.c | 108 +++++++++++++++++- 3 files changed, 110 insertions(+), 9 deletions(-) diff --git a/reactos/subsystems/win32/win32k/include/timer.h b/reactos/subsystems/win32/win32k/include/timer.h index b3ddbff9527..1123241ed07 100644 --- a/reactos/subsystems/win32/win32k/include/timer.h +++ b/reactos/subsystems/win32/win32k/include/timer.h @@ -28,5 +28,7 @@ BOOL FASTCALL IntKillTimer(HWND Wnd, UINT_PTR IDEvent, BOOL SystemTimer); UINT_PTR FASTCALL IntSetTimer(HWND Wnd, UINT_PTR IDEvent, UINT Elapse, TIMERPROC TimerFunc, BOOL SystemTimer); PTIMER FASTCALL FindSystemTimer(PMSG); BOOL FASTCALL ValidateTimerCallback(PW32THREADINFO,PWINDOW_OBJECT,WPARAM,LPARAM); +VOID CALLBACK SystemTimerProc(HWND,UINT,UINT_PTR,DWORD); +UINT_PTR FASTCALL SetSystemTimer(HWND,UINT_PTR,UINT,TIMERPROC); #endif /* _WIN32K_TIMER_H */ diff --git a/reactos/subsystems/win32/win32k/ntuser/object.c b/reactos/subsystems/win32/win32k/ntuser/object.c index a81cb855614..278e02606ab 100644 --- a/reactos/subsystems/win32/win32k/ntuser/object.c +++ b/reactos/subsystems/win32/win32k/ntuser/object.c @@ -70,7 +70,7 @@ __inline static PUSER_HANDLE_ENTRY alloc_user_entry(PUSER_HANDLE_TABLE ht) { /**/ int i, iFree = 0, iWindow = 0, iMenu = 0, iCursorIcon = 0, - iHook = 0, iCallProc = 0, iAccel = 0, iMonitor = 0; + iHook = 0, iCallProc = 0, iAccel = 0, iMonitor = 0, iTimer = 0; /**/ DPRINT1("Out of user handles! Used -> %i, NM_Handle -> %d\n", usedHandles, ht->nb_handles); //#if 0 @@ -102,12 +102,15 @@ __inline static PUSER_HANDLE_ENTRY alloc_user_entry(PUSER_HANDLE_TABLE ht) case otMonitor: iMonitor++; break; + case otTimer: + iMonitor++; + break; default: break; } } - DPRINT1("Handle Count by Type:\n Free = %d Window = %d Menu = %d CursorIcon = %d Hook = %d\n CallProc = %d Accel = %d Monitor = %d\n", - iFree, iWindow, iMenu, iCursorIcon, iHook, iCallProc, iAccel, iMonitor ); + DPRINT1("Handle Count by Type:\n Free = %d Window = %d Menu = %d CursorIcon = %d Hook = %d\n CallProc = %d Accel = %d Monitor = %d Timer = %d\n", + iFree, iWindow, iMenu, iCursorIcon, iHook, iCallProc, iAccel, iMonitor, iTimer ); //#endif return NULL; #if 0 diff --git a/reactos/subsystems/win32/win32k/ntuser/timer.c b/reactos/subsystems/win32/win32k/ntuser/timer.c index c6afb6dce76..e9291eb5a14 100644 --- a/reactos/subsystems/win32/win32k/ntuser/timer.c +++ b/reactos/subsystems/win32/win32k/ntuser/timer.c @@ -54,6 +54,72 @@ static ULONG HintIndex = 0; ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(&Mutex) /* FUNCTIONS *****************************************************************/ +PTIMER +FASTCALL +CreateTimer(VOID) +{ + HANDLE Handle; + PTIMER Ret = NULL; + + if (!FirstpTmr) + { + FirstpTmr = UserCreateObject(gHandleTable, &Handle, otTimer, sizeof(TIMER)); + if (FirstpTmr) InitializeListHead(&FirstpTmr->ptmrList); + Ret = FirstpTmr; + } + else + { + Ret = UserCreateObject(gHandleTable, &Handle, otTimer, sizeof(TIMER)); + if (Ret) InsertTailList(&FirstpTmr->ptmrList, &Ret->ptmrList); + } + return Ret; +} + +static +BOOL +FASTCALL +RemoveTimer(PTIMER pTmr) +{ + if (pTmr) + { + RemoveEntryList(&pTmr->ptmrList); + UserDeleteObject( USER_BODY_TO_HEADER(pTmr)->hSelf, otTimer); + return TRUE; + } + return FALSE; +} + +PTIMER +FASTCALL +FindTimer(PWINDOW_OBJECT Window, + UINT_PTR nID, + UINT flags, + BOOL Distroy) +{ + PTIMER pTmr = FirstpTmr; + KeEnterCriticalRegion(); + do + { + if (!pTmr) break; + + if ( pTmr->nID == nID && + pTmr->pWnd == Window && + (pTmr->flags & (TMRF_SYSTEM|TMRF_RIT)) == (flags & (TMRF_SYSTEM|TMRF_RIT))) + { + if (Distroy) + { + RemoveTimer(pTmr); + pTmr = (PTIMER)1; // We are here to remove the timer. + } + break; + } + + pTmr = (PTIMER)pTmr->ptmrList.Flink; + } while (pTmr != FirstpTmr); + KeLeaveCriticalRegion(); + + return pTmr; +} PTIMER FASTCALL @@ -104,6 +170,41 @@ ValidateTimerCallback(PW32THREADINFO pti, return TRUE; } +// Rename it to IntSetTimer after move. +UINT_PTR FASTCALL +InternalSetTimer(HWND Wnd, UINT_PTR IDEvent, UINT Elapse, TIMERPROC TimerFunc, BOOL SystemTimer) +{ + return 0; +} + +// +// Process system timers. +// +VOID +CALLBACK +SystemTimerProc(HWND hwnd, + UINT uMsg, + UINT_PTR idEvent, + DWORD dwTime) +{ +} + +UINT_PTR +FASTCALL +SetSystemTimer( HWND hWnd, + UINT_PTR nIDEvent, + UINT uElapse, + TIMERPROC lpTimerFunc) +{ + return 0; +} + + +// +// +// Old Timer Queueing +// +// UINT_PTR FASTCALL IntSetTimer(HWND Wnd, UINT_PTR IDEvent, UINT Elapse, TIMERPROC TimerFunc, BOOL SystemTimer) { @@ -268,12 +369,6 @@ InitTimerImpl(VOID) /* yes we need this, since ExAllocatePool isn't supposed to zero out allocated memory */ RtlClearAllBits(&WindowLessTimersBitMap); - if (!FirstpTmr) - { - FirstpTmr = ExAllocatePoolWithTag(PagedPool, sizeof(TIMER), TAG_TIMERBMP); - if (FirstpTmr) InitializeListHead(&FirstpTmr->ptmrList); - } - return STATUS_SUCCESS; } @@ -337,6 +432,7 @@ NtUserSetSystemTimer( DPRINT("Enter NtUserSetSystemTimer\n"); UserEnterExclusive(); + // This is wrong, lpTimerFunc is NULL! RETURN(IntSetTimer(hWnd, nIDEvent, uElapse, lpTimerFunc, TRUE)); CLEANUP: