*** /tmp/,RCSt1009912 Sun Nov 25 23:09:30 1990 --- charproc.c Sun Nov 25 23:08:08 1990 *************** *** 1038,1043 **** --- 1038,1050 ---- static int select_mask; static int write_mask; + #ifdef XCONS + /* The XCONS feature is described below. */ + static int con_mask = 0; /* mask for /dev/xcons reading -IAN! */ + static int con_fd = -1; /* fd to read from /dev/xcons -IAN! */ + extern int Console; /* -C option set on command line */ + #endif + static char v_buffer[4096]; static char *v_bufstr; static char *v_bufptr; *************** *** 1124,1129 **** --- 1131,1174 ---- static struct timeval trackTimeOut; select_mask = pty_mask; /* force initial read */ + + #ifdef XCONS + /* DEC /dev/xcons device reading to get /dev/console messages. + * This is *essential* to avoid messing up Qdss displays. + * This first part opens and adds it to the select() mask. + * -IAN! + */ + #ifdef SIGNALRETURNSINT + #define SIGNAL_T int + #else + #define SIGNAL_T void + #endif + if( Console && con_mask == 0 ) { + extern jmp_buf env; /* in main.c */ + extern SIGNAL_T hungtty(); /* in main.c */ + + if( con_fd >= 0 ) + close(con_fd); + con_fd = -1; + signal(SIGALRM, hungtty); + alarm(3); /* alarm(1) might return too soon */ + if (! setjmp(env)) + con_fd = open("/dev/xcons",O_RDONLY|O_NDELAY,0); + alarm(0); + signal(SIGALRM, SIG_DFL); + if( con_fd >= 0 ){ + if( max_plus1 <= con_fd ) + max_plus1 = con_fd + 1; + con_mask = 1 << con_fd; + Select_mask |= con_mask; + } + else { + perror("xterm: /dev/xcons"); + Console = 0; /* don't try again */ + } + } + #endif + for( ; ; ) { #ifdef CRAY trackTimeOut.tv_sec = 0; *************** *** 1208,1213 **** --- 1253,1278 ---- if (bcnt > 0) break; } + #ifdef XCONS + /* No user stuff to handle -- see what the console is doing. + * Thus, console output appears *after* user output. + * I think this is okay. -IAN! + */ + if( (select_mask & con_mask) ){ + int ret; + if((ret = read(con_fd, bptr=buffer, BUF_SIZE)) <= 0){ + perror("xterm: /dev/xcons"); + close(con_fd); + /* it will be re-opened later */ + con_fd = -1; + con_mask = 0; + } + else { + bcnt = ret; + break; + } + } + #endif } bcnt--; return(*bptr++); *************** *** 1276,1281 **** --- 1341,1363 ---- ptr += n; } } + + #ifdef ZICONBEEP + /* Flag icon name with "***" on window output when iconified. + * I'd like to do something like reverse video, but I don't + * know how to tell this to window managers in general. + * + * mapstate can be IsUnmapped, !IsUnmapped, or -1; + * -1 means no change; the other two are set by event handlers + * and indicate a new mapstate. !IsMapped is done in the handler. + * we worry about IsUnmapped when output occurs. We also try to + * flag the window when it isn't fully visible. -IAN! + */ + static int mapstate = -1; /* current mapping state */ + static int visistate = -1; /* current visibility state */ + #include + extern Widget toplevel; + #endif /*ZICONBEEP*/ /* * write a string str of length len onto the screen at *************** *** 1341,1349 **** ++ntotal; } } ! ScreenWrite(screen, str, flags, len); ! CursorForward(screen, len); } /* * process ANSI modes set, reset --- 1423,1511 ---- ++ntotal; } } ! ScreenWrite(screen, str, flags, len); ! CursorForward(screen, len); ! ! #ifdef ZICONBEEP ! /* Flag icon name with "***" on window output when iconified. ! * Also flag when fully or partially obscured. ! */ ! { ! extern int zIconBeep; ! extern int zFullyBeep; ! extern int zPartiallyBeep; ! if( (zIconBeep != 0 && mapstate == IsUnmapped) ! || ! (zFullyBeep != 0 && visistate == VisibilityFullyObscured) ! || ! (zPartiallyBeep != 0 && visistate == VisibilityPartiallyObscured) ! ){ ! static char *icon_name; ! static Arg args[] = { ! { XtNiconName, (XtArgVal) &icon_name } ! }; ! ! icon_name = NULL; ! XtGetValues(toplevel,args,XtNumber(args)); ! ! if( icon_name != NULL ){ ! if( strncmp(icon_name,"*** ",4) != 0 ){ ! char newname[1024]; ! strcpy(newname,"*** "); ! strcat(newname,icon_name); ! Changename(newname); ! } ! } ! XBell( XtDisplay(toplevel), zIconBeep ); ! } ! } ! mapstate = -1; ! visistate = -1; ! #endif /*ZICONBEEP*/ } + + #ifdef ZICONBEEP + /* Flag icon name with "***" on window output when iconified. + * Also flag when fully or partially obscured. + */ + static void HandleMapUnmapVisible(w, client_data, event ) + Widget w; + caddr_t client_data; + XEvent *event; + { + static char *icon_name; + static Arg args[] = { + { XtNiconName, (XtArgVal) &icon_name } + }; + + #ifdef DEBUG + if(debug) + fprintf(stderr,"HandleMapUnmapVisible event %d\n", event->type); + #endif + + switch( event->type ){ + case VisibilityNotify: + visistate = ((XVisibilityEvent *) event)->state; + if( visistate == VisibilityUnobscured ){ + icon_name = NULL; + XtGetValues(toplevel,args,XtNumber(args)); + if( icon_name != NULL && strncmp(icon_name,"*** ",4) == 0 ) + Changename((icon_name)+4); + } + break; + case MapNotify: + icon_name = NULL; + XtGetValues(toplevel,args,XtNumber(args)); + if( icon_name != NULL && strncmp(icon_name,"*** ",4) == 0 ) + Changename((icon_name)+4); + mapstate = !IsUnmapped; + break; + case UnmapNotify: + mapstate = IsUnmapped; + break; + } + } + #endif /*ZICONBEEP*/ /* * process ANSI modes set, reset *************** *** 2054,2059 **** --- 2216,2237 ---- HandleFocusChange, (Opaque)NULL); XtAddEventHandler(new, 0L, TRUE, VTNonMaskableEvent, (Opaque)NULL); + #ifdef ZICONBEEP + /* Flag icon name with "***" on window output when iconified. + * Also flag when fully or partially obscured. + * Put in a handler that will tell us when we get + * Map/Unmap/Visibility events. + */ + {extern void HandleMapUnmapVisible(); + extern int zIconBeep; + extern int zFullyBeep; + extern int zPartiallyBeep; + if( zIconBeep != 0 || zFullyBeep != 0 || zPartiallyBeep != 0 ) + XtAddEventHandler(XtParent(new), + VisibilityChangeMask|StructureNotifyMask, FALSE, + HandleMapUnmapVisible, (Opaque)NULL); + } + #endif /*ZICONBEEP*/ set_character_class (new->screen.charClass); *** /tmp/,RCSt1010613 Sun Nov 25 23:21:39 1990 --- main.c Sun Nov 25 23:20:51 1990 *************** *** 308,323 **** static int inhibit; static char passedPty[2]; /* name if pty if slave */ ! #ifdef TIOCCONS ! static int Console; #endif /* TIOCCONS */ #ifndef USE_SYSV_UTMP static int tslot; #endif /* USE_SYSV_UTMP */ - static jmp_buf env; char *ProgramName; Boolean sunFunctionKeys; static struct _resource { char *xterm_name; --- 308,328 ---- static int inhibit; static char passedPty[2]; /* name if pty if slave */ ! #if defined(TIOCCONS) || defined(XCONS) ! int Console; /* also used in charproc.c -IAN! */ #endif /* TIOCCONS */ #ifndef USE_SYSV_UTMP static int tslot; #endif /* USE_SYSV_UTMP */ + jmp_buf env; /* also used in charproc.c -IAN! */ char *ProgramName; Boolean sunFunctionKeys; + #ifdef ZICONBEEP /* see charproc.c for details -IAN! */ + int zIconBeep; /* beep level when output while iconified */ + int zFullyBeep; /* beep level when output FullyObscured */ + int zPartiallyBeep; /* beep level when output PartiallyObscured */ + #endif /*ZICONBEEP*/ static struct _resource { char *xterm_name; *************** *** 329,334 **** --- 334,344 ---- Boolean utmpInhibit; Boolean sunFunctionKeys; /* %%% should be widget resource? */ Boolean wait_for_map; + #ifdef ZICONBEEP /* see charproc.c for details -IAN! */ + int zIconBeep; /* beep level when output while iconified */ + int zFullyBeep; /* beep level when output FullyObscured */ + int zPartiallyBeep; /* beep level when output PartiallyObscured */ + #endif /*ZICONBEEP*/ } resource; /* used by VT (charproc.c) */ *************** *** 354,359 **** --- 364,377 ---- offset(sunFunctionKeys), XtRString, "false"}, {"waitForMap", "WaitForMap", XtRBoolean, sizeof (Boolean), offset(wait_for_map), XtRString, "false"}, + #ifdef ZICONBEEP /* see charproc.c for details -IAN! */ + {"zIconBeep", "ZIconBeep", XtRInt, sizeof (int), + offset(zIconBeep), XtRImmediate, 0}, + {"zFullyBeep", "ZFullyBeep", XtRInt, sizeof (int), + offset(zFullyBeep), XtRImmediate, 0}, + {"zPartiallyBeep", "ZPartiallyBeep", XtRInt, sizeof (int), + offset(zPartiallyBeep), XtRImmediate, 0}, + #endif /*ZICONBEEP*/ }; #undef offset *************** *** 424,429 **** --- 442,452 ---- {"+vb", "*visualBell", XrmoptionNoArg, (caddr_t) "off"}, {"-wf", "*waitForMap", XrmoptionNoArg, (caddr_t) "on"}, {"+wf", "*waitForMap", XrmoptionNoArg, (caddr_t) "off"}, + #ifdef ZICONBEEP /* see charproc.c for details -IAN! */ + {"-ziconbeep", "*zIconBeep", XrmoptionSepArg, (caddr_t) NULL}, + {"-zfullybeep", "*zFullyBeep", XrmoptionSepArg, (caddr_t) NULL}, + {"-zpartiallybeep", "*zPartiallyBeep", XrmoptionSepArg, (caddr_t) NULL}, + #endif /*ZICONBEEP*/ /* bogus old compatibility stuff for which there are standard XtInitialize options now */ {"%", "*tekGeometry", XrmoptionStickyArg, (caddr_t) NULL}, *************** *** 490,495 **** --- 513,523 ---- { "-n string", "icon name for window" }, { "-C", "intercept console messages, if supported" }, { "-Sxxd", "slave mode on \"ttyxx\", file descriptor \"d\"" }, + #ifdef ZICONBEEP /* see charproc.c for details -IAN! */ + { "-ziconbeep", "beep & flag icon of window with hidden output" }, + { "-zfullybeep", "beep & flag icon of FullyObscured window" }, + { "-zpartiallybeep", "beep & flag icon of PartiallyObscured window" }, + #endif /*ZICONBEEP*/ { NULL, NULL }}; static char *message[] = { *************** *** 696,701 **** --- 724,734 ---- xterm_name = resource.xterm_name; sunFunctionKeys = resource.sunFunctionKeys; + #ifdef ZICONBEEP /* see charproc.c for details -IAN! */ + zIconBeep = resource.zIconBeep; + zFullyBeep = resource.zFullyBeep; + zPartiallyBeep = resource.zPartiallyBeep; + #endif /*ZICONBEEP*/ if (strcmp(xterm_name, "-") == 0) xterm_name = "xterm"; if (resource.icon_geometry != NULL) { int scr, junk; *************** *** 728,734 **** Help (); /* NOTREACHED */ case 'C': ! #ifdef TIOCCONS Console = TRUE; #endif /* TIOCCONS */ continue; --- 761,767 ---- Help (); /* NOTREACHED */ case 'C': ! #if defined(TIOCCONS) || defined(XCONS) Console = TRUE; #endif /* TIOCCONS */ continue;