*** Tekproc.c.orig Tue Apr 13 13:59:51 1993 --- Tekproc.c Tue Apr 13 15:11:01 1993 *************** *** 1,5 **** /* ! * $XConsortium: Tekproc.c,v 1.107 91/06/25 19:49:48 gildea Exp $ * * Warning, there be crufty dragons here. */ --- 1,5 ---- /* ! * $XConsortium: Tekproc.c,v 1.107 91/06/25 19:49:48 diff Exp $ * * Warning, there be crufty dragons here. */ *************** *** 145,150 **** --- 145,152 ---- extern int Tpttable[]; extern int Tspttable[]; + extern XtAppContext app_con; + static int *curstate = Talptable; static int *Tparsestate = Talptable; *************** *** 595,601 **** TekGINoff(); TCursorDown(); if (!TekRefresh && ! (QLength(screen->display) > 0 || GetBytesAvailable (ConnectionNumber(screen->display)) > 0)) xevents(); break; --- 597,603 ---- TekGINoff(); TCursorDown(); if (!TekRefresh && ! (XtAppPending(app_con) || GetBytesAvailable (ConnectionNumber(screen->display)) > 0)) xevents(); break; *************** *** 695,701 **** TCursorToggle(TOGGLE); Ttoggled = FALSE; } ! if(QLength(screen->display)) Tselect_mask = X_mask; else { XFlush(screen->display); --- 697,703 ---- TCursorToggle(TOGGLE); Ttoggled = FALSE; } ! if(XtAppPending(app_con) & XtIMXEvent) Tselect_mask = X_mask; else { XFlush(screen->display); *** charproc.c.orig Tue Apr 13 13:59:58 1993 --- charproc.c Tue Apr 13 15:11:08 1993 *************** *** 1,5 **** /* ! * $XConsortium: charproc.c,v 1.176 92/03/13 18:00:30 gildea Exp $ */ /* --- 1,5 ---- /* ! * $XConsortium: charproc.c,v 1.176 92/03/13 18:00:30 diff Exp $ */ /* *************** *** 64,69 **** --- 64,70 ---- extern jmp_buf VTend; + extern XtAppContext app_con; extern Widget toplevel; extern void exit(); extern char *malloc(); *************** *** 608,614 **** Index(screen, 1); if (term->flags & LINEFEED) CarriageReturn(screen); ! if (QLength(screen->display) > 0 || GetBytesAvailable (ConnectionNumber(screen->display)) > 0) xevents(); parsestate = groundtable; --- 609,615 ---- Index(screen, 1); if (term->flags & LINEFEED) CarriageReturn(screen); ! if (XtAppPending(app_con) || GetBytesAvailable (ConnectionNumber(screen->display)) > 0) xevents(); parsestate = groundtable; *************** *** 984,990 **** case CASE_IND: /* IND */ Index(screen, 1); ! if (QLength(screen->display) > 0 || GetBytesAvailable (ConnectionNumber(screen->display)) > 0) xevents(); parsestate = groundtable; --- 985,991 ---- case CASE_IND: /* IND */ Index(screen, 1); ! if (XtAppPending(app_con) || GetBytesAvailable (ConnectionNumber(screen->display)) > 0) xevents(); parsestate = groundtable; *************** *** 995,1001 **** Index(screen, 1); CarriageReturn(screen); ! if (QLength(screen->display) > 0 || GetBytesAvailable (ConnectionNumber(screen->display)) > 0) xevents(); parsestate = groundtable; --- 996,1002 ---- Index(screen, 1); CarriageReturn(screen); ! if (XtAppPending(app_con) || GetBytesAvailable (ConnectionNumber(screen->display)) > 0) xevents(); parsestate = groundtable; *************** *** 1303,1317 **** XFlush(screen->display); /* always flush writes before waiting */ ! /* Update the masks and, unless X events are already in the queue, ! wait for I/O to be possible. */ select_mask = Select_mask; write_mask = ptymask(); select_timeout.tv_sec = 0; ! select_timeout.tv_usec = 0; ! i = select(max_plus1, &select_mask, &write_mask, (int *)NULL, ! QLength(screen->display) ? &select_timeout ! : (struct timeval *) NULL); if (i < 0) { if (errno != EINTR) SysError(ERROR_SELECT); --- 1304,1329 ---- XFlush(screen->display); /* always flush writes before waiting */ ! /* ! * Update the masks and, unless X events are already in the ! * queue, wait for I/O to be possible. ! */ select_mask = Select_mask; write_mask = ptymask(); select_timeout.tv_sec = 0; ! /* ! * if there's either an XEvent or an XtTimeout pending, just take ! * a quick peek, i.e. timeout from the select() immediately. If ! * there's nothing pending, let select() block a little while, but ! * for a shorter interval than the arrow-style scrollbar timeout. ! */ ! if (XtAppPending(app_con)) ! select_timeout.tv_usec = 0; ! else ! select_timeout.tv_usec = 50000; ! i = select(max_plus1, ! &select_mask, &write_mask, (int *)NULL, ! select_timeout); if (i < 0) { if (errno != EINTR) SysError(ERROR_SELECT); *************** *** 1325,1331 **** /* if there are X events already in our queue, it counts as being readable */ ! if (QLength(screen->display) || (select_mask & X_mask)) { xevents(); } --- 1337,1343 ---- /* if there are X events already in our queue, it counts as being readable */ ! if (XtAppPending(app_con) || (select_mask & X_mask)) { xevents(); } *************** *** 2241,2247 **** /* make sure that the resize gravity acceptable */ if ( new->misc.resizeGravity != NorthWestGravity && new->misc.resizeGravity != SouthWestGravity) { - extern XtAppContext app_con; Cardinal nparams = 1; XtAppWarningMsg(app_con, "rangeError", "resizeGravity", "XTermError", --- 2253,2258 ---- *************** *** 2681,2687 **** * (screen->max_row + 1) + 2 * screen->border, &junk, &junk); XSync(screen->display, FALSE); /* synchronize */ ! if(QLength(screen->display) > 0) xevents(); } CursorSet(screen, 0, 0, term->flags); --- 2692,2698 ---- * (screen->max_row + 1) + 2 * screen->border, &junk, &junk); XSync(screen->display, FALSE); /* synchronize */ ! if(XtAppPending(app_con)) xevents(); } CursorSet(screen, 0, 0, term->flags); *** main.c.orig Tue Apr 13 13:39:50 1993 --- main.c Tue Apr 13 15:11:20 1993 *************** *** 1,5 **** #ifndef lint ! static char *rid="$XConsortium: main.c,v 1.200 92/03/11 17:36:12 gildea Exp $"; #endif /* lint */ /* --- 1,5 ---- #ifndef lint ! static char *rid="$XConsortium: main.c,v 1.200 92/03/11 17:36:12 dif Exp $"; #endif /* lint */ /* *************** *** 176,181 **** --- 176,185 ---- #define ttyslot() 1 #endif /* apollo */ + #ifdef sun + #include + #endif + #include #ifdef LASTLOG #include *************** *** 2893,2907 **** int fd; { #ifdef FIONREAD ! static long arg; ioctl (fd, FIONREAD, (char *) &arg); return (int) arg; #else struct pollfd pollfds[1]; pollfds[0].fd = fd; pollfds[0].events = POLLIN; return poll (pollfds, 1, 0); #endif } --- 2897,2915 ---- int fd; { #ifdef FIONREAD ! long arg; ioctl (fd, FIONREAD, (char *) &arg); return (int) arg; #else + #ifdef FIORDCK + return (ioctl (fd, FIORDCHK, NULL)); + #else struct pollfd pollfds[1]; pollfds[0].fd = fd; pollfds[0].events = POLLIN; return poll (pollfds, 1, 0); + #endif #endif } *** misc.c.orig Tue Apr 13 13:17:42 1993 --- misc.c Tue Apr 13 15:11:39 1993 *************** *** 1,5 **** /* ! * $XConsortium: misc.c,v 1.92 92/03/13 17:02:08 gildea Exp $ */ /* --- 1,5 ---- /* ! * $XConsortium: misc.c,v 1.92 92/03/13 17:02:08 diff Exp $ */ /* *************** *** 63,83 **** static void DoSpecialEnterNotify(); static void DoSpecialLeaveNotify(); xevents() { XEvent event; register TScreen *screen = &term->screen; - extern XtAppContext app_con; if(screen->scroll_amt) FlushScroll(screen); ! if (!XPending (screen->display)) ! /* protect against events/errors being swallowed by us or Xlib */ ! return; do { if (waitingForTrackInfo) return; ! XNextEvent (screen->display, &event); /* * Hack to get around problems with the toolkit throwing away * eventing during the exclusive grab of the menu popup. By --- 63,95 ---- static void DoSpecialEnterNotify(); static void DoSpecialLeaveNotify(); + extern XtAppContext app_con; + xevents() { XEvent event; + XtInputMask input_mask; register TScreen *screen = &term->screen; if(screen->scroll_amt) FlushScroll(screen); ! /* ! * process timeouts, relying on the fact that XtAppProcessEvent ! * will process the timeout and return without blockng on the ! * XEvent queue. Other sources i.e. the pty are handled elsewhere ! * with select(). ! */ ! while ((input_mask = XtAppPending(app_con)) & XtIMTimer) ! XtAppProcessEvent(app_con, XtIMTimer); ! /* ! * If there's no XEvents, don't wait around... ! */ ! if ((input_mask & XtIMXEvent) != XtIMXEvent) ! return; do { if (waitingForTrackInfo) return; ! XtAppNextEvent (app_con, &event); /* * Hack to get around problems with the toolkit throwing away * eventing during the exclusive grab of the menu popup. By *************** *** 103,109 **** (event.xany.type != ButtonPress) && (event.xany.type != ButtonRelease))) XtDispatchEvent(&event); ! } while (QLength(screen->display) > 0); } --- 115,121 ---- (event.xany.type != ButtonPress) && (event.xany.type != ButtonRelease))) XtDispatchEvent(&event); ! } while ((input_mask = XtAppPending(app_con)) & XtIMXEvent); } *************** *** 321,327 **** the bell again? */ if(screen->bellSuppressTime) { if(screen->bellInProgress) { ! if (QLength(screen->display) > 0 || GetBytesAvailable (ConnectionNumber(screen->display)) > 0) xevents(); if(screen->bellInProgress) { /* even after new events? */ --- 333,339 ---- the bell again? */ if(screen->bellSuppressTime) { if(screen->bellInProgress) { ! if (XtAppPending(app_con) || GetBytesAvailable (ConnectionNumber(screen->display)) > 0) xevents(); if(screen->bellInProgress) { /* even after new events? */