mirror of
https://github.com/reactos/reactos.git
synced 2024-12-30 19:14:31 +00:00
- Fix race condition resulting in WM_xBUTTONUP sometimes being
delivered befor WM_xBUTTONDOWN - Fix double click svn path=/trunk/; revision=8100
This commit is contained in:
parent
dfd90b8ad1
commit
2966583cc6
1 changed files with 25 additions and 13 deletions
|
@ -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.64 2004/01/20 23:35:59 gvg Exp $
|
/* $Id: msgqueue.c,v 1.65 2004/02/08 21:47:10 gvg Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -63,7 +63,7 @@ static KSPIN_LOCK SystemMessageQueueLock;
|
||||||
|
|
||||||
static ULONG volatile HardwareMessageQueueStamp = 0;
|
static ULONG volatile HardwareMessageQueueStamp = 0;
|
||||||
static LIST_ENTRY HardwareMessageQueueHead;
|
static LIST_ENTRY HardwareMessageQueueHead;
|
||||||
static FAST_MUTEX HardwareMessageQueueLock;
|
static KMUTEX HardwareMessageQueueLock;
|
||||||
|
|
||||||
static KEVENT HardwareMessageEvent;
|
static KEVENT HardwareMessageEvent;
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ MsqInitializeImpl(VOID)
|
||||||
InitializeListHead(&HardwareMessageQueueHead);
|
InitializeListHead(&HardwareMessageQueueHead);
|
||||||
KeInitializeEvent(&HardwareMessageEvent, NotificationEvent, 0);
|
KeInitializeEvent(&HardwareMessageEvent, NotificationEvent, 0);
|
||||||
KeInitializeSpinLock(&SystemMessageQueueLock);
|
KeInitializeSpinLock(&SystemMessageQueueLock);
|
||||||
ExInitializeFastMutex(&HardwareMessageQueueLock);
|
KeInitializeMutex(&HardwareMessageQueueLock, 0);
|
||||||
|
|
||||||
ExInitializePagedLookasideList(&MessageLookasideList,
|
ExInitializePagedLookasideList(&MessageLookasideList,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -212,18 +212,18 @@ MsqIsDblClk(PWINDOW_OBJECT Window, PUSER_MESSAGE Message, BOOL Remove)
|
||||||
|
|
||||||
Res = (dX <= CurInfo->DblClickWidth) &&
|
Res = (dX <= CurInfo->DblClickWidth) &&
|
||||||
(dY <= CurInfo->DblClickHeight);
|
(dY <= CurInfo->DblClickHeight);
|
||||||
|
}
|
||||||
|
|
||||||
if(Remove)
|
if(Remove)
|
||||||
|
{
|
||||||
|
if (Res)
|
||||||
{
|
{
|
||||||
CurInfo->LastBtnDown = 0;
|
CurInfo->LastBtnDown = 0;
|
||||||
CurInfo->LastBtnDownX = Message->Msg.pt.x;
|
CurInfo->LastBtnDownX = Message->Msg.pt.x;
|
||||||
CurInfo->LastBtnDownY = Message->Msg.pt.y;
|
CurInfo->LastBtnDownY = Message->Msg.pt.y;
|
||||||
CurInfo->LastClkWnd = NULL;
|
CurInfo->LastClkWnd = NULL;
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else
|
|
||||||
{
|
|
||||||
if(Remove)
|
|
||||||
{
|
{
|
||||||
CurInfo->LastBtnDownX = Message->Msg.pt.x;
|
CurInfo->LastBtnDownX = Message->Msg.pt.x;
|
||||||
CurInfo->LastBtnDownY = Message->Msg.pt.y;
|
CurInfo->LastBtnDownY = Message->Msg.pt.y;
|
||||||
|
@ -436,6 +436,8 @@ MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd,
|
||||||
BOOL MouseClick;
|
BOOL MouseClick;
|
||||||
PLIST_ENTRY CurrentEntry;
|
PLIST_ENTRY CurrentEntry;
|
||||||
PWINDOW_OBJECT DesktopWindow;
|
PWINDOW_OBJECT DesktopWindow;
|
||||||
|
PVOID WaitObjects[2];
|
||||||
|
NTSTATUS WaitStatus;
|
||||||
|
|
||||||
if( !IntGetScreenDC() ||
|
if( !IntGetScreenDC() ||
|
||||||
PsGetWin32Thread()->MessageQueue == W32kGetPrimitiveMessageQueue() )
|
PsGetWin32Thread()->MessageQueue == W32kGetPrimitiveMessageQueue() )
|
||||||
|
@ -479,7 +481,19 @@ MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd,
|
||||||
ExReleaseFastMutex(&MessageQueue->HardwareLock);
|
ExReleaseFastMutex(&MessageQueue->HardwareLock);
|
||||||
|
|
||||||
/* Now try the global queue. */
|
/* Now try the global queue. */
|
||||||
ExAcquireFastMutex(&HardwareMessageQueueLock);
|
WaitObjects[1] = &MessageQueue->NewMessages;
|
||||||
|
WaitObjects[0] = &HardwareMessageQueueLock;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
WaitStatus = KeWaitForMultipleObjects(2, WaitObjects, WaitAny, UserRequest,
|
||||||
|
UserMode, TRUE, NULL, NULL);
|
||||||
|
while (MsqDispatchOneSentMessage(MessageQueue))
|
||||||
|
{
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (NT_SUCCESS(WaitStatus) && STATUS_WAIT_0 != WaitStatus);
|
||||||
|
|
||||||
/* Transfer all messages from the DPC accessible queue to the main queue. */
|
/* Transfer all messages from the DPC accessible queue to the main queue. */
|
||||||
KeAcquireSpinLock(&SystemMessageQueueLock, &OldIrql);
|
KeAcquireSpinLock(&SystemMessageQueueLock, &OldIrql);
|
||||||
while (SystemMessageQueueCount > 0)
|
while (SystemMessageQueueCount > 0)
|
||||||
|
@ -521,13 +535,11 @@ MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd,
|
||||||
Current->Msg.message <= WM_MOUSELAST)
|
Current->Msg.message <= WM_MOUSELAST)
|
||||||
{
|
{
|
||||||
const ULONG ActiveStamp = HardwareMessageQueueStamp;
|
const ULONG ActiveStamp = HardwareMessageQueueStamp;
|
||||||
ExReleaseFastMutex(&HardwareMessageQueueLock);
|
|
||||||
/* Translate the message. */
|
/* Translate the message. */
|
||||||
Accept = MsqTranslateMouseMessage(hWnd, FilterLow, FilterHigh,
|
Accept = MsqTranslateMouseMessage(hWnd, FilterLow, FilterHigh,
|
||||||
Current, Remove, &Freed,
|
Current, Remove, &Freed,
|
||||||
DesktopWindow, &HitTest,
|
DesktopWindow, &HitTest,
|
||||||
&ScreenPoint, &MouseClick, TRUE);
|
&ScreenPoint, &MouseClick, TRUE);
|
||||||
ExAcquireFastMutex(&HardwareMessageQueueLock);
|
|
||||||
if (Accept)
|
if (Accept)
|
||||||
{
|
{
|
||||||
/* Check for no more messages in the system queue. */
|
/* Check for no more messages in the system queue. */
|
||||||
|
@ -550,7 +562,7 @@ MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd,
|
||||||
&Current->ListEntry);
|
&Current->ListEntry);
|
||||||
ExReleaseFastMutex(&MessageQueue->HardwareLock);
|
ExReleaseFastMutex(&MessageQueue->HardwareLock);
|
||||||
}
|
}
|
||||||
ExReleaseFastMutex(&HardwareMessageQueueLock);
|
KeReleaseMutex(&HardwareMessageQueueLock, FALSE);
|
||||||
*Message = Current;
|
*Message = Current;
|
||||||
IntReleaseWindowObject(DesktopWindow);
|
IntReleaseWindowObject(DesktopWindow);
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
|
@ -570,7 +582,7 @@ MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd,
|
||||||
KeClearEvent(&HardwareMessageEvent);
|
KeClearEvent(&HardwareMessageEvent);
|
||||||
}
|
}
|
||||||
KeReleaseSpinLock(&SystemMessageQueueLock, OldIrql);
|
KeReleaseSpinLock(&SystemMessageQueueLock, OldIrql);
|
||||||
ExReleaseFastMutex(&HardwareMessageQueueLock);
|
KeReleaseMutex(&HardwareMessageQueueLock, FALSE);
|
||||||
|
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue