/* -*-C-*-
-$Id: ntscreen.c,v 1.28 1997/04/03 04:41:04 cph Exp $
+$Id: ntscreen.c,v 1.29 1997/05/17 07:00:14 cph Exp $
Copyright (c) 1993-97 Massachusetts Institute of Technology
*event = screen->queue_head->event;
return TRUE;
}
+
+BOOL
+Screen_pending_events_p (void)
+{
+ SCREEN screen = registered_screens;
+ while (screen)
+ {
+ if ((screen -> n_events) != 0)
+ return (TRUE);
+ screen = (screen -> registry_link);
+ }
+ return (FALSE);
+}
\f
//---------------------------------------------------------------------------
/* -*-C-*-
-$Id: ntscreen.h,v 1.14 1997/04/03 04:40:53 cph Exp $
+$Id: ntscreen.h,v 1.15 1997/05/17 06:59:56 cph Exp $
Copyright (c) 1993-97 Massachusetts Institute of Technology
// The following return false on no events
extern BOOL Screen_GetEvent (HANDLE, SCREEN_EVENT *);
extern BOOL Screen_PeekEvent (HANDLE, SCREEN_EVENT *);
+extern BOOL Screen_pending_events_p (void);
//---------------------------------------------------------------------------
// Messages
/* -*-C-*-
-$Id: prntio.c,v 1.5 1997/04/03 04:41:15 cph Exp $
+$Id: prntio.c,v 1.6 1997/05/17 07:00:23 cph Exp $
Copyright (c) 1993-97 Massachusetts Institute of Technology
{
DWORD result;
MSG m;
- /* This is a kludge. MsgWaitForMultipleObjects has a race
- condition -- it ignores messages that are already queued. So
- check the queue as late as possible before the call, in order
- to minimize the window in which we can get stuck waiting for
- a message that has already arrived. */
#ifdef TRACE_SCREEN_MSGS
fprintf (trace_file, "MsgWaitForMultipleObjects: timeout=0x%x\n", timeout);
fflush (trace_file);
#endif
- if (msgp && (PeekMessage ((&m), 0, 0, 0, PM_NOREMOVE)))
- return (((m.message) == WM_SCHEME_INTERRUPT) ? (nhand + 2) : (nhand + 1));
+ if (msgp)
+ {
+ if (Screen_pending_events_p ())
+ return (nhand + 1);
+ /* This is a kludge. MsgWaitForMultipleObjects has a race
+ condition -- it ignores messages that are already queued. So
+ check the queue as late as possible before the call, in order
+ to minimize the window in which we can get stuck waiting for
+ a message that has already arrived. */
+ if (PeekMessage ((&m), 0, 0, 0, PM_NOREMOVE))
+ return (((m.message) == WM_SCHEME_INTERRUPT)
+ ? (nhand + 2)
+ : (nhand + 1));
+ }
result =
(MsgWaitForMultipleObjects (nhand, handles, FALSE, timeout, QS_ALLINPUT));
#ifdef TRACE_SCREEN_MSGS