modified MsqInsertSystemMessage() so it prevents the system message queue from having more than one WM_MOUSEMOVE message. This should improve moving windows and reduce sending unnecessary WM_MOUSEMOVE messages to applications

svn path=/trunk/; revision=5852
This commit is contained in:
Thomas Bluemel 2003-08-25 14:26:30 +00:00
parent 7b2f150c3c
commit 9acc460ae1

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: msgqueue.c,v 1.15 2003/08/19 11:48:49 weiden Exp $ /* $Id: msgqueue.c,v 1.16 2003/08/25 14:26:30 weiden Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -124,21 +124,60 @@ MsqInitializeImpl(VOID)
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
LPMSG FASTCALL
MsgFindSystemMessage(UINT message)
{
ULONG QueuePos;
LPMSG Result = NULL;
MSG Msg;
if(SystemMessageQueueCount > 0)
{
QueuePos = SystemMessageQueueTail;
while(QueuePos >= SystemMessageQueueHead)
{
Msg = SystemMessageQueue[QueuePos];
if(Msg.message == message)
{
Result = &Msg;
break;
}
QueuePos--;
}
}
return Result;
}
VOID FASTCALL VOID FASTCALL
MsqInsertSystemMessage(MSG* Msg) MsqInsertSystemMessage(MSG* Msg)
{ {
KIRQL OldIrql; KIRQL OldIrql;
LPMSG mmov = NULL;
KeAcquireSpinLock(&SystemMessageQueueLock, &OldIrql); KeAcquireSpinLock(&SystemMessageQueueLock, &OldIrql);
if (SystemMessageQueueCount == SYSTEM_MESSAGE_QUEUE_SIZE)
/* only insert WM_MOUSEMOVE messages if not already in system message queue */
if(Msg->message == WM_MOUSEMOVE)
mmov = MsgFindSystemMessage(WM_MOUSEMOVE);
if(mmov)
{
/* overwrite the existing WM_MOUSEMOVE message */
*mmov = *Msg;
}
else
{
if (SystemMessageQueueCount == SYSTEM_MESSAGE_QUEUE_SIZE)
{ {
KeReleaseSpinLock(&SystemMessageQueueLock, OldIrql); KeReleaseSpinLock(&SystemMessageQueueLock, OldIrql);
return; return;
} }
SystemMessageQueue[SystemMessageQueueTail] = *Msg; SystemMessageQueue[SystemMessageQueueTail] = *Msg;
SystemMessageQueueTail = SystemMessageQueueTail =
(SystemMessageQueueTail + 1) % SYSTEM_MESSAGE_QUEUE_SIZE; (SystemMessageQueueTail + 1) % SYSTEM_MESSAGE_QUEUE_SIZE;
SystemMessageQueueCount++; SystemMessageQueueCount++;
}
KeReleaseSpinLock(&SystemMessageQueueLock, OldIrql); KeReleaseSpinLock(&SystemMessageQueueLock, OldIrql);
KeSetEvent(&HardwareMessageEvent, IO_NO_INCREMENT, FALSE); KeSetEvent(&HardwareMessageEvent, IO_NO_INCREMENT, FALSE);
} }