Author: weiden
Date: Sat Nov 17 08:08:13 2007
New Revision: 30516
URL:
http://svn.reactos.org/svn/reactos?rev=30516&view=rev
Log:
Optimize DispatchMessageA/W to avoid calls to win32k
Modified:
trunk/reactos/dll/win32/user32/windows/message.c
Modified: trunk/reactos/dll/win32/user32/windows/message.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/m…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/message.c (original)
+++ trunk/reactos/dll/win32/user32/windows/message.c Sat Nov 17 08:08:13 2007
@@ -1328,26 +1328,38 @@
LRESULT STDCALL
DispatchMessageA(CONST MSG *lpmsg)
{
- NTUSERDISPATCHMESSAGEINFO Info;
- LRESULT Result;
-
- Info.Ansi = TRUE;
- Info.Msg = *lpmsg;
- Result = NtUserDispatchMessage(&Info);
- if (! Info.HandledByKernel)
- {
- /* We need to send the message ourselves */
- SPY_EnterMessage(SPY_DISPATCHMESSAGE, Info.Msg.hwnd, Info.Msg.message,
- Info.Msg.wParam, Info.Msg.lParam);
- Result = IntCallWindowProcA(Info.Ansi, Info.Proc, Info.Msg.hwnd,
- Info.Msg.message, Info.Msg.wParam, Info.Msg.lParam);
- SPY_ExitMessage(SPY_RESULT_OK, Info.Msg.hwnd, Info.Msg.message, Result,
- Info.Msg.wParam, Info.Msg.lParam);
- }
- MsgConversionCleanup(lpmsg, TRUE, TRUE, &Result);
-
- return Result;
-}
+ LRESULT Ret = 0;
+ PWINDOW Wnd;
+
+ if (lpmsg->hwnd != NULL)
+ {
+ Wnd = ValidateHwnd(lpmsg->hwnd);
+ if (!Wnd || SharedPtrToUser(Wnd->ti) != GetW32ThreadInfo())
+ return 0;
+ }
+ else
+ Wnd = NULL;
+
+ if ((lpmsg->message == WM_TIMER || lpmsg->message == WM_SYSTIMER) &&
lpmsg->lParam != 0)
+ {
+ WNDPROC WndProc = (WNDPROC)lpmsg->lParam;
+ Ret = WndProc(lpmsg->hwnd,
+ lpmsg->message,
+ lpmsg->wParam,
+ GetTickCount());
+ }
+ else if (Wnd != NULL)
+ {
+ /* FIXME: WM_PAINT needs special handling */
+ Ret = IntCallMessageProc(Wnd,
+ lpmsg->hwnd,
+ lpmsg->message,
+ lpmsg->wParam,
+ lpmsg->lParam,
+ TRUE);
+ }
+
+ return Ret;}
/*
@@ -1356,25 +1368,38 @@
LRESULT STDCALL
DispatchMessageW(CONST MSG *lpmsg)
{
- NTUSERDISPATCHMESSAGEINFO Info;
- LRESULT Result;
-
- Info.Ansi = FALSE;
- Info.Msg = *lpmsg;
- Result = NtUserDispatchMessage(&Info);
- if (! Info.HandledByKernel)
- {
- /* We need to send the message ourselves */
- SPY_EnterMessage(SPY_DISPATCHMESSAGE, Info.Msg.hwnd, Info.Msg.message,
- Info.Msg.wParam, Info.Msg.lParam);
- Result = IntCallWindowProcW(Info.Ansi, Info.Proc, Info.Msg.hwnd,
- Info.Msg.message, Info.Msg.wParam, Info.Msg.lParam);
- SPY_ExitMessage(SPY_RESULT_OK, Info.Msg.hwnd, Info.Msg.message, Result,
- Info.Msg.wParam, Info.Msg.lParam);
- }
- MsgConversionCleanup(lpmsg, FALSE, TRUE, &Result);
-
- return Result;
+ LRESULT Ret = 0;
+ PWINDOW Wnd;
+
+ if (lpmsg->hwnd != NULL)
+ {
+ Wnd = ValidateHwnd(lpmsg->hwnd);
+ if (!Wnd || SharedPtrToUser(Wnd->ti) != GetW32ThreadInfo())
+ return 0;
+ }
+ else
+ Wnd = NULL;
+
+ if ((lpmsg->message == WM_TIMER || lpmsg->message == WM_SYSTIMER) &&
lpmsg->lParam != 0)
+ {
+ WNDPROC WndProc = (WNDPROC)lpmsg->lParam;
+ Ret = WndProc(lpmsg->hwnd,
+ lpmsg->message,
+ lpmsg->wParam,
+ GetTickCount());
+ }
+ else if (Wnd != NULL)
+ {
+ /* FIXME: WM_PAINT needs special handling */
+ Ret = IntCallMessageProc(Wnd,
+ lpmsg->hwnd,
+ lpmsg->message,
+ lpmsg->wParam,
+ lpmsg->lParam,
+ FALSE);
+ }
+
+ return Ret;
}