v05i062: Xrooms -- A Rooms implementation for X, Part12/14

Kent Landfield kent at ssbell.IMD.Sterling.COM
Mon Jan 15 17:19:05 AEST 1990


Submitted-by: wsl.dec.com!mikey (Mike Yang)
Posting-number: Volume 5, Issue 62
Archive-name: xrooms/part12

#! /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 12 (of 14)."
# Contents:  ./xrooms/xrXawUI.c ./xrset/xrset.c
# Wrapped by kent at ssbell on Sun Jan 14 21:58:17 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f './xrooms/xrXawUI.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./xrooms/xrXawUI.c'\"
else
echo shar: Extracting \"'./xrooms/xrXawUI.c'\" \(23300 characters\)
sed "s/^X//" >'./xrooms/xrXawUI.c' <<'END_OF_FILE'
X
X  /*\
X   *  $Header: xrXawUI.c,v 5.4 90/01/11 16:21:11 erik Exp $
X   *
X   *		              COPYRIGHT 1990
X   *		        DIGITAL EQUIPMENT CORPORATION
X   *		           MAYNARD, MASSACHUSETTS
X   *			    ALL RIGHTS RESERVED.
X   *
X   * THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND
X   * SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
X   * DIGITAL MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE 
X   * FOR ANY PURPOSE.  IT IS SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED 
X   * WARRANTY.
X   *
X   * IF THE SOFTWARE IS MODIFIED IN A MANNER CREATING DERIVATIVE COPYRIGHT
X   * RIGHTS, APPROPRIATE LEGENDS MAY BE PLACED ON THE DERIVATIVE WORK IN
X   * ADDITION TO THAT SET FORTH ABOVE.
X   *
X   * Permission to use, copy, modify, and distribute this software and its
X   * documentation for any purpose and without fee is hereby granted, provided
X   * that the above copyright notice appear in all copies and that both that
X   * copyright notice and this permission notice appear in supporting
X   * documentation, and that the name of Digital Equipment Corporation not be
X   * used in advertising or publicity pertaining to distribution of the 
X   * software without specific, written prior permission.
X  \*/
X
X#include <X11/Xos.h>
X#include <X11/Intrinsic.h>
X#include <X11/Xutil.h>
X#include <X11/StringDefs.h>
X#include <X11/cursorfont.h>
X#include <X11/Xatom.h>
X
X#include <X11/Shell.h>
X#ifdef X11R4
X#include <X11/Xaw/Form.h>
X#include <X11/Xaw/Command.h>
X#include <X11/Xaw/Dialog.h>
X#else
X#include <X11/Form.h>
X#include <X11/Command.h>
X#include <X11/Dialog.h>
X#endif
X#include <X11/IntrinsicP.h>
X
X#define	BOOLEAN_DEFINED
X#define	OPAQUE_DEFINED
X#define	DEBUG_VAR	xruiDebug
X#include "utils.h"
X#include "hash.h"
X
X#include "rooms.h"
X
X#include "xrActions.h"
X#include "xrDebug.h"
X#include "xrXUtils.h"
X#include "xrProfile.h"
X#include "xrRoom.h"
X#include "xrooms.h"
X
X#include "xrUI.h"
X
X/***====================================================================***/
X
XWidget	 xruiTopLevel,xruiMenu,xruiWinMenu;
XWidget	 xruiSetupModeItem;
XWidget	 xruiPromptWidget = NULL;
XWidget	 xruiPromptText = NULL;
X
XWidget	 xruiScrollW;
X
Xchar	*xruiDefaultRoom;
XBoolean	 xruiConfirmExit;
X
X/***====================================================================***/
X
Xstatic void 
XxruiDestroyPromptWindow()
X{
X    uENTRY("xruiDestroyPromptWindow()\n");
X    if (xruiPromptWidget != NULL) {
X	XtDestroyWidget(xruiPromptWidget);
X	xruiPromptWidget = NULL;
X    }
X    uVOIDRETURN;
X}
X
X/***====================================================================***/
X
Xvoid
XxruiPopDownWinMenu()
X{
X  XtPopdown(xruiWinMenu);
X}
X
X/***====================================================================***/
X
Xstatic	Boolean	xruiNeedString;
X
Xstatic void 
XxruiDoPromptNo(widget,clientData,callData)
XWidget	widget;
XOpaque	clientData;
XOpaque	callData;
X{
X    uENTRY3("xruiDoPromptNo(0x%x,0x%x,0x%x)\n",widget,clientData,callData);
X    xruiDestroyPromptWindow();
X    uVOIDRETURN;
X}
X
X/***====================================================================***/
X
Xvoid	(*xruiCallback)();
X
Xvoid 
XxruiDoPromptYes(widget,clientData,callData)
XWidget	widget;
XOpaque	clientData;
XOpaque	callData;
X{
Xvoid	(*callback)(/* str */);
Xchar	*ptr;
X
X    uENTRY3("xruiDoPromptYes(0x%x,0x%x,0x%x)\n",widget,clientData,callData);
X    callback= xruiCallback;
X    if (xruiPromptWidget != NULL) {
X	if (xruiNeedString) {
X	    Arg args[1];
X
X	    XtSetArg(args[0], XtNstring, &ptr);
X	    XtGetValues(xruiPromptText, args, 1);
X	    if (ptr && !strlen(ptr)) {
X	      ptr = NullString;
X	    }
X	    xruiDestroyPromptWindow();
X	    if ((ptr!=NullString)&&(index(ptr,';')!=NullString)) {
X		*(index(ptr,';'))=	NUL;
X	    }
X	    if (callback!=NULL) {
X		(*callback)(ptr);
X	    }
X	    if (ptr!=NullString)
X		XtFree(ptr);
X	}
X	else if (callback!=NULL)
X	    (*callback)(NullString);
X    }
X    uVOIDRETURN;
X}
X
X
X/***====================================================================***/
X
Xvoid
XxruiRaiseMenu(widget, subwidget, event)
XWidget	 widget;
XWidget	 subwidget;
XXEvent  *event;
X{
X    XRaiseWindow(XtDisplay(widget), XtWindow(widget));
X}
X
X/***====================================================================***/
X
Xvoid
XxruiFocusPopup(widget, subwidget, event)
XWidget	 widget;
XWidget	 subwidget;
XXEvent  *event;
X{
X    if (event->type == Expose || event->type == MapNotify) {
X      XSetInputFocus(XtDisplay(subwidget), XtWindow(subwidget),
X		     RevertToPointerRoot, CurrentTime);
X      XtRemoveEventHandler(widget, XtAllEvents, True, xruiFocusPopup, 0);
X    }
X}
X
X/***====================================================================***/
X
Xvoid
XxruiCenterWidget(w)
XWidget w;
X{
X  Window ignorew;
X  int x, y, ignorei;
X  unsigned int ignoreu;
X  Dimension width, height;
X  Arg args[5];
X  int count;
X
X  XQueryPointer(XtDisplay(w), XtWindow(w), &ignorew, &ignorew, &x, &y,
X		&ignorei, &ignorei, &ignoreu);
X
X  count = 0;
X  XtSetArg(args[count], XtNwidth, &width); count++;
X  XtSetArg(args[count], XtNheight, &height); count++;
X  XtGetValues(w, args, count);
X
X  x = x - width/2;
X  y = y - height/2;
X  if (x+width > WidthOfScreen(XtScreen(w)))
X    x = WidthOfScreen(XtScreen(w)) - width;
X  if (y+height > HeightOfScreen(XtScreen(w)))
X    y = HeightOfScreen(XtScreen(w)) - height;
X  if (x < 0) x = 0;
X  if (y < 0) y = 0;
X
X  count = 0;
X  XtSetArg(args[count], XtNx, x); count++;
X  XtSetArg(args[count], XtNy, y); count++;
X  XtSetValues(w, args, count);
X}
X
X
X/***====================================================================***/
X
Xvoid
XxruiTopWidget(w)
XWidget w;
X{
X  Window ignorew;
X  int x, y, ignorei;
X  unsigned int ignoreu;
X  Dimension width, height;
X  Arg args[5];
X  int count;
X
X  XQueryPointer(XtDisplay(w), XtWindow(w), &ignorew, &ignorew, &x, &y,
X		&ignorei, &ignorei, &ignoreu);
X
X  count = 0;
X  XtSetArg(args[count], XtNwidth, &width); count++;
X  XtSetArg(args[count], XtNheight, &height); count++;
X  XtGetValues(w, args, count);
X
X  x = x - width/2;
X  if (x+width > WidthOfScreen(XtScreen(w)))
X    x = WidthOfScreen(XtScreen(w)) - width;
X  if (y+height > HeightOfScreen(XtScreen(w)))
X    y = HeightOfScreen(XtScreen(w)) - height;
X  if (x < 0) x = 0;
X  if (y < 0) y = 0;
X
X  count = 0;
X  XtSetArg(args[count], XtNx, x); count++;
X  XtSetArg(args[count], XtNy, y); count++;
X  XtSetValues(w, args, count);
X}
X
X
X/***====================================================================***/
X
Xvoid
XxruiDoPrompt(prompt,needString,callback)
Xchar	 *prompt;
XBoolean	  needString;
Xvoid	(*callback)();
X{
X
X    Arg dargs[10];
X    int cnt = 0;
X    static XtTranslations promptoverride = NULL;
X    static Arg shellArgs[] = {
X	{XtNallowShellResize, (XtArgVal) True},
X	{XtNinput, (XtArgVal) True},
X    };
X    Widget button;
X    DialogWidget dw;
X
X    uENTRY3("xruiDoPrompt(%s,%s,0x%x)\n",uStringText(prompt),
X					booleanText(needString),callback);
X    xruiDestroyPromptWindow();
X
X    xruiPromptWidget = XtCreatePopupShell("popup",
X	transientShellWidgetClass, xruiTopLevel, shellArgs,
X					  XtNumber(shellArgs));
X
X    XtSetArg(dargs[cnt], XtNvalue, ""); cnt++;
X    XtSetArg(dargs[cnt], XtNlabel, prompt); cnt++;
X    XtSetArg(dargs[cnt], XtNinput, True); cnt++;
X    dw = (DialogWidget) XtCreateManagedWidget("dialog", dialogWidgetClass,
X					      xruiPromptWidget,
X					      dargs, cnt);
X
X    button = XtCreateManagedWidget("Yes", commandWidgetClass, dw, NULL, 0);
X    XtAddCallback(button, XtNcallback, xruiDoPromptYes, NULL);
X    button = XtCreateManagedWidget("No", commandWidgetClass, dw, NULL, 0);
X    XtAddCallback(button, XtNcallback, xruiDoPromptNo, NULL);
X
X    xruiPromptText = XtNameToWidget(dw, "value");
X    if (needString && xruiPromptText) {
X      XtSetKeyboardFocus(xruiTopLevel, None);
X      XtSetKeyboardFocus(dw, xruiPromptText);
X      XtAddEventHandler(dw, ExposureMask, False,
X			xruiFocusPopup, xruiPromptText);
X    }
X
X    xruiCallback = callback;
X    if (needString) {
X	if (promptoverride == NULL)
X	    promptoverride = 
X		XtParseTranslationTable("<Key>0xff0d: do-prompt-yes()");
X	XtOverrideTranslations(xruiPromptText, promptoverride);	
X    } else {
X      XtUnmanageChild(xruiPromptText);
X    }
X    xruiNeedString=	needString;
X
X    XtRealizeWidget(xruiPromptWidget);
X    xruiCenterWidget(xruiPromptWidget);
X    XtPopup(xruiPromptWidget, XtGrabExclusive);
X    uVOIDRETURN;
X}
X
X/***====================================================================***/
X
Xvoid
XxruiHandlePopup(widget, closure, event)
XWidget	 widget;
XOpaque	 closure;
XXEvent	*event;
X{
XArg arg;
X
X    uENTRY3("xruiHandlePopup(0x%x,0x%x,0x%x)\n",widget,closure,event);
X    if (event->type != ButtonPress || event->xbutton.button != 2) {
X	uVOIDRETURN;
X    }
X    if (xroomsSetupMode) {
X	XtSetArg(arg, XtNlabel, (XtArgVal)"Disable Set-up Mode");
X	XtSetValues(xruiSetupModeItem, &arg, 1);
X    }
X    else {
X	XtSetArg(arg, XtNlabel, (XtArgVal)"Enable Set-up Mode");
X	XtSetValues(xruiSetupModeItem, &arg, 1);
X    }
X
X    XtRealizeWidget(xruiMenu);
X    xruiTopWidget(xruiMenu);
X    XtPopup(xruiMenu, XtGrabExclusive);
X    uVOIDRETURN;
X}
X
X
X/***====================================================================***/
X
Xvoid
XxruiDoSaveProfile()
X{
X    uENTRY("xruiDoSave()\n");
X    XtPopdown(xruiMenu);
X    xruiDoPrompt("Enter file to write (<cr> for default):",
X						True,xrpfSaveProfiles);
X    uVOIDRETURN;
X}
X
X/***====================================================================***/
X
Xvoid
XxruiDoLoadProfile()
X{
X    uENTRY("xruiDoSave()\n");
X    XtPopdown(xruiMenu);
X    xruiDoPrompt("Enter file to load (<cr> for default):",True,xrpfLoadFile);
X    uVOIDRETURN;
X}
X
X/***====================================================================***/
X
Xstatic void
XxruiReallyCreateRoom(roomName)
Xchar	*roomName;
X{
XStringToken	token;
XRoomPtr		pRoom;
X
X    uENTRY1("xruiReallyCreateRoom(%s)\n",uStringText(roomName));
X    if (roomName!=NullString) {
X	token=	stGetToken(roomName);
X	pRoom=	LookupRoom(token);
X	if (pRoom==NullRoom)
X	    pRoom= CreateRoom(token);
X	if (pRoom!=NullRoom) {
X	    roomSetVisibility(pRoom,roomGetVisibility(pRoom)|roomVisible,False);
X	}
X    }
X    uVOIDRETURN;
X}
X
X/***====================================================================***/
X
Xvoid
XxruiDoCreateRoom()
X{
Xchar		*roomName= NullString;
X
X    uENTRY("xruiDoCreateRoom()\n");
X    XtPopdown(xruiMenu);
X    xruiDoPrompt("Enter room to create/show:",True,xruiReallyCreateRoom);
X    uVOIDRETURN;
X}
X
X/***====================================================================***/
X
Xstatic void
XxruiReallyDestroyRoom(roomName)
Xchar		*roomName;
X{
XStringToken	 token;
XRoomPtr		 pRoom;
X
X    uENTRY1("xruiReallyDestroyRoom(%s)\n",uStringText(roomName));
X    if (roomName!=NullString) {
X	token=	stGetToken(roomName);
X	if (token!=NullStringToken) {
X	    pRoom=	LookupRoom(token);
X	}
X    }
X    else pRoom=	GetCurrentRoom();
X    if (pRoom!=NullRoom)
X	DestroyRoom(pRoom);
X    uVOIDRETURN;
X}
X
X/***====================================================================***/
X
Xvoid
XxruiDoDestroyRoom()
X{
X    uENTRY("xruiDoDestroyRoom()\n");
X    XtPopdown(xruiMenu);
X    xruiDoPrompt("Enter room to destroy (<cr> for current):",True,
X					xruiReallyDestroyRoom);
X    uVOIDRETURN;
X}
X
X/***====================================================================***/
X
Xstatic void
XxruiReallyHideRoom(roomName)
Xchar		*roomName;
X{
XStringToken	 token;
XRoomPtr		 pRoom;
X
X    uENTRY1("xruiReallyHideRoom(%s)\n",uStringText(roomName));
X    if (roomName!=NullString) {
X	token=	stGetToken(roomName);
X	if (token!=NullStringToken) {
X	    pRoom=	LookupRoom(token);
X	}
X    }
X    else pRoom=	GetCurrentRoom();
X    if (pRoom!=NullRoom)
X	roomSetVisibility(pRoom,roomGetVisibility(pRoom)&(~roomVisible),False);
X    uVOIDRETURN;
X}
X
X/***====================================================================***/
X
Xvoid
XxruiDoHideRoom()
X{
X    uENTRY("xruiDoHideRoom()\n");
X    XtPopdown(xruiMenu);
X    xruiDoPrompt("Enter room to hide (<cr> for current):",True,
X					xruiReallyDestroyRoom);
X    uVOIDRETURN;
X}
X
X/***====================================================================***/
X
Xvoid
XxruiDoWindowStates()
X{
X    uENTRY("xruiDoWindowStates()\n");
X    XtPopdown(xruiMenu);
X    XtRealizeWidget(xruiWinMenu);
X    xruiTopWidget(xruiWinMenu);
X    XtPopup(xruiWinMenu, XtGrabExclusive);
X    uVOIDRETURN;
X}
X
X/***====================================================================***/
X
Xvoid
XxruiCloseMainMenu()
X{
X    uENTRY("xruiCloseMainMenu()\n");
X    XtPopdown(xruiMenu);
X    uVOIDRETURN;
X}
X
X/***====================================================================***/
X
Xvoid
XxruiCloseWinMenu()
X{
X    uENTRY("xruiCloseWinMenu()\n");
X    XtPopdown(xruiWinMenu);
X    uVOIDRETURN;
X}
X
X/***====================================================================***/
X
Xvoid
XxruiFlipSetupMode()
X{
X    uENTRY("xruiFlipSetupMode()\n");
X    XtPopdown(xruiMenu);
X    xroomsSetupMode=	!xroomsSetupMode;
X    uVOIDRETURN;
X}
X
X/***====================================================================***/
X
X/* ARGSUSED */
Xstatic void
XxruiReallyExit(ignoreMe)
Xchar	*ignoreMe;
X{
X    uENTRY1("xruiReallyExit(%s)\n",uStringText(ignoreMe));
X    DoExit(0,"Exit menu item selected");
X    uVOIDRETURN;
X}
X
X/***====================================================================***/
X
Xvoid
XxruiDoExit()
X{
X    uENTRY("xruiDoExit()\n");
X    XtPopdown(xruiMenu);
X    if (xruiConfirmExit)
X	xruiDoPrompt("Do you really want to exit xrooms?",False,xruiReallyExit);
X    else DoExit(0,"Exit menu item selected");
X    uVOIDRETURN;
X}
X
X
X/***====================================================================***/
X
Xstatic RoomPtr
XxruiCreateDefaultRoom()
X{
XRoomPtr	pRoom;
X
X    uENTRY("xruiCreateDefaultRoom()\n");
X    pRoom=	LookupRoom(stGetToken(xruiDefaultRoom));
X    if (pRoom==NullRoom) 
X	pRoom= CreateRoom(stGetToken(xruiDefaultRoom));
X    if (pRoom!=NullRoom)
X	roomSetVisibility(pRoom,roomVisible,True);
X    uRETURN(pRoom);
X}
X
X/***====================================================================***/
X
XRoomPtr
XxruiFindDefaultRoom()
X{
XRoomPtr		pRoom;
X
X    uENTRY("xruiFindDefaultRoom()\n");
X    pRoom=	LookupRoom(stGetToken(xruiDefaultRoom));
X    if (pRoom!=NullRoom) {
X	if (!(roomGetVisibility(pRoom)&roomVisible)) {
X	    roomSetVisibility(pRoom,roomVisible,True);
X	}
X	uRETURN(pRoom);
X    }
X    uRETURN(xruiCreateDefaultRoom());
X}
X
X/***====================================================================***/
X
Xstatic void
XxruiInitMenus(parent)
XWidget	parent;
X{
X    static Arg buttonArgs[] = {
X      {XtNfromVert, (XtArgVal) NULL},
X      {XtNlabel, (XtArgVal) NULL},
X      {XtNvertDistance, (XtArgVal) 0},
X      {XtNfromHoriz, (XtArgVal) NULL},
X      {XtNhorizDistance, (XtArgVal) 0},
X      {XtNresize, (XtArgVal) False},
X    };
X    static Arg fargs[] = {
X      {XtNheight, 1},
X      {XtNwidth, 1},
X    };
X    Widget fw, w[20];
X    int i, count = 0;
X    Dimension max, wid;
X    Arg arg;
X
X    max = 0;
X    XtSetArg(arg, XtNwidth, &wid);
X    uENTRY1("xruiInitMenus(0x%x)\n",parent);
X    XtAddEventHandler(xruiTopLevel,ButtonPressMask,False,xruiHandlePopup,NULL);
X    XtAddEventHandler(xruiScrollW,ButtonPressMask,False,xruiHandlePopup,NULL);
X
X    xruiMenu= XtCreatePopupShell("menu",
X				 overrideShellWidgetClass, parent,
X				 NULL, 0);
X    fw = XtCreateManagedWidget("form", formWidgetClass, xruiMenu,
X			       fargs, XtNumber(fargs));
X
X    buttonArgs[0].value = (XtArgVal) NULL;
X    buttonArgs[1].value = (XtArgVal) "Create Room";
X    w[count] = XtCreateManagedWidget("Create Room", commandWidgetClass, fw,
X				     buttonArgs, XtNumber(buttonArgs));
X    XtAddCallback(w[count], XtNcallback, xruiDoCreateRoom, NULL);
X    XtGetValues(w[count++], &arg, 1);
X    if (wid > max) {
X      max = wid;
X    }
X    buttonArgs[0].value = (XtArgVal) w[count-1];
X    buttonArgs[1].value = (XtArgVal) "Remove Room";
X    w[count] = XtCreateManagedWidget("Remove Room", commandWidgetClass, fw,
X				     buttonArgs, XtNumber(buttonArgs));
X    XtAddCallback(w[count], XtNcallback, xruiDoDestroyRoom, NULL);
X    XtGetValues(w[count++], &arg, 1);
X    if (wid > max) {
X      max = wid;
X    }
X    buttonArgs[0].value = (XtArgVal) w[count-1];
X    buttonArgs[1].value = (XtArgVal) "Hide Room";
X    w[count] = XtCreateManagedWidget("Hide Room", commandWidgetClass, fw,
X				     buttonArgs, XtNumber(buttonArgs));
X    XtAddCallback(w[count], XtNcallback, xruiDoHideRoom, NULL);
X    XtGetValues(w[count++], &arg, 1);
X    if (wid > max) {
X      max = wid;
X    }
X    buttonArgs[0].value = (XtArgVal) w[count-1];
X    buttonArgs[1].value = (XtArgVal) "Load Profile";
X    w[count] = XtCreateManagedWidget("Load Profile", commandWidgetClass, fw,
X				     buttonArgs, XtNumber(buttonArgs));
X    XtAddCallback(w[count], XtNcallback, xruiDoLoadProfile, NULL);
X    XtGetValues(w[count++], &arg, 1);
X    if (wid > max) {
X      max = wid;
X    }
X    buttonArgs[0].value = (XtArgVal) w[count-1];
X    buttonArgs[1].value = (XtArgVal) "Save Profile";
X    w[count] = XtCreateManagedWidget("Save Profile", commandWidgetClass, fw,
X				     buttonArgs, XtNumber(buttonArgs));
X    XtAddCallback(w[count], XtNcallback, xruiDoSaveProfile, NULL);
X    XtGetValues(w[count++], &arg, 1);
X    if (wid > max) {
X      max = wid;
X    }
X
X    buttonArgs[0].value = (XtArgVal) w[count-1];
X    buttonArgs[1].value = (XtArgVal) "Change States ...";
X    w[count] = XtCreateManagedWidget("Change State In Profile",
X			commandWidgetClass,fw,buttonArgs,XtNumber(buttonArgs));
X    XtAddCallback(w[count], XtNcallback, xruiDoWindowStates, NULL);
X    XtGetValues(w[count++], &arg, 1);
X    if (wid > max) {
X      max = wid;
X    }
X
X    buttonArgs[0].value = (XtArgVal) w[count-1];
X    buttonArgs[1].value = (XtArgVal) "Disable Set-up Mode";
X    w[count] = XtCreateManagedWidget("Set-up Mode", commandWidgetClass, fw,
X				     buttonArgs, XtNumber(buttonArgs));
X    xruiSetupModeItem= w[count];
X    XtAddCallback(w[count], XtNcallback, xruiFlipSetupMode, NULL);
X    XtGetValues(w[count++], &arg, 1);
X    if (wid > max) {
X      max = wid;
X    }
X
X    buttonArgs[0].value = (XtArgVal) w[count-1];
X    buttonArgs[1].value = (XtArgVal) "Close Menu";
X    w[count] = XtCreateManagedWidget("Close Menu", commandWidgetClass, fw,
X				     buttonArgs, XtNumber(buttonArgs));
X    XtAddCallback(w[count], XtNcallback, xruiCloseMainMenu, NULL);
X    XtGetValues(w[count++], &arg, 1);
X    if (wid > max) {
X      max = wid;
X    }
X
X    buttonArgs[0].value = (XtArgVal) w[count-1];
X    buttonArgs[1].value = (XtArgVal) "Exit xrooms";
X    w[count] = XtCreateManagedWidget("Exit xrooms", commandWidgetClass, fw,
X				     buttonArgs, XtNumber(buttonArgs));
X    XtAddCallback(w[count], XtNcallback, xruiDoExit, NULL);
X    XtGetValues(w[count++], &arg, 1);
X    if (wid > max) {
X      max = wid;
X    }
X
X    XtSetArg(arg, XtNwidth, max);
X    for (i=0; i<count; i++) {
X      XtSetValues(w[i], &arg, 1);
X    }
X
X
X    xruiWinMenu= XtCreatePopupShell("winmenu",
X				 overrideShellWidgetClass, parent,
X				 NULL, 0);
X    fw = XtCreateManagedWidget("form", formWidgetClass, xruiWinMenu,
X			       fargs, XtNumber(fargs));
X    XtSetArg(arg, XtNwidth, &wid);
X
X    count = 0;
X    buttonArgs[0].value = (XtArgVal) NULL;
X    buttonArgs[1].value = (XtArgVal) "Open In All Rooms";
X    w[count] = XtCreateManagedWidget("Open In All Rooms",commandWidgetClass,fw,
X				     buttonArgs, XtNumber(buttonArgs));
X    XtAddCallback(w[count], XtNcallback, xractDoSetAll, NULL);
X    XtGetValues(w[count++], &arg, 1);
X    if (wid > max) {
X      max = wid;
X    }
X    buttonArgs[0].value = (XtArgVal) w[count-1];
X    buttonArgs[1].value = (XtArgVal) "Open Here Only";
X    w[count] = XtCreateManagedWidget("Open Here Only", commandWidgetClass, fw,
X				     buttonArgs, XtNumber(buttonArgs));
X    XtAddCallback(w[count], XtNcallback, xractDoSetLocalOnly, NULL);
X    XtGetValues(w[count++], &arg, 1);
X    if (wid > max) {
X      max = wid;
X    }
X    buttonArgs[0].value = (XtArgVal) w[count-1];
X    buttonArgs[1].value = (XtArgVal) "Make Permanent";
X    w[count] = XtCreateManagedWidget("Make Permanent", commandWidgetClass, fw,
X				     buttonArgs, XtNumber(buttonArgs));
X    XtAddCallback(w[count], XtNcallback, xractDoMakePermanent, NULL);
X    XtGetValues(w[count++], &arg, 1);
X    if (wid > max) {
X      max = wid;
X    }
X    buttonArgs[0].value = (XtArgVal) w[count-1];
X    buttonArgs[1].value = (XtArgVal) "Make Transient";
X    w[count] = XtCreateManagedWidget("Make Transient", commandWidgetClass, fw,
X				     buttonArgs, XtNumber(buttonArgs));
X    XtAddCallback(w[count], XtNcallback, xractDoMakeTransient, NULL);
X    XtGetValues(w[count++], &arg, 1);
X    if (wid > max) {
X      max = wid;
X    }
X    buttonArgs[0].value = (XtArgVal) w[count-1];
X    buttonArgs[1].value = (XtArgVal) "Bolt Geometry";
X    w[count] = XtCreateManagedWidget("Bolt Geometry", commandWidgetClass, fw,
X				     buttonArgs, XtNumber(buttonArgs));
X    XtAddCallback(w[count], XtNcallback, xractDoBoltGeom, NULL);
X    XtGetValues(w[count++], &arg, 1);
X    if (wid > max) {
X      max = wid;
X    }
X    buttonArgs[0].value = (XtArgVal) w[count-1];
X    buttonArgs[1].value = (XtArgVal) "Unbolt Geometry";
X    w[count] = XtCreateManagedWidget("Unbolt Geometry", commandWidgetClass, fw,
X				     buttonArgs, XtNumber(buttonArgs));
X    XtAddCallback(w[count], XtNcallback, xractDoUnboltGeom, NULL);
X    XtGetValues(w[count++], &arg, 1);
X    if (wid > max) {
X      max = wid;
X    }
X    buttonArgs[0].value = (XtArgVal) w[count-1];
X    buttonArgs[1].value = (XtArgVal) "Bolt Window Open";
X    w[count] = XtCreateManagedWidget("Bolt Window Open",commandWidgetClass,fw,
X				     buttonArgs, XtNumber(buttonArgs));
X    XtAddCallback(w[count], XtNcallback, xractDoBoltState, NULL);
X    XtGetValues(w[count++], &arg, 1);
X    if (wid > max) {
X      max = wid;
X    }
X    buttonArgs[0].value = (XtArgVal) w[count-1];
X    buttonArgs[1].value = (XtArgVal) "Unbolt Window State";
X    w[count]= XtCreateManagedWidget("Unbolt Window State",commandWidgetClass,fw,
X				     buttonArgs, XtNumber(buttonArgs));
X    XtAddCallback(w[count], XtNcallback, xractDoUnboltState, NULL);
X    XtGetValues(w[count++], &arg, 1);
X    if (wid > max) {
X      max = wid;
X    }
X    buttonArgs[0].value = (XtArgVal) w[count-1];
X    buttonArgs[1].value = (XtArgVal) "Close Menu";
X    w[count] = XtCreateManagedWidget("Close Menu", commandWidgetClass, fw,
X				     buttonArgs, XtNumber(buttonArgs));
X    XtAddCallback(w[count], XtNcallback, xruiCloseWinMenu, NULL);
X    XtGetValues(w[count++], &arg, 1);
X    if (wid > max) {
X      max = wid;
X    }
X
X    XtSetArg(arg, XtNwidth, max);
X    for (i=0; i<count; i++) {
X      XtSetValues(w[i], &arg, 1);
X    }
X    uVOIDRETURN;
X}
X
X/***====================================================================***/
X
Xstatic	XtActionsRec	actions[] = {
X	{ "do-prompt-yes",	xruiDoPromptYes }
X};
X
Xvoid
XxruiInit(parent)
XWidget	parent;
X{
X    static Arg fargs[] = {
X      {XtNheight, 150},
X      {XtNwidth, 35},
X    };
X
X    uENTRY1("xruiInit(0x%x)\n",parent);
X    xruiTopLevel=	parent;
X    xroomsMainWindow=	XtWindow(xruiTopLevel);
X    xruiScrollW= XtCreateWidget("main", formWidgetClass, parent,
X				fargs, XtNumber(fargs));
X    (void)xrrInit(xruiScrollW);
X    XtManageChild(xruiScrollW);
X    XtAddActions(actions, XtNumber(actions));
X    XSync(xroomsDpy,False);
X    uVOIDRETURN;
X}
X
X/***====================================================================***/
X
Xvoid
XxruiBecomeVisible()
X{
X    uENTRY("xruiBecomeVisible()\n");
X    XtRealizeWidget(xruiTopLevel);
X    xruiInitMenus(xruiScrollW);
X    (void)GetCurrentRoom();
X    XSync(xroomsDpy,False);
X    uVOIDRETURN;
X}
X
END_OF_FILE
if test 23300 -ne `wc -c <'./xrooms/xrXawUI.c'`; then
    echo shar: \"'./xrooms/xrXawUI.c'\" unpacked with wrong size!
fi
# end of './xrooms/xrXawUI.c'
fi
if test -f './xrset/xrset.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./xrset/xrset.c'\"
else
echo shar: Extracting \"'./xrset/xrset.c'\" \(23831 characters\)
sed "s/^X//" >'./xrset/xrset.c' <<'END_OF_FILE'
X
X  /*\
X   *  $Header: xrset.c,v 5.0 90/01/10 07:02:55 erik Exp $
X   *
X   *		              COPYRIGHT 1990
X   *		        DIGITAL EQUIPMENT CORPORATION
X   *		           MAYNARD, MASSACHUSETTS
X   *			    ALL RIGHTS RESERVED.
X   *
X   * THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND
X   * SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
X   * DIGITAL MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE 
X   * FOR ANY PURPOSE.  IT IS SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED 
X   * WARRANTY.
X   *
X   * IF THE SOFTWARE IS MODIFIED IN A MANNER CREATING DERIVATIVE COPYRIGHT
X   * RIGHTS, APPROPRIATE LEGENDS MAY BE PLACED ON THE DERIVATIVE WORK IN
X   * ADDITION TO THAT SET FORTH ABOVE.
X   *
X   * Permission to use, copy, modify, and distribute this software and its
X   * documentation for any purpose and without fee is hereby granted, provided
X   * that the above copyright notice appear in all copies and that both that
X   * copyright notice and this permission notice appear in supporting
X   * documentation, and that the name of Digital Equipment Corporation not be
X   * used in advertising or publicity pertaining to distribution of the 
X   * software without specific, written prior permission.
X  \*/
X
X#include <stdio.h>
X#include "X11/Xlib.h"
X#include "X11/Xatom.h"
X#include "X11/Xutil.h"
X#include "X11/Xmd.h"
X
X#define DEBUG_VAR xrreqDebug
X#include "utils.h"
X#include "xrGen.h"
X#include "xrReq.h"
X
X/***==================================================================***/
X
Xextern	char		*getenv();
X
Xchar	*dpyName=	NullString;
XDisplay *argDpy=	NULL;
Xint	 argScrn=	0;
XWindow	 argRoot=	None;
X
X/***==================================================================***/
X
X#define	DB	uDebug
Xvoid
XUsage(name)
Xchar	*name;
X{
XDB("usage: %s ([ args ] [command [cmdargs]])*\n",name);
XDB("where recognized args are:\n");
XDB("  -display      <name>        use named display\n");
XDB("  -debug        <string>      set debugging in xrooms\n");
XDB("  -verbose     [<level>]      set amount of output\n");
XDB("  -set         [state flags]  set the managed parts of application state(s)\n");
XDB("  -merge       [state flags]  add to the managed parts of application state(s)\n");
XDB("  -clear       [state flags]  clear the managed parts of application state(s)\n");
XDB("  -bolt        [state flags]  bolt parts of application state(s)\n");
XDB("  -unbolt      [state flags]  unbolt parts of application state(s)\n");
XDB("  -tighten     [state flags]  tighten bolts in application state(s)\n");
XDB("  -loosen      [state flags]  loosen bolts in application state(s)\n");
XDB("  -setbolts    [state flags]  set bolts in application state(s)\n");
XDB("  legal state flags are:\n");
XDB("    -local                    set local state (default)\n");
XDB("    -default or -dflt         set default state\n");
XDB("    -allstates or -as         set all states\n");
XDB("    -visible                  set visible state\n");
XDB("    -winstate or -state       set window state\n");
XDB("    -x or -right              set right edge of window\n");
XDB("    +x or -left               set left edge of window\n");
XDB("    -y or -bottom             set bottom edge of window\n");
XDB("    +y or -top                set top edge of window\n");
XDB("    -position                 set top-right corner of window\n");
XDB("    -width                    set width of window\n");
XDB("    -height                   set height of window\n");
XDB("    -size                     set width and height of window\n");
XDB("    -geometry                 set entire window geometry\n");
XDB("    -everything               set both geometry and application state\n");
XDB("    -allapps or -aa           set all apps\n");
XDB("    -activeapps               set all currently active apps\n");
XDB("    -queryapp or -qa          query user for application (default)\n");
XDB("    -lastapp or -la           re-use last application\n");
XDB("    <string>                  name of application to set\n");
XDB("    -room <string>            set state only in named room\n");
XDB("    -current                  set state only in current room (default)\n");
XDB("    -queryroom or -qr         query user for room (not implemented)\n");
XDB("    -allrooms or -ar          set state in all rooms\n");
XDB("    -visrooms                 set state in all visible rooms\n");
XDB("  -remember  [args]           remember an application forever\n");
XDB("  -forget    [args]           forget an application after it exits\n");
XDB("  legal remember flags are:\n");
XDB("    -query or -select         query application (default)\n");
XDB("    -last                     re-use last selected application\n");
XDB("    -all                      remember/forget all applications\n");
XDB("    <string>                  name of application\n");
XDB("  -show  [ show flags ]       make room (conditionally) visible\n");
XDB("  -hide  [ hide flags ]       make room invisible\n");
XDB("  legal flags for both -hide and -show are:\n");
XDB("    -room <string>            name of room to change\n");
XDB("    <string>                  name of room to change\n");
XDB("    -current                  change visibility of current room\n");
XDB("    -queryroom or -qr         query user for room to change (not implemented)\n");
XDB("    -allrooms or -ar          change visibility of all rooms\n");
XDB("    -visrooms                 change visibility of all visible rooms\n");
XDB("    -create                   create the room if it doesn't exist\n");
XDB("  legal flags for -show are:\n");
XDB("    -always                   room is always visible\n");
XDB("    -[when]active             room is visible when active\n");
XDB("    -[when]nonempty           room is visible when non-empty\n");
XDB("    -now                      room is visible now\n");
XDB("  -load  [<file>]             load a profile file\n");
XDB("  -appname [-id <integer>]    query name of application\n");
Xexit(0);
X/* NOTREACHED */
Xreturn;
X}
X
X/***==================================================================***/
X
XBoolean
XOpenConnection()
X{
X    uENTRY("OpenConnection()\n");
X    if (argDpy==NULL) {
X	if (!(argDpy = XOpenDisplay(dpyName))) {
X	    if (dpyName==NullString)	dpyName=	getenv("DISPLAY");
X	    if (dpyName==NullString)	dpyName=	"unix:0";
X	    uFatalError("Cannot open display %s\n",dpyName);
X	    /*NOTREACHED */
X	}
X
X	argScrn= XDefaultScreen(argDpy);
X	argRoot= XDefaultRootWindow(argDpy);
X	xrgenInit(argDpy);
X
X	uDEBUG1(1,"Opened %s \n",(dpyName?dpyName:"default display"));
X    }
X    uRETURN(True);
X}
X
X/***==================================================================***/
X
XBoolean
XCloseConnection()
X{
X    uENTRY("CloseConnection()\n");
X/*    xrgenCleanUp(argDpy);*/
X    XCloseDisplay(argDpy);
X    argDpy=	NULL;
X    argScrn=	0;
X    argRoot=	None;
X    uDEBUG1(1,"Closed %s \n",(dpyName?dpyName:"default display"));
X    uRETURN(True);
X}
X
X/***==================================================================***/
X
Xint
XGenArg(argc,argv,i)
Xint	argc;
Xchar	*argv[];
X{
X    uENTRY3("GenArg(%d,0x%x,%d)\n",argc,argv,i);
X    if (argc>i+1) {
X	if (uStringPrefix(argv[i],"-display")) {
X	     if ((dpyName!=NullString)&&(!uStringEqual(dpyName,argv[i]))&&
X		 (argDpy!=NULL)) {
X		CloseConnection();
X	     }
X	     if (!uStringEqual(dpyName,argv[i])) {
X		dpyName=	argv[i+1];
X	     }
X	     uRETURN(2);
X	}
X	else if (uStringPrefix(argv[i],"-verbose")) {
X	     int	level;
X	     if ((sscanf(argv[i+1],"%d",&level)!=1)&&
X		 (sscanf(argv[i+1],"0x%x",&level)!=1)) {
X		 uDEBUG(1,"Setting verbose (1)\n");
X		 xrreqDebug=	1;
X		 uRETURN(1);
X	     }
X	     else {
X		 uDEBUG1(1,"Setting verbose (%d)\n",level);
X		 xrreqDebug=	level;
X		 uRETURN(2);
X	     }
X	}
X    }
X    if (uStringPrefix(argv[i],"-help")) {
X	Usage(argv[0]);
X	/* NOTREACHED */
X    }
X    uRETURN(0);
X}
X
X/***====================================================================***/
X
Xint
XGetStringArg(argc,argv,i,ppStr)
Xint	 argc;
Xchar	*argv[];
Xint	 i;
Xchar	**ppStr;
X{
Xchar	*arg;
X
X    uENTRY4("GetStringArg(%d,0x%x,%d,0x%x)\n",argc,argv,i,ppStr);
X    arg= argv[i];
X    if (uStringEqual(arg,"--")) {
X	i++;
X	if (i<argc) {
X	    *ppStr=	argv[i];
X	    uRETURN(2);
X	}
X	else {
X	    uError("Missing string after \"--\"\n");
X	    *ppStr=	NullString;
X	    uRETURN(1);
X	}
X    }
X    else if (arg[0]=='-') {
X	*ppStr=	NullString;
X	uRETURN(0);
X    }
X
X    *ppStr=	argv[i];
X    uRETURN(1);
X}
X
X/***====================================================================***/
X
X/* ARGSUSED */
Xint
XDebugArgs(argc,argv,i,ignored)
Xint	 argc;
Xchar	*argv[];
Xint	 i;
Xchar	*ignored;
X{
XBoolean ok= True;
Xint	first=i;
Xint	nUsed;
Xchar	*arg;
X
X    uENTRY4("handleDebug(0x%x,0x%x,%s,%s)\n",argc,argv,i,uStringText(ignored));
X    while ((i<argc)&&(ok)) {
X	nUsed=	GetStringArg(argc,argv,i,&arg);
X	if ((nUsed>0)&&(arg!=NullString)&&(OpenConnection())) {
X	    ok= xrreqIssueDebug(argDpy,argRoot,arg);
X	    i+=	nUsed;
X	}
X	else {
X	    nUsed=	GenArg(argc,argv,i);
X	    if (nUsed)	i+= nUsed;
X	    else	ok= False;
X	}
X    }
X    uRETURN(i-first);
X}
X
X/***====================================================================***/
X
Xint
XWhichAppArg(argc,argv,i,pWhich,ppName)
Xint	argc;
Xchar	*argv[];
Xint	i;
Xunsigned	*pWhich;
Xchar		**ppName;
X{
Xint	nUsed=	1;
Xchar	*arg,*tmp;
X
X    uENTRY5("WhichAppArg(%d,0x%x,%d,0x%x,0x%x)\n",argc,argv,i,pWhich,ppName);
X    if (i<argc) {
X	arg=	argv[i];
X	if (uStringPrefix(arg,"-allapps")||uStringPrefix(arg,"-aa")) {
X	    *pWhich=	XR_ALL_APPS;
X	    *ppName=	NullString;
X	}
X	else if (uStringPrefix(arg,"-activeapps")) {
X	    *pWhich=	XR_ACTIVE_APPS;
X	    *ppName=	NullString;
X	}
X	else if (uStringPrefix(arg,"-queryapp")||uStringPrefix(arg,"-qa"))  {
X	    *pWhich=	XR_QUERY_APP;
X	    *ppName=	NullString;
X	}
X	else if (uStringPrefix(arg,"-lastapp")||uStringPrefix(arg,"-la")) {
X	    *pWhich=	XR_LAST_APP;
X	    *ppName=	NullString;
X	}
X	else if (uStringPrefix(arg,"-application")) {
X	    i++;
X	    if (i<argc) {
X		nUsed=	2;
X		*pWhich=	XR_NAMED_APP;
X		*ppName=	argv[i];
X	    }
X	    else nUsed=	0;
X	}
X	else if (uStringPrefix(arg,"-id")||uStringPrefix(arg,"-window")) {
X	    int	winId;
X	    i++;
X	    if ((i<argc)&&
X		((sscanf(argv[i],"0x%x",&winId)==1)||
X		 (sscanf(argv[i],"%d",&winId)==1))) {
X		*ppName=	(char *)uAlloc(strlen(argv[i])+3);
X		if (*ppName!=NullString) {
X		    nUsed=	2;
X		    sprintf(*ppName,"0x%x",winId);
X		    *pWhich=	XR_WINDOW_APP;
X		}
X		else nUsed=	0;
X	    }
X	    else nUsed=	0;
X	}
X	else if ((nUsed=GetStringArg(argc,argv,i,&tmp))>0) {
X	    *pWhich=	XR_NAMED_APP;
X	    *ppName=	tmp;
X	}
X	else {
X	    nUsed=	0;
X	    *pWhich=	XR_QUERY_APP;
X	    *ppName=	tmp;
X	}
X    }
X    uRETURN(nUsed);
X}
X
X/***====================================================================***/
X
Xint
XWhichRoomArg(argc,argv,i,pWhich,ppName)
Xint	argc;
Xchar	*argv[];
Xint	i;
Xunsigned	*pWhich;
Xchar		**ppName;
X{
Xint	nUsed=	1;
Xchar	*arg,*tmp;
X
X    uENTRY5("WhichRoomArg(%d,0x%x,%d,0x%x,0x%x)\n",argc,argv,i,pWhich,ppName);
X    if (i<argc) {
X	arg=	argv[i];
X	if (uStringPrefix(arg,"-current")) {
X	    *pWhich=	XR_CURRENT_ROOM;
X	    *ppName=	NullString;
X	}
X	else if (uStringPrefix(arg,"-lastroom")||uStringPrefix(arg,"-lr")) { 
X	    *pWhich=	XR_LAST_ROOM;
X	    *ppName=	NullString;
X	}
X	else if (uStringPrefix(arg,"-queryroom")||uStringPrefix(arg,"-qr")) {
X	    *pWhich=	XR_QUERY_ROOM;
X	    *ppName=	NullString;
X	}
X	else if (uStringPrefix(arg,"-visrooms")||uStringPrefix(arg,"-visible")){
X	    *pWhich=	XR_VISIBLE_ROOMS;
X	    *ppName=	NullString;
X	}
X	else if (uStringPrefix(arg,"-allrooms")||uStringPrefix(arg,"-ar")) {
X	    *pWhich=	XR_ALL_ROOMS;
X	    *ppName=	NullString;
X	}
X	else if (uStringPrefix(arg,"-room")) {
X	    i++;
X	    if (i<argc) {
X		nUsed=	2;
X		*pWhich=	XR_NAMED_APP;
X		*ppName=	argv[i];
X	    }
X	    else nUsed=	0;
X	}
X	else if ((nUsed=GetStringArg(argc,argv,i,&tmp))>0) {
X	    *pWhich=	XR_NAMED_ROOM;
X	    *ppName=	tmp;
X	}
X	else {
X	    nUsed=	0;
X	    *pWhich=	XR_CURRENT_ROOM;
X	    *ppName=	NullString;
X	}
X    }
X    uRETURN(nUsed);
X}
X
X/***====================================================================***/
X
Xint
XWhichStateArg(argc,argv,i,pWhich)
Xint	argc;
Xchar	*argv[];
Xint	i;
Xunsigned	*pWhich;
X{
Xint	nUsed=	1;
Xchar	*arg;
X
X    uENTRY4("WhichStateArg(%d,0x%x,%d,0x%x)\n",argc,argv,i,pWhich);
X    if (i<argc) {
X	arg=	argv[i];
X	if (uStringPrefix(arg,"-local")) {
X	    *pWhich=	XR_LOCAL_STATE;
X	}
X	else if (uStringPrefix(arg,"-default")||uStringPrefix(arg,"-dflt")) {
X	    *pWhich=	XR_DFLT_STATE;
X	}
X	else if (uStringPrefix(arg,"-allstates")||uStringPrefix(arg,"-as")) {
X	    *pWhich= 	XR_ALL_STATES;
X	}
X	else if (uStringPrefix(argv[i],"-visible")) {
X	    *pWhich=	XR_VISIBLE_STATE;
X	}
X	else {
X	    nUsed=	0;
X	    *pWhich=	XR_VISIBLE_STATE;
X	}
X    }
X    uRETURN(nUsed);
X}
X
X/***====================================================================***/
X
Xint
XWhichPartArg(argc,argv,i,pWhich)
Xint	argc;
Xchar	*argv[];
Xint	i;
Xunsigned	*pWhich;
X{
Xint	nUsed=	1;
Xchar	*arg;
X
X    uENTRY4("WhichPartArg(%d,0x%x,%d,0x%x)\n",argc,argv,i,pWhich);
X    if (i<argc) {
X	arg=	argv[i];
X	if (uStringPrefix(arg,"-winstate")||uStringPrefix(arg,"-state"))
X	    *pWhich=	XR_WINSTATE_PART;
X	else if (uStringEqual(arg,"-x")||uStringPrefix(arg,"-right"))
X	    *pWhich=	XR_X_PART|XR_X_NEGATIVE;
X	else if (uStringEqual(arg,"+x")||uStringPrefix(arg,"-left"))
X	    *pWhich=	XR_X_PART;
X	else if (uStringEqual(arg,"-y")||uStringPrefix(arg,"-bottom"))
X	    *pWhich=	XR_Y_PART|XR_Y_NEGATIVE;
X	else if (uStringEqual(arg,"+y")||uStringPrefix(arg,"-top"))
X	    *pWhich=	XR_Y_PART;
X	else if (uStringPrefix(arg,"-position"))
X	    *pWhich=	XR_POSITION_PART;
X	else if (uStringPrefix(arg,"-width"))
X	    *pWhich=	XR_WIDTH_PART;
X	else if (uStringPrefix(arg,"-height"))
X	    *pWhich=	XR_HEIGHT_PART;
X	else if (uStringPrefix(arg,"-size"))
X	    *pWhich=	XR_SIZE_PART;
X	else if (uStringPrefix(arg,"-geometry"))
X	    *pWhich=	XR_GEOM_PARTS;
X	else if (uStringPrefix(arg,"-everything"))
X	    *pWhich=	XR_ALL_PARTS;
X	else {
X	    nUsed=	0;
X	    *pWhich=	XR_GEOM_PARTS;
X	}
X    }
X    uRETURN(nUsed);
X}
X
X/***====================================================================***/
X
Xint
XSetStateArgs(argc,argv,i,what)
Xint	 argc;
Xchar	*argv[];
Xint	 i;
Xchar	*what;
X{
XBoolean	ok=	True;
Xint	first=	 i;
XBoolean	partSpec=	False;
XBoolean	appSpec=	False;
XBoolean	roomSpec=	False;
XBoolean	stateSpec=	False;
Xunsigned		 tmpInt;
Xchar			*tmpStr;
XxrSetStateArgsRec	 args;
Xint			 nUsed;
X
X    uENTRY4("SetStateArgs(%d,0x%x,%d,%s)\n",argc,argv,i,uStringText(what));
X    args.doWhat=	what[0];
X    args.toWhat=	what[1];
X    args.whichPart=	0;
X    args.whichState=	XR_VISIBLE_STATE;
X    args.whichApp=	XR_QUERY_APP;
X    args.appName=	NullString;
X    args.whichRoom=	XR_CURRENT_ROOM;
X    args.roomName=	NullString;
X
X    while ((i<argc)&&(ok)) {
X	if ((nUsed= WhichPartArg(argc,argv,i,&tmpInt))>0) {
X	    if (partSpec)	args.whichPart|=	tmpInt;
X	    else		args.whichPart=		tmpInt;
X	    partSpec=	True;
X	}
X	else if ((nUsed= WhichStateArg(argc,argv,i,&tmpInt))>0) {
X	    if (stateSpec&&OpenConnection()) {
X		ok=	xrreqIssueSetState(argDpy,argRoot,&args);
X	    }
X	    args.whichState=	tmpInt;
X	    stateSpec=		True;
X	}
X	else if ((nUsed= WhichAppArg(argc,argv,i,&tmpInt,&tmpStr))>0) {
X	    if (appSpec&&OpenConnection()) {
X		ok=	xrreqIssueSetState(argDpy,argRoot,&args);
X	    }
X	    args.whichApp=	tmpInt;
X	    args.appName=	tmpStr;
X	    appSpec=		True;
X	}
X	else if ((nUsed= WhichRoomArg(argc,argv,i,&tmpInt,&tmpStr))>0) {
X	    if (roomSpec&&OpenConnection()) {
X		ok=	xrreqIssueSetState(argDpy,argRoot,&args);
X	    }
X	    args.whichRoom=	tmpInt;
X	    args.roomName=	tmpStr;
X	    roomSpec=		True;
X	}
X	else {
X	    nUsed=		GenArg(argc,argv,i);
X	    if (nUsed>0)	i+= nUsed;
X	    else		ok= False;
X	    continue;
X	}
X	i+=	nUsed;;
X    }
X    if (OpenConnection()) {
X	ok= xrreqIssueSetState(argDpy,argRoot,&args);
X    }
X    if (!ok) {
X	uInformation("Set state request failed\n");
X    }
X    uRETURN(i-first);
X}
X
X/***==================================================================***/
X
Xint
XRememberArgs(argc,argv,i,remember)
Xint	argc;
Xchar	*argv[];
Xint	i;
Xchar	*remember;
X{
Xint			first=	 i;
Xint			nUsed;
XBoolean			ok=	True;
XBoolean			appSpec=	False;
Xunsigned		tmpInt;
Xchar			*tmpStr;
XxrRememberArgsRec	args;
X
X    uENTRY4("RememberArgs(%d,0x%x,%d,%s)\n",argc,argv,i,uStringText(remember));
X
X    args.remember=	(remember[0]=='T');
X    args.whichApp=	XR_QUERY_APP;
X
X    while ((i<argc)&&(ok)) {
X	if ((nUsed= WhichAppArg(argc,argv,i,&tmpInt,&tmpStr))>0) {
X	    if (appSpec&&OpenConnection()) {
X		ok=	xrreqIssueRemember(argDpy,argRoot,&args);
X	    }
X	    args.whichApp=	tmpInt;
X	    args.appName=	tmpStr;
X	    appSpec=		True;
X	}
X	else {
X	    nUsed=		GenArg(argc,argv,i);
X	    if (nUsed>0)	i+= nUsed;
X	    else		ok= False;
X	}
X	i+= nUsed;
X    }
X    if (OpenConnection()) {
X	ok= xrreqIssueRemember(argDpy,argRoot,&args);
X    }
X    if (!ok) {
X	uInformation("Remember request failed\n");
X    }
X    uRETURN(i-first);
X}
X
X/***==================================================================***/
X
X/* ARGSUSED */
Xint
XHideArgs(argc,argv,i,ignored)
Xint	argc;
Xchar	*argv[];
Xint	i;
XOpaque	ignored;
X{
XBoolean	ok=	True;
Xint	first=	 i;
XBoolean	roomSpec=	False;
Xunsigned		 tmpInt;
Xchar			*tmpStr;
XxrVisibilityArgsRec	 args;
Xint			 nUsed;
X
X    uENTRY4("HideArgs(%d,0x%x,%d,0x%x)\n",argc,argv,i,ignored);
X    args.visibility=	XR_ROOM_HIDDEN;
X    args.whichRoom=	XR_CURRENT_ROOM;
X    args.roomName=	NullString;
X    args.checkAuto=	False;
X    args.createRoom=	False;
X
X    while ((i<argc)&&(ok)) {
X	if ((nUsed= WhichRoomArg(argc,argv,i,&tmpInt,&tmpStr))>0) {
X	    if (roomSpec&&OpenConnection()) {
X		ok=	xrreqIssueVisibility(argDpy,argRoot,&args);
X	    }
X	    args.whichRoom=	tmpInt;
X	    args.roomName=	tmpStr;
X	    roomSpec=		True;
X	}
X	else if ((nUsed=GetStringArg(argc,argv,i,&tmpStr))>0) {
X	    if ((roomSpec)&&(OpenConnection())) {
X		ok= xrreqIssueVisibility(argDpy,argRoot,&args);
X	    }
X	    args.whichRoom=	XR_NAMED_ROOM;
X	    args.roomName=	tmpStr;
X	    roomSpec=		True;
X	}
X	else if (uStringPrefix(argv[i],"-create")) {
X	    args.createRoom=	True;
X	}
X	else {
X	    nUsed=		GenArg(argc,argv,i);
X	    if (nUsed>0)	i+= nUsed;
X	    else		ok= False;
X	    continue;
X	}
X	i+=	nUsed;;
X    }
X    if (OpenConnection()) {
X	ok= xrreqIssueVisibility(argDpy,argRoot,&args);
X    }
X    if (!ok) {
X	uInformation("HIDE request failed\n");
X    }
X    uRETURN(i-first);
X}
X
X/***==================================================================***/
X
X/* ARGSUSED */
Xint
XShowArgs(argc,argv,i,ignored)
Xint	argc;
Xchar	*argv[];
Xint	i;
XOpaque	ignored;
X{
XBoolean	ok=	True;
Xint	first=	 i;
XBoolean	roomSpec=	False;
Xunsigned		 tmpInt;
Xchar			*tmpStr;
XxrVisibilityArgsRec	 args;
Xint			 nUsed;
X
X    uENTRY4("ShowArgs(%d,0x%x,%d,0x%x)\n",argc,argv,i,ignored);
X    args.visibility=	XR_ROOM_VISIBLE;
X    args.whichRoom=	XR_CURRENT_ROOM;
X    args.roomName=	NullString;
X    args.checkAuto=	True;
X    args.createRoom=	False;
X
X    while ((i<argc)&&(ok)) {
X	if ((nUsed= WhichRoomArg(argc,argv,i,&tmpInt,&tmpStr))>0) {
X	    if (roomSpec&&OpenConnection()) {
X		ok=	xrreqIssueVisibility(argDpy,argRoot,&args);
X	    }
X	    args.whichRoom=	tmpInt;
X	    args.roomName=	tmpStr;
X	    roomSpec=		True;
X	}
X	else if ((nUsed=GetStringArg(argc,argv,i,&tmpStr))>0) {
X	    if ((roomSpec)&&(OpenConnection())) {
X		ok= xrreqIssueVisibility(argDpy,argRoot,&args);
X	    }
X	    args.whichRoom=	XR_NAMED_ROOM;
X	    args.roomName=	tmpStr;
X	    roomSpec=		True;
X	}
X	else if (uStringPrefix(argv[i],"-create")) {
X	    args.createRoom=	True;
X	}
X	else if (uStringPrefix(argv[i],"-always")) {
X	    args.visibility|=	XR_ROOM_ALWAYS;
X	}
X	else if (uStringPrefix(argv[i],"-active")||
X		 uStringPrefix(argv[i],"-whenactive")) {
X	    args.visibility|=	XR_ROOM_WHEN_ACTIVE;
X	}
X	else if (uStringPrefix(argv[i],"-nonempty")||
X		 uStringPrefix(argv[i],"-whennonempty")) {
X	    args.visibility|=	XR_ROOM_WHEN_NON_EMPTY;
X	}
X	else if (uStringPrefix(argv[i],"-now")) {
X	    args.checkAuto=	False;	
X	}
X	else {
X	    nUsed=		GenArg(argc,argv,i);
X	    if (nUsed>0)	i+= nUsed;
X	    else		ok= False;
X	    continue;
X	}
X	i+=	nUsed;;
X    }
X    if (OpenConnection()) {
X	ok= xrreqIssueVisibility(argDpy,argRoot,&args);
X    }
X    if (!ok) {
X	uInformation("SHOW request failed\n");
X    }
X    uRETURN(i-first);
X}
X
X/***==================================================================***/
X
X/* ARGSUSED */
Xint
XLoadArgs(argc,argv,i,ignored)
Xint	argc;
Xchar	*argv[];
Xint	i;
XOpaque	ignored;
X{
Xint	 first=	 i;
Xint	 nUsed;
Xchar	*fileName= NullString,*tmp;
XBoolean	 fileSpec;
XBoolean	 ok=	True;
X
X    uENTRY4("LoadArgs(%d,0x%x,%d,0x%x)\n",argc,argv,i,ignored);
X    while ((i<argc)&&(ok)) {
X	if ((nUsed=GetStringArg(argc,argv,i,&tmp))>0) {
X	    if ((fileSpec)&&(OpenConnection())) {
X		ok= xrreqIssueLoad(argDpy,argRoot,fileName);
X	    }
X	    fileName=	tmp;
X	    fileSpec=	True;
X	}
X	else {
X	    nUsed=		GenArg(argc,argv,i);
X	    if (nUsed>0)	i+= nUsed;
X	    else		ok= False;
X	    continue;
X	}
X	i+=	nUsed;
X    }
X    if (OpenConnection()) {
X	ok= xrreqIssueLoad(argDpy,argRoot,fileName);
X    }
X    if (!ok) {
X	uInformation("Load request failed\n");
X    }
X    uRETURN(i-first);
X}
X
X/***==================================================================***/
X
X/* ARGSUSED */
Xint
XGetAppNameArgs(argc,argv,i,ignored)
Xint	argc;
Xchar	*argv[];
Xint	i;
XOpaque	ignored;
X{
Xint			first=	 i;
Xint			nUsed;
XBoolean			ok=	True;
XBoolean			appSpec=	False;
Xunsigned		tmpInt;
Xchar			*tmpStr;
Xunsigned		whichApp;
Xchar			*name;
X
X    uENTRY4("GetAppNameArgs(%d,0x%x,%d,0x%x)\n",argc,argv,i,ignored);
X    whichApp=	XR_QUERY_APP;
X    name=	NullString;
X
X    while ((i<argc)&&(ok)) {
X	if ((nUsed= WhichAppArg(argc,argv,i,&tmpInt,&tmpStr))>0) {
X	    if (appSpec&&OpenConnection()) {
X		char *rtrn= xrreqIssueGetAppName(argDpy,argRoot,whichApp,name);
X		fprintf(stderr,"%s\n",uStringText(rtrn));
X	    }
X	    whichApp=	tmpInt;
X	    name=	tmpStr;
X	    appSpec=		True;
X	}
X	else {
X	    nUsed=		GenArg(argc,argv,i);
X	    if (nUsed>0)	i+= nUsed;
X	    else		ok= False;
X	}
X	i+= nUsed;
X    }
X    if (OpenConnection()) {
X	char *rtrn= xrreqIssueGetAppName(argDpy,argRoot,whichApp,name);
X	fprintf(stderr,"%s\n",uStringText(rtrn));
X    }
X    uRETURN(i-first);
X}
X
X/***==================================================================***/
X
Xtypedef struct _CommandArgRec {
X	char	*cmdLineArg;
X	int	(*argFunc)();
X	char	*funcArg;
X} CommandArgRec,*CommandArgPtr;
X
Xstatic	CommandArgRec	cmdArgs[] = {
X	{ "-debug",	DebugArgs,	""	},
X	{ "-set",	SetStateArgs,	"SP"	},
X	{ "-merge",	SetStateArgs,	"MP"	},
X	{ "-clear",	SetStateArgs,	"CP"	},
X	{ "-bolt",	SetStateArgs,	"MB"	},
X	{ "-unbolt",	SetStateArgs,	"CB"	},
X	{ "-tighten",	SetStateArgs,	"CL"	},
X	{ "-loosen",	SetStateArgs,	"ML"	},
X	{ "-setbolts",	SetStateArgs,	"SB"	},
X	{ "-remember",	RememberArgs,	"T"	},
X	{ "-forget",	RememberArgs,	"F"	},
X	{ "-hide",      HideArgs,	""	},
X	{ "-show",      ShowArgs,	""	},
X	{ "-load",	LoadArgs,	""	},
X	{ "-appname",	GetAppNameArgs,	""	},
X	{ NULL,		NULL,		NULL	}
X};
X
Xint
XCommandArgs(argc,argv,i)
Xint	argc;
Xchar	*argv[];
X{
XCommandArgPtr	pCmd;
X
X    uENTRY3("CommandArgs(%d,0x%x,%d)\n",argc,argv,i);
X    pCmd=	cmdArgs;
X    while (pCmd->cmdLineArg!=NullString) {
X	if (uStringPrefix(argv[i],pCmd->cmdLineArg)) {
X	    uRETURN(1+(*pCmd->argFunc)(argc,argv,i+1,pCmd->funcArg));
X	}
X	pCmd++;
X    }
X    uRETURN(0);
X}
X
X/***==================================================================***/
X
XBoolean
XHandleArgs(argc, argv)
Xint	argc;
Xchar	*argv[];
X{
Xint	i,nUsed;
X
X    uENTRY2("HandleArgs(%d,0x%x)\n",argc,argv);
X    i= 1;
X    if (argc==1) {
X	Usage(argv[0]);
X	/* NOTREACHED */
X    }
X    while (i<argc) {
X	nUsed=	GenArg(argc,argv,i);
X	if (nUsed==0)
X	    nUsed= CommandArgs(argc,argv,i);
X	if (nUsed==0) {
X	    uError("Unknown argument \"%s\"\n",argv[i]);
X	    Usage(argv[0]);
X	    /* NOTREACHED */
X	}
X	i+= nUsed;
X    }
X    uRETURN(True);
X}
X
X/***====================================================================***/
X
Xmain(argc, argv)
Xint argc;
Xchar **argv;
X{
XBoolean	ok;
X
X    (void)stInit(100,10,False,False);
X    ok= HandleArgs(argc, argv);
X    ok= CloseConnection()&&ok;
X    if (ok)	return(0);
X    else	return(1);
X}
X
END_OF_FILE
if test 23831 -ne `wc -c <'./xrset/xrset.c'`; then
    echo shar: \"'./xrset/xrset.c'\" unpacked with wrong size!
fi
# end of './xrset/xrset.c'
fi
echo shar: End of archive 12 \(of 14\).
cp /dev/null ark12isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 14 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0



More information about the Comp.sources.x mailing list