From: Jacek Caban jacek@codeweavers.com
We will eventually want to make GetWindowThreadProcessId fast (probably based on shared handle table) instead of calling win32u. --- dlls/user32/win.c | 47 +++----------------------------------------- dlls/win32u/window.c | 10 ++++++++++ include/ntuser.h | 4 ++++ 3 files changed, 17 insertions(+), 44 deletions(-)
diff --git a/dlls/user32/win.c b/dlls/user32/win.c index 8b5033ad821..b149a202433 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -153,13 +153,7 @@ void WIN_ReleasePtr( WND *ptr ) */ HWND WIN_IsCurrentProcess( HWND hwnd ) { - WND *ptr; - HWND ret; - - if (!(ptr = WIN_GetPtr( hwnd )) || ptr == WND_OTHER_PROCESS || ptr == WND_DESKTOP) return 0; - ret = ptr->obj.handle; - WIN_ReleasePtr( ptr ); - return ret; + return UlongToHandle( NtUserCallHwnd( hwnd, NtUserIsCurrehtProcessWindow )); }
@@ -170,13 +164,7 @@ HWND WIN_IsCurrentProcess( HWND hwnd ) */ HWND WIN_IsCurrentThread( HWND hwnd ) { - WND *ptr; - HWND ret = 0; - - if (!(ptr = WIN_GetPtr( hwnd )) || ptr == WND_OTHER_PROCESS || ptr == WND_DESKTOP) return 0; - if (ptr->tid == GetCurrentThreadId()) ret = ptr->obj.handle; - WIN_ReleasePtr( ptr ); - return ret; + return UlongToHandle( NtUserCallHwnd( hwnd, NtUserIsCurrehtThreadWindow )); }
@@ -205,36 +193,7 @@ UINT win_set_flags( HWND hwnd, UINT set_mask, UINT clear_mask ) */ HWND WIN_GetFullHandle( HWND hwnd ) { - WND *ptr; - - if (!hwnd || (ULONG_PTR)hwnd >> 16) return hwnd; - if (LOWORD(hwnd) <= 1 || LOWORD(hwnd) == 0xffff) return hwnd; - /* do sign extension for -2 and -3 */ - if (LOWORD(hwnd) >= (WORD)-3) return (HWND)(LONG_PTR)(INT16)LOWORD(hwnd); - - if (!(ptr = WIN_GetPtr( hwnd ))) return hwnd; - - if (ptr == WND_DESKTOP) - { - if (LOWORD(hwnd) == LOWORD(GetDesktopWindow())) return GetDesktopWindow(); - else return get_hwnd_message_parent(); - } - - if (ptr != WND_OTHER_PROCESS) - { - hwnd = ptr->obj.handle; - WIN_ReleasePtr( ptr ); - } - else /* may belong to another process */ - { - SERVER_START_REQ( get_window_info ) - { - req->handle = wine_server_user_handle( hwnd ); - if (!wine_server_call_err( req )) hwnd = wine_server_ptr_handle( reply->full_handle ); - } - SERVER_END_REQ; - } - return hwnd; + return UlongToHandle( NtUserCallHwnd( hwnd, NtUserGetFullWindowHandle )); }
diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index a2ef9e72a06..1b72635e99c 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -5408,6 +5408,16 @@ ULONG_PTR WINAPI NtUserCallHwnd( HWND hwnd, DWORD code ) case NtUserCallHwnd_SetForegroundWindow: return set_foreground_window( hwnd, FALSE );
+ /* temporary exports */ + case NtUserGetFullWindowHandle: + return HandleToUlong( get_full_window_handle( hwnd )); + + case NtUserIsCurrehtProcessWindow: + return HandleToUlong( is_current_process_window( hwnd )); + + case NtUserIsCurrehtThreadWindow: + return HandleToUlong( is_current_thread_window( hwnd )); + default: FIXME( "invalid code %u\n", code ); return 0; diff --git a/include/ntuser.h b/include/ntuser.h index 59916d25d6d..dc5f5ee501a 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -1112,6 +1112,10 @@ enum NtUserCallHwnd_IsWindowUnicode, NtUserCallHwnd_IsWindowVisible, NtUserCallHwnd_SetForegroundWindow, + /* temporary exports */ + NtUserGetFullWindowHandle, + NtUserIsCurrehtProcessWindow, + NtUserIsCurrehtThreadWindow, };
static inline UINT NtUserArrangeIconicWindows( HWND parent )
From: Jacek Caban jacek@codeweavers.com
--- dlls/user32/win.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/dlls/user32/win.c b/dlls/user32/win.c index b149a202433..23263166eeb 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -1413,20 +1413,17 @@ BOOL WINAPI DragDetect( HWND hwnd, POINT pt ) */ UINT WINAPI GetWindowModuleFileNameA( HWND hwnd, LPSTR module, UINT size ) { - WND *win; HINSTANCE hinst;
TRACE( "%p, %p, %u\n", hwnd, module, size );
- win = WIN_GetPtr( hwnd ); - if (!win || win == WND_OTHER_PROCESS || win == WND_DESKTOP) + if (!WIN_IsCurrentProcess( hwnd )) { SetLastError( ERROR_INVALID_WINDOW_HANDLE ); return 0; } - hinst = win->hInstance; - WIN_ReleasePtr( win );
+ hinst = (HINSTANCE)GetWindowLongPtrA( hwnd, GWLP_HINSTANCE ); return GetModuleFileNameA( hinst, module, size ); }
@@ -1435,20 +1432,17 @@ UINT WINAPI GetWindowModuleFileNameA( HWND hwnd, LPSTR module, UINT size ) */ UINT WINAPI GetWindowModuleFileNameW( HWND hwnd, LPWSTR module, UINT size ) { - WND *win; HINSTANCE hinst;
TRACE( "%p, %p, %u\n", hwnd, module, size );
- win = WIN_GetPtr( hwnd ); - if (!win || win == WND_OTHER_PROCESS || win == WND_DESKTOP) + if (!WIN_IsCurrentProcess( hwnd )) { SetLastError( ERROR_INVALID_WINDOW_HANDLE ); return 0; } - hinst = win->hInstance; - WIN_ReleasePtr( win );
+ hinst = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE ); return GetModuleFileNameW( hinst, module, size ); }
From: Jacek Caban jacek@codeweavers.com
And use it instead of accessing window object from user32. --- dlls/user32/defdlg.c | 22 ++++------------------ dlls/win32u/window.c | 32 ++++++++++++++++++++++++++++++++ include/ntuser.h | 12 ++++++++++++ 3 files changed, 48 insertions(+), 18 deletions(-)
diff --git a/dlls/user32/defdlg.c b/dlls/user32/defdlg.c index e330cf6603d..1e1ff71b87b 100644 --- a/dlls/user32/defdlg.c +++ b/dlls/user32/defdlg.c @@ -237,15 +237,11 @@ static LRESULT DEFDLG_Proc( HWND hwnd, UINT msg, WPARAM wParam, case WM_NCDESTROY: if (dlgInfo) { - WND *wndPtr; - if (dlgInfo->hUserFont) DeleteObject( dlgInfo->hUserFont ); if (dlgInfo->hMenu) NtUserDestroyMenu( dlgInfo->hMenu ); HeapFree( GetProcessHeap(), 0, dlgInfo );
- wndPtr = WIN_GetPtr( hwnd ); - wndPtr->dlgInfo = NULL; - WIN_ReleasePtr( wndPtr ); + NtUserSetDialogInfo( hwnd, NULL ); } /* Window clean-up */ return DefWindowProcA( hwnd, msg, wParam, lParam ); @@ -323,22 +319,14 @@ static LRESULT DEFDLG_Proc( HWND hwnd, UINT msg, WPARAM wParam, */ DIALOGINFO *DIALOG_get_info( HWND hwnd, BOOL create ) { - WND* wndPtr; DIALOGINFO* dlgInfo;
- wndPtr = WIN_GetPtr( hwnd ); - if (!wndPtr || wndPtr == WND_OTHER_PROCESS || wndPtr == WND_DESKTOP) - { - SetLastError( ERROR_INVALID_WINDOW_HANDLE ); - return NULL; - } - - dlgInfo = wndPtr->dlgInfo; + dlgInfo = NtUserGetDialogInfo( hwnd );
if (!dlgInfo && create) { if (!(dlgInfo = HeapAlloc( GetProcessHeap(), 0, sizeof(*dlgInfo) ))) - goto out; + return NULL; dlgInfo->hwndFocus = 0; dlgInfo->hUserFont = 0; dlgInfo->hMenu = 0; @@ -346,11 +334,9 @@ DIALOGINFO *DIALOG_get_info( HWND hwnd, BOOL create ) dlgInfo->yBaseUnit = 0; dlgInfo->idResult = IDOK; dlgInfo->flags = 0; - wndPtr->dlgInfo = dlgInfo; + NtUserSetDialogInfo( hwnd, dlgInfo ); }
-out: - WIN_ReleasePtr( wndPtr ); return dlgInfo; }
diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 1b72635e99c..71e500abb0f 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -5359,6 +5359,32 @@ failed: return 0; }
+static void *get_dialog_info( HWND hwnd ) +{ + WND *win; + void *ret; + + if (!(win = get_win_ptr( hwnd )) || win == WND_OTHER_PROCESS || win == WND_DESKTOP) + { + SetLastError( ERROR_INVALID_WINDOW_HANDLE ); + return NULL; + } + + ret = win->dlgInfo; + release_win_ptr( win ); + return ret; +} + +static BOOL set_dialog_info( HWND hwnd, void *info ) +{ + WND *win; + + if (!(win = get_win_ptr( hwnd )) || win == WND_OTHER_PROCESS || win == WND_DESKTOP) return FALSE; + win->dlgInfo = info; + release_win_ptr( win ); + return TRUE; +} + /***************************************************************************** * NtUserCallHwnd (win32u.@) */ @@ -5381,6 +5407,9 @@ ULONG_PTR WINAPI NtUserCallHwnd( HWND hwnd, DWORD code ) case NtUserCallHwnd_GetParent: return HandleToUlong( get_parent( hwnd ));
+ case NtUserCallHwnd_GetDialogInfo: + return (ULONG_PTR)get_dialog_info( hwnd ); + case NtUserCallHwnd_GetWindowContextHelpId: return get_window_context_help_id( hwnd );
@@ -5510,6 +5539,9 @@ ULONG_PTR WINAPI NtUserCallHwndParam( HWND hwnd, DWORD_PTR param, DWORD code ) case NtUserCallHwndParam_ScreenToClient: return screen_to_client( hwnd, (POINT *)param );
+ case NtUserCallHwndParam_SetDialogInfo: + return set_dialog_info( hwnd, (void *)param ); + case NtUserCallHwndParam_SetWindowContextHelpId: return set_window_context_help_id( hwnd, param );
diff --git a/include/ntuser.h b/include/ntuser.h index dc5f5ee501a..9ba128bdbda 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -1101,6 +1101,7 @@ enum NtUserCallHwnd_ArrangeIconicWindows, NtUserCallHwnd_DrawMenuBar, NtUserCallHwnd_GetDefaultImeWindow, + NtUserCallHwnd_GetDialogInfo, NtUserCallHwnd_GetDpiForWindow, NtUserCallHwnd_GetParent, NtUserCallHwnd_GetWindowContextHelpId, @@ -1138,6 +1139,11 @@ static inline HWND NtUserGetDefaultImeWindow( HWND hwnd ) return UlongToHandle( NtUserCallHwnd( hwnd, NtUserCallHwnd_GetDefaultImeWindow )); }
+static inline void *NtUserGetDialogInfo( HWND hwnd ) +{ + return (void *)NtUserCallHwnd( hwnd, NtUserCallHwnd_GetDialogInfo ); +} + static inline UINT NtUserGetDpiForWindow( HWND hwnd ) { return NtUserCallHwnd( hwnd, NtUserCallHwnd_GetDpiForWindow ); @@ -1216,6 +1222,7 @@ enum NtUserCallHwndParam_MirrorRgn, NtUserCallHwndParam_MonitorFromWindow, NtUserCallHwndParam_ScreenToClient, + NtUserCallHwndParam_SetDialogInfo, NtUserCallHwndParam_SetWindowContextHelpId, NtUserCallHwndParam_SetWindowPixelFormat, NtUserCallHwndParam_ShowOwnedPopups, @@ -1365,6 +1372,11 @@ static inline BOOL NtUserScreenToClient( HWND hwnd, POINT *pt ) return NtUserCallHwndParam( hwnd, (UINT_PTR)pt, NtUserCallHwndParam_ScreenToClient ); }
+static inline void NtUserSetDialogInfo( HWND hwnd, void *info ) +{ + NtUserCallHwndParam( hwnd, (UINT_PTR)info, NtUserCallHwndParam_SetDialogInfo ); +} + static inline BOOL NtUserSetWindowContextHelpId( HWND hwnd, DWORD id ) { return NtUserCallHwndParam( hwnd, id, NtUserCallHwndParam_SetWindowContextHelpId );
From: Jacek Caban jacek@codeweavers.com
And use it in user32 instead of DEFDLG_GetDlgProc. --- dlls/user32/defdlg.c | 34 ++++------------------------------ dlls/user32/dialog.c | 23 ++++------------------- dlls/user32/user_private.h | 4 ++-- dlls/user32/winproc.c | 36 ++++++++++++++++-------------------- dlls/win32u/class.c | 25 +++++++++++++++++++++++++ dlls/win32u/ntuser_private.h | 1 + dlls/win32u/window.c | 3 +++ include/ntuser.h | 13 +++++++++++++ 8 files changed, 68 insertions(+), 71 deletions(-)
diff --git a/dlls/user32/defdlg.c b/dlls/user32/defdlg.c index 1e1ff71b87b..238951aa21c 100644 --- a/dlls/user32/defdlg.c +++ b/dlls/user32/defdlg.c @@ -29,27 +29,6 @@ #include "user_private.h" #include "wine/debug.h"
-WINE_DEFAULT_DEBUG_CHANNEL(dialog); - - -/*********************************************************************** - * DEFDLG_GetDlgProc - */ -static DLGPROC DEFDLG_GetDlgProc( HWND hwnd ) -{ - DLGPROC ret; - WND *wndPtr = WIN_GetPtr( hwnd ); - - if (!wndPtr) return 0; - if (wndPtr == WND_OTHER_PROCESS) - { - ERR( "cannot get dlg proc %p from other process\n", hwnd ); - return 0; - } - ret = *(DLGPROC *)((char *)wndPtr->wExtra + DWLP_DLGPROC); - WIN_ReleasePtr( wndPtr ); - return ret; -}
/*********************************************************************** * DEFDLG_SetFocus @@ -343,16 +322,14 @@ DIALOGINFO *DIALOG_get_info( HWND hwnd, BOOL create ) static LRESULT USER_DefDlgProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { DIALOGINFO *dlgInfo; - DLGPROC dlgproc; - LRESULT result = 0; + LRESULT result;
/* Perform DIALOGINFO initialization if not done */ if(!(dlgInfo = DIALOG_get_info( hwnd, TRUE ))) return 0;
SetWindowLongPtrW( hwnd, DWLP_MSGRESULT, 0 );
- if ((dlgproc = DEFDLG_GetDlgProc( hwnd ))) /* Call dialog procedure */ - result = WINPROC_CallDlgProcA( dlgproc, hwnd, msg, wParam, lParam ); + result = WINPROC_CallDlgProcA( hwnd, msg, wParam, lParam );
if (!result && IsWindow(hwnd)) { @@ -397,16 +374,13 @@ static LRESULT USER_DefDlgProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar static LRESULT USER_DefDlgProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { DIALOGINFO *dlgInfo; - DLGPROC dlgproc; - LRESULT result = 0; + LRESULT result;
/* Perform DIALOGINFO initialization if not done */ if(!(dlgInfo = DIALOG_get_info( hwnd, TRUE ))) return 0;
SetWindowLongPtrW( hwnd, DWLP_MSGRESULT, 0 ); - - if ((dlgproc = DEFDLG_GetDlgProc( hwnd ))) /* Call dialog procedure */ - result = WINPROC_CallDlgProcW( dlgproc, hwnd, msg, wParam, lParam ); + result = WINPROC_CallDlgProcW( hwnd, msg, wParam, lParam );
if (!result && IsWindow(hwnd)) { diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c index b804de90df2..5c74de65ac0 100644 --- a/dlls/user32/dialog.c +++ b/dlls/user32/dialog.c @@ -1038,19 +1038,10 @@ static HWND DIALOG_FindMsgDestination( HWND hwndDlg ) { while (GetWindowLongA(hwndDlg, GWL_STYLE) & DS_CONTROL) { - WND *pParent; HWND hParent = GetParent(hwndDlg); - if (!hParent) break;
- pParent = WIN_GetPtr(hParent); - if (!pParent || pParent == WND_OTHER_PROCESS || pParent == WND_DESKTOP) break; - - if (!pParent->dlgInfo) - { - WIN_ReleasePtr(pParent); - break; - } - WIN_ReleasePtr(pParent); + if (!hParent || !WIN_IsCurrentProcess( hParent )) break; + if (!NtUserGetDialogInfo( hParent )) break;
hwndDlg = hParent; } @@ -1183,14 +1174,8 @@ BOOL WINAPI IsDialogMessageW( HWND hwndDlg, LPMSG msg ) case VK_TAB: if (!(dlgCode & DLGC_WANTTAB)) { - BOOL fIsDialog = TRUE; - WND *pWnd = WIN_GetPtr( hwndDlg ); - - if (pWnd && pWnd != WND_OTHER_PROCESS) - { - fIsDialog = (pWnd->dlgInfo != NULL); - WIN_ReleasePtr(pWnd); - } + BOOL fIsDialog = !WIN_IsCurrentProcess( hwndDlg ) || + NtUserGetDialogInfo( hwndDlg ) != NULL;
/* I am not sure under which circumstances the TAB is handled * each way. All I do know is that it does not always simply diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h index 81c3c5021ab..3e2cebd99ae 100644 --- a/dlls/user32/user_private.h +++ b/dlls/user32/user_private.h @@ -86,8 +86,8 @@ extern LRESULT WINPROC_CallProcAtoW( winproc_callback_t callback, HWND hwnd, UIN WPARAM wParam, LPARAM lParam, LRESULT *result, void *arg, enum wm_char_mapping mapping ) DECLSPEC_HIDDEN;
-extern INT_PTR WINPROC_CallDlgProcA( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN; -extern INT_PTR WINPROC_CallDlgProcW( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN; +extern INT_PTR WINPROC_CallDlgProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN; +extern INT_PTR WINPROC_CallDlgProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN; extern void winproc_init(void) DECLSPEC_HIDDEN; extern void dispatch_win_proc_params( struct win_proc_params *params ) DECLSPEC_HIDDEN; extern void get_winproc_params( struct win_proc_params *params ) DECLSPEC_HIDDEN; diff --git a/dlls/user32/winproc.c b/dlls/user32/winproc.c index 5fc134c6718..e71b222ce79 100644 --- a/dlls/user32/winproc.c +++ b/dlls/user32/winproc.c @@ -1361,50 +1361,46 @@ LRESULT WINAPI CallWindowProcW( WNDPROC func, HWND hwnd, UINT msg, WPARAM wParam /********************************************************************** * WINPROC_CallDlgProcA */ -INT_PTR WINPROC_CallDlgProcA( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) +INT_PTR WINPROC_CallDlgProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { - WINDOWPROC *proc; LRESULT result; - INT_PTR ret; + DLGPROC func;
- if (!func) return 0; + if (!(func = NtUserGetDialogProc( hwnd, DLGPROC_ANSI ))) return 0;
- if (!(proc = handle_to_proc( (WNDPROC)func ))) - ret = call_dialog_proc( hwnd, msg, wParam, lParam, &result, func ); - else if (proc == WINPROC_PROC16) + if (func == WINPROC_PROC16) { + INT_PTR ret; + if (!(func = NtUserGetDialogProc( hwnd, DLGPROC_WIN16 ))) return 0; ret = wow_handlers.call_dialog_proc( hwnd, msg, wParam, lParam, &result, func ); SetWindowLongPtrW( hwnd, DWLP_MSGRESULT, result ); + return ret; } - else - ret = call_dialog_proc( hwnd, msg, wParam, lParam, &result, proc->procW ? proc->procW : proc->procA );
- return ret; + return call_dialog_proc( hwnd, msg, wParam, lParam, &result, func ); }
/********************************************************************** * WINPROC_CallDlgProcW */ -INT_PTR WINPROC_CallDlgProcW( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) +INT_PTR WINPROC_CallDlgProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { - WINDOWPROC *proc; LRESULT result; - INT_PTR ret; + DLGPROC func;
- if (!func) return 0; + if (!(func = NtUserGetDialogProc( hwnd, DLGPROC_UNICODE ))) return 0;
- if (!(proc = handle_to_proc( (WNDPROC)func ))) - ret = call_dialog_proc( hwnd, msg, wParam, lParam, &result, func ); - else if (proc == WINPROC_PROC16) + if (func == WINPROC_PROC16) { + INT_PTR ret; + if (!(func = NtUserGetDialogProc( hwnd, DLGPROC_WIN16 ))) return 0; ret = WINPROC_CallProcWtoA( wow_handlers.call_dialog_proc, hwnd, msg, wParam, lParam, &result, func ); SetWindowLongPtrW( hwnd, DWLP_MSGRESULT, result ); + return ret; } - else - ret = call_dialog_proc( hwnd, msg, wParam, lParam, &result, proc->procW ? proc->procW : proc->procA );
- return ret; + return call_dialog_proc( hwnd, msg, wParam, lParam, &result, func ); }
diff --git a/dlls/win32u/class.c b/dlls/win32u/class.c index 6a3f039bc3b..5fa5436436b 100644 --- a/dlls/win32u/class.c +++ b/dlls/win32u/class.c @@ -203,6 +203,31 @@ void get_winproc_params( struct win_proc_params *params ) } }
+DLGPROC get_dialog_proc( HWND hwnd, enum dialog_proc_type type ) +{ + WINDOWPROC *proc; + DLGPROC ret; + WND *win; + + if (!(win = get_win_ptr( hwnd ))) return NULL; + if (win == WND_OTHER_PROCESS || win == WND_DESKTOP) + { + ERR( "cannot get dlg proc %p from other process\n", hwnd ); + return 0; + } + ret = *(DLGPROC *)((char *)win->wExtra + DWLP_DLGPROC); + release_win_ptr( win ); + if (type == DLGPROC_WIN16 || !(proc = get_winproc_ptr( ret ))) return ret; + if (proc == WINPROC_PROC16) return WINPROC_PROC16; + + if (type == DLGPROC_ANSI) + ret = proc->procA ? proc->procA : proc->procW; + else + ret = proc->procW ? proc->procW : proc->procA; + + return ret; +} + /*********************************************************************** * NtUserInitializeClientPfnArrays (win32u.@) */ diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h index 313382505d4..ecb5ab82164 100644 --- a/dlls/win32u/ntuser_private.h +++ b/dlls/win32u/ntuser_private.h @@ -249,6 +249,7 @@ DWORD get_class_long( HWND hwnd, INT offset, BOOL ansi ) DECLSPEC_HIDDEN; WNDPROC get_class_winproc( struct tagCLASS *class ) DECLSPEC_HIDDEN; ULONG_PTR get_class_long_ptr( HWND hwnd, INT offset, BOOL ansi ) DECLSPEC_HIDDEN; WORD get_class_word( HWND hwnd, INT offset ) DECLSPEC_HIDDEN; +DLGPROC get_dialog_proc( HWND hwnd, enum dialog_proc_type type ) DECLSPEC_HIDDEN; ATOM get_int_atom_value( UNICODE_STRING *name ) DECLSPEC_HIDDEN; WNDPROC get_winproc( WNDPROC proc, BOOL ansi ) DECLSPEC_HIDDEN; void get_winproc_params( struct win_proc_params *params ) DECLSPEC_HIDDEN; diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 71e500abb0f..506af7530d3 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -5484,6 +5484,9 @@ ULONG_PTR WINAPI NtUserCallHwndParam( HWND hwnd, DWORD_PTR param, DWORD code ) case NtUserCallHwndParam_GetClientRect: return get_client_rect( hwnd, (RECT *)param );
+ case NtUserCallHwndParam_GetDialogProc: + return (ULONG_PTR)get_dialog_proc( hwnd, param ); + case NtUserCallHwndParam_GetScrollInfo: { struct get_scroll_info_params *params = (void *)param; diff --git a/include/ntuser.h b/include/ntuser.h index 9ba128bdbda..c223d1f2704 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -1206,6 +1206,7 @@ enum NtUserCallHwndParam_GetClassLongPtrW, NtUserCallHwndParam_GetClassWord, NtUserCallHwndParam_GetClientRect, + NtUserCallHwndParam_GetDialogProc, NtUserCallHwndParam_GetScrollInfo, NtUserCallHwndParam_GetWindowInfo, NtUserCallHwndParam_GetWindowLongA, @@ -1271,6 +1272,18 @@ static inline BOOL NtUserGetClientRect( HWND hwnd, RECT *rect ) return NtUserCallHwndParam( hwnd, (UINT_PTR)rect, NtUserCallHwndParam_GetClientRect ); }
+enum dialog_proc_type +{ + DLGPROC_ANSI, + DLGPROC_UNICODE, + DLGPROC_WIN16, +}; + +static inline DLGPROC NtUserGetDialogProc( HWND hwnd, enum dialog_proc_type type ) +{ + return (DLGPROC)NtUserCallHwndParam( hwnd, type, NtUserCallHwndParam_GetDialogProc ); +} + struct get_scroll_info_params { int bar;
From: Jacek Caban jacek@codeweavers.com
--- dlls/user32/user_main.c | 19 ------------------- dlls/user32/user_private.h | 3 --- dlls/user32/winproc.c | 26 -------------------------- dlls/win32u/class.c | 6 ++++++ dlls/win32u/ntuser_private.h | 12 ++---------- dlls/win32u/sysparams.c | 6 ------ include/ntuser.h | 2 -- 7 files changed, 8 insertions(+), 66 deletions(-)
diff --git a/dlls/user32/user_main.c b/dlls/user32/user_main.c index d3940d4a95c..91f2891f198 100644 --- a/dlls/user32/user_main.c +++ b/dlls/user32/user_main.c @@ -39,8 +39,6 @@ WINE_DECLARE_DEBUG_CHANNEL(message);
HMODULE user32_module = 0;
-static DWORD exiting_thread_id; - extern void WDML_NotifyThreadDetach(void);
/*********************************************************************** @@ -241,15 +239,6 @@ static BOOL process_attach(void) }
-/********************************************************************** - * USER_IsExitingThread - */ -BOOL USER_IsExitingThread( DWORD tid ) -{ - return (tid == exiting_thread_id); -} - - /********************************************************************** * thread_detach */ @@ -257,15 +246,12 @@ static void thread_detach(void) { struct user_thread_info *thread_info = get_user_thread_info();
- exiting_thread_id = GetCurrentThreadId(); NtUserCallNoParam( NtUserExitingThread );
WDML_NotifyThreadDetach();
NtUserCallNoParam( NtUserThreadDetach ); HeapFree( GetProcessHeap(), 0, thread_info->wmchar_data ); - - exiting_thread_id = 0; }
@@ -380,11 +366,6 @@ const char *SPY_GetMsgName( UINT msg, HWND hwnd ) return (const char *)NtUserCallHwndParam( hwnd, msg, NtUserSpyGetMsgName ); }
-const char *SPY_GetVKeyName( WPARAM wparam ) -{ - return (const char *)NtUserCallOneParam( wparam, NtUserSpyGetVKeyName ); -} - void SPY_EnterMessage( INT flag, HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { if (TRACE_ON(message)) NtUserMessageCall( hwnd, msg, wparam, lparam, 0, NtUserSpyEnter, flag ); diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h index 3e2cebd99ae..d4a296f4bb7 100644 --- a/dlls/user32/user_private.h +++ b/dlls/user32/user_private.h @@ -77,7 +77,6 @@ extern HPEN SYSCOLOR_GetPen( INT index ) DECLSPEC_HIDDEN; extern HBRUSH SYSCOLOR_Get55AABrush(void) DECLSPEC_HIDDEN; extern void SYSPARAMS_Init(void) DECLSPEC_HIDDEN; extern void USER_CheckNotLock(void) DECLSPEC_HIDDEN; -extern BOOL USER_IsExitingThread( DWORD tid ) DECLSPEC_HIDDEN;
typedef LRESULT (*winproc_callback_t)( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp, LRESULT *result, void *arg ); @@ -90,7 +89,6 @@ extern INT_PTR WINPROC_CallDlgProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM extern INT_PTR WINPROC_CallDlgProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN; extern void winproc_init(void) DECLSPEC_HIDDEN; extern void dispatch_win_proc_params( struct win_proc_params *params ) DECLSPEC_HIDDEN; -extern void get_winproc_params( struct win_proc_params *params ) DECLSPEC_HIDDEN;
extern ATOM get_class_info( HINSTANCE instance, const WCHAR *name, WNDCLASSEXW *info, UNICODE_STRING *name_str, BOOL ansi ) DECLSPEC_HIDDEN; @@ -107,7 +105,6 @@ BOOL WINAPI User32RegisterBuiltinClasses( const struct win_hook_params *params, /* message spy definitions */
extern const char *SPY_GetMsgName( UINT msg, HWND hWnd ) DECLSPEC_HIDDEN; -extern const char *SPY_GetVKeyName(WPARAM wParam) DECLSPEC_HIDDEN; extern void SPY_EnterMessage( INT iFlag, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN; extern void SPY_ExitMessage( INT iFlag, HWND hwnd, UINT msg, LRESULT lReturn, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN; diff --git a/dlls/user32/winproc.c b/dlls/user32/winproc.c index e71b222ce79..3b7927891b5 100644 --- a/dlls/user32/winproc.c +++ b/dlls/user32/winproc.c @@ -66,13 +66,6 @@ static inline void free_buffer( void *static_buffer, void *buffer ) if (buffer != static_buffer) HeapFree( GetProcessHeap(), 0, buffer ); }
-/* return the window proc for a given handle, or NULL for an invalid handle, - * or WINPROC_PROC16 for a handle to a 16-bit proc. */ -static inline WINDOWPROC *handle_to_proc( WNDPROC handle ) -{ - return (WINDOWPROC *)NtUserCallOneParam( HandleToUlong(handle), NtUserGetWinProcPtr ); -} - #ifdef __i386__ /* Some window procedures modify registers they shouldn't, or are not * properly declared stdcall; so we need a small assembly wrapper to @@ -1276,25 +1269,6 @@ BOOL WINAPI User32CallWindowProc( struct win_proc_params *params, ULONG size ) return TRUE; }
-void get_winproc_params( struct win_proc_params *params ) -{ - WINDOWPROC *proc = handle_to_proc( params->func ); - - if (!proc) - { - params->procW = params->procA = NULL; - } - else if (proc == WINPROC_PROC16) - { - params->procW = params->procA = WINPROC_PROC16; - } - else - { - params->procA = proc->procA; - params->procW = proc->procW; - } -} - BOOL WINAPI User32CallSendAsyncCallback( const struct send_async_params *params, ULONG size ) { params->callback( params->hwnd, params->msg, params->data, params->result ); diff --git a/dlls/win32u/class.c b/dlls/win32u/class.c index 5fa5436436b..eab65b72ef6 100644 --- a/dlls/win32u/class.c +++ b/dlls/win32u/class.c @@ -60,6 +60,12 @@ typedef struct tagCLASS struct client_menu_name menu_name; /* Default menu name */ } CLASS;
+typedef struct tagWINDOWPROC +{ + WNDPROC procA; /* ANSI window proc */ + WNDPROC procW; /* Unicode window proc */ +} WINDOWPROC; + static WINDOWPROC winproc_array[MAX_WINPROCS]; static UINT winproc_used = NB_BUILTIN_WINPROCS; static pthread_mutex_t winproc_lock = PTHREAD_MUTEX_INITIALIZER; diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h index ecb5ab82164..3ecd7424f77 100644 --- a/dlls/win32u/ntuser_private.h +++ b/dlls/win32u/ntuser_private.h @@ -106,8 +106,8 @@ typedef struct tagWND #define WIN_CHILDREN_MOVED 0x0040 /* children may have moved, ignore stored positions */ #define WIN_HAS_IME_WIN 0x0080 /* the window has been registered with imm32 */
-#define WND_OTHER_PROCESS ((WND *)1) /* returned by WIN_GetPtr on unknown window handles */ -#define WND_DESKTOP ((WND *)2) /* returned by WIN_GetPtr on the desktop window */ +#define WND_OTHER_PROCESS ((WND *)1) /* returned by get_win_ptr on unknown window handles */ +#define WND_DESKTOP ((WND *)2) /* returned by get_win_ptr on the desktop window */
/* check if hwnd is a broadcast magic handle */ static inline BOOL is_broadcast( HWND hwnd ) @@ -197,13 +197,6 @@ struct scroll_bar_win_data struct scroll_info info; };
-/* FIXME: make it private to class.c */ -typedef struct tagWINDOWPROC -{ - WNDPROC procA; /* ANSI window proc */ - WNDPROC procW; /* Unicode window proc */ -} WINDOWPROC; - #define WINPROC_HANDLE (~0u >> 16) #define BUILTIN_WINPROC(index) ((WNDPROC)(ULONG_PTR)((index) | (WINPROC_HANDLE << 16)))
@@ -243,7 +236,6 @@ extern void spy_exit_message( INT flag, HWND hwnd, UINT msg, /* class.c */ extern HINSTANCE user32_module DECLSPEC_HIDDEN; WNDPROC alloc_winproc( WNDPROC func, BOOL ansi ) DECLSPEC_HIDDEN; -WINDOWPROC *get_winproc_ptr( WNDPROC handle ) DECLSPEC_HIDDEN; BOOL is_winproc_unicode( WNDPROC proc, BOOL def_val ) DECLSPEC_HIDDEN; DWORD get_class_long( HWND hwnd, INT offset, BOOL ansi ) DECLSPEC_HIDDEN; WNDPROC get_class_winproc( struct tagCLASS *class ) DECLSPEC_HIDDEN; diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 3c1051b2d80..0a453f937c3 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -5031,9 +5031,6 @@ ULONG_PTR WINAPI NtUserCallOneParam( ULONG_PTR arg, ULONG code ) case NtUserGetDeskPattern: return get_entry( &entry_DESKPATTERN, 256, (WCHAR *)arg );
- case NtUserGetWinProcPtr: - return (UINT_PTR)get_winproc_ptr( UlongToHandle(arg) ); - case NtUserLock: switch( arg ) { @@ -5042,9 +5039,6 @@ ULONG_PTR WINAPI NtUserCallOneParam( ULONG_PTR arg, ULONG code ) default: user_check_not_lock(); return 0; }
- case NtUserSpyGetVKeyName: - return (UINT_PTR)debugstr_vkey_name( arg ); - default: FIXME( "invalid code %u\n", code ); return 0; diff --git a/include/ntuser.h b/include/ntuser.h index c223d1f2704..86e2d329eb9 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -922,9 +922,7 @@ enum NtUserCallOneParam_SetProcessDefaultLayout, /* temporary exports */ NtUserGetDeskPattern, - NtUserGetWinProcPtr, NtUserLock, - NtUserSpyGetVKeyName, };
static inline HDWP NtUserBeginDeferWindowPos( INT count )
From: Jacek Caban jacek@codeweavers.com
--- dlls/user32/controls.h | 3 --- dlls/user32/defwnd.c | 36 ------------------------------------ dlls/user32/scroll.c | 30 +++++++++++++++++++++--------- 3 files changed, 21 insertions(+), 48 deletions(-)
diff --git a/dlls/user32/controls.h b/dlls/user32/controls.h index 955c9092a54..036d872c43c 100644 --- a/dlls/user32/controls.h +++ b/dlls/user32/controls.h @@ -106,9 +106,6 @@ struct tagWND; extern ATOM get_int_atom_value( UNICODE_STRING *name ) DECLSPEC_HIDDEN; extern void register_desktop_class(void) DECLSPEC_HIDDEN;
-/* defwnd proc */ -extern HBRUSH DEFWND_ControlColor( HDC hDC, UINT ctlType ) DECLSPEC_HIDDEN; - /* desktop */ extern BOOL update_wallpaper( const WCHAR *wallpaper, const WCHAR *pattern ) DECLSPEC_HIDDEN;
diff --git a/dlls/user32/defwnd.c b/dlls/user32/defwnd.c index 9e258e5d3c0..34a4f294429 100644 --- a/dlls/user32/defwnd.c +++ b/dlls/user32/defwnd.c @@ -34,42 +34,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(win);
-/*********************************************************************** - * DEFWND_ControlColor - * - * Default colors for control painting. - */ -HBRUSH DEFWND_ControlColor( HDC hDC, UINT ctlType ) -{ - if( ctlType == CTLCOLOR_SCROLLBAR) - { - HBRUSH hb = GetSysColorBrush(COLOR_SCROLLBAR); - COLORREF bk = GetSysColor(COLOR_3DHILIGHT); - SetTextColor( hDC, GetSysColor(COLOR_3DFACE)); - SetBkColor( hDC, bk); - - /* if COLOR_WINDOW happens to be the same as COLOR_3DHILIGHT - * we better use 0x55aa bitmap brush to make scrollbar's background - * look different from the window background. - */ - if (bk == GetSysColor(COLOR_WINDOW)) - return SYSCOLOR_Get55AABrush(); - - UnrealizeObject( hb ); - return hb; - } - - SetTextColor( hDC, GetSysColor(COLOR_WINDOWTEXT)); - - if ((ctlType == CTLCOLOR_EDIT) || (ctlType == CTLCOLOR_LISTBOX)) - SetBkColor( hDC, GetSysColor(COLOR_WINDOW) ); - else { - SetBkColor( hDC, GetSysColor(COLOR_3DFACE) ); - return GetSysColorBrush(COLOR_3DFACE); - } - return GetSysColorBrush(COLOR_WINDOW); -} -
/*********************************************************************** * DefWindowProcA (USER32.@) diff --git a/dlls/user32/scroll.c b/dlls/user32/scroll.c index 9453df9dedd..9e17424a8de 100644 --- a/dlls/user32/scroll.c +++ b/dlls/user32/scroll.c @@ -97,18 +97,30 @@ static void SCROLL_DrawInterior( HWND hwnd, HDC hdc, INT nBar, HPEN hSavePen; HBRUSH hSaveBrush,hBrush;
- /* Select the correct brush and pen */ - - /* Only scrollbar controls send WM_CTLCOLORSCROLLBAR. - * The window-owned scrollbars need to call DEFWND_ControlColor - * to correctly setup default scrollbar colors - */ - if (nBar == SB_CTL) { + if (nBar == SB_CTL) + { hBrush = (HBRUSH)SendMessageW( GetParent(hwnd), WM_CTLCOLORSCROLLBAR, (WPARAM)hdc,(LPARAM)hwnd); - } else { - hBrush = DEFWND_ControlColor( hdc, CTLCOLOR_SCROLLBAR ); } + else + { + COLORREF bk = GetSysColor( COLOR_3DHILIGHT ); + SetTextColor( hdc, GetSysColor( COLOR_3DFACE )); + SetBkColor( hdc, bk ); + + /* if COLOR_WINDOW happens to be the same as COLOR_3DHILIGHT + * we better use 0x55aa bitmap brush to make scrollbar's background + * look different from the window background. + */ + if (bk == GetSysColor( COLOR_WINDOW )) + hBrush = SYSCOLOR_Get55AABrush(); + else + { + hBrush = GetSysColorBrush( COLOR_SCROLLBAR ); + UnrealizeObject( hBrush ); + } + } + hSavePen = SelectObject( hdc, SYSCOLOR_GetPen(COLOR_WINDOWFRAME) ); hSaveBrush = SelectObject( hdc, hBrush );
This merge request was approved by Huw Davies.