Get rid of the client-side window timer structures.
This commit is contained in:
parent
ff986a5a93
commit
e0db46c4aa
|
@ -37,7 +37,6 @@ C_SRCS = \
|
|||
$(TOPOBJDIR)/windows/syscolor.c \
|
||||
$(TOPOBJDIR)/windows/sysmetrics.c \
|
||||
$(TOPOBJDIR)/windows/sysparams.c \
|
||||
$(TOPOBJDIR)/windows/timer.c \
|
||||
$(TOPOBJDIR)/windows/user.c \
|
||||
$(TOPOBJDIR)/windows/win.c \
|
||||
$(TOPOBJDIR)/windows/winhelp.c \
|
||||
|
|
|
@ -48,6 +48,8 @@ WINE_DECLARE_DEBUG_CHANNEL(relay);
|
|||
|
||||
#define MAX_PACK_COUNT 4
|
||||
|
||||
#define SYS_TIMER_RATE 55 /* min. timer rate in ms (actually 54.925)*/
|
||||
|
||||
/* description of the data fields that need to be packed along with a sent message */
|
||||
struct packed_message
|
||||
{
|
||||
|
@ -2423,6 +2425,110 @@ BOOL WINAPI MessageBeep( UINT i )
|
|||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* SetTimer (USER32.@)
|
||||
*/
|
||||
UINT_PTR WINAPI SetTimer( HWND hwnd, UINT_PTR id, UINT timeout, TIMERPROC proc )
|
||||
{
|
||||
UINT_PTR ret;
|
||||
WNDPROC winproc = 0;
|
||||
|
||||
if (proc) winproc = WINPROC_AllocProc( (WNDPROC)proc, WIN_PROC_32A );
|
||||
|
||||
SERVER_START_REQ( set_win_timer )
|
||||
{
|
||||
req->win = hwnd;
|
||||
req->msg = WM_TIMER;
|
||||
req->id = id;
|
||||
req->rate = max( timeout, SYS_TIMER_RATE );
|
||||
req->lparam = (unsigned int)winproc;
|
||||
if (!wine_server_call_err( req ))
|
||||
{
|
||||
ret = reply->id;
|
||||
if (!ret) ret = TRUE;
|
||||
}
|
||||
else ret = 0;
|
||||
}
|
||||
SERVER_END_REQ;
|
||||
|
||||
TRACE("Added %p %x %p timeout %d\n", hwnd, id, winproc, timeout );
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* SetSystemTimer (USER32.@)
|
||||
*/
|
||||
UINT_PTR WINAPI SetSystemTimer( HWND hwnd, UINT_PTR id, UINT timeout, TIMERPROC proc )
|
||||
{
|
||||
UINT_PTR ret;
|
||||
WNDPROC winproc = 0;
|
||||
|
||||
if (proc) winproc = WINPROC_AllocProc( (WNDPROC)proc, WIN_PROC_32A );
|
||||
|
||||
SERVER_START_REQ( set_win_timer )
|
||||
{
|
||||
req->win = hwnd;
|
||||
req->msg = WM_SYSTIMER;
|
||||
req->id = id;
|
||||
req->rate = max( timeout, SYS_TIMER_RATE );
|
||||
req->lparam = (unsigned int)winproc;
|
||||
if (!wine_server_call_err( req ))
|
||||
{
|
||||
ret = reply->id;
|
||||
if (!ret) ret = TRUE;
|
||||
}
|
||||
else ret = 0;
|
||||
}
|
||||
SERVER_END_REQ;
|
||||
|
||||
TRACE("Added %p %x %p timeout %d\n", hwnd, id, winproc, timeout );
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* KillTimer (USER32.@)
|
||||
*/
|
||||
BOOL WINAPI KillTimer( HWND hwnd, UINT_PTR id )
|
||||
{
|
||||
BOOL ret;
|
||||
|
||||
TRACE("%p %d\n", hwnd, id );
|
||||
|
||||
SERVER_START_REQ( kill_win_timer )
|
||||
{
|
||||
req->win = hwnd;
|
||||
req->msg = WM_TIMER;
|
||||
req->id = id;
|
||||
ret = !wine_server_call_err( req );
|
||||
}
|
||||
SERVER_END_REQ;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* KillSystemTimer (USER32.@)
|
||||
*/
|
||||
BOOL WINAPI KillSystemTimer( HWND hwnd, UINT_PTR id )
|
||||
{
|
||||
BOOL ret;
|
||||
|
||||
TRACE("%p %d\n", hwnd, id );
|
||||
|
||||
SERVER_START_REQ( kill_win_timer )
|
||||
{
|
||||
req->win = hwnd;
|
||||
req->msg = WM_SYSTIMER;
|
||||
req->id = id;
|
||||
ret = !wine_server_call_err( req );
|
||||
}
|
||||
SERVER_END_REQ;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* AttachThreadInput (USER32.@)
|
||||
*
|
||||
|
|
|
@ -229,7 +229,6 @@ static void thread_detach(void)
|
|||
|
||||
WDML_NotifyThreadDetach();
|
||||
|
||||
TIMER_RemoveThreadTimers();
|
||||
WIN_DestroyThreadWindows( GetDesktopWindow() );
|
||||
QUEUE_DeleteMsgQueue();
|
||||
|
||||
|
|
|
@ -129,8 +129,4 @@ extern void CLASS_RegisterBuiltinClasses(void);
|
|||
extern void CLASS_AddWindow( struct tagCLASS *class, struct tagWND *win, WINDOWPROCTYPE type );
|
||||
extern void CLASS_FreeModuleClasses( HMODULE16 hModule );
|
||||
|
||||
/* Timer functions */
|
||||
extern void TIMER_RemoveWindowTimers( HWND hwnd );
|
||||
extern void TIMER_RemoveThreadTimers(void);
|
||||
|
||||
#endif /* __WINE_WINPROC_H */
|
||||
|
|
284
windows/timer.c
284
windows/timer.c
|
@ -1,284 +0,0 @@
|
|||
/*
|
||||
* Timer functions
|
||||
*
|
||||
* Copyright 1993 Alexandre Julliard
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "wine/port.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "wingdi.h"
|
||||
#include "wine/winuser16.h"
|
||||
#include "winuser.h"
|
||||
#include "winerror.h"
|
||||
|
||||
#include "winproc.h"
|
||||
#include "message.h"
|
||||
#include "win.h"
|
||||
#include "wine/server.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(timer);
|
||||
|
||||
|
||||
typedef struct tagTIMER
|
||||
{
|
||||
HWND hwnd;
|
||||
DWORD thread;
|
||||
UINT msg; /* WM_TIMER or WM_SYSTIMER */
|
||||
UINT id;
|
||||
UINT timeout;
|
||||
} TIMER;
|
||||
|
||||
#define NB_TIMERS 34
|
||||
#define NB_RESERVED_TIMERS 2 /* for SetSystemTimer */
|
||||
|
||||
#define SYS_TIMER_RATE 55 /* min. timer rate in ms (actually 54.925)*/
|
||||
|
||||
static TIMER TimersArray[NB_TIMERS];
|
||||
|
||||
static CRITICAL_SECTION csTimer;
|
||||
static CRITICAL_SECTION_DEBUG critsect_debug =
|
||||
{
|
||||
0, 0, &csTimer,
|
||||
{ &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
|
||||
0, 0, { 0, (DWORD)(__FILE__ ": csTimer") }
|
||||
};
|
||||
static CRITICAL_SECTION csTimer = { &critsect_debug, -1, 0, 0, 0, 0 };
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* TIMER_ClearTimer
|
||||
*
|
||||
* Clear and remove a timer.
|
||||
*/
|
||||
static void TIMER_ClearTimer( TIMER * pTimer )
|
||||
{
|
||||
pTimer->hwnd = 0;
|
||||
pTimer->msg = 0;
|
||||
pTimer->id = 0;
|
||||
pTimer->timeout = 0;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* TIMER_RemoveWindowTimers
|
||||
*
|
||||
* Remove all timers for a given window.
|
||||
*/
|
||||
void TIMER_RemoveWindowTimers( HWND hwnd )
|
||||
{
|
||||
int i;
|
||||
TIMER *pTimer;
|
||||
|
||||
EnterCriticalSection( &csTimer );
|
||||
|
||||
for (i = NB_TIMERS, pTimer = TimersArray; i > 0; i--, pTimer++)
|
||||
if ((pTimer->hwnd == hwnd) && pTimer->timeout)
|
||||
TIMER_ClearTimer( pTimer );
|
||||
|
||||
LeaveCriticalSection( &csTimer );
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* TIMER_RemoveThreadTimers
|
||||
*
|
||||
* Remove all timers for the current thread.
|
||||
*/
|
||||
void TIMER_RemoveThreadTimers(void)
|
||||
{
|
||||
int i;
|
||||
TIMER *pTimer;
|
||||
|
||||
EnterCriticalSection( &csTimer );
|
||||
|
||||
for (i = NB_TIMERS, pTimer = TimersArray; i > 0; i--, pTimer++)
|
||||
if ((pTimer->thread == GetCurrentThreadId()) && pTimer->timeout)
|
||||
TIMER_ClearTimer( pTimer );
|
||||
|
||||
LeaveCriticalSection( &csTimer );
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* TIMER_SetTimer
|
||||
*/
|
||||
static UINT_PTR TIMER_SetTimer( HWND hwnd, UINT_PTR id, UINT timeout, TIMERPROC proc, BOOL sys )
|
||||
{
|
||||
int i;
|
||||
TIMER * pTimer;
|
||||
WNDPROC winproc = 0;
|
||||
|
||||
if (hwnd && !(hwnd = WIN_IsCurrentThread( hwnd )))
|
||||
{
|
||||
SetLastError( ERROR_INVALID_WINDOW_HANDLE );
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!timeout)
|
||||
{ /* timeout==0 is a legal argument UB 990821*/
|
||||
WARN("Timeout== 0 not implemented, using timeout=1\n");
|
||||
timeout=1;
|
||||
}
|
||||
|
||||
EnterCriticalSection( &csTimer );
|
||||
|
||||
/* Check if there's already a timer with the same hwnd and id */
|
||||
|
||||
for (i = 0, pTimer = TimersArray; i < NB_TIMERS; i++, pTimer++)
|
||||
if ((pTimer->hwnd == hwnd) && (pTimer->id == id) &&
|
||||
(pTimer->timeout != 0))
|
||||
{
|
||||
TIMER_ClearTimer( pTimer );
|
||||
break;
|
||||
}
|
||||
|
||||
if ( i == NB_TIMERS )
|
||||
{
|
||||
/* Find a free timer */
|
||||
|
||||
for (i = 0, pTimer = TimersArray; i < NB_TIMERS; i++, pTimer++)
|
||||
if (!pTimer->timeout) break;
|
||||
|
||||
if ( (i >= NB_TIMERS) ||
|
||||
(!sys && (i >= NB_TIMERS-NB_RESERVED_TIMERS)) )
|
||||
{
|
||||
LeaveCriticalSection( &csTimer );
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hwnd) id = i + 1;
|
||||
|
||||
if (proc) winproc = WINPROC_AllocProc( (WNDPROC)proc, WIN_PROC_32A );
|
||||
|
||||
SERVER_START_REQ( set_win_timer )
|
||||
{
|
||||
req->win = hwnd;
|
||||
req->msg = sys ? WM_SYSTIMER : WM_TIMER;
|
||||
req->id = id;
|
||||
req->rate = max( timeout, SYS_TIMER_RATE );
|
||||
req->lparam = (unsigned int)winproc;
|
||||
wine_server_call( req );
|
||||
}
|
||||
SERVER_END_REQ;
|
||||
|
||||
/* Add the timer */
|
||||
|
||||
pTimer->hwnd = hwnd;
|
||||
pTimer->thread = GetCurrentThreadId();
|
||||
pTimer->msg = sys ? WM_SYSTIMER : WM_TIMER;
|
||||
pTimer->id = id;
|
||||
pTimer->timeout = timeout;
|
||||
|
||||
TRACE("Timer added: %p, %p, %04x, %04x, %p\n",
|
||||
pTimer, pTimer->hwnd, pTimer->msg, pTimer->id, winproc );
|
||||
|
||||
LeaveCriticalSection( &csTimer );
|
||||
|
||||
if (!id) return TRUE;
|
||||
else return id;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* TIMER_KillTimer
|
||||
*/
|
||||
static BOOL TIMER_KillTimer( HWND hwnd, UINT_PTR id, BOOL sys )
|
||||
{
|
||||
int i;
|
||||
TIMER * pTimer;
|
||||
|
||||
SERVER_START_REQ( kill_win_timer )
|
||||
{
|
||||
req->win = hwnd;
|
||||
req->msg = sys ? WM_SYSTIMER : WM_TIMER;
|
||||
req->id = id;
|
||||
wine_server_call( req );
|
||||
}
|
||||
SERVER_END_REQ;
|
||||
|
||||
EnterCriticalSection( &csTimer );
|
||||
|
||||
/* 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) ||
|
||||
(!sys && (i >= NB_TIMERS-NB_RESERVED_TIMERS)) ||
|
||||
(!sys && (pTimer->msg != WM_TIMER)) ||
|
||||
(sys && (pTimer->msg != WM_SYSTIMER)) )
|
||||
{
|
||||
LeaveCriticalSection( &csTimer );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Delete the timer */
|
||||
|
||||
TIMER_ClearTimer( pTimer );
|
||||
|
||||
LeaveCriticalSection( &csTimer );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* SetTimer (USER32.@)
|
||||
*/
|
||||
UINT_PTR WINAPI SetTimer( HWND hwnd, UINT_PTR id, UINT timeout, TIMERPROC proc )
|
||||
{
|
||||
TRACE("%p %d %d %p\n", hwnd, id, timeout, proc );
|
||||
return TIMER_SetTimer( hwnd, id, timeout, proc, FALSE );
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* SetSystemTimer (USER32.@)
|
||||
*/
|
||||
UINT_PTR WINAPI SetSystemTimer( HWND hwnd, UINT_PTR id, UINT timeout, TIMERPROC proc )
|
||||
{
|
||||
TRACE("%p %d %d %p\n", hwnd, id, timeout, proc );
|
||||
return TIMER_SetTimer( hwnd, id, timeout, proc, TRUE );
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* KillTimer (USER32.@)
|
||||
*/
|
||||
BOOL WINAPI KillTimer( HWND hwnd, UINT_PTR id )
|
||||
{
|
||||
TRACE("%p %d\n", hwnd, id );
|
||||
return TIMER_KillTimer( hwnd, id, FALSE );
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* KillSystemTimer (USER32.@)
|
||||
*/
|
||||
BOOL WINAPI KillSystemTimer( HWND hwnd, UINT_PTR id )
|
||||
{
|
||||
TRACE("%p %d\n", hwnd, id );
|
||||
return TIMER_KillTimer( hwnd, id, TRUE );
|
||||
}
|
|
@ -634,8 +634,6 @@ LRESULT WIN_DestroyWindow( HWND hwnd )
|
|||
|
||||
/* free resources associated with the window */
|
||||
|
||||
TIMER_RemoveWindowTimers( hwnd );
|
||||
|
||||
if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0;
|
||||
|
||||
if (!(wndPtr->dwStyle & WS_CHILD))
|
||||
|
|
Loading…
Reference in New Issue