Commit 648994c3 authored by Alexandre Julliard's avatar Alexandre Julliard

Changed winproc allocation to be based only on the procedure address,

to avoid the need to keep track of winprocs for each window and class.
parent 958f4c64
......@@ -36,13 +36,6 @@ typedef enum
WIN_PROC_32W
} WINDOWPROCTYPE;
typedef enum
{
WIN_PROC_CLASS,
WIN_PROC_WINDOW,
WIN_PROC_TIMER
} WINDOWPROCUSER;
typedef struct
{
WPARAM16 wParam;
......@@ -60,9 +53,7 @@ typedef struct
struct tagWINDOWPROC;
extern WNDPROC16 WINPROC_GetProc( WNDPROC proc, WINDOWPROCTYPE type );
extern BOOL WINPROC_SetProc( WNDPROC *pFirst, WNDPROC func,
WINDOWPROCTYPE type, WINDOWPROCUSER user );
extern void WINPROC_FreeProc( WNDPROC proc, WINDOWPROCUSER user );
extern WNDPROC WINPROC_AllocProc( WNDPROC func, WINDOWPROCTYPE type );
extern WINDOWPROCTYPE WINPROC_GetProcType( WNDPROC proc );
extern INT WINPROC_MapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM *pwparam,
......
......@@ -187,20 +187,14 @@ static WNDPROC16 CLASS_SetProc( CLASS *classPtr, WNDPROC newproc, WINDOWPROCTYPE
if (!*proc || type == WIN_PROC_32W) proc = &classPtr->winprocW;
}
ret = WINPROC_GetProc( *proc, type );
WINPROC_SetProc( proc, newproc, type, WIN_PROC_CLASS );
/* now free the one that we didn't set */
*proc = WINPROC_AllocProc( newproc, type );
/* now clear the one that we didn't set */
if (classPtr->winprocA && classPtr->winprocW)
{
if (proc == &classPtr->winprocA)
{
WINPROC_FreeProc( classPtr->winprocW, WIN_PROC_CLASS );
classPtr->winprocW = 0;
}
else
{
WINPROC_FreeProc( classPtr->winprocA, WIN_PROC_CLASS );
classPtr->winprocA = 0;
}
}
return ret;
}
......@@ -303,8 +297,6 @@ static void CLASS_FreeClass( CLASS *classPtr )
if (classPtr->dce) DCE_FreeDCE( classPtr->dce );
if (classPtr->hbrBackground > (HBRUSH)(COLOR_GRADIENTINACTIVECAPTION + 1))
DeleteObject( classPtr->hbrBackground );
WINPROC_FreeProc( classPtr->winprocA, WIN_PROC_CLASS );
WINPROC_FreeProc( classPtr->winprocW, WIN_PROC_CLASS );
UnMapLS( classPtr->segMenuName );
HeapFree( GetProcessHeap(), 0, classPtr->menuName );
HeapFree( GetProcessHeap(), 0, classPtr );
......@@ -458,10 +450,8 @@ static CLASS *register_builtin( const struct builtin_class_descr *descr )
classPtr->hCursor = LoadCursorA( 0, (LPSTR)descr->cursor );
classPtr->hbrBackground = descr->brush;
if (descr->procA) WINPROC_SetProc( &classPtr->winprocA, descr->procA,
WIN_PROC_32A, WIN_PROC_CLASS );
if (descr->procW) WINPROC_SetProc( &classPtr->winprocW, descr->procW,
WIN_PROC_32W, WIN_PROC_CLASS );
if (descr->procA) classPtr->winprocA = WINPROC_AllocProc( descr->procA, WIN_PROC_32A );
if (descr->procW) classPtr->winprocW = WINPROC_AllocProc( descr->procW, WIN_PROC_32W );
release_class_ptr( classPtr );
return classPtr;
}
......@@ -623,8 +613,7 @@ ATOM WINAPI RegisterClassEx16( const WNDCLASSEX16 *wc )
classPtr->hCursor = HCURSOR_32(wc->hCursor);
classPtr->hbrBackground = HBRUSH_32(wc->hbrBackground);
WINPROC_SetProc( &classPtr->winprocA, (WNDPROC)wc->lpfnWndProc,
WIN_PROC_16, WIN_PROC_CLASS );
classPtr->winprocA = WINPROC_AllocProc( (WNDPROC)wc->lpfnWndProc, WIN_PROC_16 );
CLASS_SetMenuNameA( classPtr, MapSL(wc->lpszMenuName) );
release_class_ptr( classPtr );
return atom;
......@@ -662,7 +651,7 @@ ATOM WINAPI RegisterClassExA( const WNDCLASSEXA* wc )
classPtr->hIconSm = wc->hIconSm;
classPtr->hCursor = wc->hCursor;
classPtr->hbrBackground = wc->hbrBackground;
WINPROC_SetProc( &classPtr->winprocA, wc->lpfnWndProc, WIN_PROC_32A, WIN_PROC_CLASS );
classPtr->winprocA = WINPROC_AllocProc( wc->lpfnWndProc, WIN_PROC_32A );
CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
release_class_ptr( classPtr );
return atom;
......@@ -700,7 +689,7 @@ ATOM WINAPI RegisterClassExW( const WNDCLASSEXW* wc )
classPtr->hIconSm = wc->hIconSm;
classPtr->hCursor = wc->hCursor;
classPtr->hbrBackground = wc->hbrBackground;
WINPROC_SetProc( &classPtr->winprocW, wc->lpfnWndProc, WIN_PROC_32W, WIN_PROC_CLASS );
classPtr->winprocW = WINPROC_AllocProc( wc->lpfnWndProc, WIN_PROC_32W );
CLASS_SetMenuNameW( classPtr, wc->lpszMenuName );
release_class_ptr( classPtr );
return atom;
......
......@@ -247,7 +247,6 @@ static LRESULT DEFDLG_Proc( HWND hwnd, UINT msg, WPARAM wParam,
}
if (dlgInfo->hUserFont) DeleteObject( dlgInfo->hUserFont );
if (dlgInfo->hMenu) DestroyMenu( dlgInfo->hMenu );
WINPROC_FreeProc( DEFDLG_GetDlgProc( hwnd ), WIN_PROC_WINDOW );
HeapFree( GetProcessHeap(), 0, dlgInfo );
}
/* Window clean-up */
......
......@@ -77,7 +77,6 @@ static void TIMER_ClearTimer( TIMER * pTimer )
pTimer->msg = 0;
pTimer->id = 0;
pTimer->timeout = 0;
WINPROC_FreeProc( pTimer->proc, WIN_PROC_TIMER );
}
......@@ -172,7 +171,7 @@ static UINT_PTR TIMER_SetTimer( HWND hwnd, UINT_PTR id, UINT timeout,
if (!hwnd) id = i + 1;
if (proc) WINPROC_SetProc( &winproc, proc, type, WIN_PROC_TIMER );
if (proc) winproc = WINPROC_AllocProc( proc, type );
SERVER_START_REQ( set_win_timer )
{
......
......@@ -650,7 +650,6 @@ LRESULT WIN_DestroyWindow( HWND hwnd )
}
DCE_FreeWindowDCE( hwnd ); /* Always do this to catch orphaned DCs */
if (USER_Driver.pDestroyWindow) USER_Driver.pDestroyWindow( hwnd );
WINPROC_FreeProc( wndPtr->winproc, WIN_PROC_WINDOW );
wndPtr->class = NULL;
wndPtr->dwMagic = 0; /* Mark it as invalid */
WIN_ReleaseWndPtr( wndPtr );
......@@ -2058,7 +2057,7 @@ static LONG_PTR WIN_SetWindowLong( HWND hwnd, INT offset, LONG_PTR newval,
}
case GWLP_WNDPROC:
retval = (ULONG_PTR)WINPROC_GetProc( wndPtr->winproc, type );
WINPROC_SetProc( &wndPtr->winproc, (WNDPROC)newval, type, WIN_PROC_WINDOW );
wndPtr->winproc = WINPROC_AllocProc( (WNDPROC)newval, type );
WIN_ReleasePtr( wndPtr );
return retval;
case GWLP_ID:
......@@ -2070,7 +2069,7 @@ static LONG_PTR WIN_SetWindowLong( HWND hwnd, INT offset, LONG_PTR newval,
{
WNDPROC *ptr = (WNDPROC *)((char *)wndPtr->wExtra + DWLP_DLGPROC);
retval = (ULONG_PTR)WINPROC_GetProc( *ptr, type );
WINPROC_SetProc( ptr, (WNDPROC)newval, type, WIN_PROC_WINDOW );
*ptr = WINPROC_AllocProc( (WNDPROC)newval, type );
WIN_ReleasePtr( wndPtr );
return retval;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment