user32: Make WINPROC_AllocProc take a unicode flag for consistency with the other winproc functions.
This commit is contained in:
parent
d081a7352c
commit
77ab435402
|
@ -551,7 +551,7 @@ ATOM WINAPI RegisterClassExA( const WNDCLASSEXA* wc )
|
|||
classPtr->hIconSm = wc->hIconSm;
|
||||
classPtr->hCursor = wc->hCursor;
|
||||
classPtr->hbrBackground = wc->hbrBackground;
|
||||
classPtr->winproc = WINPROC_AllocProc( wc->lpfnWndProc, NULL );
|
||||
classPtr->winproc = WINPROC_AllocProc( wc->lpfnWndProc, FALSE );
|
||||
CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
|
||||
release_class_ptr( classPtr );
|
||||
return atom;
|
||||
|
@ -589,7 +589,7 @@ ATOM WINAPI RegisterClassExW( const WNDCLASSEXW* wc )
|
|||
classPtr->hIconSm = wc->hIconSm;
|
||||
classPtr->hCursor = wc->hCursor;
|
||||
classPtr->hbrBackground = wc->hbrBackground;
|
||||
classPtr->winproc = WINPROC_AllocProc( NULL, wc->lpfnWndProc );
|
||||
classPtr->winproc = WINPROC_AllocProc( wc->lpfnWndProc, TRUE );
|
||||
CLASS_SetMenuNameW( classPtr, wc->lpszMenuName );
|
||||
release_class_ptr( classPtr );
|
||||
return atom;
|
||||
|
@ -903,8 +903,7 @@ static ULONG_PTR CLASS_SetClassLong( HWND hwnd, INT offset, LONG_PTR newval,
|
|||
break;
|
||||
case GCLP_WNDPROC:
|
||||
retval = (ULONG_PTR)WINPROC_GetProc( class->winproc, unicode );
|
||||
class->winproc = WINPROC_AllocProc( unicode ? NULL : (WNDPROC)newval,
|
||||
unicode ? (WNDPROC)newval : NULL );
|
||||
class->winproc = WINPROC_AllocProc( (WNDPROC)newval, unicode );
|
||||
break;
|
||||
case GCLP_HBRBACKGROUND:
|
||||
retval = (ULONG_PTR)class->hbrBackground;
|
||||
|
|
|
@ -110,7 +110,7 @@ struct wow_handlers32
|
|||
LRESULT (*scrollbar_proc)(HWND,UINT,WPARAM,LPARAM,BOOL);
|
||||
LRESULT (*static_proc)(HWND,UINT,WPARAM,LPARAM,BOOL);
|
||||
HWND (*create_window)(CREATESTRUCTW*,LPCWSTR,HINSTANCE,UINT);
|
||||
WNDPROC (*alloc_winproc)(WNDPROC,WNDPROC);
|
||||
WNDPROC (*alloc_winproc)(WNDPROC,BOOL);
|
||||
};
|
||||
|
||||
extern struct wow_handlers16 wow_handlers DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -3589,7 +3589,7 @@ 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, NULL );
|
||||
if (proc) winproc = WINPROC_AllocProc( (WNDPROC)proc, FALSE );
|
||||
|
||||
SERVER_START_REQ( set_win_timer )
|
||||
{
|
||||
|
@ -3620,7 +3620,7 @@ UINT_PTR WINAPI SetSystemTimer( HWND hwnd, UINT_PTR id, UINT timeout, TIMERPROC
|
|||
UINT_PTR ret;
|
||||
WNDPROC winproc = 0;
|
||||
|
||||
if (proc) winproc = WINPROC_AllocProc( (WNDPROC)proc, NULL );
|
||||
if (proc) winproc = WINPROC_AllocProc( (WNDPROC)proc, FALSE );
|
||||
|
||||
SERVER_START_REQ( set_win_timer )
|
||||
{
|
||||
|
|
|
@ -231,10 +231,7 @@ done:
|
|||
*/
|
||||
WNDPROC16 WINPROC_GetProc16( WNDPROC proc, BOOL unicode )
|
||||
{
|
||||
WNDPROC winproc;
|
||||
|
||||
if (unicode) winproc = wow_handlers32.alloc_winproc( NULL, proc );
|
||||
else winproc = wow_handlers32.alloc_winproc( proc, NULL );
|
||||
WNDPROC winproc = wow_handlers32.alloc_winproc( proc, unicode );
|
||||
|
||||
if ((ULONG_PTR)winproc >> 16 != WINPROC_HANDLE) return (WNDPROC16)winproc;
|
||||
return alloc_win16_thunk( winproc );
|
||||
|
|
|
@ -239,7 +239,7 @@ typedef LRESULT (*winproc_callback16_t)( HWND16 hwnd, UINT16 msg, WPARAM16 wp, L
|
|||
extern WNDPROC16 WINPROC_GetProc16( WNDPROC proc, BOOL unicode ) DECLSPEC_HIDDEN;
|
||||
extern WNDPROC WINPROC_AllocProc16( WNDPROC16 func ) DECLSPEC_HIDDEN;
|
||||
extern WNDPROC WINPROC_GetProc( WNDPROC proc, BOOL unicode ) DECLSPEC_HIDDEN;
|
||||
extern WNDPROC WINPROC_AllocProc( WNDPROC funcA, WNDPROC funcW ) DECLSPEC_HIDDEN;
|
||||
extern WNDPROC WINPROC_AllocProc( WNDPROC func, BOOL unicode ) DECLSPEC_HIDDEN;
|
||||
extern BOOL WINPROC_IsUnicode( WNDPROC proc, BOOL def_val ) DECLSPEC_HIDDEN;
|
||||
|
||||
extern LRESULT WINPROC_CallProcAtoW( winproc_callback_t callback, HWND hwnd, UINT msg,
|
||||
|
|
|
@ -2099,8 +2099,7 @@ LONG_PTR WIN_SetWindowLong( HWND hwnd, INT offset, UINT size, LONG_PTR newval, B
|
|||
WNDPROC proc;
|
||||
UINT old_flags = wndPtr->flags;
|
||||
retval = WIN_GetWindowLong( hwnd, offset, size, unicode );
|
||||
if (unicode) proc = WINPROC_AllocProc( NULL, (WNDPROC)newval );
|
||||
else proc = WINPROC_AllocProc( (WNDPROC)newval, NULL );
|
||||
proc = WINPROC_AllocProc( (WNDPROC)newval, unicode );
|
||||
if (proc) wndPtr->winproc = proc;
|
||||
if (WINPROC_IsUnicode( proc, unicode )) wndPtr->flags |= WIN_ISUNICODE;
|
||||
else wndPtr->flags &= ~WIN_ISUNICODE;
|
||||
|
@ -2122,8 +2121,7 @@ LONG_PTR WIN_SetWindowLong( HWND hwnd, INT offset, UINT size, LONG_PTR newval, B
|
|||
{
|
||||
WNDPROC *ptr = (WNDPROC *)((char *)wndPtr->wExtra + DWLP_DLGPROC);
|
||||
retval = (ULONG_PTR)WINPROC_GetProc( *ptr, unicode );
|
||||
if (unicode) *ptr = WINPROC_AllocProc( NULL, (WNDPROC)newval );
|
||||
else *ptr = WINPROC_AllocProc( (WNDPROC)newval, NULL );
|
||||
*ptr = WINPROC_AllocProc( (WNDPROC)newval, unicode );
|
||||
WIN_ReleasePtr( wndPtr );
|
||||
return retval;
|
||||
}
|
||||
|
|
|
@ -104,21 +104,20 @@ static inline void free_buffer( void *static_buffer, void *buffer )
|
|||
|
||||
/* find an existing winproc for a given function and type */
|
||||
/* FIXME: probably should do something more clever than a linear search */
|
||||
static inline WINDOWPROC *find_winproc( WNDPROC funcA, WNDPROC funcW )
|
||||
static inline WINDOWPROC *find_winproc( WNDPROC func, BOOL unicode )
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < NB_BUILTIN_AW_WINPROCS; i++)
|
||||
{
|
||||
/* match either proc, some apps confuse A and W */
|
||||
if (funcA && winproc_array[i].procA != funcA && winproc_array[i].procW != funcA) continue;
|
||||
if (funcW && winproc_array[i].procA != funcW && winproc_array[i].procW != funcW) continue;
|
||||
if (winproc_array[i].procA != func && winproc_array[i].procW != func) continue;
|
||||
return &winproc_array[i];
|
||||
}
|
||||
for (i = NB_BUILTIN_AW_WINPROCS; i < winproc_used; i++)
|
||||
{
|
||||
if (funcA && winproc_array[i].procA != funcA) continue;
|
||||
if (funcW && winproc_array[i].procW != funcW) continue;
|
||||
if (!unicode && winproc_array[i].procA != func) continue;
|
||||
if (unicode && winproc_array[i].procW != func) continue;
|
||||
return &winproc_array[i];
|
||||
}
|
||||
return NULL;
|
||||
|
@ -142,32 +141,31 @@ static inline WNDPROC proc_to_handle( WINDOWPROC *proc )
|
|||
}
|
||||
|
||||
/* allocate and initialize a new winproc */
|
||||
static inline WINDOWPROC *alloc_winproc( WNDPROC funcA, WNDPROC funcW )
|
||||
static inline WINDOWPROC *alloc_winproc( WNDPROC func, BOOL unicode )
|
||||
{
|
||||
WINDOWPROC *proc;
|
||||
|
||||
/* check if the function is already a win proc */
|
||||
if (funcA && (proc = handle_to_proc( funcA ))) return proc;
|
||||
if (funcW && (proc = handle_to_proc( funcW ))) return proc;
|
||||
if (!funcA && !funcW) return NULL;
|
||||
if (!func) return NULL;
|
||||
if ((proc = handle_to_proc( func ))) return proc;
|
||||
|
||||
EnterCriticalSection( &winproc_cs );
|
||||
|
||||
/* check if we already have a winproc for that function */
|
||||
if (!(proc = find_winproc( funcA, funcW )))
|
||||
if (!(proc = find_winproc( func, unicode )))
|
||||
{
|
||||
if (winproc_used < MAX_WINPROCS)
|
||||
{
|
||||
proc = &winproc_array[winproc_used++];
|
||||
proc->procA = funcA;
|
||||
proc->procW = funcW;
|
||||
if (unicode) proc->procW = func;
|
||||
else proc->procA = func;
|
||||
TRACE( "allocated %p for %c %p (%d/%d used)\n",
|
||||
proc_to_handle(proc), funcA ? 'A' : 'W', funcA ? funcA : funcW,
|
||||
proc_to_handle(proc), unicode ? 'W' : 'A', func,
|
||||
winproc_used, MAX_WINPROCS );
|
||||
}
|
||||
else FIXME( "too many winprocs, cannot allocate one for %p/%p\n", funcA, funcW );
|
||||
else FIXME( "too many winprocs, cannot allocate one for %p\n", func );
|
||||
}
|
||||
else TRACE( "reusing %p for %p/%p\n", proc_to_handle(proc), funcA, funcW );
|
||||
else TRACE( "reusing %p for %p\n", proc_to_handle(proc), func );
|
||||
|
||||
LeaveCriticalSection( &winproc_cs );
|
||||
return proc;
|
||||
|
@ -304,12 +302,12 @@ WNDPROC WINPROC_GetProc( WNDPROC proc, BOOL unicode )
|
|||
* lot of windows, it will usually only have a limited number of window procedures, so the
|
||||
* array won't grow too large, and this way we avoid the need to track allocations per window.
|
||||
*/
|
||||
WNDPROC WINPROC_AllocProc( WNDPROC funcA, WNDPROC funcW )
|
||||
WNDPROC WINPROC_AllocProc( WNDPROC func, BOOL unicode )
|
||||
{
|
||||
WINDOWPROC *proc;
|
||||
|
||||
if (!(proc = alloc_winproc( funcA, funcW ))) return NULL;
|
||||
if (proc == WINPROC_PROC16) return funcA ? funcA : funcW;
|
||||
if (!(proc = alloc_winproc( func, unicode ))) return NULL;
|
||||
if (proc == WINPROC_PROC16) return func;
|
||||
return proc_to_handle( proc );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue