wine/windows/timer.c
Alexandre Julliard dba420a731 Release 940201
Tue Feb  1 21:14:47 1994  Bob Amstadt  (bob@pooh)

	* [loader/selector.c]
	Added function CreateNewSegments().  Modified IPCCopySelector
	to allow aliasing to any arbitrary memory space.

	* [memory/global.c]
	Fixed potential bug in GlobalGetFreeSegments().

	* [memory/linear.c]
	Created functions GlobalLinearLock() and GlobalLinearUnlock().

Tue Feb  1 05:51:43 1994  julliard@di.epfl.ch (Alexandre Julliard)

	* [controls/widgets.c]
	Removed CAPTION window class.

	* [loader/cursor.c]
	Bug fix in LoadCursor(): don't allocate memory every time for
	built-in cursors.

	* [windows/clipping.c]
	Invalidate child windows in InvalidateRgn().

	* [windows/defwnd.c]
	Added repaint of the caption when changing window text.

	* [windows/event.c]
	Modified SetCapture() to allow keyboard events while capturing.

	* [windows/message.c]
	New function MSG_GetHardwareMessage(), to do mouse tracking
	without returning control to the Windows program.

	* [windows/nonclient.c]
	A couple of changes in frame drawing for DLGMODALFRAME windows.
	Rewritten window moving code, to use MSG_GetHardwareMessage()
	instead of non-client mouse events (this is the way Windows
	does it), and to send WM_ENTERSIZEMOVE messages.
	Removed WM_NCBUTTONUP and WM_NCMOUSEMOVE handlers.

	* [windows/win.c]
	Allocate temporary structures on the USER heap instead of
	using GlobalAlloc().

	* [windows/winpos.c]
	Added function WINPOS_GetMinMaxInfo() to get sizing informations.

Jan 31, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)

	* [windows/nonclient.c]
	Call to StdDrawScrollBar() during NC's drawing.
	Call to NC_ScrollBarButtonDown() on NC mouse events WM_LBUTTONDOWN.
	Call to NC_ScrollBarButtonUp() on NC mouse events WM_LBUTTONUP.
	Call to NC_ScrollBarMouseMove() on NC mouse events WM_MOUSEMOVE.

	* [controls/menu.c]
	New GetSubMenu() function.
	Move GetMenu() & SetMenu() functions from 'windows/win.c'.

	* [controls/listbox.c]
	Start changes to satisfy recent changes in scrollbars/windows.

	* [loader/resource.c]
	Put some code in LoadAccelerators() stub.
	New TranslateAccelerator() function.

	* [windows/win.c]
	Remove GetMenu() & SetMenu() functions.
	Call to NC_CreateScrollBars() if required by CreateWindow().

Mon Jan 24 10:40:10 EST 1994 John Richardson (jrichard@cs.uml.edu)

        * [window/win.c]
        Added functions EnumWindows, EnumChildWindows, and helper
        WIN_EnumChildWin.  EnumWindows won't list all wine windows
        because GetDesktopWindow isn't complete.  However, the code
        is in place for it to work correctly and only needs 
        GetDesktopWindow to do so.  

Tue Jan 25 05:51:47 1994  julliard@di.epfl.ch (Alexandre Julliard)

	* [windows/defwnd.c]
	Added handling of activation messages (WM_ACTIVATE,
	WM_NCACTIVATE, WM_MOUSEACTIVATE)

	* [windows/event.c]
	De-activate the window when losing input focus.

	* [windows/focus.c]
	Bug fix in SetFocus().

	* [windows/message.c]
	Added activation of the window on mouse-clicks.

	* [windows/nonclient.c]
	Changed non-client area painting to use the correct colors
	depending upon the activation state.
	Added WM_NCACTIVATE message handling.
	Fixed a couple of bugs in window moving and resizing.

	* [windows/winpos.c]
	Implemented Get/SetActiveWindow().
	Implemented SWP_NOACTIVATE flag in SetWindowPos().

Jan 17, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)

	* [misc/message.c]
	MessageBox has a CaptionBar for his title except for
		MB_SYSTEMMODAL with MB_ICONHAND.

	* [windows/nonclient.c]
	Call to NC_TrackSysMenu on SysMenu button mouse click.

	* [windows/defwnd.c]
	Call to NC_TrackSysMenu on Alt key (VK_MENU).

	* [controls/menu.c]
	New GetSystemMenu() function.
	New CopySystemMenu() internal function.
	New NC_TrackSysMenu() internal function.

	* [include/windows.h]
	New WM_INITMENU, WM_INITMENUPOPUP, WM_MENUSELECT & WM_MENUCHAR defines.
1994-02-02 06:48:31 +00:00

229 lines
5.7 KiB
C

/*
* Timer functions
*
* Copyright 1993 Alexandre Julliard
*/
static char Copyright[] = "Copyright Alexandre Julliard, 1993";
#include "windows.h"
#include "message.h"
typedef struct tagTIMER
{
HWND hwnd;
WORD msg; /* WM_TIMER or WM_SYSTIMER */
WORD id;
WORD timeout;
struct tagTIMER *next;
DWORD expires;
FARPROC proc;
} TIMER;
#define NB_TIMERS 34
#define NB_RESERVED_TIMERS 2 /* for SetSystemTimer */
static TIMER TimersArray[NB_TIMERS];
static TIMER * pNextTimer = NULL; /* Next timer to expire */
/***********************************************************************
* TIMER_InsertTimer
*
* Insert the timer at its place in the chain.
*/
static void TIMER_InsertTimer( TIMER * pTimer )
{
if (!pNextTimer || (pTimer->expires < pNextTimer->expires))
{
pTimer->next = pNextTimer;
pNextTimer = pTimer;
}
else
{
TIMER * ptr = pNextTimer;
while (ptr->next && (pTimer->expires >= ptr->next->expires))
ptr = ptr->next;
pTimer->next = ptr;
ptr->next = pTimer;
}
}
/***********************************************************************
* TIMER_RemoveTimer
*
* Remove the timer from the chain.
*/
static void TIMER_RemoveTimer( TIMER * pTimer )
{
if (pTimer == pNextTimer) pNextTimer = pTimer->next;
else
{
TIMER * ptr = pNextTimer;
while (ptr && (ptr->next != pTimer)) ptr = ptr->next;
if (ptr) ptr->next = pTimer->next;
}
pTimer->next = NULL;
}
/***********************************************************************
* TIMER_NextExpire
*
* Return time until next timer expiration (-1 if none).
*/
static DWORD TIMER_NextExpire( DWORD curTime )
{
if (!pNextTimer) return -1;
if (pNextTimer->expires <= curTime) return 0;
return pNextTimer->expires - curTime;
}
/***********************************************************************
* TIMER_CheckTimer
*
* Check whether a timer has expired, and post a message if necessary.
* Return TRUE if msg posted, and return time until next expiration in 'next'.
*/
BOOL TIMER_CheckTimer( DWORD *next )
{
TIMER * pTimer = pNextTimer;
DWORD curTime = GetTickCount();
if ((*next = TIMER_NextExpire( curTime )) != 0) return FALSE;
PostMessage( pTimer->hwnd, pTimer->msg, pTimer->id, (LONG)pTimer->proc );
TIMER_RemoveTimer( pTimer );
/* If timeout == 0, the timer has been removed by KillTimer */
if (pTimer->timeout)
{
/* Restart the timer */
pTimer->expires = curTime + pTimer->timeout;
TIMER_InsertTimer( pTimer );
}
*next = TIMER_NextExpire( curTime );
return TRUE;
}
/***********************************************************************
* TIMER_SetTimer
*/
static WORD TIMER_SetTimer( HWND hwnd, WORD id, WORD timeout,
FARPROC proc, BOOL sys )
{
int i;
TIMER * pTimer;
if (!timeout) return 0;
if (!hwnd && !proc) return 0;
/* Find a free timer */
for (i = 0, pTimer = TimersArray; i < NB_TIMERS; i++, pTimer++)
if (!pTimer->timeout) break;
if (i >= NB_TIMERS) return 0;
if (!sys && (i >= NB_TIMERS-NB_RESERVED_TIMERS)) return 0;
if (!hwnd) id = i + 1;
/* Add the timer */
pTimer->hwnd = hwnd;
pTimer->msg = sys ? WM_SYSTIMER : WM_TIMER;
pTimer->id = id;
pTimer->timeout = timeout;
pTimer->expires = GetTickCount() + timeout;
pTimer->proc = proc;
TIMER_InsertTimer( pTimer );
MSG_IncTimerCount( GetTaskQueue(0) );
if (!id)
return TRUE;
else
return id;
}
/***********************************************************************
* TIMER_KillTimer
*/
static BOOL TIMER_KillTimer( HWND hwnd, WORD id, BOOL sys )
{
int i;
TIMER * pTimer;
/* Find the timer */
for (i = 0, pTimer = TimersArray; i < NB_TIMERS; i++, pTimer++)
if ((pTimer->hwnd == hwnd) && (pTimer->id == id) &&
(pTimer->timeout != 0)) break;
if (i >= NB_TIMERS) return FALSE;
if (!sys && (i >= NB_TIMERS-NB_RESERVED_TIMERS)) return FALSE;
if (!sys && (pTimer->msg != WM_TIMER)) return FALSE;
else if (sys && (pTimer->msg != WM_SYSTIMER)) return FALSE;
/* Delete the timer */
pTimer->hwnd = 0;
pTimer->msg = 0;
pTimer->id = 0;
pTimer->timeout = 0;
pTimer->proc = 0;
TIMER_RemoveTimer( pTimer );
MSG_DecTimerCount( GetTaskQueue(0) );
return TRUE;
}
/***********************************************************************
* SetTimer (USER.10)
*/
WORD SetTimer( HWND hwnd, WORD id, WORD timeout, FARPROC proc )
{
#ifdef DEBUG_TIMER
printf( "SetTimer: %d %d %d %p\n", hwnd, id, timeout, proc );
#endif
return TIMER_SetTimer( hwnd, id, timeout, proc, FALSE );
}
/***********************************************************************
* SetSystemTimer (USER.11)
*/
WORD SetSystemTimer( HWND hwnd, WORD id, WORD timeout, FARPROC proc )
{
#ifdef DEBUG_TIMER
printf( "SetSystemTimer: %d %d %d %p\n", hwnd, id, timeout, proc );
#endif
return TIMER_SetTimer( hwnd, id, timeout, proc, TRUE );
}
/***********************************************************************
* KillTimer (USER.12)
*/
BOOL KillTimer( HWND hwnd, WORD id )
{
#ifdef DEBUG_TIMER
printf( "KillTimer: %d %d\n", hwnd, id );
#endif
return TIMER_KillTimer( hwnd, id, FALSE );
}
/***********************************************************************
* KillSystemTimer (USER.182)
*/
BOOL KillSystemTimer( HWND hwnd, WORD id )
{
#ifdef DEBUG_TIMER
printf( "KillSystemTimer: %d %d\n", hwnd, id );
#endif
return TIMER_KillTimer( hwnd, id, TRUE );
}