user: Replace WINDOWPROCTYPE by a unicode flag in WINPROC_GetProc/AllocProc.

This commit is contained in:
Alexandre Julliard 2006-05-10 13:20:34 +02:00
parent ef74193949
commit a9e5e94b0d
6 changed files with 57 additions and 61 deletions

View File

@ -162,7 +162,7 @@ static WNDPROC16 CLASS_GetProc16( CLASS *classPtr )
*
* Get the class winproc for a given proc type
*/
static WNDPROC CLASS_GetProc( CLASS *classPtr, WINDOWPROCTYPE type )
static WNDPROC CLASS_GetProc( CLASS *classPtr, BOOL unicode )
{
WNDPROC proc = classPtr->winprocA;
@ -171,9 +171,9 @@ static WNDPROC CLASS_GetProc( CLASS *classPtr, WINDOWPROCTYPE type )
/* if we have a Unicode proc, use it if we have no ASCII proc
* or if we have both and Unicode was requested
*/
if (!proc || type == WIN_PROC_32W) proc = classPtr->winprocW;
if (!proc || unicode) proc = classPtr->winprocW;
}
return WINPROC_GetProc( proc, type );
return WINPROC_GetProc( proc, unicode );
}
@ -206,9 +206,9 @@ static void CLASS_SetProc16( CLASS *classPtr, WNDPROC16 newproc )
* Set the class winproc for a given proc type.
* Returns the previous window proc.
*/
static void CLASS_SetProc( CLASS *classPtr, WNDPROC newproc, WINDOWPROCTYPE type )
static void CLASS_SetProc( CLASS *classPtr, WNDPROC newproc, BOOL unicode )
{
WNDPROC proc = WINPROC_AllocProc( newproc, type );
WNDPROC proc = WINPROC_AllocProc( newproc, unicode );
if (WINPROC_GetProcType( proc ) == WIN_PROC_32W)
{
@ -474,8 +474,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) classPtr->winprocA = WINPROC_AllocProc( descr->procA, WIN_PROC_32A );
if (descr->procW) classPtr->winprocW = WINPROC_AllocProc( descr->procW, WIN_PROC_32W );
if (descr->procA) classPtr->winprocA = WINPROC_AllocProc( descr->procA, FALSE );
if (descr->procW) classPtr->winprocW = WINPROC_AllocProc( descr->procW, TRUE );
release_class_ptr( classPtr );
return classPtr;
}
@ -621,7 +621,7 @@ ATOM WINAPI RegisterClassExA( const WNDCLASSEXA* wc )
classPtr->hIconSm = wc->hIconSm;
classPtr->hCursor = wc->hCursor;
classPtr->hbrBackground = wc->hbrBackground;
classPtr->winprocA = WINPROC_AllocProc( wc->lpfnWndProc, WIN_PROC_32A );
classPtr->winprocA = WINPROC_AllocProc( wc->lpfnWndProc, FALSE );
CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
release_class_ptr( classPtr );
return atom;
@ -659,7 +659,7 @@ ATOM WINAPI RegisterClassExW( const WNDCLASSEXW* wc )
classPtr->hIconSm = wc->hIconSm;
classPtr->hCursor = wc->hCursor;
classPtr->hbrBackground = wc->hbrBackground;
classPtr->winprocW = WINPROC_AllocProc( wc->lpfnWndProc, WIN_PROC_32W );
classPtr->winprocW = WINPROC_AllocProc( wc->lpfnWndProc, TRUE );
CLASS_SetMenuNameW( classPtr, wc->lpszMenuName );
release_class_ptr( classPtr );
return atom;
@ -872,7 +872,7 @@ DWORD WINAPI GetClassLongW( HWND hwnd, INT offset )
retvalue = (DWORD)class->hInstance;
break;
case GCLP_WNDPROC:
retvalue = (DWORD)CLASS_GetProc( class, WIN_PROC_32W );
retvalue = (DWORD)CLASS_GetProc( class, TRUE );
break;
case GCLP_MENUNAME:
retvalue = (DWORD)CLASS_GetMenuNameW( class );
@ -912,7 +912,7 @@ DWORD WINAPI GetClassLongA( HWND hwnd, INT offset )
}
if (offset == GCLP_WNDPROC)
retvalue = (DWORD)CLASS_GetProc( class, WIN_PROC_32A );
retvalue = (DWORD)CLASS_GetProc( class, FALSE );
else /* GCL_MENUNAME */
retvalue = (DWORD)CLASS_GetMenuNameA( class );
@ -1011,8 +1011,8 @@ DWORD WINAPI SetClassLongW( HWND hwnd, INT offset, LONG newval )
retval = 0; /* Old value is now meaningless anyway */
break;
case GCLP_WNDPROC:
retval = (DWORD)CLASS_GetProc( class, WIN_PROC_32W );
CLASS_SetProc( class, (WNDPROC)newval, WIN_PROC_32W );
retval = (DWORD)CLASS_GetProc( class, TRUE );
CLASS_SetProc( class, (WNDPROC)newval, TRUE );
break;
case GCLP_HBRBACKGROUND:
retval = (DWORD)class->hbrBackground;
@ -1079,8 +1079,8 @@ DWORD WINAPI SetClassLongA( HWND hwnd, INT offset, LONG newval )
if (offset == GCLP_WNDPROC)
{
retval = (DWORD)CLASS_GetProc( class, WIN_PROC_32A );
CLASS_SetProc( class, (WNDPROC)newval, WIN_PROC_32A );
retval = (DWORD)CLASS_GetProc( class, FALSE );
CLASS_SetProc( class, (WNDPROC)newval, FALSE );
}
else /* GCL_MENUNAME */
{
@ -1202,7 +1202,7 @@ BOOL WINAPI GetClassInfoExA( HINSTANCE hInstance, LPCSTR name, WNDCLASSEXA *wc )
return FALSE;
}
wc->style = classPtr->style;
wc->lpfnWndProc = (WNDPROC)CLASS_GetProc( classPtr, WIN_PROC_32A );
wc->lpfnWndProc = (WNDPROC)CLASS_GetProc( classPtr, FALSE );
wc->cbClsExtra = classPtr->cbClsExtra;
wc->cbWndExtra = classPtr->cbWndExtra;
wc->hInstance = (hInstance == user32_module) ? 0 : hInstance;
@ -1237,7 +1237,7 @@ BOOL WINAPI GetClassInfoExW( HINSTANCE hInstance, LPCWSTR name, WNDCLASSEXW *wc
return FALSE;
}
wc->style = classPtr->style;
wc->lpfnWndProc = (WNDPROC)CLASS_GetProc( classPtr, WIN_PROC_32W );
wc->lpfnWndProc = (WNDPROC)CLASS_GetProc( classPtr, TRUE );
wc->cbClsExtra = classPtr->cbClsExtra;
wc->cbWndExtra = classPtr->cbWndExtra;
wc->hInstance = (hInstance == user32_module) ? 0 : hInstance;

View File

@ -3338,7 +3338,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, WIN_PROC_32A );
if (proc) winproc = WINPROC_AllocProc( (WNDPROC)proc, FALSE );
SERVER_START_REQ( set_win_timer )
{
@ -3369,7 +3369,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, WIN_PROC_32A );
if (proc) winproc = WINPROC_AllocProc( (WNDPROC)proc, FALSE );
SERVER_START_REQ( set_win_timer )
{

View File

@ -1832,7 +1832,7 @@ WORD WINAPI SetWindowWord( HWND hwnd, INT offset, WORD newval )
*
* Helper function for GetWindowLong().
*/
static LONG_PTR WIN_GetWindowLong( HWND hwnd, INT offset, WINDOWPROCTYPE type )
static LONG_PTR WIN_GetWindowLong( HWND hwnd, INT offset, BOOL unicode )
{
LONG_PTR retvalue = 0;
WND *wndPtr;
@ -1897,7 +1897,7 @@ static LONG_PTR WIN_GetWindowLong( HWND hwnd, INT offset, WINDOWPROCTYPE type )
retvalue = *(LONG_PTR *)(((char *)wndPtr->wExtra) + offset);
/* Special case for dialog window procedure */
if ((offset == DWLP_DLGPROC) && (wndPtr->flags & WIN_ISDIALOG))
retvalue = (LONG_PTR)WINPROC_GetProc( (WNDPROC)retvalue, type );
retvalue = (LONG_PTR)WINPROC_GetProc( (WNDPROC)retvalue, unicode );
WIN_ReleasePtr( wndPtr );
return retvalue;
}
@ -1908,7 +1908,7 @@ static LONG_PTR WIN_GetWindowLong( HWND hwnd, INT offset, WINDOWPROCTYPE type )
case GWL_STYLE: retvalue = wndPtr->dwStyle; break;
case GWL_EXSTYLE: retvalue = wndPtr->dwExStyle; break;
case GWLP_ID: retvalue = (ULONG_PTR)wndPtr->wIDmenu; break;
case GWLP_WNDPROC: retvalue = (ULONG_PTR)WINPROC_GetProc( wndPtr->winproc, type ); break;
case GWLP_WNDPROC: retvalue = (ULONG_PTR)WINPROC_GetProc( wndPtr->winproc, unicode ); break;
case GWLP_HINSTANCE: retvalue = (ULONG_PTR)wndPtr->hInstance; break;
default:
WARN("Unknown offset %d\n", offset );
@ -1928,15 +1928,14 @@ static LONG_PTR WIN_GetWindowLong( HWND hwnd, INT offset, WINDOWPROCTYPE type )
* 0 is the failure code. However, in the case of failure SetLastError
* must be set to distinguish between a 0 return value and a failure.
*/
static LONG_PTR WIN_SetWindowLong( HWND hwnd, INT offset, LONG_PTR newval,
WINDOWPROCTYPE type )
static LONG_PTR WIN_SetWindowLong( HWND hwnd, INT offset, LONG_PTR newval, BOOL unicode )
{
STYLESTRUCT style;
BOOL ok;
LONG_PTR retval = 0;
WND *wndPtr;
TRACE( "%p %d %lx %x\n", hwnd, offset, newval, type );
TRACE( "%p %d %lx %c\n", hwnd, offset, newval, unicode ? 'W' : 'A' );
if (is_broadcast(hwnd))
{
@ -1992,8 +1991,8 @@ static LONG_PTR WIN_SetWindowLong( HWND hwnd, INT offset, LONG_PTR newval,
case GWLP_WNDPROC:
{
UINT old_flags = wndPtr->flags;
retval = (ULONG_PTR)WINPROC_GetProc( wndPtr->winproc, type );
wndPtr->winproc = WINPROC_AllocProc( (WNDPROC)newval, type );
retval = (ULONG_PTR)WINPROC_GetProc( wndPtr->winproc, unicode );
wndPtr->winproc = WINPROC_AllocProc( (WNDPROC)newval, unicode );
if (WINPROC_GetProcType( wndPtr->winproc ) == WIN_PROC_32W) wndPtr->flags |= WIN_ISUNICODE;
else wndPtr->flags &= ~WIN_ISUNICODE;
if (!((old_flags ^ wndPtr->flags) & WIN_ISUNICODE))
@ -2012,8 +2011,8 @@ static LONG_PTR WIN_SetWindowLong( HWND hwnd, INT offset, LONG_PTR newval,
if ((wndPtr->cbWndExtra - sizeof(LONG_PTR) >= DWLP_DLGPROC) && (wndPtr->flags & WIN_ISDIALOG))
{
WNDPROC *ptr = (WNDPROC *)((char *)wndPtr->wExtra + DWLP_DLGPROC);
retval = (ULONG_PTR)WINPROC_GetProc( *ptr, type );
*ptr = WINPROC_AllocProc( (WNDPROC)newval, type );
retval = (ULONG_PTR)WINPROC_GetProc( *ptr, unicode );
*ptr = WINPROC_AllocProc( (WNDPROC)newval, unicode );
WIN_ReleasePtr( wndPtr );
return retval;
}
@ -2178,7 +2177,7 @@ LONG WINAPI GetWindowLong16( HWND16 hwnd, INT16 offset )
*/
LONG WINAPI GetWindowLongA( HWND hwnd, INT offset )
{
return WIN_GetWindowLong( hwnd, offset, WIN_PROC_32A );
return WIN_GetWindowLong( hwnd, offset, FALSE );
}
@ -2187,7 +2186,7 @@ LONG WINAPI GetWindowLongA( HWND hwnd, INT offset )
*/
LONG WINAPI GetWindowLongW( HWND hwnd, INT offset )
{
return WIN_GetWindowLong( hwnd, offset, WIN_PROC_32W );
return WIN_GetWindowLong( hwnd, offset, TRUE );
}
@ -2231,7 +2230,7 @@ LONG WINAPI SetWindowLong16( HWND16 hwnd, INT16 offset, LONG newval )
*/
LONG WINAPI SetWindowLongA( HWND hwnd, INT offset, LONG newval )
{
return WIN_SetWindowLong( hwnd, offset, newval, WIN_PROC_32A );
return WIN_SetWindowLong( hwnd, offset, newval, FALSE );
}
@ -2306,7 +2305,7 @@ LONG WINAPI SetWindowLongW(
INT offset, /* [in] offset, in bytes, of location to alter */
LONG newval /* [in] new value of location */
) {
return WIN_SetWindowLong( hwnd, offset, newval, WIN_PROC_32W );
return WIN_SetWindowLong( hwnd, offset, newval, TRUE );
}

View File

@ -119,13 +119,14 @@ static inline WINDOWPROC *find_winproc16( WNDPROC16 func )
/* 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 func, WINDOWPROCTYPE type )
static inline WINDOWPROC *find_winproc( WNDPROC func, BOOL unicode )
{
unsigned int i;
for (i = 0; i < winproc_used; i++)
{
if (winproc_array[i].type == type && winproc_array[i].thunk.proc == func)
if (winproc_array[i].thunk.proc == func &&
winproc_array[i].type == (unicode ? WIN_PROC_32W : WIN_PROC_32A))
return &winproc_array[i];
}
return NULL;
@ -139,7 +140,7 @@ static inline void set_winproc16( WINDOWPROC *proc, WNDPROC16 func )
}
/* initialize a new winproc */
static inline void set_winproc( WINDOWPROC *proc, WNDPROC func, WINDOWPROCTYPE type )
static inline void set_winproc( WINDOWPROC *proc, WNDPROC func, BOOL unicode )
{
#ifdef __i386__
static FARPROC16 relay_32A, relay_32W;
@ -148,29 +149,24 @@ static inline void set_winproc( WINDOWPROC *proc, WNDPROC func, WINDOWPROCTYPE t
proc->thunk.pushl_func = 0x68; /* pushl $proc */
proc->thunk.pushl_eax = 0x50; /* pushl %eax */
proc->thunk.ljmp = 0xea; /* ljmp relay*/
switch(type)
if (!unicode)
{
case WIN_PROC_32A:
if (!relay_32A) relay_32A = GetProcAddress16( GetModuleHandle16("user"),
"__wine_call_wndproc_32A" );
proc->thunk.relay_offset = OFFSETOF(relay_32A);
proc->thunk.relay_sel = SELECTOROF(relay_32A);
break;
case WIN_PROC_32W:
}
else
{
if (!relay_32W) relay_32W = GetProcAddress16( GetModuleHandle16("user"),
"__wine_call_wndproc_32W" );
proc->thunk.relay_offset = OFFSETOF(relay_32W);
proc->thunk.relay_sel = SELECTOROF(relay_32W);
break;
default:
/* Should not happen */
assert(0);
break;
}
#endif /* __i386__ */
proc->thunk.proc = func;
proc->proc16 = 0;
proc->type = type;
proc->type = unicode ? WIN_PROC_32W : WIN_PROC_32A;
}
static WORD get_winproc_selector(void)
@ -479,11 +475,11 @@ WNDPROC16 WINPROC_GetProc16( WNDPROC proc )
*
* Get a window procedure pointer that can be passed to the Windows program.
*/
WNDPROC WINPROC_GetProc( WNDPROC proc, WINDOWPROCTYPE type )
WNDPROC WINPROC_GetProc( WNDPROC proc, BOOL unicode )
{
WINDOWPROC *ptr = handle_to_proc( proc );
if (!ptr || type != ptr->type) return proc;
if (!ptr || ptr->type != (unicode ? WIN_PROC_32W : WIN_PROC_32A)) return proc;
return ptr->thunk.proc; /* we can return the original proc in that case */
}
@ -538,34 +534,35 @@ WNDPROC WINPROC_AllocProc16( WNDPROC16 func )
* 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 func, WINDOWPROCTYPE type )
WNDPROC WINPROC_AllocProc( WNDPROC func, BOOL unicode )
{
WINDOWPROC *proc;
if (!func) return NULL;
EnterCriticalSection( &winproc_cs );
/* check if the function is already a win proc */
if (!(proc = handle_to_proc( func )))
{
EnterCriticalSection( &winproc_cs );
/* then check if we already have a winproc for that function */
if (!(proc = find_winproc( func, type )))
if (!(proc = find_winproc( func, unicode )))
{
if (winproc_used >= MAX_WINPROCS)
FIXME( "too many winprocs, cannot allocate one for %p/%d\n", func, type );
FIXME( "too many winprocs, cannot allocate one for %p %c\n", func, unicode ? 'W' : 'A' );
else
{
proc = &winproc_array[winproc_used++];
set_winproc( proc, func, type );
TRACE( "allocated %p for %p/%d (%d/%d used)\n",
proc_to_handle(proc), func, type, winproc_used, MAX_WINPROCS );
set_winproc( proc, func, unicode );
TRACE( "allocated %p for %p %c (%d/%d used)\n",
proc_to_handle(proc), func, unicode ? 'W' : 'A', winproc_used, MAX_WINPROCS );
}
}
else TRACE( "reusing %p for %p/%d\n", proc_to_handle(proc), func, type );
else TRACE( "reusing %p for %p %c\n", proc_to_handle(proc), func, unicode ? 'W' : 'A' );
LeaveCriticalSection( &winproc_cs );
}
LeaveCriticalSection( &winproc_cs );
return proc_to_handle( proc );
}

View File

@ -54,8 +54,8 @@ struct tagWINDOWPROC;
extern WNDPROC16 WINPROC_GetProc16( WNDPROC proc );
extern WNDPROC WINPROC_AllocProc16( WNDPROC16 func );
extern WNDPROC WINPROC_GetProc( WNDPROC proc, WINDOWPROCTYPE type );
extern WNDPROC WINPROC_AllocProc( WNDPROC func, WINDOWPROCTYPE type );
extern WNDPROC WINPROC_GetProc( WNDPROC proc, BOOL unicode );
extern WNDPROC WINPROC_AllocProc( WNDPROC func, BOOL unicode );
extern WINDOWPROCTYPE WINPROC_GetProcType( WNDPROC proc );
extern INT WINPROC_MapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM *pwparam,

View File

@ -1357,7 +1357,7 @@ BOOL16 WINAPI GetClassInfoEx16( HINSTANCE16 hInst16, SEGPTR name, WNDCLASSEX16 *
if (ret)
{
WNDPROC proc = WINPROC_AllocProc( wc32.lpfnWndProc, WIN_PROC_32A );
WNDPROC proc = WINPROC_AllocProc( wc32.lpfnWndProc, FALSE );
wc->lpfnWndProc = WINPROC_GetProc16( proc );
wc->style = wc32.style;
wc->cbClsExtra = wc32.cbClsExtra;