Commit 0667292e authored by Alexandre Julliard's avatar Alexandre Julliard

user: Support storing multiple winprocs in a single winproc handle.

Allows to remove special cases for window classes being Ascii and Unicode at the same time.
parent 2a809c19
...@@ -48,8 +48,7 @@ typedef struct tagCLASS ...@@ -48,8 +48,7 @@ typedef struct tagCLASS
struct list entry; /* Entry in class list */ struct list entry; /* Entry in class list */
UINT style; /* Class style */ UINT style; /* Class style */
BOOL local; /* Local class? */ BOOL local; /* Local class? */
WNDPROC winprocA; /* Window procedure (ASCII) */ WNDPROC winproc; /* Window procedure */
WNDPROC winprocW; /* Window procedure (Unicode) */
INT cbClsExtra; /* Class extra bytes */ INT cbClsExtra; /* Class extra bytes */
INT cbWndExtra; /* Window extra bytes */ INT cbWndExtra; /* Window extra bytes */
LPWSTR menuName; /* Default menu name (Unicode followed by ASCII) */ LPWSTR menuName; /* Default menu name (Unicode followed by ASCII) */
...@@ -144,49 +143,6 @@ static BOOL set_server_info( HWND hwnd, INT offset, LONG newval ) ...@@ -144,49 +143,6 @@ static BOOL set_server_info( HWND hwnd, INT offset, LONG newval )
/*********************************************************************** /***********************************************************************
* CLASS_GetProc
*
* Get the class winproc for a given proc type
*/
static WNDPROC CLASS_GetProc( CLASS *classPtr, BOOL unicode )
{
WNDPROC proc = classPtr->winprocA;
if (classPtr->winprocW)
{
/* 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 || unicode) proc = classPtr->winprocW;
}
return WINPROC_GetProc( proc, unicode );
}
/***********************************************************************
* CLASS_SetProc
*
* Set the class winproc for a given proc type.
* Returns the previous window proc.
*/
static void CLASS_SetProc( CLASS *classPtr, WNDPROC newproc, BOOL unicode )
{
WNDPROC proc = WINPROC_AllocProc( newproc, unicode );
if (WINPROC_IsUnicode( proc, unicode ))
{
classPtr->winprocA = 0;
classPtr->winprocW = proc;
}
else
{
classPtr->winprocA = proc;
classPtr->winprocW = 0;
}
}
/***********************************************************************
* CLASS_GetMenuNameA * CLASS_GetMenuNameA
* *
* Get the menu name as a ASCII string. * Get the menu name as a ASCII string.
...@@ -417,9 +373,7 @@ static CLASS *register_builtin( const struct builtin_class_descr *descr ) ...@@ -417,9 +373,7 @@ static CLASS *register_builtin( const struct builtin_class_descr *descr )
classPtr->hCursor = LoadCursorA( 0, (LPSTR)descr->cursor ); classPtr->hCursor = LoadCursorA( 0, (LPSTR)descr->cursor );
classPtr->hbrBackground = descr->brush; classPtr->hbrBackground = descr->brush;
classPtr->winproc = WINPROC_AllocProc( descr->procA, descr->procW );
if (descr->procA) classPtr->winprocA = WINPROC_AllocProc( descr->procA, FALSE );
if (descr->procW) classPtr->winprocW = WINPROC_AllocProc( descr->procW, TRUE );
release_class_ptr( classPtr ); release_class_ptr( classPtr );
return classPtr; return classPtr;
} }
...@@ -466,16 +420,9 @@ void CLASS_RegisterBuiltinClasses(void) ...@@ -466,16 +420,9 @@ void CLASS_RegisterBuiltinClasses(void)
*/ */
void CLASS_AddWindow( CLASS *class, WND *win, BOOL unicode ) void CLASS_AddWindow( CLASS *class, WND *win, BOOL unicode )
{ {
if (unicode)
{
if (!(win->winproc = class->winprocW)) win->winproc = class->winprocA;
}
else
{
if (!(win->winproc = class->winprocA)) win->winproc = class->winprocW;
}
win->class = class; win->class = class;
win->clsStyle = class->style; win->clsStyle = class->style;
win->winproc = class->winproc;
if (WINPROC_IsUnicode( win->winproc, unicode )) win->flags |= WIN_ISUNICODE; if (WINPROC_IsUnicode( win->winproc, unicode )) win->flags |= WIN_ISUNICODE;
} }
...@@ -565,7 +512,7 @@ ATOM WINAPI RegisterClassExA( const WNDCLASSEXA* wc ) ...@@ -565,7 +512,7 @@ ATOM WINAPI RegisterClassExA( const WNDCLASSEXA* wc )
classPtr->hIconSm = wc->hIconSm; classPtr->hIconSm = wc->hIconSm;
classPtr->hCursor = wc->hCursor; classPtr->hCursor = wc->hCursor;
classPtr->hbrBackground = wc->hbrBackground; classPtr->hbrBackground = wc->hbrBackground;
classPtr->winprocA = WINPROC_AllocProc( wc->lpfnWndProc, FALSE ); classPtr->winproc = WINPROC_AllocProc( wc->lpfnWndProc, NULL );
CLASS_SetMenuNameA( classPtr, wc->lpszMenuName ); CLASS_SetMenuNameA( classPtr, wc->lpszMenuName );
release_class_ptr( classPtr ); release_class_ptr( classPtr );
return atom; return atom;
...@@ -603,7 +550,7 @@ ATOM WINAPI RegisterClassExW( const WNDCLASSEXW* wc ) ...@@ -603,7 +550,7 @@ ATOM WINAPI RegisterClassExW( const WNDCLASSEXW* wc )
classPtr->hIconSm = wc->hIconSm; classPtr->hIconSm = wc->hIconSm;
classPtr->hCursor = wc->hCursor; classPtr->hCursor = wc->hCursor;
classPtr->hbrBackground = wc->hbrBackground; classPtr->hbrBackground = wc->hbrBackground;
classPtr->winprocW = WINPROC_AllocProc( wc->lpfnWndProc, TRUE ); classPtr->winproc = WINPROC_AllocProc( NULL, wc->lpfnWndProc );
CLASS_SetMenuNameW( classPtr, wc->lpszMenuName ); CLASS_SetMenuNameW( classPtr, wc->lpszMenuName );
release_class_ptr( classPtr ); release_class_ptr( classPtr );
return atom; return atom;
...@@ -782,7 +729,7 @@ DWORD WINAPI GetClassLongW( HWND hwnd, INT offset ) ...@@ -782,7 +729,7 @@ DWORD WINAPI GetClassLongW( HWND hwnd, INT offset )
retvalue = (DWORD)class->hInstance; retvalue = (DWORD)class->hInstance;
break; break;
case GCLP_WNDPROC: case GCLP_WNDPROC:
retvalue = (DWORD)CLASS_GetProc( class, TRUE ); retvalue = (DWORD)WINPROC_GetProc( class->winproc, TRUE );
break; break;
case GCLP_MENUNAME: case GCLP_MENUNAME:
retvalue = (DWORD)CLASS_GetMenuNameW( class ); retvalue = (DWORD)CLASS_GetMenuNameW( class );
...@@ -822,7 +769,7 @@ DWORD WINAPI GetClassLongA( HWND hwnd, INT offset ) ...@@ -822,7 +769,7 @@ DWORD WINAPI GetClassLongA( HWND hwnd, INT offset )
} }
if (offset == GCLP_WNDPROC) if (offset == GCLP_WNDPROC)
retvalue = (DWORD)CLASS_GetProc( class, FALSE ); retvalue = (DWORD)WINPROC_GetProc( class->winproc, FALSE );
else /* GCL_MENUNAME */ else /* GCL_MENUNAME */
retvalue = (DWORD)CLASS_GetMenuNameA( class ); retvalue = (DWORD)CLASS_GetMenuNameA( class );
...@@ -893,8 +840,8 @@ DWORD WINAPI SetClassLongW( HWND hwnd, INT offset, LONG newval ) ...@@ -893,8 +840,8 @@ DWORD WINAPI SetClassLongW( HWND hwnd, INT offset, LONG newval )
retval = 0; /* Old value is now meaningless anyway */ retval = 0; /* Old value is now meaningless anyway */
break; break;
case GCLP_WNDPROC: case GCLP_WNDPROC:
retval = (DWORD)CLASS_GetProc( class, TRUE ); retval = (DWORD)WINPROC_GetProc( class->winproc, TRUE );
CLASS_SetProc( class, (WNDPROC)newval, TRUE ); class->winproc = WINPROC_AllocProc( NULL, (WNDPROC)newval );
break; break;
case GCLP_HBRBACKGROUND: case GCLP_HBRBACKGROUND:
retval = (DWORD)class->hbrBackground; retval = (DWORD)class->hbrBackground;
...@@ -961,8 +908,8 @@ DWORD WINAPI SetClassLongA( HWND hwnd, INT offset, LONG newval ) ...@@ -961,8 +908,8 @@ DWORD WINAPI SetClassLongA( HWND hwnd, INT offset, LONG newval )
if (offset == GCLP_WNDPROC) if (offset == GCLP_WNDPROC)
{ {
retval = (DWORD)CLASS_GetProc( class, FALSE ); retval = (DWORD)WINPROC_GetProc( class->winproc, FALSE );
CLASS_SetProc( class, (WNDPROC)newval, FALSE ); class->winproc = WINPROC_AllocProc( (WNDPROC)newval, NULL );
} }
else /* GCL_MENUNAME */ else /* GCL_MENUNAME */
{ {
...@@ -1084,7 +1031,7 @@ BOOL WINAPI GetClassInfoExA( HINSTANCE hInstance, LPCSTR name, WNDCLASSEXA *wc ) ...@@ -1084,7 +1031,7 @@ BOOL WINAPI GetClassInfoExA( HINSTANCE hInstance, LPCSTR name, WNDCLASSEXA *wc )
return FALSE; return FALSE;
} }
wc->style = classPtr->style; wc->style = classPtr->style;
wc->lpfnWndProc = (WNDPROC)CLASS_GetProc( classPtr, FALSE ); wc->lpfnWndProc = WINPROC_GetProc( classPtr->winproc, FALSE );
wc->cbClsExtra = classPtr->cbClsExtra; wc->cbClsExtra = classPtr->cbClsExtra;
wc->cbWndExtra = classPtr->cbWndExtra; wc->cbWndExtra = classPtr->cbWndExtra;
wc->hInstance = (hInstance == user32_module) ? 0 : hInstance; wc->hInstance = (hInstance == user32_module) ? 0 : hInstance;
...@@ -1119,7 +1066,7 @@ BOOL WINAPI GetClassInfoExW( HINSTANCE hInstance, LPCWSTR name, WNDCLASSEXW *wc ...@@ -1119,7 +1066,7 @@ BOOL WINAPI GetClassInfoExW( HINSTANCE hInstance, LPCWSTR name, WNDCLASSEXW *wc
return FALSE; return FALSE;
} }
wc->style = classPtr->style; wc->style = classPtr->style;
wc->lpfnWndProc = (WNDPROC)CLASS_GetProc( classPtr, TRUE ); wc->lpfnWndProc = WINPROC_GetProc( classPtr->winproc, TRUE );
wc->cbClsExtra = classPtr->cbClsExtra; wc->cbClsExtra = classPtr->cbClsExtra;
wc->cbWndExtra = classPtr->cbWndExtra; wc->cbWndExtra = classPtr->cbWndExtra;
wc->hInstance = (hInstance == user32_module) ? 0 : hInstance; wc->hInstance = (hInstance == user32_module) ? 0 : hInstance;
......
...@@ -3338,7 +3338,7 @@ UINT_PTR WINAPI SetTimer( HWND hwnd, UINT_PTR id, UINT timeout, TIMERPROC proc ) ...@@ -3338,7 +3338,7 @@ UINT_PTR WINAPI SetTimer( HWND hwnd, UINT_PTR id, UINT timeout, TIMERPROC proc )
UINT_PTR ret; UINT_PTR ret;
WNDPROC winproc = 0; WNDPROC winproc = 0;
if (proc) winproc = WINPROC_AllocProc( (WNDPROC)proc, FALSE ); if (proc) winproc = WINPROC_AllocProc( (WNDPROC)proc, NULL );
SERVER_START_REQ( set_win_timer ) SERVER_START_REQ( set_win_timer )
{ {
...@@ -3369,7 +3369,7 @@ UINT_PTR WINAPI SetSystemTimer( HWND hwnd, UINT_PTR id, UINT timeout, TIMERPROC ...@@ -3369,7 +3369,7 @@ UINT_PTR WINAPI SetSystemTimer( HWND hwnd, UINT_PTR id, UINT timeout, TIMERPROC
UINT_PTR ret; UINT_PTR ret;
WNDPROC winproc = 0; WNDPROC winproc = 0;
if (proc) winproc = WINPROC_AllocProc( (WNDPROC)proc, FALSE ); if (proc) winproc = WINPROC_AllocProc( (WNDPROC)proc, NULL );
SERVER_START_REQ( set_win_timer ) SERVER_START_REQ( set_win_timer )
{ {
......
...@@ -1987,7 +1987,8 @@ static LONG_PTR WIN_SetWindowLong( HWND hwnd, INT offset, LONG_PTR newval, BOOL ...@@ -1987,7 +1987,8 @@ static LONG_PTR WIN_SetWindowLong( HWND hwnd, INT offset, LONG_PTR newval, BOOL
{ {
UINT old_flags = wndPtr->flags; UINT old_flags = wndPtr->flags;
retval = (ULONG_PTR)WINPROC_GetProc( wndPtr->winproc, unicode ); retval = (ULONG_PTR)WINPROC_GetProc( wndPtr->winproc, unicode );
wndPtr->winproc = WINPROC_AllocProc( (WNDPROC)newval, unicode ); if (unicode) wndPtr->winproc = WINPROC_AllocProc( NULL, (WNDPROC)newval );
else wndPtr->winproc = WINPROC_AllocProc( (WNDPROC)newval, NULL );
if (WINPROC_IsUnicode( wndPtr->winproc, unicode )) wndPtr->flags |= WIN_ISUNICODE; if (WINPROC_IsUnicode( wndPtr->winproc, unicode )) wndPtr->flags |= WIN_ISUNICODE;
else wndPtr->flags &= ~WIN_ISUNICODE; else wndPtr->flags &= ~WIN_ISUNICODE;
if (!((old_flags ^ wndPtr->flags) & WIN_ISUNICODE)) if (!((old_flags ^ wndPtr->flags) & WIN_ISUNICODE))
...@@ -2007,7 +2008,8 @@ static LONG_PTR WIN_SetWindowLong( HWND hwnd, INT offset, LONG_PTR newval, BOOL ...@@ -2007,7 +2008,8 @@ static LONG_PTR WIN_SetWindowLong( HWND hwnd, INT offset, LONG_PTR newval, BOOL
{ {
WNDPROC *ptr = (WNDPROC *)((char *)wndPtr->wExtra + DWLP_DLGPROC); WNDPROC *ptr = (WNDPROC *)((char *)wndPtr->wExtra + DWLP_DLGPROC);
retval = (ULONG_PTR)WINPROC_GetProc( *ptr, unicode ); retval = (ULONG_PTR)WINPROC_GetProc( *ptr, unicode );
*ptr = WINPROC_AllocProc( (WNDPROC)newval, unicode ); if (unicode) *ptr = WINPROC_AllocProc( NULL, (WNDPROC)newval );
else *ptr = WINPROC_AllocProc( (WNDPROC)newval, NULL );
WIN_ReleasePtr( wndPtr ); WIN_ReleasePtr( wndPtr );
return retval; return retval;
} }
......
...@@ -47,7 +47,7 @@ struct tagWINDOWPROC; ...@@ -47,7 +47,7 @@ struct tagWINDOWPROC;
extern WNDPROC16 WINPROC_GetProc16( WNDPROC proc, BOOL unicode ); extern WNDPROC16 WINPROC_GetProc16( WNDPROC proc, BOOL unicode );
extern WNDPROC WINPROC_AllocProc16( WNDPROC16 func ); extern WNDPROC WINPROC_AllocProc16( WNDPROC16 func );
extern WNDPROC WINPROC_GetProc( WNDPROC proc, BOOL unicode ); extern WNDPROC WINPROC_GetProc( WNDPROC proc, BOOL unicode );
extern WNDPROC WINPROC_AllocProc( WNDPROC func, BOOL unicode ); extern WNDPROC WINPROC_AllocProc( WNDPROC funcA, WNDPROC funcW );
extern BOOL WINPROC_IsUnicode( WNDPROC proc, BOOL def_val ); extern BOOL WINPROC_IsUnicode( WNDPROC proc, BOOL def_val );
extern INT WINPROC_MapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM *pwparam, extern INT WINPROC_MapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM *pwparam,
......
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