[alt.sources] xse - An interface to XSendEvent

ferguson@cs.rochester.edu (George Ferguson) (08/16/90)

Dangnabbit, figures. Already I've noticed that you'll have to check the
filename of the sed script in "ad2c" if you use xse. Sorry about that
folks; I should have mentioned it in the README.

George
-- 
George Ferguson			ARPA: ferguson@cs.rochester.edu
University of Rochester		UUCP: {decvax,rutgers}!rochester!ferguson
Rochester  NY  14627		VOX:  (716) 275-2527

ferguson@cs.rochester.edu (George Ferguson) (08/16/90)

Yep, I sure munged that one. The poster seems to have chopped the end off
of the first two parts of the archive, and our rn doesn't seem to want to
let me cancel the corrupted articles.

If you're still interested in xse, you can ftp it from cayuga.cs.rochester.edu
(192.5.53.209) in pub/xse.tar.Z. Please avoid ftp between 9:00 and 17:00 EDT.
I hope there are no further problems with this. 

George
-- 
George Ferguson			ARPA: ferguson@cs.rochester.edu
University of Rochester		UUCP: {decvax,rutgers}!rochester!ferguson
Rochester  NY  14627		VOX:  (716) 275-2527

ferguson@cs.rochester.edu (George Ferguson) (08/17/90)

I've had several requests to attempt a repost, so here goes. Apologies
to those who are (understandably) frustrated by my and my poster's screwups.

George

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 1 (of 3)."
# Contents:  Imakefile MANIFEST README Xse.ad ad2c ad2c.sed
#   app-resources.h parse.h translate.c translate.h xse.c
# Wrapped by ferguson@swan.cs.rochester.edu on Thu Aug 16 15:17:58 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Imakefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Imakefile'\"
else
echo shar: Extracting \"'Imakefile'\" \(694 characters\)
sed "s/^X//" >'Imakefile' <<'END_OF_FILE'
X/**/#
X/**/#	Imakefile for xse - An interface to XSendEvent()
X/**/#
X/**/#	George Ferguson, ferguson@cs.rochester.edu, 1 Jun 1990.
X/**/#
X/**/#	$Id: Imakefile,v 1.3 90/08/15 11:32:06 ferguson Exp $
X/**/#
X
X#ifdef BandAidCompiler
X#include BandAidCompiler
X#endif
X
XDEPLIBS =		XawClientDepLibs
XLOCAL_LIBRARIES =	XawClientLibs
XCDEBUGFLAGS = 		-g
X
XAD2C = ./ad2c
X
XSRCS = xse.c parse.c translate.c
XOBJS = xse.o parse.o translate.o
XINCS = app-resources.h parse.h translate.h
X
XComplexProgramTarget(xse)
X
X/**/#
X/**/#	C code for fallback resources
X/**/#
XXse.ad.h: Xse.ad
X	$(AD2C) Xse.ad >Xse.ad.h
X
X/**/#
X/**/#	Misc
X/**/#
X
Xci:
X	ci -u -q -m' ' -t/dev/null Imakefile $(SRCS) $(INCS) xse.man
X
Xclean::
X	rm Xse.ad.h
END_OF_FILE
if test 694 -ne `wc -c <'Imakefile'`; then
    echo shar: \"'Imakefile'\" unpacked with wrong size!
fi
# end of 'Imakefile'
fi
if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MANIFEST'\"
else
echo shar: Extracting \"'MANIFEST'\" \(126 characters\)
sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
XMANIFEST
XREADME
XImakefile
XMakefile
XXse.ad
Xad2c
Xad2c.sed
Xapp-resources.h
Xparse.c
Xparse.h
Xtranslate.c
Xtranslate.h
Xxse.c
Xxse.man
END_OF_FILE
if test 126 -ne `wc -c <'MANIFEST'`; then
    echo shar: \"'MANIFEST'\" unpacked with wrong size!
fi
# end of 'MANIFEST'
fi
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(1689 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
X		XSE - An interface to XSendEvent()
X
X	    George Ferguson, ferguson@cs.rochester.edu
X
XOVERVIEW:
X
XXse provides an interface to XSendEvent(); sort of an inverse of xev(1).
XIt provides two interfaces depending on how it is invoked. If extra
Xcommand-line arguments are given, then these are parsed into an event
Xsequence and sent to the proper window (either the default or the one
Xgiven by the "-window" argument). If no event sequence is given, then
Xxse creates a tool as specified by the "widgets" resource of its
Xapplication-defaults file. Presumably this tool will create Command buttons
Xor menus which will use the xse-send() and xse-quit() actions.
X
XIncluded in this distribution is the program "ad2c" which converts an
Xapplication-defaults file to C declarations for inclusion as fallback
Xresources. Also, the code used to specify and create widgets from a
Xresource entry is very modular (see translate.c and initWidgets() in
Xxse.c).
X
X
XINSTALLATION:
X
X     1. Edit the Imakefile as necessary to reflect changes for your
X	site. In particular, you may want to set BINDIR and MANDIR to
X	change the install targets. You may have to edit the filename
X	used in "ad2c" (the name of the sed script).
X
X     2. Execute
X		% xmkmf
X	to make the Makefile.
X
X     3. Execute
X		% make depend
X	to add the dependencies to the Makefile. IMPORTANT: Ignore the
X	warning message from makedepend about missing Xse.ad.h; it will
X	be created automatically.
X
X     4. Execute
X		% make
X	to make the program or
X		% make install install.man
X	to make and install it. Making xse required the program ad2c
X	to translate an application-defaults file into C declarations.
X	Ad2c should be included with this distribution.
END_OF_FILE
if test 1689 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'Xse.ad' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Xse.ad'\"
else
echo shar: Extracting \"'Xse.ad'\" \(727 characters\)
sed "s/^X//" >'Xse.ad' <<'END_OF_FILE'
X!
X!	Xse.ad - Resources for xse: An interface to XSendEvent()
X!
X!	George Ferguson, fergsuon@cs.rochester.edu, 1 Jun 1990.
X!
X!	$Id: Xse.ad,v 1.4 90/08/15 11:32:13 ferguson Exp $
X!
X! This has must be the first line in the "official" app-defaults file.
XXse.revision:	$Revision: 1.4 $
X
X! Non-widget stuff
X
XXse.window:	InputFocus
X
X
X! Widget stuff
X
XXse.widgets: \
X	Form		form		toplevel \n\
X	Command		button1		form \n\
X	Command		button2		form \n
X
XXse*button1.label:	send a to default window
XXse*button1.translations:#override\n\
X	<Btn1Down>,<Btn1Up> : xse-send(<Key>a)\n
X
XXse*button2.label:	send a to ClickWindow
XXse*button2.fromVert:	button1
XXse*button2.translations:#override\n\
X	<Btn1Down>,<Btn1Up> : xse-send(ClickWindow,<Key>a)\n
END_OF_FILE
if test 727 -ne `wc -c <'Xse.ad'`; then
    echo shar: \"'Xse.ad'\" unpacked with wrong size!
fi
# end of 'Xse.ad'
fi
if test -f 'ad2c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ad2c'\"
else
echo shar: Extracting \"'ad2c'\" \(86 characters\)
sed "s/^X//" >'ad2c' <<'END_OF_FILE'
X#!/bin/csh
X#
X#	Convert app-defaults file to C strings decls.
X#
X
Xsed -n -f ad2c.sed $*
END_OF_FILE
if test 86 -ne `wc -c <'ad2c'`; then
    echo shar: \"'ad2c'\" unpacked with wrong size!
fi
chmod +x 'ad2c'
# end of 'ad2c'
fi
if test -f 'ad2c.sed' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ad2c.sed'\"
else
echo shar: Extracting \"'ad2c.sed'\" \(470 characters\)
sed "s/^X//" >'ad2c.sed' <<'END_OF_FILE'
X#
X#	Convert app-defaults file to C strings decls.
X#
X#	Invoke by: sed -n -f ad2c.sed
X#
X: read
X# remove comments
X/^!/d
X# remove blanks
X/^$/d
X# escape quotes
Xs/"/\\"/g
X# escape backslash
Xs/\\/\\\\/g
X# except the line continuation ones
Xs/\\$//g
X# add leading quote
Xs/^/"/
X#
X: test
X/\\$/b slash
Xs/$/",/
Xp
Xn
Xb read
X#
X: slash
Xp
Xn
X# just like "read" only doesn't add leading quote
X/^!/d
X/^$/d
Xs/"/\\"/g
Xs/\\\\/\\/g
Xs/\\n/\\\\n/g
Xs/\\t/\\\\t/g
Xs/\\f/\\\\f/g
Xs/\\b/\\\\b/g
Xb test
END_OF_FILE
if test 470 -ne `wc -c <'ad2c.sed'`; then
    echo shar: \"'ad2c.sed'\" unpacked with wrong size!
fi
# end of 'ad2c.sed'
fi
if test -f 'app-resources.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'app-resources.h'\"
else
echo shar: Extracting \"'app-resources.h'\" \(306 characters\)
sed "s/^X//" >'app-resources.h' <<'END_OF_FILE'
X/*
X *	app-resources.h : External app-defaults defs.
X *
X *	George Ferguson, ferguson@cs.rochester.edu,  1 Jun 1990.
X *
X *	$Id: app-resources.h,v 1.1 90/08/15 10:22:35 ferguson Exp $
X *
X */
Xtypedef struct {
X	String window;
X	String widgets;
X	String revision;
X} AppResources;
Xextern AppResources appResources;
END_OF_FILE
if test 306 -ne `wc -c <'app-resources.h'`; then
    echo shar: \"'app-resources.h'\" unpacked with wrong size!
fi
# end of 'app-resources.h'
fi
if test -f 'parse.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'parse.h'\"
else
echo shar: Extracting \"'parse.h'\" \(290 characters\)
sed "s/^X//" >'parse.h' <<'END_OF_FILE'
X/*
X *	parse.h - George Ferguson, ferguson@cs.rochester.edu, 1 Jun 1990.
X *
X *	$Id: parse.h,v 1.1 90/08/15 10:22:42 ferguson Exp $
X */
X
Xtypedef struct eventListStruct {
X	XEvent event;
X	long count;
X	struct eventListStruct *next;
X} EventListElem,*EventListPtr;
X
Xextern char *parseEventList();
END_OF_FILE
if test 290 -ne `wc -c <'parse.h'`; then
    echo shar: \"'parse.h'\" unpacked with wrong size!
fi
# end of 'parse.h'
fi
if test -f 'translate.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'translate.c'\"
else
echo shar: Extracting \"'translate.c'\" \(2196 characters\)
sed "s/^X//" >'translate.c' <<'END_OF_FILE'
X/*
X *	translate.c : Map class names to classes. This code is
X *		      totally self-contained. A smaller executable
X *		      might result from only including the classes
X *		      an application needs.
X *
X *      George Ferguson, ferguson@cs.rochester.edu, 15 Jul 1990.
X *
X *	$Id: translate.c,v 1.1 90/08/15 10:22:44 ferguson Exp $
X */
X#include <X11/Intrinsic.h>
X#include <X11/StringDefs.h>
X#include <X11/Xaw/Command.h>
X#include <X11/Xaw/Grip.h>
X#include <X11/Xaw/Label.h>
X#include <X11/Xaw/List.h>
X#include <X11/Xaw/Scrollbar.h>
X#include <X11/Xaw/Simple.h>
X#include <X11/Xaw/StripChart.h>
X#include <X11/Xaw/Toggle.h>
X#include <X11/Xaw/SimpleMenu.h>
X#include <X11/Xaw/SmeBSB.h>
X#include <X11/Xaw/SmeLine.h>
X#include <X11/Xaw/MenuButton.h>
X#include <X11/Xaw/AsciiText.h>
X#include <X11/Xaw/Box.h>
X#include <X11/Xaw/Dialog.h>
X#include <X11/Xaw/Form.h>
X#include <X11/Xaw/Paned.h>
X#include <X11/Xaw/Viewport.h>
X#include <X11/Shell.h>
X
Xstatic struct tableRec {
X	char *name;
X	WidgetClass *class;
X	Boolean isShell;
X} table[] = {
X	{ "Command",	&commandWidgetClass,	False },
X	{ "Grip",	&gripWidgetClass,	False },
X	{ "Label",	&labelWidgetClass,	False },
X	{ "List",	&listWidgetClass,	False },
X	{ "Scrollbar",	&scrollbarWidgetClass,	False },
X	{ "Simple",	&simpleWidgetClass,	False },
X	{ "StripChart",	&stripChartWidgetClass,	False },
X	{ "Toggle",	&toggleWidgetClass,	False },
X	{ "SimpleMenu",	&simpleMenuWidgetClass,	True },
X	{ "SmeBSB",	&smeBSBObjectClass,	False },
X	{ "SmeLine",	&smeLineObjectClass,	False },
X	{ "MenuButton",	&menuButtonWidgetClass,	False },
X	{ "AsciiText",	&asciiTextWidgetClass,	False },
X	{ "Box",	&boxWidgetClass,	False },
X	{ "Dialog",	&dialogWidgetClass,	False },
X	{ "Form",	&formWidgetClass,	False },
X	{ "Paned",	&panedWidgetClass,	False },
X	{ "Viewport",	&viewportWidgetClass,	False },
X	{ "TransientShell", &transientShellWidgetClass, True },
X	{ "ApplicationShell", &applicationShellWidgetClass, True },
X};
X
XWidgetClass
XclassNameToWidgetClass(name,isShell)
Xchar *name;
XBoolean *isShell;
X{
X    int i;
X
X    for (i=0; i < XtNumber(table); i++)
X	if (strcmp(name,table[i].name) == 0) {
X	    *isShell = table[i].isShell;
X	    return(*(table[i].class));
X	}
X    return((WidgetClass)NULL);
X}
END_OF_FILE
if test 2196 -ne `wc -c <'translate.c'`; then
    echo shar: \"'translate.c'\" unpacked with wrong size!
fi
# end of 'translate.c'
fi
if test -f 'translate.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'translate.h'\"
else
echo shar: Extracting \"'translate.h'\" \(45 characters\)
sed "s/^X//" >'translate.h' <<'END_OF_FILE'
Xextern WidgetClass classNameToWidgetClass();
END_OF_FILE
if test 45 -ne `wc -c <'translate.h'`; then
    echo shar: \"'translate.h'\" unpacked with wrong size!
fi
# end of 'translate.h'
fi
if test -f 'xse.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xse.c'\"
else
echo shar: Extracting \"'xse.c'\" \(9393 characters\)
sed "s/^X//" >'xse.c' <<'END_OF_FILE'
X/*
X *	xse - an interface to XSendEvent()
X *
X *	George Ferguson, ferguson@cs.rochester.edu,  1 Jun 1990.
X *
X *	$Id: xse.c,v 1.4 90/08/15 11:32:30 ferguson Exp $
X *
X */
Xstatic char *rcsid = "$Id: xse.c,v 1.4 90/08/15 11:32:30 ferguson Exp $";
X#include <stdio.h>
X#include <ctype.h>
X#include <X11/Intrinsic.h>
X#include <X11/StringDefs.h>
X#include <X11/Shell.h>	
X#include <X11/Xaw/Form.h>	
X#include <X11/Xaw/Command.h>	
X#include <X11/Xaw/Cardinals.h>	
X#include "app-resources.h"
X#include "translate.h"
X#include "parse.h"
X
X/*	-	-	-	-	-	-	-	-	*/
X/*
X * Functions defined in this file
X */
Xstatic void initGraphics(),initWidgets();
Xstatic void quit(),send();
Xstatic void parseAndSendEvents(), fail();
Xstatic Window windowFromString(), Window_With_Name(), Select_Window();
X
X/*
X * Action binding table
X */
Xstatic XtActionsRec cmdActionsTable[] = {
X    { "xse-quit", quit },
X    { "xse-send", send },
X};
X
X/*
X * Global graphics data, needed in parse.c
X */
XDisplay *display;
XWindow root;
X
X/*
X * Global widget data
X */
Xstatic XtAppContext app_con;
Xstatic Widget toplevel;
X
X/*
X * The application resources struct
X */
Xstatic AppResources appResources;
X
X/*
X *	Non-widget resources obtained from resource manager
X */
Xstatic XtResource resources[] = {
X    { "widgets", "Widgets", XtRString, sizeof(String),
X      XtOffset(AppResources *,widgets), XtRImmediate, NULL },
X    { "window", "Window", XtRString, sizeof(String),
X      XtOffset(AppResources *,window), XtRImmediate, "InputFocus" },
X    { "revision", "Revision", XtRString, sizeof(String),
X      XtOffset(AppResources *,revision), XtRImmediate, "" },
X};
X
X/*
X *	Non-widget resources set on command line.
X */
Xstatic XrmOptionDescRec options[] = {
X    { "-window",	"window",	XrmoptionSepArg,	"InputFocus"},
X};
X
X/*
X *	Widget and non-widget resources if the application defaults
X *	file can't be found.
X *	[ Generated automatically from Xse.ad. ]
X */
Xstatic String fallbackResources[] = {
X#include "Xse.ad.h"
X	NULL
X};
X
X/*	-	-	-	-	-	-	-	-	*/
X/*
X * main() : Initialize the graphics, then if args remain send them directly
X *	    (ie. we are in command mode) otherwise initialize the widgets
X *	    (ie. we are in widget mode) and call XtAppMainLoop().
X */
Xmain(argc, argv)
Xint argc;
Xchar **argv;
X{
X    Window win;
X
X    initGraphics(&argc,argv);
X    argv += 1;
X    argc -= 1;
X    if (argc > 0) {
X	win = windowFromString(appResources.window);
X	while (argc--)
X	    parseAndSendEvents(win,*argv++);
X	XtDestroyApplicationContext(app_con);
X	exit(0);
X    }
X    initWidgets();
X    XtRealizeWidget(toplevel);
X    XtAppMainLoop(app_con);
X}
X
X/*
X * initGraphics() : Initialize the application context and set global
X *		    graphics variables.
X */
Xstatic void
XinitGraphics(argcp,argv)
Xint *argcp;
Xchar **argv;
X{
X    toplevel = XtAppInitialize(&app_con, "Xse",
X			       options, XtNumber(options),
X			       argcp,argv,fallbackResources,NULL,ZERO);
X    XtGetApplicationResources(toplevel,(XtPointer)&appResources,
X                              resources,XtNumber(resources),NULL,ZERO);
X    display = XtDisplay(toplevel);
X    root = RootWindowOfScreen(XtScreen(toplevel));
X    XtAppAddActions(app_con,cmdActionsTable,XtNumber(cmdActionsTable));
X}
X
X/*
X * initWidgets() : Parse the widgets resource and create whatever widgets
X *		   specified in it as children of toplevel (or sub-children,
X *		   etc.).
X */
Xstatic void
XinitWidgets()
X{
X    char name[32],class[32],parent[32];
X    char *s;
X    int i;
X    Boolean isShell;
X    WidgetClass wc;
X    Widget w;
X
X    if ((s=appResources.widgets) == NULL)
X	fail("no widgets specified!\n","");
X    while (*s) {
X        while (isspace(*s))
X            s += 1;
X	if (!*s)
X	    break;
X        i = 0;
X        while (*s && !isspace(*s))
X            class[i++] = *s++;
X        class[i] = '\0';
X        while (isspace(*s))
X            s += 1;
X        i = 0;
X        while (*s && !isspace(*s))
X            name[i++] = *s++;
X        name[i] = '\0';
X        while (isspace(*s))
X            s += 1;
X        i = 0;
X        while (*s && !isspace(*s))
X            parent[i++] = *s++;
X        parent[i] = '\0';
X	isShell = False;
X        if ((wc=classNameToWidgetClass(class,&isShell)) == NULL)
X	    fail("can't convert string \"%s\" to widgetClass\n",class);
X	if (strcmp(parent,"toplevel") == 0)
X	    w = toplevel;
X	else if ((w=XtNameToWidget(toplevel,parent)) == NULL)
X	    fail("can't convert string \"%s\" to widget\n",parent);
X	if (isShell)
X            w = XtCreatePopupShell(name,wc,w,NULL,ZERO);
X        else
X            w = XtCreateManagedWidget(name,wc,w,NULL,ZERO);
X    }
X}
X
X/*	-	-	-	-	-	-	-	-	*/
X/*
X * windowFromString() : Convert a string to a Window, handling our special
X *			cases of PointerWindow, InputFocus, or ClickWindow.
X */
Xstatic Window
XwindowFromString(str)
Xchar *str;
X{
X    Window w;
X
X    if (strcmp(str,"PointerWindow") == 0)
X	return(PointerWindow);
X    else if (strcmp(str,"InputFocus") == 0)
X	return(InputFocus);
X    else if (strcmp(str,"ClickWindow") == 0)
X	return(Select_Window(display));
X    else if ((w=Window_With_Name(display,root,str)) != NULL)
X	return(w);
X    else
X	return((Window)strtol(str,NULL,0));
X}
X
X/*	-	-	-	-	-	-	-	-	*/
X/* Action procedures */
X
X/*
X * quit() : Quit the tool.
X */
Xstatic void
Xquit(w,event,params,num_params)
XWidget w;
XXEvent *event;
XString *params;
XCardinal *num_params;
X{
X    XtDestroyApplicationContext(app_con);
X    exit(0);
X}
X
X/*
X * send() : With one argument, send the event sequence given by the first
X *	    argument to the default window. With two arguments, the first
X *	    is the window to send the event sequence given by the second
X *	    to.
X */
Xstatic void
Xsend(w,event,params,num_params)
XWidget w;
XXEvent *event;
XString *params;
XCardinal *num_params;
X{
X    char *estr,*wstr;
X
X    if (*num_params == ONE) {
X	wstr = appResources.window;
X        estr = params[0];
X    } else if (*num_params == TWO) {
X	wstr = params[0];
X        estr = params[1];
X    } else {
X	fprintf(stderr,"xse: too many arguments to xse-send()\n");
X        return;
X    }
X    parseAndSendEvents(windowFromString(wstr),estr);
X}
X
X/*
X * parseAndSendEvents() : Calls parseEventList() then dispatches the list
X *			  of returned events.
X */
Xstatic void
XparseAndSendEvents(window,str)
XWindow window;
Xchar *str;
X{
X    char *s;
X    EventListPtr list = NULL;
X
X    s = parseEventList(str,&list);
X    if (*s != '\0') {
X	fprintf("xse: garbage at end of event spec: \"%s\"\n",s);
X	return;
X    }
X    while (list != NULL) {
X	if (list->event.xany.type != -1) {
X	    list->event.xany.display = display;
X	    list->event.xany.window = window;
X	    while (list->count-- != 0)
X		XSendEvent(display,window,True,0xfff,&(list->event));
X	}
X	list = list->next;
X    }
X    freeEventList(&list);
X}
X
X/*	-	-	-	-	-	-	-	-	*/
X/*
X *	fail() : Print a message and die.
X */
Xstatic void
Xfail(fmt,arg)
Xchar *fmt,*arg;
X{
X    fprintf(stderr,fmt,arg);
X    XtDestroyApplicationContext(app_con);
X    exit(1);
X}
X
X/*	-	-	-	-	-	-	-	-	*/
X/*	-	-	-	-	-	-	-	-	*/
X/*
X * [These functions are from the file "dsimple.c" used with xwininfo.]
X *
X * Written by Mark Lillibridge.   Last updated 7/1/87
X *
X * Send bugs, etc. to chariot@athena.mit.edu.
X *
X * Window_With_Name: routine to locate a window with a given name on a display.
X *                   If no window with the given name is found, 0 is returned.
X *                   If more than one window has the given name, the first
X *                   one found will be returned.  Only top and its subwindows
X *                   are looked at.  Normally, top should be the RootWindow.
X */
Xstatic Window
XWindow_With_Name(dpy, top, name)
X     Display *dpy;
X     Window top;
X     char *name;
X{
X	Window *children, dummy;
X	unsigned int nchildren;
X	int i;
X	Window w=0;
X	char *window_name;
X
X	if (XFetchName(dpy, top, &window_name) && !strcmp(window_name, name))
X	  return(top);
X
X	if (!XQueryTree(dpy, top, &dummy, &dummy, &children, &nchildren))
X	  return(0);
X
X	for (i=0; i<nchildren; i++) {
X		w = Window_With_Name(dpy, children[i], name);
X		if (w)
X		  break;
X	}
X	if (children) XFree ((char *)children);
X	return(w);
X}
X
X/*
X * Routine to let user select a window using the mouse
X * gf: Doesn't need "screen" defined.
X */
X#include <X11/cursorfont.h>
X
Xstatic Window
XSelect_Window(dpy)
X      Display *dpy;
X{
X  static Cursor cursor = NULL;
X  Window target_win = None, root = DefaultRootWindow(dpy);
X  XEvent event;
X  int status;
X  int buttons = 0;
X
X  if (cursor == NULL)
X    cursor = XCreateFontCursor(dpy, XC_crosshair);
X  /* Grab the pointer using target cursor, letting it room all over */
X  status = XGrabPointer(dpy, root, False,
X			ButtonPressMask|ButtonReleaseMask, GrabModeSync,
X			GrabModeAsync, root, cursor, CurrentTime);
X  if (status != GrabSuccess) {
X    fprintf(stderr,"xse: can't grab pointer");
X    return(None);
X  }
X  /* Let the user select a window... */
X  while ((target_win == None) || (buttons != 0)) {
X    /* allow one more event */
X    XAllowEvents(dpy, SyncPointer, CurrentTime);
X    XWindowEvent(dpy, root, ButtonPressMask|ButtonReleaseMask, &event);
X    switch (event.type) {
X    case ButtonPress:
X      if (target_win == None) {
X	target_win = event.xbutton.subwindow; /* window selected */
X	if (target_win == None) target_win = root;
X      }
X      buttons++;
X      break;
X    case ButtonRelease:
X      if (buttons > 0) /* there may have been some down before we started */
X	buttons--;
X       break;
X    }
X  } 
X  XUngrabPointer(dpy, CurrentTime);      /* Done with pointer */
X  return(target_win);
X}
END_OF_FILE
if test 9393 -ne `wc -c <'xse.c'`; then
    echo shar: \"'xse.c'\" unpacked with wrong size!
fi
# end of 'xse.c'
fi
echo shar: End of archive 1 \(of 3\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 3 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 3 archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
George Ferguson			ARPA: ferguson@cs.rochester.edu
University of Rochester		UUCP: {decvax,rutgers}!rochester!ferguson
Rochester  NY  14627		VOX:  (716) 275-2527

ferguson@cs.rochester.edu (George Ferguson) (08/17/90)

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 2 (of 3)."
# Contents:  Makefile xse.man
# Wrapped by ferguson@swan.cs.rochester.edu on Thu Aug 16 15:17:59 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(12752 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X# Makefile generated by imake - do not edit!
X# $XConsortium: imake.c,v 1.51 89/12/12 12:37:30 jim Exp $
X#
X# The cpp used on this machine replaces all newlines and multiple tabs and
X# spaces in a macro expansion with a single space.  Imake tries to compensate
X# for this, but is not always successful.
X#
X
X###########################################################################
X# Makefile generated from "Imake.tmpl" and <Imakefile>
X# $XConsortium: Imake.tmpl,v 1.77 89/12/18 17:01:37 jim Exp $
X#
X# Platform-specific parameters may be set in the appropriate .cf
X# configuration files.  Site-wide parameters may be set in the file
X# site.def.  Full rebuilds are recommended if any parameters are changed.
X#
X# If your C preprocessor doesn't define any unique symbols, you'll need
X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
X# "make Makefile", "make Makefiles", or "make World").
X#
X# If you absolutely can't get imake to work, you'll need to set the
X# variables at the top of each Makefile as well as the dependencies at the
X# bottom (makedepend will do this automatically).
X#
X
X###########################################################################
X# platform-specific configuration parameters - edit sun.cf to change
X
X# platform:  $XConsortium: sun.cf,v 1.38 89/12/23 16:10:10 jim Exp $
X# operating system:  SunOS 4.0.3
X
X###########################################################################
X# site-specific configuration parameters - edit site.def to change
X
X# site:  $XConsortium: site.def,v 1.21 89/12/06 11:46:50 jim Exp $
X
X            SHELL = /bin/sh
X
X              TOP = .
X      CURRENT_DIR = .
X
X               AR = ar cq
X  BOOTSTRAPCFLAGS =
X               CC = cc
X
X         COMPRESS = compress
X              CPP = /lib/cpp $(STD_CPP_DEFINES)
X    PREPROCESSCMD = cc -E $(STD_CPP_DEFINES)
X          INSTALL = install
X               LD = ld
X             LINT = lint
X      LINTLIBFLAG = -C
X         LINTOPTS = -axz
X               LN = ln -s
X             MAKE = make
X               MV = mv
X               CP = cp
X           RANLIB = ranlib
X  RANLIBINSTFLAGS =
X               RM = rm -f
X     STD_INCLUDES =
X  STD_CPP_DEFINES =
X      STD_DEFINES =
X EXTRA_LOAD_FLAGS =
X  EXTRA_LIBRARIES =
X             TAGS = ctags
X
X    SHAREDCODEDEF = -DSHAREDCODE
X         SHLIBDEF = -DSUNSHLIB
X
X    PROTO_DEFINES =
X
X     INSTPGMFLAGS =
X
X     INSTBINFLAGS = -m 0755
X     INSTUIDFLAGS = -m 4755
X     INSTLIBFLAGS = -m 0664
X     INSTINCFLAGS = -m 0444
X     INSTMANFLAGS = -m 0444
X     INSTDATFLAGS = -m 0444
X    INSTKMEMFLAGS = -g kmem -m 2755
X
X          DESTDIR =
X
X     TOP_INCLUDES = -I$(INCROOT)
X
X      CDEBUGFLAGS = -O
X        CCOPTIONS =
X      COMPATFLAGS =
X
X      ALLINCLUDES = $(STD_INCLUDES) $(TOP_INCLUDES) $(INCLUDES) $(EXTRA_INCLUDES)
X       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(PROTO_DEFINES) $(DEFINES) $(COMPATFLAGS)
X           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES)
X        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES)
X           LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
X        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS)
X   LDCOMBINEFLAGS = -X -r
X
X        MACROFILE = sun.cf
X           RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut
X
X    IMAKE_DEFINES =
X
X         IRULESRC = $(CONFIGDIR)
X        IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES)
X
X     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \
X			$(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \
X			$(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES)
X
X###########################################################################
X# X Window System Build Parameters
X# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $
X
X###########################################################################
X# X Window System make variables; this need to be coordinated with rules
X# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $
X
X          PATHSEP = /
X        USRLIBDIR = /usr/staff/lib
X           BINDIR = /usr/staff/bin
X          INCROOT = /usr/staff/include
X     BUILDINCROOT = $(TOP)
X      BUILDINCDIR = $(BUILDINCROOT)/X11
X      BUILDINCTOP = ..
X           INCDIR = $(INCROOT)/X11
X           ADMDIR = /tmp
X           LIBDIR = $(USRLIBDIR)/X11
X        CONFIGDIR = $(LIBDIR)/config
X       LINTLIBDIR = $(USRLIBDIR)/lint
X
X          FONTDIR = $(LIBDIR)/fonts
X         XINITDIR = $(LIBDIR)/xinit
X           XDMDIR = $(LIBDIR)/xdm
X           AWMDIR = $(LIBDIR)/awm
X           TWMDIR = $(LIBDIR)/twm
X           GWMDIR = $(LIBDIR)/gwm
X          MANPATH = $(DESTDIR)/usr/staff/man
X    MANSOURCEPATH = $(MANPATH)/man
X           MANDIR = $(MANSOURCEPATH)1
X        LIBMANDIR = $(MANSOURCEPATH)3
X      XAPPLOADDIR = $(LIBDIR)/app-defaults
XXFILESEARCHPATHDEFAULT = $(LIBDIR)/%L/%T/%N%S:$(LIBDIR)/%l/%T/%N%S:$(LIBDIR)/%T/%N%S
X	         ERRORDB = $(LIBDIR)/XtErrorDB
X
X        SOXLIBREV = 4.2
X          SOXTREV = 4.0
X         SOXAWREV = 4.0
X        SOOLDXREV = 4.0
X         SOXMUREV = 4.0
X        SOXEXTREV = 4.0
X
X       FONTCFLAGS = -t
X
X     INSTAPPFLAGS = $(INSTDATFLAGS)
X
X            IMAKE = imake
X           DEPEND = makedepend
X              RGB = rgb
X            FONTC = bdftosnf
X        MKFONTDIR = mkfontdir
X        MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier.sh
X
X        CONFIGSRC = $(TOP)/config
X        CLIENTSRC = $(TOP)/clients
X          DEMOSRC = $(TOP)/demos
X           LIBSRC = $(TOP)/lib
X          FONTSRC = $(TOP)/fonts
X       INCLUDESRC = $(TOP)/X11
X        SERVERSRC = $(TOP)/server
X          UTILSRC = $(TOP)/util
X        SCRIPTSRC = $(UTILSRC)/scripts
X       EXAMPLESRC = $(TOP)/examples
X       CONTRIBSRC = $(TOP)/../contrib
X           DOCSRC = $(TOP)/doc
X           RGBSRC = $(TOP)/rgb
X        DEPENDSRC = $(UTILSRC)/makedepend
X         IMAKESRC = $(CONFIGSRC)
X         XAUTHSRC = $(LIBSRC)/Xau
X          XLIBSRC = $(LIBSRC)/X
X           XMUSRC = $(LIBSRC)/Xmu
X       TOOLKITSRC = $(LIBSRC)/Xt
X       AWIDGETSRC = $(LIBSRC)/Xaw
X       OLDXLIBSRC = $(LIBSRC)/oldX
X      XDMCPLIBSRC = $(LIBSRC)/Xdmcp
X      BDFTOSNFSRC = $(FONTSRC)/bdftosnf
X     MKFONTDIRSRC = $(FONTSRC)/mkfontdir
X     EXTENSIONSRC = $(TOP)/extensions
X
X  DEPEXTENSIONLIB = $(USRLIBDIR)/libXext.a
X     EXTENSIONLIB =  -lXext
X
X          DEPXLIB = $(DEPEXTENSIONLIB)
X             XLIB = $(EXTENSIONLIB) -lX11
X
X      DEPXAUTHLIB = $(USRLIBDIR)/libXau.a
X         XAUTHLIB =  -lXau
X
X        DEPXMULIB =
X           XMULIB = -lXmu
X
X       DEPOLDXLIB =
X          OLDXLIB = -loldX
X
X      DEPXTOOLLIB =
X         XTOOLLIB = -lXt
X
X        DEPXAWLIB =
X           XAWLIB = -lXaw
X
X LINTEXTENSIONLIB = $(USRLIBDIR)/llib-lXext.ln
X         LINTXLIB = $(USRLIBDIR)/llib-lX11.ln
X          LINTXMU = $(USRLIBDIR)/llib-lXmu.ln
X        LINTXTOOL = $(USRLIBDIR)/llib-lXt.ln
X          LINTXAW = $(USRLIBDIR)/llib-lXaw.ln
X
X          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
X
X         DEPLIBS1 = $(DEPLIBS)
X         DEPLIBS2 = $(DEPLIBS)
X         DEPLIBS3 = $(DEPLIBS)
X
X###########################################################################
X# Imake rules for building libraries, programs, scripts, and data files
X# rules:  $XConsortium: Imake.rules,v 1.67 89/12/18 17:14:15 jim Exp $
X
X###########################################################################
X# start of Imakefile
X
X#
X#	Imakefile for xse - An interface to XSendEvent()
X#
X#	George Ferguson, ferguson@cs.rochester.edu, 1 Jun 1990.
X#
X#	$Id: Imakefile,v 1.2 90/08/15 10:22:32 ferguson Exp $
X#
X
XDEPLIBS =		$(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
XLOCAL_LIBRARIES =	$(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
XCDEBUGFLAGS = 		-g
X
XSRCS = xse.c parse.c translate.c
XOBJS = xse.o parse.o translate.o
XINCS = app-resources.h parse.h translate.h
X
X PROGRAM = xse
X
Xall:: xse
X
Xxse: $(OBJS) $(DEPLIBS)
X	$(RM) $@
X	$(CC) -o $@ $(OBJS) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS)
X
Xsaber_xse:
X	#load $(ALLDEFINES) $(SRCS) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
X
Xosaber_xse:
X	#load $(ALLDEFINES) $(OBJS) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
X
Xinstall:: xse
X	$(INSTALL) -c $(INSTPGMFLAGS)   xse $(BINDIR)
X
Xinstall.man:: xse.man
X	$(INSTALL) -c $(INSTMANFLAGS) xse.man $(MANDIR)/xse.1
X
Xdepend::
X	$(DEPEND) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS)
X
Xlint:
X	$(LINT) $(LINTFLAGS) $(SRCS) $(LINTLIBS)
Xlint1:
X	$(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS)
X
Xclean::
X	$(RM) $(PROGRAM)
X
X#
X#	C code for fallback resources
X#
XXse.ad.h: Xse.ad
X	ad2c Xse.ad >Xse.ad.h
X
X#
X#	Misc
X#
X
Xci:
X	ci -u -q -m' ' -t/dev/null Imakefile $(SRCS) $(INCS) xse.man
X
Xclean::
X	rm Xse.ad.h
X
X###########################################################################
X# common rules for all Makefiles - do not edit
X
Xemptyrule::
X
Xclean::
X	$(RM_CMD) \#*
X
XMakefile::
X	-@if [ -f Makefile ]; then \
X	echo "	$(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \
X	$(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
X	else exit 0; fi
X	$(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR)
X
Xtags::
X	$(TAGS) -w *.[ch]
X	$(TAGS) -xw *.[ch] > TAGS
X
Xsaber:
X	#load $(ALLDEFINES) $(SRCS)
X
Xosaber:
X	#load $(ALLDEFINES) $(OBJS)
X
X###########################################################################
X# empty rules for directories that do not have SUBDIRS - do not edit
X
Xinstall::
X	@echo "install in $(CURRENT_DIR) done"
X
Xinstall.man::
X	@echo "install.man in $(CURRENT_DIR) done"
X
XMakefiles::
X
Xincludes::
X
X###########################################################################
X# dependencies generated by makedepend
X
X# DO NOT DELETE
X
Xxse.o: /usr/staff/include/X11/Intrinsic.h /usr/staff/include/X11/Xlib.h
Xxse.o: /usr/include/sys/types.h /usr/include/sys/sysmacros.h
Xxse.o: /usr/staff/include/X11/X.h /usr/staff/include/X11/Xutil.h
Xxse.o: /usr/staff/include/X11/Xresource.h /usr/staff/include/X11/Xos.h
Xxse.o: /usr/include/strings.h /usr/include/sys/file.h
Xxse.o: /usr/include/sys/fcntlcom.h /usr/include/sys/time.h
Xxse.o: /usr/include/sys/time.h /usr/staff/include/X11/Core.h
Xxse.o: /usr/staff/include/X11/Composite.h /usr/staff/include/X11/Constraint.h
Xxse.o: /usr/staff/include/X11/Object.h /usr/staff/include/X11/RectObj.h
Xxse.o: /usr/staff/include/X11/StringDefs.h /usr/staff/include/X11/Shell.h
Xxse.o: /usr/staff/include/X11/Xaw/Form.h /usr/staff/include/X11/Xaw/Command.h
Xxse.o: /usr/staff/include/X11/Xaw/Label.h /usr/staff/include/X11/Xaw/Simple.h
Xxse.o: /usr/staff/include/X11/Xmu/Converters.h
Xxse.o: /usr/staff/include/X11/Xaw/Cardinals.h app-resources.h translate.h
Xxse.o: parse.h Xse.ad.h /usr/staff/include/X11/cursorfont.h
Xparse.o: /usr/include/stdio.h /usr/include/ctype.h /usr/include/string.h
Xparse.o: /usr/staff/include/X11/Xlib.h /usr/include/sys/types.h
Xparse.o: /usr/include/sys/sysmacros.h /usr/staff/include/X11/X.h
Xparse.o: /usr/staff/include/X11/keysym.h /usr/staff/include/X11/keysymdef.h
Xparse.o: parse.h
Xtranslate.o: /usr/staff/include/X11/Intrinsic.h /usr/staff/include/X11/Xlib.h
Xtranslate.o: /usr/include/sys/types.h /usr/include/sys/sysmacros.h
Xtranslate.o: /usr/staff/include/X11/X.h /usr/staff/include/X11/Xutil.h
Xtranslate.o: /usr/staff/include/X11/Xresource.h /usr/staff/include/X11/Xos.h
Xtranslate.o: /usr/include/strings.h /usr/include/sys/file.h
Xtranslate.o: /usr/include/sys/fcntlcom.h /usr/include/sys/time.h
Xtranslate.o: /usr/include/sys/time.h /usr/staff/include/X11/Core.h
Xtranslate.o: /usr/staff/include/X11/Composite.h
Xtranslate.o: /usr/staff/include/X11/Constraint.h
Xtranslate.o: /usr/staff/include/X11/Object.h /usr/staff/include/X11/RectObj.h
Xtranslate.o: /usr/staff/include/X11/StringDefs.h
Xtranslate.o: /usr/staff/include/X11/Xaw/Command.h
Xtranslate.o: /usr/staff/include/X11/Xaw/Label.h
Xtranslate.o: /usr/staff/include/X11/Xaw/Simple.h
Xtranslate.o: /usr/staff/include/X11/Xmu/Converters.h
Xtranslate.o: /usr/staff/include/X11/Xaw/Grip.h
Xtranslate.o: /usr/staff/include/X11/Xaw/List.h
Xtranslate.o: /usr/staff/include/X11/Xaw/Scrollbar.h
Xtranslate.o: /usr/staff/include/X11/Xaw/StripChart.h
Xtranslate.o: /usr/staff/include/X11/Xaw/Toggle.h
Xtranslate.o: /usr/staff/include/X11/Xaw/SimpleMenu.h
Xtranslate.o: /usr/staff/include/X11/Shell.h
Xtranslate.o: /usr/staff/include/X11/Xaw/SmeBSB.h
Xtranslate.o: /usr/staff/include/X11/Xaw/Sme.h
Xtranslate.o: /usr/staff/include/X11/Xaw/SmeLine.h
Xtranslate.o: /usr/staff/include/X11/Xaw/MenuButton.h
Xtranslate.o: /usr/staff/include/X11/Xaw/AsciiText.h
Xtranslate.o: /usr/staff/include/X11/Xaw/Text.h
Xtranslate.o: /usr/staff/include/X11/Xaw/TextSink.h
Xtranslate.o: /usr/staff/include/X11/Xaw/TextSrc.h
Xtranslate.o: /usr/staff/include/X11/Xaw/AsciiSrc.h
Xtranslate.o: /usr/staff/include/X11/Xaw/AsciiSink.h
Xtranslate.o: /usr/staff/include/X11/Xaw/Box.h
Xtranslate.o: /usr/staff/include/X11/Xaw/Dialog.h
Xtranslate.o: /usr/staff/include/X11/Xaw/Form.h
Xtranslate.o: /usr/staff/include/X11/Xaw/Paned.h
Xtranslate.o: /usr/staff/include/X11/Xaw/Viewport.h
END_OF_FILE
if test 12752 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'xse.man' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xse.man'\"
else
echo shar: Extracting \"'xse.man'\" \(11655 characters\)
sed "s/^X//" >'xse.man' <<'END_OF_FILE'
X.\"
X.\"	xse - an interface to XSendEvent()
X.\"
X.\"	George Ferguson, ferguson@cs.rochester.edu, 19 Jun 1990.
X.\"
X.\"	$Id: xse.man,v 1.1 90/08/15 10:23:02 ferguson Exp $
X.\"
X.TH XSE 1 "19/6/1990"
X.ds ]W U of Rochester
X.SH NAME
Xxse \- an interface to XSendEvent()
X.SH SYNOPSIS
X.B xse
X[XToolkit options]
X[options]
X[event specs]
X.sp
X.SH DESCRIPTION
X.PP
XXse provides a way to send an arbitrary XEvent to an arbitrary window. It
Xprovides both command line and widget-based interfaces.
X.PP
XIf extra arguments are given on the command line, they are taken to be
Xevent specifiers (see below) and no tool is created. Each argument is
Xparsed into an event sequence which is sent to the desired window (see
XOptions, below). A window can be specified by giving it's name, in which
Xcase the first child of the root window whose name matches the given string
Xwill be used, or by giving it's XID, as obtained, e.g. from
X.BR xev (1),
Xor by using one of the keywords
X.BR PointerWindow ,
X.BR InputFocus ,
Xor
X.BR ClickWindow .
XPointerWindow will send the event to the window that the pointer is over,
XInputFocus will send it to the window with the input focus, and ClickWindow
Xwill allow you to select the window which will receive the event by clicking
Xin it. The default is InputFocus.
X.PP
XIf no extra arguments are present, then a tool is created using the
Xresources in the application default file. To customize this tool, see
Xbelow under Customizing.
X.sp
X.SH OPTIONS
X.PP
XThe following resources can be set on the command line or in a resource
Xfile:
X.IP "\fB-window\fP win"
XSend events to specified window unless the actions explicitly override
Xthis.
X.sp
X.SH "SPECIFYING EVENTS"
X.PP
XThe syntax for specifying events is modelled after that described in
XAppendix B of the XToolkit Intrinsics (Xt) manual for specifying
Xtranslations. It is extended to allow more complete specification of fields
Xthat are not needed for recognition but are useful for generation.
X.PP
XAn event sequence is a comma-separated list of events.
X.PP
XAn event is an optional list of modifiers, followed by an event type
Xdescription in angle brackets (`<' and `>'), followed by optional
Xfield specifiers.
X.PP
XThe list of modifiers is a whitespace-separated list of the following
Xsymbols:
X.na
X.nf
X		Shift	s	Mod1	Button1
X		Lock		l	Mod2	Button2
X		Ctrl		c	Mod3	Button3
X		Meta		m	Mod4	Button4
X		Hyper	h	Mod5	Button5
X		Super	su
X		Alt		a
X.fi
X.ad
XThe effect of specifying these is to inclusively-OR them into the state
Xfield of events for which this field exists. They are ignored for other
Xevents.
X.PP
XThe event type should be one of the following list, which includes all
Xpossible types of XEvent. They are described along with possible field
Xspecifiers. Certain event types have shorthands that are also described.
XExcept in keysyms and atoms, case is not significant. Where integers are
Xcalled for, a leading zero (`0') indicates octal, and a leading `0x' or
X`0X' indicates hexadecimal. An XID is an integer, usually in hex.
X.LP
X\fBKey\fP detail x y xroot yroot
X.br
X\fBKeyPress\fP detail x y xroot yroot
X.br
X\fBKeyDown\fP detail x y xroot yroot
X.br
X\fBKeyRelease\fP detail x y xroot yroot
X.br
X\fBKeyUp\fP detail x y xroot yroot
X.in +\n(INu
XThis sets the state field from the modifier list and sets same_screen to True.
XIt uses XStringToKeysym(3X) and XKeysymToKeycode(3X) to translate the
Xdetail (a keysym) to the keycode to send.
X.LP
X\fBCtrl\fP detail x y xroot yroot
X.br
X\fBShift\fP detail x y xroot yroot
X.br
X\fBMeta\fP detail x y xroot yroot
X.in +\n(INu
XThese are shorthand for a
X.B KeyPress
Xevent with the appropriate modifier bit set.
X.LP
X\fBButtonPress\fP detail
X.br
X\fBBtnDown\fP detail
X.br
X\fBButtonRelease\fP detail
X.br
X\fBBtnUp\fP detail
X.in +\n(INu
XSets the detail (which button) field and sets the state from the modifier
Xlist. The same_screen field is set to True.
X.LP
X\fBBtn1Down\fP
X.br
X\fBBtn2Down\fP
X.br
X\fBBtn3Down\fP
X.br
X\fBBtn4Down\fP
X.br
X\fBBtn5Down\fP
X.in +\n(INu
XShorthand for a
X.B ButtonPress
Xevent with the appropriate detail.
X.LP
X\fBBtn1Up\fP
X.br
X\fBBtn2Up\fP
X.br
X\fBBtn3Up\fP
X.br
X\fBBtn4Up\fP
X.br
X\fBBtn5Up\fP
X.in +\n(INu
XShorthand for a
X.B ButtonRelease
Xevent with the appropriate detail.
X.LP
X\fBMotionNotify\fP detail
X.br
X\fBPtrMoved\fP detail
X.br
X\fBMotion\fP detail
X.br
X\fBMouseMoved\fP detail
X.br
X\fBBtnMotion\fP detail
X.in +\n(INu
XThe detail should be one of
X.B Normal
Xor
X.BR Hint .
XThe same_screen field is set to True.
X.LP
X\fBBtn1Motion\fP detail
X.br
X\fBBtn2Motion\fP detail
X.br
X\fBBtn3Motion\fP detail
X.br
X\fBBtn4Motion\fP detail
X.br
X\fBBtn5Motion\fP detail
X.in +\n(INu
XShorthand for a
X.B MotionNotify
Xevent with the appropriate modifier bit set.
X.LP
X\fBEnterNotify\fP mode detail
X.br
X\fBEnter\fP mode detail
X.br
X\fBEnterWindow\fP mode detail
X.br
X\fBLeaveNotify\fP mode detail
X.br
X\fBLeave\fP mode detail
X.br
X\fBLeaveWindow\fP mode detail
X.in +\n(INu
XThe mode should be one of
X.BR Normal ,
X.BR Grab ,
X.BR Ungrab ,
Xor
X.BR WhileGrabbed .
XThe detail can be one of
X.BR Ancestor ,
X.BR Virtual ,
X.BR Inferior ,
X.BR Nonlinear ,
X.BR NonlinearVirtual ,
X.BR Pointer ,
X.BR PointerRoot ,
Xor
X.BR DetailNone .
XThe state field is set from the modifier list and the same_screen field is
Xset to True.
X.LP
X\fBFocusIn\fP mode detail
X.br
X\fBFocusOut\fP mode detail
X.in +\n(INu
XThe mode and detail should be as above.
X.LP
X\fBKeymapNotify\fP key_vector
X.in +\n(INu
XThe key_vector should be a whitespace-separated list of up to thirty-two
Xintegers representing the keyboard bitmap.
X.LP
X\fBExpose\fP x y width height count
X.br
X\fBGraphicsExpose\fP x y width height count
X.br
X\fBGrExp\fP x y width height count maj_code min_code
X.br
X\fBNoExpose\fP maj_code min_code
X.br
X\fBNoExp\fP maj_code min_code
X.in +\n(INu
XAll field specifiers should be integers.
X.LP
X\fBCirculateNotify\fP detail
X.br
X\fBCirc\fP detail
X.br
X\fBCirculateRequest\fP detail
X.br
X\fBCircReq\fP detail
X.in +\n(INu
XThe detail should be one of
X.BR PlaceOnTop ,
X.BR OnTop ,
X.BR PlaceOnBottom ,
Xor
X.BR OnBottom .
X.LP
X\fBConfigureNotify\fP x y width height border_width above override
X.br
X\fBConfigure\fP x y width height border_width above override
X.br
X\fBConfigureRequest\fP x y width height border_width above override
X.br
X\fBConfigureReq\fP x y width height border_width above override
X.in +\n(INu
XAll fields should be integers except above which should be
Xan XID and override which should be a boolean.
X.LP
X\fBCreateNotify\fP x y width height border_width override
X.br
X\fBCreate\fP x y width height border_width override
X.in +\n(INu
XAll fields should be integers except override which should be a
Xboolean.
X.LP
X\fBDestroyNotify\fP window
X.br
X\fBDestroy\fP window
X.in +\n(INu
XThe window field should be an XID in any base.
X.LP
X\fBGravityNotify\fP x y
X.br
X\fBGrav\fP x y
X.in +\n(INu
XBoth fields should be integers.
X.LP
X\fBMapNotify\fP override
X.br
X\fBMap\fP override
X.br
X\fBMapRequest\fP override
X.br
X\fBMapReq\fP override
X.in +\n(INu
XThe override field should be a boolean.
X.LP
X\fBMappingNotify\fP request [first_keycode count]
X.br
X\fBMapping\fP request [first_keycode count]
X.in +\n(INu
XThe request field should be one of
X.BR Modifier ,
X.BR Keyboard ,
Xor
X.BR Pointer .
XIf it is
X.BR Keyboard ,
Xthen first_keycode and count should be integers.
X.LP
X\fBReparentNotify\fP parent x y override
X.br
X\fBReparent\fP parent x y override
X.in +\n(INu
XThe parent field should be an XID, x and y should be
Xintegers, and override should be a boolean.
X.LP
X\fBUnmapNotify\fP from_configure
X.br
X\fBUnmap\fP from_configure
X.in +\n(INu
XThe from_configure field should be a boolean.
X.LP
X\fBVisibilityNotify\fP state
X.br
X\fBVisible\fP state
X.in +\n(INu
XThe state field should be one of
X.BR Unobscured ,
X.BR PartiallyObscured ,
Xor
X.BR FullyObscured .
X.LP
X\fBResizeRequest\fP width height
X.br
X\fBResReq\fP width height
X.in +\n(INu
XBoth fields should be integers.
X.LP
X\fBClientMessage\fP message_type format data
X.br
X\fBMessage\fP message_type format data
X.in +\n(INu
XThe message_type field should be an atom. The format field can be
X.BR b ,
X.BR c ,
X.BR s ,
Xor
X.BR l ,
Xin which case the data field is a whitespace-separated list of twenty bytes,
Xtwenty characters, ten shorts or five longs respectively. These can be in
Xany base, except characters which are taken as is.
X.LP
X\fBPropertyNotify\fP atom state
X.br
X\fBProp\fP atom state
X.in +\n(INu
XThe atom field should be an atom and the state field should be one of
X.B NewValue
Xor
X.BR Delete .
X.LP
X\fBSelectionClear\fP selection
X.br
X\fBSelClr\fP selection
X.in +\n(INu
XThe selection field should be an atom. The time field is set to
XCurrentTime.
X.LP
X\fBSelectionRequest\fP selection target property
X.br
X\fBSelReq\fP selection target property
X.in +\n(INu
XThe selection and target fields should be atoms. The property field should
Xbe an atom or the special value
X.BR None .
XThe time field is set to CurrentTime.
X.LP
X\fBSelectionNotify\fP selection target property
X.br
X\fBSelect\fP selection target property
X.in +\n(INu
XThe selection and target fields should be atoms. The property field should
Xbe an atom or the special value
X.BR None .
XThe time field is set to CurrentTime.
X.sp
X.SH EXAMPLES
X.PP
XThe following command would cause the date command to be executed if the
Xmouse is clicked in a shell window:
X
X.nf
X.na
X	% xse -win ClickWindow '<Key>d,<Key>a,<Key>t,<Key>e,<Key>Return'
X.ad
X.fi
X
XIt could also be specified as
X
X.nf
X.na
X	% xse '<Key>d' '<Key>a' '<Key>t' '<Key>e' '<Key>Return'
X.ad
X.fi
X
Xand this time the events would go to the window with the keyboard focus.
X.sp
X.SH "CUSTOMIZING XSE"
X.PP
XWhen xse operates in tool mode, it displays a form filled with an
Xarbitrary number and arrangement of Command buttons. To customize the
Xbehaviour, copy the default application defaults file (see below under
XFiles) and edit it to add your own buttons and actions.
X.PP
XThe application class is
X.BR Xse .
XThe resource
X.B numButtons
Xdetermines how many buttons will be created. They are named `buttonN' where
XN ranges from 1 to numButtons. The widget hierarchy is
X
X.nf
X.na
X	Xse toplevel
X	    Form form
X		Command buttonN
X.ad
X.fi
X
XYou can create different versions of xse from the same application
Xdefaults file by specifying different program names in place of `Xse', and
Xmaking links to the xse executable with those names. Thus
X`xsevi.numButtons' applies when the command `xse-vi' is executed,
Xand this should be a link to xse.
X.sp
X.SH "Translation Actions"
X.PP
XThere are only two translation actions:
X.B xse-quit()
Xexits the tool and
X.B xse_send()
Xsends an event sequence to a window. If only one argument is given, it is
Xtaken to be an event sequence and the events are sent to the default window.
XIf two arguments are given, the first is the window and the second the event
Xsequence. Embedded commas in the event sequence must be escaped.
X.sp
X.SH ENVIRONMENT
X.PP
X.ad
X.nf
XXAPPLRESDIR	application defaults directory
X.fi
X.ad
X.sp
X.SH FILES
X.PP
X.ad
X.nf
X/u/ferguson/lib/app-default/Xse	default app-defaults file
X.fi
X.ad
X.sp
X.SH DIAGNOSTICS
X.PP
XA variety of messages can be generated if xse cannot parse an event
Xsequence. These should give enough information and context for debugging.
XIn addition, bad window specifications and the like are flagged by the
Xdefault X mechanism of printing lots of error messages and exiting.
X.sp
X.SH BUGS
X.PP
XXse cannot send
X.B ColormapNotify
Xevents, at least not yet.
X.PP
XNot really a bug, but if you are using xse with
X.BR xterm (1),
Xmake sure to enable send events using the main menu or the allowSendEvents
Xresource.
X.PP
XAlso not really a bug, but note that while sending a
X.B Unmap
Xevent will cause a window to disappear, sending a
X.B Map
Xevent will not make it reappear.
X.sp
X.SH SEE ALSO
X.PP
XXSendEvent(3X),
Xxev(1).
X.sp
X.SH AUTHOR
X.PP
XGeorge Ferguson (ferguson@cs.rochester.edu).
END_OF_FILE
if test 11655 -ne `wc -c <'xse.man'`; then
    echo shar: \"'xse.man'\" unpacked with wrong size!
fi
# end of 'xse.man'
fi
echo shar: End of archive 2 \(of 3\).
cp /dev/null ark2isdone
MISSING=""
for I in 1 2 3 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 3 archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
George Ferguson			ARPA: ferguson@cs.rochester.edu
University of Rochester		UUCP: {decvax,rutgers}!rochester!ferguson
Rochester  NY  14627		VOX:  (716) 275-2527

ferguson@cs.rochester.edu (George Ferguson) (08/17/90)

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 3 (of 3)."
# Contents:  parse.c
# Wrapped by ferguson@swan.cs.rochester.edu on Thu Aug 16 15:18:00 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'parse.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'parse.c'\"
else
echo shar: Extracting \"'parse.c'\" \(20674 characters\)
sed "s/^X//" >'parse.c' <<'END_OF_FILE'
X/*
X *	parse.c - Parse event specifications (see Xt manual, appendix B)
X *
X *	George Ferguson, ferguson@cs.rochester.edu, 1 Jun 1990.
X *
X *	$Id: parse.c,v 1.4 90/08/15 11:32:19 ferguson Exp $
X *
X */
X
X#include <stdio.h>
X#include <ctype.h>
X#include <string.h>
X#include <X11/Xlib.h>
X#include <X11/keysym.h>
X#include "parse.h"
Xextern Display *display;
Xextern Window root;
X
X/*
X * Functions defined
X */
Xchar *parseEventList();
Xvoid freeEventList();
Xstatic char *parseEvent(),*parseMods(),*parseType(),*parseDetail();
Xstatic unsigned int lookup();
Xstatic void parseError();
X
X#define SKIPWHITE(S)	while (isspace(*(S))) (S) += 1
X
X/*
X * Text to value mappings
X */
Xtypedef struct {
X        char *name;
X        unsigned int value;
X} NameValue;
X
Xstatic NameValue booleans[] = {
X    {"True",	True},
X    {"False",	False},
X    {"On",	True},
X    {"Off",	False},
X    {NULL,	0},
X};
X
Xstatic NameValue modifiers[] = {
X    {"None",	None},
X    {"Shift",	ShiftMask},
X    {"Lock",	LockMask},
X    {"Ctrl",	ControlMask},
X    {"Mod1",	Mod1Mask},
X    {"Mod2",	Mod2Mask},
X    {"Mod3",	Mod3Mask},
X    {"Mod4",	Mod4Mask},
X    {"Mod5",	Mod5Mask},
X    {"Meta",	XK_Meta_L},
X    {"m",	XK_Meta_L},
X    {"h",	XK_Hyper_L},
X    {"su",	XK_Super_L},
X    {"a",	XK_Alt_L},
X    {"Hyper",	XK_Hyper_L},
X    {"Super",	XK_Super_L},
X    {"Alt",	XK_Alt_L},
X    {"Button1",	Button1Mask},
X    {"Button2",	Button2Mask},
X    {"Button3",	Button3Mask},
X    {"Button4",	Button4Mask},
X    {"Button5",	Button5Mask},
X    {"Any",	AnyModifier},
X    {"c",	ControlMask},
X    {"s",	ShiftMask},
X    {"l",	LockMask},
X    {NULL,	0},
X};
X
Xstatic NameValue buttonNames[] = {
X    {"Button1",	Button1},
X    {"Button2", Button2},
X    {"Button3", Button3},
X    {"Button4", Button4},
X    {"Button5", Button5},
X    {NULL,	0},
X};
X
Xstatic NameValue motionDetails[] = {
X    {"Normal",	NotifyNormal},
X    {"Hint",	NotifyHint},
X    {NULL,	0},
X};
X
Xstatic NameValue notifyModes[] = {
X    {"Normal",		NotifyNormal},
X    {"Grab",		NotifyGrab},
X    {"Ungrab",		NotifyUngrab},
X    {"WhileGrabbed",    NotifyWhileGrabbed},
X    {NULL,		0},
X};
X
Xstatic NameValue notifyDetails[] = {
X    {"Ancestor",	NotifyAncestor},
X    {"Virtual",		NotifyVirtual},
X    {"Inferior",	NotifyInferior},
X    {"Nonlinear",	NotifyNonlinear},
X    {"NonlinearVirtual",NotifyNonlinearVirtual},
X    {"Pointer",		NotifyPointer},
X    {"PointerRoot",	NotifyPointerRoot},
X    {"DetailNone",	NotifyDetailNone},
X    {NULL,		0},
X};
X
Xstatic NameValue circulateDetails[] = {
X    {"PlaceOnTop",	PlaceOnTop},
X    {"OnTop",		PlaceOnTop},
X    {"PlaceOnBottom", 	PlaceOnBottom},
X    {"OnBottom", 	PlaceOnBottom},
X    {NULL,		0},
X};
X
Xstatic NameValue mappingDetails[] = {
X    {"Modifier",	MappingModifier},
X    {"Keyboard",	MappingKeyboard},
X    {"Pointer",		MappingPointer},
X    {NULL,		0},
X};
X
Xstatic NameValue visibilityDetails[] = {
X    {"Unobscured",	 VisibilityUnobscured},
X    {"PartiallyObscured",VisibilityPartiallyObscured},
X    {"FullyObscured",    VisibilityFullyObscured},
X    {NULL,		0},
X};
X
Xstatic NameValue propertyDetails[] = {
X    {"NewValue",	PropertyNewValue},
X    {"Delete",		PropertyDelete},
X    {NULL,		0},
X};
X
Xtypedef struct {
X        char *name;
X        unsigned int value;
X        unsigned int mods;
X        unsigned int detail;
X} NameValueModsDetail;
X
Xstatic NameValueModsDetail types[] = {
X{"KeyPress",	     KeyPress,	 0,		0},
X{"Key", 	     KeyPress,	 0,		0},
X{"KeyDown",	     KeyPress,	 0,		0},
X{"Ctrl",             KeyPress,   ControlMask,	0},
X{"Shift",            KeyPress,   ShiftMask,	0},
X{"Meta",             KeyPress,   0,		0},
X{"KeyUp",	     KeyRelease, 0,		0},
X{"KeyRelease",	     KeyRelease, 0,		0},
X{"ButtonPress",      ButtonPress, 0,	0},
X{"BtnDown",	     ButtonPress, 0,	0},
X{"Btn1Down",	     ButtonPress, 0,	Button1},
X{"Btn2Down", 	     ButtonPress, 0,	Button2},
X{"Btn3Down", 	     ButtonPress, 0,	Button3},
X{"Btn4Down", 	     ButtonPress, 0,	Button4},
X{"Btn5Down", 	     ButtonPress, 0,	Button5},
X{"ButtonRelease",    ButtonRelease, 0,	0},
X{"BtnUp", 	     ButtonRelease, 0,	0},
X{"Btn1Up", 	     ButtonRelease, 0,	Button1},
X{"Btn2Up", 	     ButtonRelease, 0,	Button2},
X{"Btn3Up", 	     ButtonRelease, 0,	Button3},
X{"Btn4Up", 	     ButtonRelease, 0,	Button4},
X{"Btn5Up", 	     ButtonRelease, 0,	Button5},
X{"MotionNotify",     MotionNotify, 0,			0},
X{"PtrMoved", 	     MotionNotify, 0,			0},
X{"Motion", 	     MotionNotify, 0,			0},
X{"MouseMoved", 	     MotionNotify, 0,			0},
X{"BtnMotion",        MotionNotify, 0,			0},
X{"Btn1Motion",       MotionNotify, Button1Mask,		0},
X{"Btn2Motion",       MotionNotify, Button2Mask,		0},
X{"Btn3Motion",       MotionNotify, Button3Mask,		0},
X{"Btn4Motion",       MotionNotify, Button4Mask,		0},
X{"Btn5Motion",       MotionNotify, Button5Mask,		0},
X{"EnterNotify",      EnterNotify, 0, 0},
X{"Enter",	     EnterNotify, 0, 0},
X{"EnterWindow",      EnterNotify, 0, 0},
X{"LeaveNotify",      LeaveNotify, 0, 0},
X{"LeaveWindow",      LeaveNotify, 0, 0},
X{"Leave",	     LeaveNotify, 0, 0},
X{"FocusIn",	     FocusIn,  0, 0},
X{"FocusOut",	     FocusOut, 0, 0},
X{"KeymapNotify",     KeymapNotify, 0, 0},
X{"Keymap",	     KeymapNotify, 0, 0},
X{"Expose", 	     Expose, 0, 0},
X{"GraphicsExpose",   GraphicsExpose, 0, 0},
X{"GrExp",	     GraphicsExpose, 0, 0},
X{"NoExpose",	     NoExpose, 0, 0},
X{"NoExp",	     NoExpose, 0, 0},
X{"VisibilityNotify", VisibilityNotify, 0, 0},
X{"Visible",	     VisibilityNotify, 0, 0},
X{"CreateNotify",     CreateNotify, 0, 0},
X{"Create",	     CreateNotify, 0, 0},
X{"DestroyNotify",    DestroyNotify, 0, 0},
X{"Destroy",	     DestroyNotify, 0, 0},
X{"UnmapNotify",      UnmapNotify, 0, 0},
X{"Unmap",	     UnmapNotify, 0, 0},
X{"MapNotify",	     MapNotify,	0, 0},
X{"Map",		     MapNotify,	0, 0},
X{"MapRequest",	     MapRequest, 0, 0},
X{"MapReq",	     MapRequest, 0, 0},
X{"ReparentNotify",   ReparentNotify, 0, 0},
X{"Reparent",	     ReparentNotify, 0, 0},
X{"ConfigureNotify",  ConfigureNotify, 0, 0},
X{"Configure",	     ConfigureNotify, 0, 0},
X{"ConfigureRequest", ConfigureRequest, 0, 0},
X{"ConfigureReq",     ConfigureRequest, 0, 0},
X{"GravityNotify",    GravityNotify, 0, 0},
X{"Grav",	     GravityNotify, 0, 0},
X{"ResizeRequest",    ResizeRequest, 0, 0},
X{"ResReq",	     ResizeRequest, 0, 0},
X{"CirculateNotify",  CirculateNotify, 0, 0},
X{"Circ",	     CirculateNotify, 0, 0},
X{"CirculateRequest", CirculateRequest, 0, 0},
X{"CircReq",	     CirculateRequest, 0, 0},
X{"PropertyNotify",   PropertyNotify, 0, 0},
X{"Prop",	     PropertyNotify, 0, 0},
X{"SelectionClear",   SelectionClear, 0, 0},
X{"SelClr",	     SelectionClear, 0, 0},
X{"SelectionRequest", SelectionRequest, 0, 0},
X{"SelReq",	     SelectionRequest, 0, 0},
X{"SelectionNotify",  SelectionNotify, 0, 0},
X{"Select",	     SelectionNotify, 0, 0},
X{"ColormapNotify",   ColormapNotify, 0, 0},
X{"Clrmap",	     ColormapNotify, 0, 0},
X{"ClientMessage",    ClientMessage, 0, 0},
X{"Message",	     ClientMessage, 0, 0},
X{"MappingNotify",    MappingNotify, 0, 0},
X{"Mapping",	     MappingNotify, 0, 0},
X{NULL,		     0, 0, 0}
X};
X
X/*	-	-	-	-	-	-	-	-	*/
X
Xstatic unsigned int
Xlookup(table,name)
XNameValue *table;
Xchar *name;
X{
X    while (table->name != NULL && strcasecmp(name,table->name) != 0)
X	table += 1;
X    return(table->value);
X}
X
Xchar *
XparseEventList(str,evp)
Xchar *str;
XEventListPtr *evp;
X{
X    EventListPtr ev,end;
X
X    *evp == NULL;
X    while (*str) {
X	str = parseEvent(str,&ev);
X	if (ev != NULL)
X	    if (*evp == NULL)
X		end = *evp = ev;
X	    else
X		end = end->next = ev;	/* wow! */
X	else
X	    return(str);
X	if (*str && *str != ',') {
X	    parseError("',' expected",str);
X	    return(str);
X	} else if (*str)
X	   str += 1;		/* skip comma */
X    }
X    return(str);
X}
X
Xstatic char *
XparseEvent(str,evp)
Xchar *str;
XEventListPtr *evp;
X{
X    unsigned int mods;
X    int type,count;
X    unsigned int detail;
X
X    str = parseMods(str,&mods);
X    SKIPWHITE(str);
X    if (*str != '<') {
X	parseError("'<' expected",str);
X	return(str);
X    } else
X	str += 1;
X    str = parseType(str,&type,&mods,&detail);
X    if (*str != '>') {
X	parseError("'>' expected",str);
X	return(str);
X    } else
X	str += 1;
X    SKIPWHITE(str);
X    count = 1;		/* default */
X    if (*str == '(') {
X	str += 1;
X	count = (int)strtol(str,&str,0);
X	if (count == 0) {
X	    parseError("count expected",str);
X	    return(str);
X	}
X	if (*str != ')')  {
X	    parseError("')' expected",str);
X	    return(str);
X	} else
X	    str += 1;
X    }
X    SKIPWHITE(str);
X    *evp = (EventListElem *)malloc(sizeof(EventListElem)); 
X    (*evp)->count = count;
X    (*evp)->next = NULL;
X    str = parseDetail(str,&((*evp)->event),type,mods,detail);
X    return(str);
X}
X
Xstatic char *
XparseMods(str,modsp)
Xchar *str;
Xunsigned int *modsp;
X{
X    char modstr[32];
X    int i;
X    unsigned int m;
X
X    *modsp = (unsigned int)0;
X    while (*str && *str != '<') {
X	SKIPWHITE(str);
X	i = 0;
X	while (isalnum(*str) && i < 30)
X	    modstr[i++] = *str++;
X	if (i == 31)
X	    parseError("modifier name too long",str);
X	modstr[i] = '\0';
X	if ((m=lookup(modifiers,modstr)) == 0)
X	    parseError("unknown modifier",modstr);
X	else
X	    *modsp |= m;
X    }
X    return(str);
X}
X
Xstatic char *
XparseType(str,typep,modsp,detailp)
Xchar *str;
Xint *typep;
Xunsigned int *modsp,*detailp;
X{
X    char typestr[32];
X    int i; 
X
X    i = 0;
X    while (isalnum(*str) && i < 30)
X	typestr[i++] = *str++;
X    if (i == 31)
X	parseError("event type too long",str);
X    typestr[i] = '\0';
X    for (i=0; types[i].name!=NULL && strcasecmp(types[i].name,typestr)!=0; i++);
X    if (types[i].name == NULL) {
X	parseError("unknown event type",typestr);
X	*typep = 0;
X    } else {
X	*typep = types[i].value;
X	*detailp = types[i].detail;
X	*modsp |= types[i].mods;
X    }
X    return(str);
X}
X
Xstatic char *
XparseDetail(str,xevp,type,mods,detail)
Xchar *str;
XXEvent *xevp;
Xint type;
Xunsigned int mods,detail;
X{
X    char detailstr[256];
X    int i;
X
X    i = 0;
X    while (*str && !(i > 0 && *str == ',') && i < 255)
X	detailstr[i++] = *str++;
X    if (i == 255)
X	parseError("detail too long (truncated)",str);
X    detailstr[i] = '\0';
X    xevp->type = type;
X    switch (type) {
X	case KeyPress:
X	case KeyRelease: {
X	    XKeyEvent *xkevp = (XKeyEvent *)xevp;
X	    KeyCode k;
X	    char *s = strchr(detailstr,' ');
X	    if (s != NULL)
X		*s++ = '\0';
X	    k = XKeysymToKeycode(display,XStringToKeysym(detailstr));
X	    if (detail != 0 && k != 0) {
X		parseError("key detail conflict",detailstr);
X	    	xkevp->type = -1;
X		break;
X	    } else if (detail == 0)
X	    	xkevp->keycode = k;
X	    else
X	    	xkevp->keycode = detail;
X	    if (s != NULL) {
X		xkevp->x = (int)strtol(s,&s,0);
X		xkevp->y = (int)strtol(s,&s,0);
X		xkevp->x_root = (int)strtol(s,&s,0);
X		xkevp->y_root = (int)strtol(s,&s,0);
X	    }
X	    xkevp->state = mods;
X	    xkevp->root = root;
X	    xkevp->same_screen = True;
X	    break;
X	}
X	case ButtonPress:
X	case ButtonRelease: {
X	    XButtonEvent *xbevp = (XButtonEvent *)xevp;
X	    unsigned b = lookup(buttonNames,detailstr);
X	    if (*detailstr && b == 0) {
X		parseError("bad button detail",detailstr);
X		xbevp->type = -1;
X		break;
X	    }
X	    if (detail != 0 && b != 0) {
X		parseError("button detail conflict",detailstr);
X	    	xbevp->button = 0;
X	    } else if (detail == 0)
X	    	xbevp->button = b;
X	    else
X	    	xbevp->button = detail;
X	    xbevp->state = mods;
X	    xbevp->root = root;
X	    xbevp->same_screen = True;
X	    break;
X	}
X	case MotionNotify: {
X	    XMotionEvent *xmevp = (XMotionEvent *)xevp;
X	    xmevp->is_hint = lookup(motionDetails,detailstr);
X	    if (*detailstr && xmevp->is_hint == 0) {
X		parseError("bad motion detail",detailstr);
X		xmevp->type = -1;
X	    }
X	    xmevp->state = mods;
X	    xmevp->root = root;
X	    xmevp->same_screen = True;
X	    break;
X	}
X	case EnterNotify:
X	case LeaveNotify: {
X	    XCrossingEvent *xcevp = (XCrossingEvent *)xevp;
X	    char *s = strchr(detailstr,' ');
X	    if (s != NULL)
X		*s++ = '\0';
X	    xcevp->mode = lookup(notifyModes,detailstr);
X	    if (s != NULL)
X		xcevp->detail = lookup(notifyDetails,s);
X	    xcevp->state = mods;
X	    xcevp->root = root;
X	    xcevp->same_screen = True;
X	    break;
X	}
X	case FocusIn:
X	case FocusOut: {
X	    XFocusChangeEvent *xfcevp = (XFocusChangeEvent *)xevp;
X	    char *s = strchr(detailstr,' ');
X	    if (s != NULL)
X		*s++ = '\0';
X	    xfcevp->mode = lookup(notifyModes,detailstr);
X	    if (s != NULL)
X	        xfcevp->detail = lookup(notifyDetails,s);
X	    if (*detailstr && xfcevp->mode == 0 && xfcevp->detail == 0) {
X		parseError("bad focus mode or detail",detailstr);
X		xfcevp->type = -1;
X	    }
X	    break;
X	}
X	case KeymapNotify: {
X	    XKeymapEvent *xkevp = (XKeymapEvent *)xevp;
X	    int i;
X	    char *s = detailstr;
X	    for (i=0; i < 32; i++)
X		xkevp->key_vector[i] = (char)strtol(s,&s,0);
X	    break;
X	}
X	case Expose: {
X	    XExposeEvent *xeevp = (XExposeEvent *)xevp;
X	    char *s = detailstr;
X	    xeevp->x = (int)strtol(s,&s,0);
X	    xeevp->y = (int)strtol(s,&s,0);
X	    xeevp->width = (int)strtol(s,&s,0);
X	    xeevp->height = (int)strtol(s,&s,0);
X	    xeevp->count = (int)strtol(s,&s,0);
X	    break;
X	}
X	case GraphicsExpose: {
X	    XGraphicsExposeEvent *xgevp = (XGraphicsExposeEvent *)xevp;
X	    char *s = detailstr;
X	    xgevp->x = (int)strtol(s,&s,0);
X	    xgevp->y = (int)strtol(s,&s,0);
X	    xgevp->width = (int)strtol(s,&s,0);
X	    xgevp->height = (int)strtol(s,&s,0);
X	    xgevp->count = (int)strtol(s,&s,0);
X	    xgevp->major_code = (int)strtol(s,&s,0);
X	    xgevp->minor_code = (int)strtol(s,&s,0);
X	    break;
X	}
X	case NoExpose: {
X	    XNoExposeEvent *xnevp = (XNoExposeEvent *)xevp;
X	    char *s = detailstr;
X	    xnevp->major_code = (int)strtol(s,&s,0);
X	    xnevp->minor_code = (int)strtol(s,&s,0);
X	    break;
X	}
X	case CirculateNotify:
X	case CirculateRequest: {
X	    XCirculateEvent *xcevp = (XCirculateEvent *)xevp;
X	    if ((xcevp->place=lookup(circulateDetails,detailstr)) == 99) {
X		parseError("bad circulate detail",detailstr);
X		xcevp->type = -1;
X	    }
X	    break;
X	}
X	case ConfigureNotify:
X	case ConfigureRequest: {
X	    XConfigureEvent *xcevp = (XConfigureEvent *)xevp;
X	    char *s = detailstr;
X	    xcevp->x = (int)strtol(s,&s,0);
X	    xcevp->y = (int)strtol(s,&s,0);
X	    xcevp->width = (int)strtol(s,&s,0);
X	    xcevp->height = (int)strtol(s,&s,0);
X	    xcevp->border_width = (int)strtol(s,&s,0);
X	    xcevp->above = (Window)strtol(s,&s,0);
X	    SKIPWHITE(s);
X	    xcevp->override_redirect=lookup(booleans,s);
X	    break;
X	}
X	case CreateNotify: {
X	    XCreateWindowEvent *xcevp = (XCreateWindowEvent *)xevp;
X	    char *s = detailstr;
X	    xcevp->x = (int)strtol(s,&s,0);
X	    xcevp->y = (int)strtol(s,&s,0);
X	    xcevp->width = (int)strtol(s,&s,0);
X	    xcevp->height = (int)strtol(s,&s,0);
X	    xcevp->border_width = (int)strtol(s,&s,0);
X	    SKIPWHITE(s);
X	    xcevp->override_redirect=lookup(booleans,s);
X	    break;
X	}
X	case DestroyNotify: {
X	    XDestroyWindowEvent *xdevp = (XDestroyWindowEvent *)xevp;
X	    xdevp->window = (Window)strtol(detailstr,NULL,0);
X	    break;
X	}
X	case GravityNotify: {
X	    XGravityEvent *xgevp = (XGravityEvent *)xevp;
X	    char *s = detailstr;
X	    xgevp->x = (int)strtol(s,&s,0);
X	    xgevp->y = (int)strtol(s,&s,0);
X	    break;
X	}
X	case MapNotify:
X	case MapRequest: {
X	    XMapEvent *xmevp = (XMapEvent *)xevp;
X	    xmevp->override_redirect = lookup(booleans,detailstr);
X	    break;
X	}
X	case MappingNotify: {
X	    XMappingEvent *xmevp = (XMappingEvent *)xevp;
X	    char *s=strchr(detailstr,' ');
X	    if (s != NULL)
X		*s++ = '\0';
X	    if ((xmevp->request=lookup(mappingDetails,detailstr)) == 0) {
X		parseError("bad mapping detail",detailstr);
X		xmevp->type = -1;
X	    }
X	    if (xmevp->request == MappingKeyboard && s != NULL) {
X		SKIPWHITE(s);
X		xmevp->first_keycode = (int)strtol(s,&s,0);
X		xmevp->count = (int)strtol(s,&s,0);
X	    }
X	    break;
X	}
X	case ReparentNotify: {
X	    XReparentEvent *xrevp = (XReparentEvent *)xevp;
X	    char *s = strchr(detailstr,' ');
X	    if (s != NULL)
X		*s++ = '\0';
X	    xrevp->parent = (Window)strtol(detailstr,NULL,0);
X	    if (s != NULL) {
X		SKIPWHITE(s);
X		xrevp->x = (int)strtol(s,&s,0);
X		xrevp->y = (int)strtol(s,&s,0);
X		SKIPWHITE(s);
X		xrevp->override_redirect = lookup(booleans,s);
X	    }
X	    break;
X	}
X	case UnmapNotify: {
X	    XUnmapEvent *xuevp = (XUnmapEvent *)xevp;
X	    xuevp->from_configure = lookup(booleans,detailstr);
X	    break;
X	}
X	case VisibilityNotify: {
X	    XVisibilityEvent *xvevp = (XVisibilityEvent *)xevp;
X	    xvevp->state = lookup(visibilityDetails,detailstr);
X	    break;
X	}
X	case ResizeRequest: {
X	    XResizeRequestEvent *xrevp = (XResizeRequestEvent *)xevp;
X	    char *s = detailstr;
X	    xrevp->width = (int)strtol(s,&s,0);
X	    xrevp->height = (int)strtol(s,&s,0);
X	    break;
X	}
X	case ColormapNotify:
X	    parseError("can't handle ColormapNotify events","");
X	    xevp->type = -1;
X	    break;
X	case ClientMessage: {
X	    XClientMessageEvent *xcevp = (XClientMessageEvent *)xevp;
X	    char *s = strchr(detailstr,' ');
X	    int i;
X	    if (*detailstr == '\0') {
X		parseError("missing atom for client message","");
X		xcevp->type = -1;
X		break;
X	    }
X	    if (s != NULL)
X		*s++ = '\0';
X	    xcevp->message_type = XInternAtom(display,detailstr,True);
X	    if (s != NULL) {
X		SKIPWHITE(s);
X		if (*s == 'b') {
X		    xcevp->format = 8;
X		    SKIPWHITE(s);
X		    for (i=0; i < 20; i++)
X			xcevp->data.b[i] = (char)strtol(s,&s,0);
X		} else if (*s == 'c') {
X		    xcevp->format = 8;
X		    SKIPWHITE(s);
X		    for (i=0; i < 20; i++)
X			xcevp->data.b[i] = *s++;
X		} else if (*s == 's') {
X		    xcevp->format = 16;
X		    SKIPWHITE(s);
X		    for (i=0; i < 10; i++)
X			xcevp->data.s[i] = (short)strtol(s,&s,0);
X		} else if (*s == 'l') {
X		    xcevp->format = 32;
X		    SKIPWHITE(s);
X		    for (i=0; i < 5; i++)
X			xcevp->data.l[i] = strtol(s,&s,0);
X		}
X	    }
X	}
X	case PropertyNotify: {
X	    XPropertyEvent *xpevp = (XPropertyEvent *)xevp;
X	    char *s = strchr(detailstr,' ');
X	    if (*detailstr == '\0') {
X		parseError("missing atom for property notify","");
X		xpevp->type = -1;
X		break;
X	    }
X	    if (s != NULL)
X		*s++ = '\0';
X	    xpevp->atom = XInternAtom(display,detailstr,True);
X	    if (s != NULL) {
X		SKIPWHITE(s);
X		xpevp->state = lookup(propertyDetails,s);
X	    }
X	    xpevp->time = CurrentTime;
X	    break;
X	}
X	case SelectionClear: {
X	    XSelectionClearEvent *xsevp = (XSelectionClearEvent *)xevp;
X	    if (*detailstr == '\0') {
X		parseError("missing atom for selection clear","");
X		xsevp->type = -1;
X		break;
X	    }
X	    xsevp->selection = XInternAtom(display,detailstr,True);
X	    xsevp->time = CurrentTime;
X	    break;
X	}
X	/* Note SelectionRequest and Selection are identical except the
X	   event types have different structures (and different errors). */
X	case SelectionRequest: {
X	    XSelectionRequestEvent *xsevp = (XSelectionRequestEvent *)xevp;
X	    char *s1 = detailstr;
X	    char *s2,*s3;
X	    if (*s1 == '\0') {
X		parseError("missing atom for selection request (selection)","");
X		xsevp->type = -1;
X		break;
X	    }
X	    if ((s2=strchr(s1,' ')) == NULL) {
X		parseError("missing atom for selection request (target)","");
X		xsevp->type = -1;
X		break;
X	    }
X	    *s2++ = '\0';
X	    SKIPWHITE(s2);
X	    if ((s3=strchr(s2,' ')) == NULL) {
X		parseError("missing atom for selection request (property)","");
X		xsevp->type = -1;
X		break;
X	    }
X	    *s3++ = '\0';
X	    SKIPWHITE(s3);
X	    xsevp->selection = XInternAtom(display,s1,True);
X	    xsevp->target = XInternAtom(display,s2,True);
X	    if (*s3 == '\0' || strcasecmp(s3,"None") == 0)
X		xsevp->property = None;
X	    else
X		xsevp->property = XInternAtom(display,s3,True);
X	    xsevp->time = CurrentTime;
X	}
X	case SelectionNotify: {
X	    XSelectionEvent *xsevp = (XSelectionEvent *)xevp;
X	    char *s1 = detailstr;
X	    char *s2,*s3;
X	    if (*s1 == '\0') {
X		parseError("missing atom for selection notify (selection)","");
X		xsevp->type = -1;
X		break;
X	    }
X	    if ((s2=strchr(s1,' ')) == NULL) {
X		parseError("missing atom for selection notify (target)","");
X		xsevp->type = -1;
X		break;
X	    }
X	    *s2++ = '\0';
X	    SKIPWHITE(s2);
X	    if ((s3=strchr(s2,' ')) == NULL) {
X		parseError("missing atom for selection notify (property)","");
X		xsevp->type = -1;
X		break;
X	    }
X	    *s3++ = '\0';
X	    SKIPWHITE(s3);
X	    xsevp->selection = XInternAtom(display,s1,True);
X	    xsevp->target = XInternAtom(display,s2,True);
X	    if (*s3 == '\0' || strcasecmp(s3,"None") == 0)
X		xsevp->property = None;
X	    else
X		xsevp->property = XInternAtom(display,s3,True);
X	    xsevp->time = CurrentTime;
X	}
X	default:
X	    parseError("don't understand event type\n","");
X	    xevp->type = -1;
X    }
X    return(str);
X}
X
Xstatic void
XparseError(s1,s2)
Xchar *s1,*s2;
X{
X    if (*s2 == '\0')
X	fprintf(stderr,"xse: %s\n",s1);
X    else
X	fprintf(stderr,"xse: %s: \"%s\"\n",s1,s2);
X}
X
Xvoid
XfreeEventList(p)
XEventListPtr p;
X{
X    EventListPtr q;
X
X    while (p != NULL) {
X	q = p;
X	p = p->next;
X	free(q);
X    }
X}
END_OF_FILE
if test 20674 -ne `wc -c <'parse.c'`; then
    echo shar: \"'parse.c'\" unpacked with wrong size!
fi
# end of 'parse.c'
fi
echo shar: End of archive 3 \(of 3\).
cp /dev/null ark3isdone
MISSING=""
for I in 1 2 3 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 3 archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
George Ferguson			ARPA: ferguson@cs.rochester.edu
University of Rochester		UUCP: {decvax,rutgers}!rochester!ferguson
Rochester  NY  14627		VOX:  (716) 275-2527