Path: watdragon!watmath!watserv1!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!mcsun!cernvax!chx400!sicsun!sic!brossard From: brossard@sic.epfl.ch (Alain Brossard EPFL-SIC/SII) Newsgroups: comp.windows.x Subject: xterm, new options to prevent flicker and add a warning while iconified Message-ID: <1795@sicsun.epfl.ch> Date: 2 Oct 91 14:10:29 GMT Sender: news@sicsun.epfl.ch Lines: 392 VERSION: xterm R5, public-patch-3 This patch addresses two different issues: 1- When the title or icon name are changed frequently but the string stays the same, flicker is induced on the screen. This flicker can be annoying. I added a switch (-samename) and a resource that enable a check and if the string is the same, no change request are sent to the server. 2- It is often useful to be warned when output occurs in a window which is iconified. Using code from Ian! (idallen@watcgl.uwaterloo.ca), I added a switch (-ziconbeep) and a related resource which tells xterm to add "*** " to the icon name when output is received while the window is iconified. I also added code to correctly take care of the case when the icon name is changed while the "warning" is "active". All patches are between ifdef (ZICONBEEP and SAME_NAME) which are enabled in the Imakefile patch (also included). Files affected: charproc.c, main.c, misc.c and xterm.man. Alain Brossard brossard@sic.epfl.ch SAMPLE FIX: *** /tmp/,RCSt1a15124 Wed Oct 2 14:52:44 1991 --- charproc.c Wed Oct 2 14:51:53 1991 *************** *** 1402,1407 **** --- 1402,1421 ---- } } + #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. -IAN! + */ + static int mapstate = -1; + #include + extern Widget toplevel; + #endif /*ZICONBEEP*/ /* * write a string str of length len onto the screen at * the current cursor position. update cursor position. *************** *** 1469,1476 **** --- 1483,1549 ---- } ScreenWrite(screen, str, flags, len); CursorForward(screen, len); + #ifdef ZICONBEEP + /* Flag icon name with "***" on window output when iconified. + */ + { + extern int zIconBeep; + extern Boolean zIconBeep_flagged; + if( zIconBeep && mapstate == IsUnmapped && ! zIconBeep_flagged){ + static char *icon_name; + static Arg args[] = { + { XtNiconName, (XtArgVal) &icon_name } + }; + + icon_name = NULL; + XtGetValues(toplevel,args,XtNumber(args)); + + if( icon_name != NULL ){ + zIconBeep_flagged = True; + Changename(icon_name); + } + XBell( XtDisplay(toplevel), zIconBeep ); + } + } + mapstate = -1; + #endif /*ZICONBEEP*/ } + #ifdef ZICONBEEP + /* Flag icon name with "***" on window output when iconified. + */ + static void HandleMapUnmap(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,"HandleMapUnmap event %d\n", event->type); + #endif + + switch( event->type ){ + case MapNotify: + if( zIconBeep_flagged ) { + zIconBeep_flagged = False; + icon_name = NULL; + XtGetValues(toplevel,args,XtNumber(args)); + if( icon_name != NULL ) + Changename((icon_name)+4); + } + mapstate = !IsUnmapped; + break; + case UnmapNotify: + mapstate = IsUnmapped; + break; + } + } + #endif /*ZICONBEEP*/ /* * process ANSI modes set, reset */ *************** *** 2224,2229 **** --- 2297,2313 ---- VTNonMaskableEvent, (Opaque)NULL); XtAddEventHandler((Widget)new, PropertyChangeMask, FALSE, HandleBellPropertyChange, (Opaque)NULL); + #ifdef ZICONBEEP + /* Flag icon name with "***" on window output when iconified. + * Put in a handler that will tell us when we get Map/Unmap events. + */ + {extern void HandleMapUnmap(); + extern int zIconBeep; + if( zIconBeep ) + XtAddEventHandler(XtParent(new), StructureNotifyMask, FALSE, + HandleMapUnmap, (Opaque)NULL); + } + #endif /*ZICONBEEP*/ new->screen.bellInProgress = FALSE; set_character_class (new->screen.charClass); *** /tmp/,RCSt1a15139 Wed Oct 2 14:53:50 1991 --- main.c Wed Oct 2 14:53:38 1991 *************** *** 1,7 **** #ifndef lint static char *rid="$XConsortium: main.c,v 1.195 91/07/22 12:23:31 gildea Exp $"; #endif /* lint */ - /* * W A R N I N G * --- 1,6 ---- *************** *** 414,419 **** --- 413,427 ---- char *ProgramName; Boolean sunFunctionKeys; + #ifdef ZICONBEEP + int zIconBeep; /* non-zero means beep; see charproc.c for details -IAN! */ + Boolean zIconBeep_flagged; /* True if the icon name has been changed */ + #endif /*ZICONBEEP*/ + #ifdef SAME_NAME + Boolean sameName; /* Don't change the title or icon name if it + is the same. This prevents flicker on the screen at + the cost of an extra request to the server */ + #endif /*SAME_NAME*/ static struct _resource { char *xterm_name; *************** *** 426,431 **** --- 434,447 ---- Boolean sunFunctionKeys; /* %%% should be widget resource? */ Boolean wait_for_map; Boolean useInsertMode; + #ifdef ZICONBEEP + int zIconBeep; /* beep level when output while iconified */ + #endif /*ZICONBEEP*/ + #ifdef SAME_NAME + Boolean sameName; /* Don't change the title or icon name if it + is the same. This prevents flicker on the screen at + the cost of an extra request to the server */ + #endif /*SAME_NAME*/ } resource; /* used by VT (charproc.c) */ *************** *** 453,458 **** --- 469,482 ---- offset(wait_for_map), XtRString, "false"}, {"useInsertMode", "UseInsertMode", XtRBoolean, sizeof (Boolean), offset(useInsertMode), XtRString, "false"}, + #ifdef ZICONBEEP + {"zIconBeep", "ZIconBeep", XtRInt, sizeof (int), + offset(zIconBeep), XtRImmediate, 0}, + #endif /*ZICONBEEP*/ + #ifdef SAME_NAME + {"sameName", "SameName", XtRBoolean, sizeof (Boolean), + offset(sameName), XtRString, "true"}, + #endif /*SAME_NAME*/ }; #undef offset *************** *** 527,532 **** --- 551,563 ---- {"+vb", "*visualBell", XrmoptionNoArg, (caddr_t) "off"}, {"-wf", "*waitForMap", XrmoptionNoArg, (caddr_t) "on"}, {"+wf", "*waitForMap", XrmoptionNoArg, (caddr_t) "off"}, + #ifdef ZICONBEEP + {"-ziconbeep", "*zIconBeep", XrmoptionSepArg, (caddr_t) NULL}, + #endif /*ZICONBEEP*/ + #ifdef SAME_NAME + {"-samename", "*sameName", XrmoptionNoArg, (caddr_t) "on"}, + {"+samename", "*sameName", XrmoptionNoArg, (caddr_t) "off"}, + #endif /*SAME_NAME*/ /* bogus old compatibility stuff for which there are standard XtAppInitialize options now */ {"%", "*tekGeometry", XrmoptionStickyArg, (caddr_t) NULL}, *************** *** 604,609 **** --- 635,646 ---- { "-C", "intercept console messages (not supported)" }, #endif { "-Sxxd", "slave mode on \"ttyxx\", file descriptor \"d\"" }, + #ifdef ZICONBEEP + { "-ziconbeep percent", "beep and flag icon of window having hidden output" }, + #endif /*ZICONBEEP*/ + #ifdef SAME_NAME + {"-/+sameName", "Turn on/off the no flicker option for title and icon name" }, + #endif /*SAME_NAME*/ { NULL, NULL }}; static char *message[] = { *************** *** 897,902 **** --- 934,950 ---- xterm_name = resource.xterm_name; sunFunctionKeys = resource.sunFunctionKeys; + #ifdef ZICONBEEP + zIconBeep = resource.zIconBeep; + zIconBeep_flagged = False; + if ( zIconBeep > 100 || zIconBeep < 0 ) { + zIconBeep = 100; + fprintf( stderr, "a number between 0 and 100 is required for zIconBeep. 100 used by default\n"); + } + #endif /*ZICONBEEP*/ + #ifdef SAME_NAME + sameName = resource.sameName; + #endif /*SAME_NAME*/ if (strcmp(xterm_name, "-") == 0) xterm_name = "xterm"; if (resource.icon_geometry != NULL) { int scr, junk; *** /tmp/,RCSt1a15163 Wed Oct 2 14:55:03 1991 --- misc.c Wed Oct 2 14:42:56 1991 *************** *** 664,670 **** --- 664,682 ---- { extern Widget toplevel; Arg args[1]; + #ifdef SAME_NAME + char *buf; + extern Boolean sameName; + /* If the attribute isn't going to change, then don't bother... */ + + if( sameName ) { + XtSetArg( args[0], attribute, &buf ); + XtGetValues( toplevel, args, 1 ); + if (strcmp((char *)value,buf) == 0) return; + } + #endif /* SAME_NAME */ + XtSetArg( args[0], attribute, value ); XtSetValues( toplevel, args, 1 ); } *************** *** 672,678 **** Changename(name) register char *name; { ! ChangeGroup( XtNiconName, (XtArgVal)name ); } Changetitle(name) --- 684,702 ---- Changename(name) register char *name; { ! #ifdef ZICONBEEP /* If warning should be given then give it */ ! extern int zIconBeep; ! extern Boolean zIconBeep_flagged; ! if( zIconBeep && zIconBeep_flagged ) { ! char *newname = malloc( strlen( name + 4 + 1 ) ); ! if(!newname){ fprintf(stderr,"malloc failed in Changename\n"); return;} ! strcpy(newname,"*** "); ! strcat(newname,name); ! ChangeGroup( XtNiconName, (XtArgVal)newname ); ! free(newname); ! } else ! #endif /*ZICONBEEP*/ ! ChangeGroup( XtNiconName, (XtArgVal)name ); } Changetitle(name) *** /tmp/,RCSt1a15177 Wed Oct 2 14:56:36 1991 --- xterm.man Wed Oct 2 12:56:27 1991 *************** *** 464,469 **** --- 464,488 ---- .B \-iconic This option indicates that \fIxterm\fP should ask the window manager to start it as an icon rather than as the normal window. + .TP 8 + .B \-ziconbeep \fIpercent\fP + Same as zIconBeep resource. + If percent is non-zero, xterms that produce output while iconified + will cause an XBell sound at the given volume + and have "***" prepened to their icon titles. + Most window managers will detect this change immediately, showing you + which window has the output. + (A similar feature was in x10 xterm.) + .TP 8 + .B \-samename + Doesn't send title and icon name change requests when the request + would have no effect: the name isn't changed. This has the advantage + of preventing flicker and the disadvantage of requiring an extra + round trip to the server to find out the previous value. In practice + this should never be a problem. + .TP 8 + .B +samename + Always send title and icon name change requests. .SH RESOURCES The program understands all of the core X Toolkit resource names and classes as well as: *************** *** 504,509 **** --- 523,545 ---- .B "sunFunctionKeys (\fPclass\fB SunFunctionKeys)" Specifies whether or not Sun Function Key escape codes should be generated for function keys instead of standard escape sequences. + .TP 8 + .B "zIconBeep" (\fPclass\fB ZIconBeep)" + Same as \-ziconbeep command line argument. + If the value of this resource is non-zero, xterms that produce output + while iconified will cause an XBell sound at the given volume + and have "***" prepened to their icon titles. + Most window managers will detect this change immediately, showing you + which window has the output. + (A similar feature was in x10 xterm.) + .TP 8 + .B "sameName" (\fPclass\fB SameName)" + If the value of this resource is "true", xterm doesn't send + title and icon name change requests when the request + would have no effect: the name isn't changed. This has the advantage + of preventing flicker and the disadvantage of requiring an extra + round trip to the server to find out the previous value. In practice + this should never be a problem. The default is "true". .\".in -1in .TP 8 .B "waitForMap (\fPclass\fB WaitForMap)" *** /tmp/,RCSt1a15226 Wed Oct 2 15:05:34 1991 --- Imakefile Wed Oct 2 15:05:21 1991 *************** *** 19,25 **** PUCCPTYDDEF = -DPUCC_PTYD /* does not need to be setuid */ PTYLIB = -lpucc #endif ! MAIN_DEFINES = -DUTMP $(TTYGROUPDEF) $(PUCCPTYDDEF) MISC_DEFINES = /* -DALLOWLOGFILEEXEC */ --- 19,30 ---- PUCCPTYDDEF = -DPUCC_PTYD /* does not need to be setuid */ PTYLIB = -lpucc #endif ! /* ! * -DZICONBEEP to change the icon name when text is output to the window ! * -DSAME_ICON_NAME to avoid redrawing the icon or title name when it hasn't ! changed ! */ ! DEFINES = -DZICONBEEP -DSAME_NAME MAIN_DEFINES = -DUTMP $(TTYGROUPDEF) $(PUCCPTYDDEF) MISC_DEFINES = /* -DALLOWLOGFILEEXEC */