From 5d2a7901f7b1ee553647c71ad36a657e8f3bb722 Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Sat, 19 Feb 2011 12:22:52 +0000 Subject: [PATCH] [win32k] - Revert r50121 and r50154 svn path=/trunk/; revision=50816 --- .../win32/win32k/include/msgqueue.h | 7 +++- .../win32/win32k/ntuser/clipboard.c | 2 +- .../subsystems/win32/win32k/ntuser/desktop.c | 6 ++- .../subsystems/win32/win32k/ntuser/focus.c | 16 ++++---- .../subsystems/win32/win32k/ntuser/message.c | 41 +++++++++++++++++++ .../subsystems/win32/win32k/ntuser/ntstubs.c | 2 +- .../subsystems/win32/win32k/ntuser/painting.c | 2 +- 7 files changed, 63 insertions(+), 13 deletions(-) diff --git a/reactos/subsystems/win32/win32k/include/msgqueue.h b/reactos/subsystems/win32/win32k/include/msgqueue.h index ed80d369dc3..6831cc701c4 100644 --- a/reactos/subsystems/win32/win32k/include/msgqueue.h +++ b/reactos/subsystems/win32/win32k/include/msgqueue.h @@ -180,6 +180,11 @@ co_IntSendMessage(HWND hWnd, WPARAM wParam, LPARAM lParam); LRESULT FASTCALL +co_IntPostOrSendMessage(HWND hWnd, + UINT Msg, + WPARAM wParam, + LPARAM lParam); +LRESULT FASTCALL co_IntSendMessageTimeout(HWND hWnd, UINT Msg, WPARAM wParam, @@ -187,7 +192,7 @@ co_IntSendMessageTimeout(HWND hWnd, UINT uFlags, UINT uTimeout, ULONG_PTR *uResult); -BOOL FASTCALL UserSendNotifyMessage( HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam ); + LRESULT FASTCALL co_IntSendMessageNoWait(HWND hWnd, UINT Msg, WPARAM wParam, diff --git a/reactos/subsystems/win32/win32k/ntuser/clipboard.c b/reactos/subsystems/win32/win32k/ntuser/clipboard.c index 121d7af06ae..b75cb2da3f5 100644 --- a/reactos/subsystems/win32/win32k/ntuser/clipboard.c +++ b/reactos/subsystems/win32/win32k/ntuser/clipboard.c @@ -601,7 +601,7 @@ NtUserEmptyClipboard(VOID) if (ret && ClipboardOwnerWindow) { DPRINT("Clipboard: WM_DESTROYCLIPBOARD to %p", ClipboardOwnerWindow->head.h); - co_IntSendMessageNoWait( ClipboardOwnerWindow->head.h, WM_DESTROYCLIPBOARD, 0, 0); + co_IntSendMessage( ClipboardOwnerWindow->head.h, WM_DESTROYCLIPBOARD, 0, 0); } UserLeave(); diff --git a/reactos/subsystems/win32/win32k/ntuser/desktop.c b/reactos/subsystems/win32/win32k/ntuser/desktop.c index 74da248d3e7..b0b3c7ce803 100644 --- a/reactos/subsystems/win32/win32k/ntuser/desktop.c +++ b/reactos/subsystems/win32/win32k/ntuser/desktop.c @@ -738,7 +738,11 @@ VOID co_IntShellHookNotify(WPARAM Message, LPARAM lParam) for (; *cursor; cursor++) { - UserPostMessage(*cursor, gpsi->uiShellMsg, Message, lParam); + DPRINT("Sending notify\n"); + co_IntPostOrSendMessage(*cursor, + gpsi->uiShellMsg, + Message, + lParam); } ExFreePool(HwndList); diff --git a/reactos/subsystems/win32/win32k/ntuser/focus.c b/reactos/subsystems/win32/win32k/ntuser/focus.c index 6b1428c45e4..0ce1b388bd2 100644 --- a/reactos/subsystems/win32/win32k/ntuser/focus.c +++ b/reactos/subsystems/win32/win32k/ntuser/focus.c @@ -77,12 +77,12 @@ co_IntSendActivateMessages(HWND hWndPrev, HWND hWnd, BOOL MouseActivate) if (WindowPrev) UserRefObjectCo(WindowPrev, &RefPrev); /* Send palette messages */ - if (co_IntSendMessage(hWnd, WM_QUERYNEWPALETTE, 0, 0)) + if (co_IntPostOrSendMessage(hWnd, WM_QUERYNEWPALETTE, 0, 0)) { - UserSendNotifyMessage( HWND_BROADCAST, - WM_PALETTEISCHANGING, - (WPARAM)hWnd, - 0); + UserPostMessage( HWND_BROADCAST, + WM_PALETTEISCHANGING, + (WPARAM)hWnd, + 0); } if (Window->spwndPrev != NULL) @@ -166,7 +166,7 @@ co_IntSendKillFocusMessages(HWND hWndPrev, HWND hWnd) if (hWndPrev) { IntNotifyWinEvent(EVENT_OBJECT_FOCUS, NULL, OBJID_CLIENT, CHILDID_SELF, 0); - co_IntSendMessageNoWait(hWndPrev, WM_KILLFOCUS, (WPARAM)hWnd, 0); + co_IntPostOrSendMessage(hWndPrev, WM_KILLFOCUS, (WPARAM)hWnd, 0); } } @@ -177,7 +177,7 @@ co_IntSendSetFocusMessages(HWND hWndPrev, HWND hWnd) { PWND pWnd = UserGetWindowObject(hWnd); IntNotifyWinEvent(EVENT_OBJECT_FOCUS, pWnd, OBJID_CLIENT, CHILDID_SELF, 0); - co_IntSendMessageNoWait(hWnd, WM_SETFOCUS, (WPARAM)hWndPrev, 0); + co_IntPostOrSendMessage(hWnd, WM_SETFOCUS, (WPARAM)hWndPrev, 0); } } @@ -579,7 +579,7 @@ NtUserSetCapture(HWND hWnd) if (Window) IntNotifyWinEvent(EVENT_SYSTEM_CAPTURESTART, Window, OBJID_WINDOW, CHILDID_SELF, WEF_SETBYWNDPTI); - co_IntSendMessageNoWait(hWndPrev, WM_CAPTURECHANGED, 0, (LPARAM)hWnd); + co_IntPostOrSendMessage(hWndPrev, WM_CAPTURECHANGED, 0, (LPARAM)hWnd); ThreadQueue->CaptureWindow = hWnd; RETURN( hWndPrev); diff --git a/reactos/subsystems/win32/win32k/ntuser/message.c b/reactos/subsystems/win32/win32k/ntuser/message.c index 9abaa04d357..5c66991361b 100644 --- a/reactos/subsystems/win32/win32k/ntuser/message.c +++ b/reactos/subsystems/win32/win32k/ntuser/message.c @@ -1549,6 +1549,47 @@ CLEANUP: END_CLEANUP; } +/* This function posts a message if the destination's message queue belongs to +another thread, otherwise it sends the message. It does not support broadcast +messages! */ +LRESULT FASTCALL +co_IntPostOrSendMessage( HWND hWnd, + UINT Msg, + WPARAM wParam, + LPARAM lParam ) +{ + ULONG_PTR Result; + PTHREADINFO pti; + PWND Window; + + if ( hWnd == HWND_BROADCAST ) + { + return 0; + } + + if(!(Window = UserGetWindowObject(hWnd))) + { + return 0; + } + + pti = PsGetCurrentThreadWin32Thread(); + + if ( Window->head.pti->MessageQueue != pti->MessageQueue && + FindMsgMemory(Msg) == 0 ) + { + Result = UserPostMessage(hWnd, Msg, wParam, lParam); + } + else + { + if ( !co_IntSendMessageTimeoutSingle(hWnd, Msg, wParam, lParam, SMTO_NORMAL, 0, &Result) ) + { + Result = 0; + } + } + + return (LRESULT)Result; +} + LRESULT FASTCALL co_IntDoSendMessage( HWND hWnd, UINT Msg, diff --git a/reactos/subsystems/win32/win32k/ntuser/ntstubs.c b/reactos/subsystems/win32/win32k/ntuser/ntstubs.c index 821d4d6ddf4..44d718131c6 100644 --- a/reactos/subsystems/win32/win32k/ntuser/ntstubs.c +++ b/reactos/subsystems/win32/win32k/ntuser/ntstubs.c @@ -564,7 +564,7 @@ NtUserSetSysColors( } if (Ret) { - UserSendNotifyMessage(HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0); + UserPostMessage(HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0); } UserLeave(); return Ret; diff --git a/reactos/subsystems/win32/win32k/ntuser/painting.c b/reactos/subsystems/win32/win32k/ntuser/painting.c index c9bc3146a60..59e370c4c89 100644 --- a/reactos/subsystems/win32/win32k/ntuser/painting.c +++ b/reactos/subsystems/win32/win32k/ntuser/painting.c @@ -1957,7 +1957,7 @@ UserRealizePalette(HDC hdc) hWnd = IntWindowFromDC(hdc); if (hWnd) // Send broadcast if dc is associated with a window. { // FYI: Thread locked in CallOneParam. - UserSendNotifyMessage((HWND)HWND_BROADCAST, WM_PALETTECHANGED, (WPARAM)hWnd, 0); + co_IntSendMessage((HWND)HWND_BROADCAST, WM_PALETTECHANGED, (WPARAM)hWnd, 0); } } return Ret;