[NTUSER] Fix PeekMessageA for MsgFilterLow/High mouse clicks (#6427)
authorDoug Lyons <douglyons@douglyons.com>
Mon, 11 Mar 2024 13:34:34 +0000 (08:34 -0500)
committerGitHub <noreply@github.com>
Mon, 11 Mar 2024 13:34:34 +0000 (14:34 +0100)
Fix MSO and Word Viewer not closing when "X" on title bar is clicked.
This is another @I_Kill_Bugs patch.

CORE-14436 , CORE-16985

win32ss/user/ntuser/msgqueue.c

index c8ae61a..b704dbc 100644 (file)
@@ -1986,8 +1986,7 @@ co_MsqPeekHardwareMessage(IN PTHREADINFO pti,
             ( Window == PWND_BOTTOM && CurrentMessage->Msg.hwnd == NULL ) || // 2
             ( Window != PWND_BOTTOM && UserHMGetHandle(Window) == CurrentMessage->Msg.hwnd ) || // 3
             ( is_mouse_message(CurrentMessage->Msg.message) ) ) && // Null window for anything mouse.
-            ( ( ( MsgFilterLow == 0 && MsgFilterHigh == 0 ) && CurrentMessage->QS_Flags & QSflags ) ||
-              ( MsgFilterLow <= CurrentMessage->Msg.message && MsgFilterHigh >= CurrentMessage->Msg.message ) ) )
+            ( CurrentMessage->QS_Flags & QSflags ) )
       {
          idSave = MessageQueue->idSysPeek;
          MessageQueue->idSysPeek = (ULONG_PTR)CurrentMessage;
@@ -2000,6 +1999,13 @@ co_MsqPeekHardwareMessage(IN PTHREADINFO pti,
 
          UpdateKeyStateFromMsg(MessageQueue, &msg);
          AcceptMessage = co_IntProcessHardwareMessage(&msg, &Remove, &NotForUs, ExtraInfo, MsgFilterLow, MsgFilterHigh);
+         
+         if (MsgFilterLow != 0 || MsgFilterHigh != 0)
+         {
+             /* Don't return message if not in range */
+             if (msg.message < MsgFilterLow || msg.message > MsgFilterHigh)
+                 AcceptMessage = FALSE;
+         }
 
          if (Remove)
          {