changeset 923:3b122a8e1d51

[xemacs-hg @ 2002-07-14 23:20:35 by mta] event-msw.c (mswindows_need_event): Don't wait for a new message if the queue is not empty. Suggested by Paul Moore.
author mta
date Sun, 14 Jul 2002 23:20:36 +0000
parents 0288e82c84b3
children 1b114504fa80
files src/ChangeLog src/event-msw.c
diffstat 2 files changed, 23 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Sun Jul 14 23:09:40 2002 +0000
+++ b/src/ChangeLog	Sun Jul 14 23:20:36 2002 +0000
@@ -1,3 +1,8 @@
+2002-07-14  Mike Alexander  <mta@arbortext.com>
+
+	* event-msw.c (mswindows_need_event): Don't wait for a new message
+	if the queue is not empty.  Suggested by Paul Moore.
+
 2002-07-08  Stephen J. Turnbull  <stephen@xemacs.org>
 
 	* lisp.h: Declare Fcdr_safe to be callable from C.
--- a/src/event-msw.c	Sun Jul 14 23:09:40 2002 +0000
+++ b/src/event-msw.c	Sun Jul 14 23:20:36 2002 +0000
@@ -1622,10 +1622,24 @@
 
       __try
 	{
-	  active = MsgWaitForMultipleObjects (mswindows_waitable_count,
-					      mswindows_waitable_handles,
-					      FALSE, badly_p ? INFINITE : 0,
-					      what_events);
+	  /* This fixes a long outstanding bug, where XEmacs would occasionally
+	   * not redraw its window (or process other events) until "something
+	   * happened" - usually the mouse moving over a frame.
+	   *
+	   * The problem is that MsgWaitForMultipleObjects only checks to see
+	   * if NEW messages have been placed into the thread queue. So we
+	   * specifically check to see if the queue is empty (using PeekMessage
+	   * with the PM_NOREMOVE flag) before we wait.
+	   */
+	  MSG msg;
+	  if (what_events == QS_ALLINPUT && badly_p &&
+	      qxePeekMessage (&msg, 0, 0, 0, PM_NOREMOVE))
+	    active = WAIT_OBJECT_0 + mswindows_waitable_count;
+	  else
+	    active = MsgWaitForMultipleObjects (mswindows_waitable_count,
+						mswindows_waitable_handles,
+						FALSE, badly_p ? INFINITE : 0,
+						what_events);
 	}
       __except (GetExceptionCode () == EXCEPTION_BREAKPOINT ?
 		EXCEPTION_CONTINUE_EXECUTION :