* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id$
- *
+/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* PURPOSE: Message queues
- * FILE: subsys/win32k/ntuser/msgqueue.c
+ * FILE: subsystems/win32/win32k/ntuser/msgqueue.c
* PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
* REVISION HISTORY:
* 06-06-2001 CSH Created
/* FUNCTIONS *****************************************************************/
+//
+// Wakeup any thread/process waiting on idle input.
+//
+static VOID FASTCALL
+IdlePing(VOID)
+{
+ HWND hWnd;
+ PWINDOW_OBJECT Window;
+ PPROCESSINFO W32d = PsGetCurrentProcessWin32Process();
+
+ hWnd = UserGetForegroundWindow();
+
+ Window = UserGetWindowObject(hWnd);
+
+ if (Window && Window->ti)
+ {
+ if (Window->ti->fsHooks & HOOKID_TO_FLAG(WH_FOREGROUNDIDLE))
+ {
+ co_HOOK_CallHooks(WH_FOREGROUNDIDLE,HC_ACTION,0,0);
+ }
+ }
+
+ if (W32d && W32d->InputIdleEvent)
+ KePulseEvent( W32d->InputIdleEvent, EVENT_INCREMENT, TRUE);
+}
+
HANDLE FASTCALL
IntMsqSetWakeMask(DWORD WakeMask)
{
- PW32THREAD Win32Thread;
+ PTHREADINFO Win32Thread;
PUSER_MESSAGE_QUEUE MessageQueue;
HANDLE MessageEventHandle;
BOOL FASTCALL
IntMsqClearWakeMask(VOID)
{
- PW32THREAD Win32Thread;
+ PTHREADINFO Win32Thread;
PUSER_MESSAGE_QUEUE MessageQueue;
Win32Thread = PsGetCurrentThreadWin32Thread();
return FALSE;
MessageQueue = Win32Thread->MessageQueue;
+// HACK!!!!!!! Newbies that wrote this should hold your head down in shame! (jt)
MessageQueue->WakeMask = ~0;
return TRUE;
NULL,
0,
sizeof(USER_MESSAGE),
- 0,
+ TAG_USRMSG,
256);
ExInitializePagedLookasideList(&TimerLookasideList,
NULL,
NULL,
0,
sizeof(TIMER_ENTRY),
- 0,
+ TAG_TIMER,
64);
return(STATUS_SUCCESS);
LARGE_INTEGER LargeTickCount;
KIRQL OldIrql;
ULONG Prev;
+ EVENTMSG Event;
IntLockSystemMessageQueue(OldIrql);
KeQueryTickCount(&LargeTickCount);
Msg->time = MsqCalculateMessageTime(&LargeTickCount);
+ Event.message = Msg->message;
+ Event.time = Msg->time;
+ Event.hwnd = Msg->hwnd;
+ Event.paramL = Msg->pt.x;
+ Event.paramH = Msg->pt.y;
+ co_HOOK_CallHooks( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)&Event);
+
/*
* If we got WM_MOUSEMOVE and there are already messages in the
* system message queue, check if the last message is mouse move
BOOL FASTCALL
MsqIsDblClk(LPMSG Msg, BOOL Remove)
{
+ PTHREADINFO pti;
PWINSTATION_OBJECT WinStaObject;
PSYSTEM_CURSORINFO CurInfo;
LONG dX, dY;
BOOL Res;
- if (PsGetCurrentThreadWin32Thread()->Desktop == NULL)
+ pti = PsGetCurrentThreadWin32Thread();
+ if (pti->Desktop == NULL)
{
return FALSE;
}
- WinStaObject = PsGetCurrentThreadWin32Thread()->Desktop->WindowStation;
+ WinStaObject = pti->Desktop->WindowStation;
CurInfo = IntGetSysCursorInfo(WinStaObject);
Res = (Msg->hwnd == (HWND)CurInfo->LastClkWnd) &&
return Res;
}
-BOOL static STDCALL
-co_MsqTranslateMouseMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd, UINT FilterLow, UINT FilterHigh,
+static BOOL APIENTRY
+co_MsqTranslateMouseMessage(PUSER_MESSAGE_QUEUE MessageQueue, PWINDOW_OBJECT Window, UINT FilterLow, UINT FilterHigh,
PUSER_MESSAGE Message, BOOL Remove, PBOOL Freed,
- PWINDOW_OBJECT ScopeWin, PPOINT ScreenPoint, BOOL FromGlobalQueue)
+ PWINDOW_OBJECT ScopeWin, PPOINT ScreenPoint, BOOL FromGlobalQueue, PLIST_ENTRY *Next)
{
USHORT Msg = Message->Msg.message;
- PWINDOW_OBJECT Window = NULL;
+ PWINDOW_OBJECT CaptureWindow = NULL;
HWND hCaptureWin;
ASSERT_REFS_CO(ScopeWin);
hCaptureWin = IntGetCaptureWindow();
if (hCaptureWin == NULL)
{
- if(Msg == WM_MOUSEWHEEL)
+ if (Msg == WM_MOUSEWHEEL)
{
- Window = UserGetWindowObject(IntGetFocusWindow());
- if (Window) UserRefObject(Window);
+ CaptureWindow = UserGetWindowObject(IntGetFocusWindow());
+ if (CaptureWindow) UserReferenceObject(CaptureWindow);
}
else
{
- co_WinPosWindowFromPoint(ScopeWin, NULL, &Message->Msg.pt, &Window);
- if(Window == NULL)
+ co_WinPosWindowFromPoint(ScopeWin, NULL, &Message->Msg.pt, &CaptureWindow);
+ if(CaptureWindow == NULL)
{
- Window = ScopeWin;
- if (Window) UserRefObject(Window);
+ CaptureWindow = ScopeWin;
+ if (CaptureWindow) UserReferenceObject(CaptureWindow);
}
else
{
{
/* FIXME - window messages should go to the right window if no buttons are
pressed */
- Window = UserGetWindowObject(hCaptureWin);
- if (Window) UserRefObject(Window);
+ CaptureWindow = UserGetWindowObject(hCaptureWin);
+ if (CaptureWindow) UserReferenceObject(CaptureWindow);
}
- if (Window == NULL)
+ if (CaptureWindow == NULL)
{
if(!FromGlobalQueue)
{
MessageQueue->MouseMoveMsg = NULL;
}
}
+ // when FromGlobalQueue is true, the caller has already removed the Message
ExFreePool(Message);
*Freed = TRUE;
return(FALSE);
}
- if (Window->MessageQueue != MessageQueue)
+ if (CaptureWindow->MessageQueue != MessageQueue)
{
if (! FromGlobalQueue)
{
/* lock the destination message queue, so we don't get in trouble with other
threads, messing with it at the same time */
- IntLockHardwareMessageQueue(Window->MessageQueue);
- InsertTailList(&Window->MessageQueue->HardwareMessagesListHead,
+ IntLockHardwareMessageQueue(CaptureWindow->MessageQueue);
+ InsertTailList(&CaptureWindow->MessageQueue->HardwareMessagesListHead,
&Message->ListEntry);
if(Message->Msg.message == WM_MOUSEMOVE)
{
- if(Window->MessageQueue->MouseMoveMsg)
+ if(CaptureWindow->MessageQueue->MouseMoveMsg)
{
/* remove the old WM_MOUSEMOVE message, we're processing a more recent
one */
- RemoveEntryList(&Window->MessageQueue->MouseMoveMsg->ListEntry);
- ExFreePool(Window->MessageQueue->MouseMoveMsg);
+ RemoveEntryList(&CaptureWindow->MessageQueue->MouseMoveMsg->ListEntry);
+ ExFreePool(CaptureWindow->MessageQueue->MouseMoveMsg);
}
/* save the pointer to the WM_MOUSEMOVE message in the new queue */
- Window->MessageQueue->MouseMoveMsg = Message;
+ CaptureWindow->MessageQueue->MouseMoveMsg = Message;
- Window->MessageQueue->QueueBits |= QS_MOUSEMOVE;
- Window->MessageQueue->ChangedBits |= QS_MOUSEMOVE;
- if (Window->MessageQueue->WakeMask & QS_MOUSEMOVE)
- KeSetEvent(Window->MessageQueue->NewMessages, IO_NO_INCREMENT, FALSE);
+ CaptureWindow->MessageQueue->QueueBits |= QS_MOUSEMOVE;
+ CaptureWindow->MessageQueue->ChangedBits |= QS_MOUSEMOVE;
+ if (CaptureWindow->MessageQueue->WakeMask & QS_MOUSEMOVE)
+ KeSetEvent(CaptureWindow->MessageQueue->NewMessages, IO_NO_INCREMENT, FALSE);
}
else
{
- Window->MessageQueue->QueueBits |= QS_MOUSEBUTTON;
- Window->MessageQueue->ChangedBits |= QS_MOUSEBUTTON;
- if (Window->MessageQueue->WakeMask & QS_MOUSEBUTTON)
- KeSetEvent(Window->MessageQueue->NewMessages, IO_NO_INCREMENT, FALSE);
+ CaptureWindow->MessageQueue->QueueBits |= QS_MOUSEBUTTON;
+ CaptureWindow->MessageQueue->ChangedBits |= QS_MOUSEBUTTON;
+ if (CaptureWindow->MessageQueue->WakeMask & QS_MOUSEBUTTON)
+ KeSetEvent(CaptureWindow->MessageQueue->NewMessages, IO_NO_INCREMENT, FALSE);
}
- IntUnLockHardwareMessageQueue(Window->MessageQueue);
+ IntUnLockHardwareMessageQueue(CaptureWindow->MessageQueue);
*Freed = FALSE;
- UserDerefObject(Window);
+ UserDereferenceObject(CaptureWindow);
return(FALSE);
}
*ScreenPoint = Message->Msg.pt;
- if((hWnd != NULL && Window->hSelf != hWnd) ||
- ((FilterLow != 0 || FilterLow != 0) && (Msg < FilterLow || Msg > FilterHigh)))
+ if((Window != NULL && (int)Window != 1 && CaptureWindow->hSelf != Window->hSelf) ||
+ ((FilterLow != 0 || FilterHigh != 0) && (Msg < FilterLow || Msg > FilterHigh)))
{
/* Reject the message because it doesn't match the filter */
/* Lock the message queue so no other thread can mess with it.
Our own message queue is not locked while fetching from the global
queue, so we have to make sure nothing interferes! */
- IntLockHardwareMessageQueue(Window->MessageQueue);
+ IntLockHardwareMessageQueue(CaptureWindow->MessageQueue);
/* if we're from the global queue, we need to add our message to our
private queue so we don't loose it! */
- InsertTailList(&Window->MessageQueue->HardwareMessagesListHead,
+ InsertTailList(&CaptureWindow->MessageQueue->HardwareMessagesListHead,
&Message->ListEntry);
}
if (Message->Msg.message == WM_MOUSEMOVE)
{
- if(Window->MessageQueue->MouseMoveMsg &&
- (Window->MessageQueue->MouseMoveMsg != Message))
+ if(CaptureWindow->MessageQueue->MouseMoveMsg &&
+ (CaptureWindow->MessageQueue->MouseMoveMsg != Message))
{
/* delete the old message */
- RemoveEntryList(&Window->MessageQueue->MouseMoveMsg->ListEntry);
- ExFreePool(Window->MessageQueue->MouseMoveMsg);
+ RemoveEntryList(&CaptureWindow->MessageQueue->MouseMoveMsg->ListEntry);
+ ExFreePool(CaptureWindow->MessageQueue->MouseMoveMsg);
+ if (!FromGlobalQueue)
+ {
+ // We might have deleted the next one in our queue, so fix next
+ *Next = Message->ListEntry.Flink;
+ }
}
/* always save a pointer to this WM_MOUSEMOVE message here because we're
sure that the message is in the private queue */
- Window->MessageQueue->MouseMoveMsg = Message;
+ CaptureWindow->MessageQueue->MouseMoveMsg = Message;
}
if(FromGlobalQueue)
{
- IntUnLockHardwareMessageQueue(Window->MessageQueue);
+ IntUnLockHardwareMessageQueue(CaptureWindow->MessageQueue);
}
- UserDerefObject(Window);
+ UserDereferenceObject(CaptureWindow);
*Freed = FALSE;
return(FALSE);
}
/* FIXME - only assign if removing? */
- Message->Msg.hwnd = Window->hSelf;
+ Message->Msg.hwnd = CaptureWindow->hSelf;
Message->Msg.message = Msg;
Message->Msg.lParam = MAKELONG(Message->Msg.pt.x, Message->Msg.pt.y);
/* Lock the message queue so no other thread can mess with it.
Our own message queue is not locked while fetching from the global
queue, so we have to make sure nothing interferes! */
- IntLockHardwareMessageQueue(Window->MessageQueue);
- if(Window->MessageQueue->MouseMoveMsg)
+ IntLockHardwareMessageQueue(CaptureWindow->MessageQueue);
+ if(CaptureWindow->MessageQueue->MouseMoveMsg)
{
/* delete the WM_(NC)MOUSEMOVE message in the private queue, we're dealing
with one that's been sent later */
- RemoveEntryList(&Window->MessageQueue->MouseMoveMsg->ListEntry);
- ExFreePool(Window->MessageQueue->MouseMoveMsg);
+ RemoveEntryList(&CaptureWindow->MessageQueue->MouseMoveMsg->ListEntry);
+ ExFreePool(CaptureWindow->MessageQueue->MouseMoveMsg);
/* our message is not in the private queue so we can remove the pointer
instead of setting it to the current message we're processing */
- Window->MessageQueue->MouseMoveMsg = NULL;
+ CaptureWindow->MessageQueue->MouseMoveMsg = NULL;
}
- IntUnLockHardwareMessageQueue(Window->MessageQueue);
+ IntUnLockHardwareMessageQueue(CaptureWindow->MessageQueue);
}
- else if(Window->MessageQueue->MouseMoveMsg == Message)
+ else if (CaptureWindow->MessageQueue->MouseMoveMsg == Message)
{
- Window->MessageQueue->MouseMoveMsg = NULL;
+ CaptureWindow->MessageQueue->MouseMoveMsg = NULL;
}
}
- UserDerefObject(Window);
+ UserDereferenceObject(CaptureWindow);
*Freed = FALSE;
return(TRUE);
}
-BOOL STDCALL
-co_MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd,
+BOOL APIENTRY
+co_MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, PWINDOW_OBJECT Window,
UINT FilterLow, UINT FilterHigh, BOOL Remove,
PUSER_MESSAGE* Message)
{
NTSTATUS WaitStatus;
DECLARE_RETURN(BOOL);
USER_REFERENCE_ENTRY Ref;
+ PDESKTOPINFO Desk = NULL;
WaitObjects[1] = MessageQueue->NewMessages;
WaitObjects[0] = &HardwareMessageQueueLock;
do
{
+ IdlePing();
+
UserLeaveCo();
WaitStatus = KeWaitForMultipleObjects(2, WaitObjects, WaitAny, UserRequest,
UserMode, FALSE, NULL, NULL);
UserEnterCo();
-
- while (co_MsqDispatchOneSentMessage(MessageQueue))
- {
- ;
- }
}
while (NT_SUCCESS(WaitStatus) && STATUS_WAIT_0 != WaitStatus);
DesktopWindow = UserGetWindowObject(IntGetDesktopWindow());
- if (DesktopWindow) UserRefObjectCo(DesktopWindow, &Ref);//can DesktopWindow be NULL?
+ if (DesktopWindow)
+ {
+ UserRefObjectCo(DesktopWindow, &Ref);//can DesktopWindow be NULL?
+ Desk = DesktopWindow->ti->pDeskInfo;
+ }
/* Process messages in the message queue itself. */
IntLockHardwareMessageQueue(MessageQueue);
{
-
- Accept = co_MsqTranslateMouseMessage(MessageQueue, hWnd, FilterLow, FilterHigh,
+ Accept = co_MsqTranslateMouseMessage(MessageQueue, Window, FilterLow, FilterHigh,
Current, Remove, &Freed,
- DesktopWindow, &ScreenPoint, FALSE);
+ DesktopWindow, &ScreenPoint, FALSE, &CurrentEntry);
if (Accept)
{
if (Remove)
IntUnLockSystemHardwareMessageQueueLock(FALSE);
*Message = Current;
+ if (Desk)
+ Desk->LastInputWasKbd = FALSE;
+
RETURN(TRUE);
}
{
const ULONG ActiveStamp = HardwareMessageQueueStamp;
/* Translate the message. */
- Accept = co_MsqTranslateMouseMessage(MessageQueue, hWnd, FilterLow, FilterHigh,
+ Accept = co_MsqTranslateMouseMessage(MessageQueue, Window, FilterLow, FilterHigh,
Current, Remove, &Freed,
- DesktopWindow, &ScreenPoint, TRUE);
+ DesktopWindow, &ScreenPoint, TRUE, NULL);
if (Accept)
{
/* Check for no more messages in the system queue. */
END_CLEANUP;
}
+//
+// Note: Only called from input.c.
+//
VOID FASTCALL
co_MsqPostKeyboardMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
MSG Msg;
LARGE_INTEGER LargeTickCount;
KBDLLHOOKSTRUCT KbdHookData;
+ EVENTMSG Event;
+ BOOLEAN Entered = FALSE;
DPRINT("MsqPostKeyboardMessage(uMsg 0x%x, wParam 0x%x, lParam 0x%x)\n",
uMsg, wParam, lParam);
+ // Condition may arise when calling MsqPostMessage and waiting for an event.
+ if (!UserIsEntered())
+ {
+ // Fixme: Not sure ATM if this thread is locked.
+ UserEnterExclusive();
+ Entered = TRUE;
+ }
+
+ FocusMessageQueue = IntGetFocusMessageQueue();
+
Msg.hwnd = 0;
+
+ if (FocusMessageQueue && (FocusMessageQueue->FocusWindow != (HWND)0))
+ Msg.hwnd = FocusMessageQueue->FocusWindow;
+
Msg.message = uMsg;
Msg.wParam = wParam;
Msg.lParam = lParam;
KeQueryTickCount(&LargeTickCount);
Msg.time = MsqCalculateMessageTime(&LargeTickCount);
+
+ Event.message = Msg.message;
+ Event.hwnd = Msg.hwnd;
+ Event.time = Msg.time;
+ Event.paramL = (Msg.wParam & 0xFF) | (HIWORD(Msg.lParam) << 8);
+ Event.paramH = Msg.lParam & 0x7FFF;
+ if (HIWORD(Msg.lParam) & 0x0100) Event.paramH |= 0x8000;
+ co_HOOK_CallHooks( WH_JOURNALRECORD, HC_ACTION, 0, (LPARAM)&Event);
+
/* We can't get the Msg.pt point here since we don't know thread
(and thus the window station) the message will end up in yet. */
{
DPRINT("Kbd msg %d wParam %d lParam 0x%08x dropped by WH_KEYBOARD_LL hook\n",
Msg.message, Msg.wParam, Msg.lParam);
+ if (Entered) UserLeave();
return;
}
- FocusMessageQueue = IntGetFocusMessageQueue();
- if (FocusMessageQueue == NULL)
- {
+ if (FocusMessageQueue == NULL)
+ {
DPRINT("No focus message queue\n");
+ if (Entered) UserLeave();
return;
- }
+ }
- if (FocusMessageQueue->FocusWindow != (HWND)0)
- {
+ if (FocusMessageQueue->FocusWindow != (HWND)0)
+ {
Msg.hwnd = FocusMessageQueue->FocusWindow;
DPRINT("Msg.hwnd = %x\n", Msg.hwnd);
+
+ FocusMessageQueue->Desktop->DesktopInfo->LastInputWasKbd = TRUE;
+
IntGetCursorLocation(FocusMessageQueue->Desktop->WindowStation,
&Msg.pt);
MsqPostMessage(FocusMessageQueue, &Msg, FALSE, QS_KEY);
- }
- else
- {
+ }
+ else
+ {
DPRINT("Invalid focus window handle\n");
- }
}
+ if (Entered) UserLeave();
+ return;
+}
+
VOID FASTCALL
MsqPostHotKeyMessage(PVOID Thread, HWND hWnd, WPARAM wParam, LPARAM lParam)
{
PWINDOW_OBJECT Window;
- PW32THREAD Win32Thread;
+ PTHREADINFO Win32Thread;
PWINSTATION_OBJECT WinSta;
MSG Mesg;
LARGE_INTEGER LargeTickCount;
Mesg.time = MsqCalculateMessageTime(&LargeTickCount);
IntGetCursorLocation(WinSta, &Mesg.pt);
MsqPostMessage(Window->MessageQueue, &Mesg, FALSE, QS_HOTKEY);
- ObmDereferenceObject(Window);
+ UserDereferenceObject(Window);
ObDereferenceObject (Thread);
// InsertHeadList(&pThread->MessageQueue->PostedMessagesListHead,
InsertTailList(&MessageQueue->LocalDispatchingMessagesHead,
&Message->ListEntry);
- if (Message->HookMessage)
+ if (Message->HookMessage == MSQ_ISHOOK)
{
Result = co_HOOK_CallHooks(Message->Msg.message,
- (INT) Message->Msg.hwnd,
+ (INT)(INT_PTR)Message->Msg.hwnd,
Message->Msg.wParam,
Message->Msg.lParam);
}
+ else if (Message->HookMessage == MSQ_ISEVENT)
+ {
+ Result = co_EVENT_CallEvents( Message->Msg.message,
+ Message->Msg.hwnd,
+ Message->Msg.wParam,
+ Message->Msg.lParam);
+ }
else
{
/* Call the window procedure. */
return(TRUE);
}
-VOID STDCALL
+VOID APIENTRY
MsqRemoveWindowMessagesFromQueue(PVOID pWindow)
{
PUSER_SENT_MESSAGE SentMessage;
NTSTATUS FASTCALL
co_MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue,
HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam,
- UINT uTimeout, BOOL Block, BOOL HookMessage,
+ UINT uTimeout, BOOL Block, INT HookMessage,
ULONG_PTR *uResult)
{
+ PTHREADINFO pti;
PUSER_SENT_MESSAGE Message;
KEVENT CompletionEvent;
NTSTATUS WaitStatus;
KeInitializeEvent(&CompletionEvent, NotificationEvent, FALSE);
- ThreadQueue = PsGetCurrentThreadWin32Thread()->MessageQueue;
+ pti = PsGetCurrentThreadWin32Thread();
+ ThreadQueue = pti->MessageQueue;
ASSERT(ThreadQueue != MessageQueue);
Timeout.QuadPart = (LONGLONG) uTimeout * (LONGLONG) -10000;
if(Block)
{
+ IdlePing();
UserLeaveCo();
WaitObjects[1] = ThreadQueue->NewMessages;
do
{
+ IdlePing();
UserLeaveCo();
KeSetEvent(MessageQueue->NewMessages, IO_NO_INCREMENT, FALSE);
}
-BOOLEAN STDCALL
+BOOLEAN APIENTRY
co_MsqFindMessage(IN PUSER_MESSAGE_QUEUE MessageQueue,
IN BOOLEAN Hardware,
IN BOOLEAN Remove,
- IN HWND Wnd,
+ IN PWINDOW_OBJECT Window,
IN UINT MsgFilterLow,
IN UINT MsgFilterHigh,
OUT PUSER_MESSAGE* Message)
if (Hardware)
{
- return(co_MsqPeekHardwareMessage(MessageQueue, Wnd,
+ return(co_MsqPeekHardwareMessage(MessageQueue, Window,
MsgFilterLow, MsgFilterHigh,
Remove, Message));
}
{
CurrentMessage = CONTAINING_RECORD(CurrentEntry, USER_MESSAGE,
ListEntry);
- if ((Wnd == 0 || Wnd == CurrentMessage->Msg.hwnd) &&
+ if ((!Window || (int)Window == 1 || Window->hSelf == CurrentMessage->Msg.hwnd) &&
((MsgFilterLow == 0 && MsgFilterHigh == 0) ||
(MsgFilterLow <= CurrentMessage->Msg.message &&
MsgFilterHigh >= CurrentMessage->Msg.message)))
}
NTSTATUS FASTCALL
-co_MsqWaitForNewMessages(PUSER_MESSAGE_QUEUE MessageQueue, HWND WndFilter,
+co_MsqWaitForNewMessages(PUSER_MESSAGE_QUEUE MessageQueue, PWINDOW_OBJECT WndFilter,
UINT MsgFilterMin, UINT MsgFilterMax)
{
PVOID WaitObjects[2] = {MessageQueue->NewMessages, &HardwareMessageEvent};
Timeout = NULL;
}
+ IdlePing(); // Going to wait so send Idle ping.
+
UserLeaveCo();
ret = KeWaitForMultipleObjects(2,
MessageQueue->LastMsgRead = LargeTickCount.u.LowPart;
MessageQueue->FocusWindow = NULL;
MessageQueue->PaintCount = 0;
+// HACK!!!!!!! Newbies that wrote this should hold your head down in shame! (jt)
MessageQueue->WakeMask = ~0;
MessageQueue->NewMessagesHandle = NULL;
{
PUSER_MESSAGE_QUEUE MessageQueue;
- MessageQueue = (PUSER_MESSAGE_QUEUE)ExAllocatePoolWithTag(PagedPool,
+ MessageQueue = (PUSER_MESSAGE_QUEUE)ExAllocatePoolWithTag(NonPagedPool,
sizeof(USER_MESSAGE_QUEUE) + sizeof(THRDCARETINFO),
TAG_MSGQ);
VOID FASTCALL
MsqDestroyMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue)
{
- PDESKTOP_OBJECT desk;
+ PDESKTOP desk;
/* remove the message queue from any desktops */
- if ((desk = (PDESKTOP_OBJECT)InterlockedExchange((LONG*)&MessageQueue->Desktop, 0)))
+ if ((desk = InterlockedExchangePointer((PVOID*)&MessageQueue->Desktop, 0)))
{
- InterlockedExchange((LONG*)&desk->ActiveMessageQueue, 0);
+ (void)InterlockedExchangePointer((PVOID*)&desk->ActiveMessageQueue, 0);
IntDereferenceMessageQueue(MessageQueue);
}
MsqSetMessageExtraInfo(LPARAM lParam)
{
LPARAM Ret;
+ PTHREADINFO pti;
PUSER_MESSAGE_QUEUE MessageQueue;
- MessageQueue = PsGetCurrentThreadWin32Thread()->MessageQueue;
+ pti = PsGetCurrentThreadWin32Thread();
+ MessageQueue = pti->MessageQueue;
if(!MessageQueue)
{
return 0;
LPARAM FASTCALL
MsqGetMessageExtraInfo(VOID)
{
+ PTHREADINFO pti;
PUSER_MESSAGE_QUEUE MessageQueue;
- MessageQueue = PsGetCurrentThreadWin32Thread()->MessageQueue;
+ pti = PsGetCurrentThreadWin32Thread();
+ MessageQueue = pti->MessageQueue;
if(!MessageQueue)
{
return 0;
BOOLEAN FASTCALL
MsqGetTimerMessage(PUSER_MESSAGE_QUEUE MessageQueue,
- HWND WndFilter, UINT MsgFilterMin, UINT MsgFilterMax,
+ PWINDOW_OBJECT WindowFilter, UINT MsgFilterMin, UINT MsgFilterMax,
MSG *Msg, BOOLEAN Restart)
{
PTIMER_ENTRY Timer;
LARGE_INTEGER LargeTickCount;
PLIST_ENTRY EnumEntry;
BOOLEAN GotMessage;
+ PTHREADINFO pti;
DPRINT("MsqGetTimerMessage queue %p msg %p restart %s\n",
MessageQueue, Msg, Restart ? "TRUE" : "FALSE");
DPRINT("Checking timer %p wnd %x expiry %I64d\n", Timer, Timer->Wnd,
Timer->ExpiryTime.QuadPart);
EnumEntry = EnumEntry->Flink;
- if ((NULL == WndFilter || Timer->Wnd == WndFilter) &&
+ if ((NULL == WindowFilter || Timer->Wnd == WindowFilter->hSelf) &&
((MsgFilterMin == 0 && MsgFilterMax == 0) ||
(MsgFilterMin <= Timer->Msg &&
Timer->Msg <= MsgFilterMax)))
else
{
DPRINT("timer %p (wnd %x msg %d) failed filter wnd %x msgmin %d msgmax %d\n",
- Timer, Timer->Wnd, Timer->Msg, WndFilter, MsgFilterMin, MsgFilterMax);
+ Timer, Timer->Wnd, Timer->Msg, WindowFilter->hSelf, MsgFilterMin, MsgFilterMax);
}
}
Msg->lParam = (LPARAM) Timer->TimerFunc;
KeQueryTickCount(&LargeTickCount);
Msg->time = MsqCalculateMessageTime(&LargeTickCount);
- IntGetCursorLocation(PsGetCurrentThreadWin32Thread()->Desktop->WindowStation,
+ pti = PsGetCurrentThreadWin32Thread();
+ IntGetCursorLocation(pti->Desktop->WindowStation,
&Msg->pt);
if (Restart)
BOOLEAN FASTCALL
MsqGetFirstTimerExpiry(PUSER_MESSAGE_QUEUE MessageQueue,
- HWND WndFilter, UINT MsgFilterMin, UINT MsgFilterMax,
+ PWINDOW_OBJECT WndFilter, UINT MsgFilterMin, UINT MsgFilterMax,
PLARGE_INTEGER FirstTimerExpiry)
{
PTIMER_ENTRY Timer;
Timer = CONTAINING_RECORD(MessageQueue->TimerListHead.Flink,
TIMER_ENTRY, ListEntry);
EnumEntry = EnumEntry->Flink;
- if ((NULL == WndFilter || Timer->Wnd == WndFilter) &&
+ if ((NULL == WndFilter || (int)WndFilter == 1 || Timer->Wnd == WndFilter->hSelf) &&
((MsgFilterMin == 0 && MsgFilterMax == 0) ||
(MsgFilterMin <= Timer->Msg &&
Timer->Msg <= MsgFilterMax)))