kent@ssbell.IMD.Sterling.COM (Kent Landfield) (01/15/90)
Submitted-by: wsl.dec.com!mikey (Mike Yang) Posting-number: Volume 5, Issue 61 Archive-name: xrooms/part11 #! /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 11 (of 14)." # Contents: ./lib/appstate.h ./xrooms/xrApp.c # Wrapped by kent@ssbell on Sun Jan 14 21:58:13 1990 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f './lib/appstate.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'./lib/appstate.h'\" else echo shar: Extracting \"'./lib/appstate.h'\" \(20723 characters\) sed "s/^X//" >'./lib/appstate.h' <<'END_OF_FILE' X#ifndef APPSTATE_H X#define APPSTATE_H 1 X X /*\ X * $Header: appstate.h,v 5.0 90/01/10 06:53:13 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 /*\ X X \*/ X X /*\ X * A positive specification of X or Y means that the defined value X * refers to the left or top edge of a window. A negative X or Y X * specification means that the defined value refers to the right X * or bottom edge of the window. X * X * A number of these functions distinguish between <real> AppStates X * and <profile> AppStates: X * <real> AppStates must be fully specified with positive X and Y. X * NullAppState is not a legal <real> AppState. X * <profile> AppStates may be partially specified and may have X * negative X and Y. <profile> AppStates may not have window state X * Inactive or Withdrawn. NullAppState is a legal <profile> state X * with no values specified for any field. X * It is an error to try to change any values in NullAppState. X * By convention, the variable "pReal" should always refer to a X * <real> AppState and "pProf" should always refer to a <profile> X * AppState. X * X * Values in a <profile> AppState may be "bolted." A bolted value X * is not affected by values in a <real> state. i.e. Copying a X * <real> state into a bolted state does not change any bolted values. X * X * Bolts may be "loose." A loose bolt has no effect, but may be X * rebolted. Rebolting does not affect values that do not have loose X * bolts. X * X * PUBLIC PACKAGE GLOBALS -- X * unsigned asDebug; [ default: 0 ] X * Debugging flags. The only flag currently used is ENTER (0x10) X * defined in ../utils/utils.h, which tracks function entry and X * exit. X * X * AppStatePtr asDefaultReal; [ default: [ inactive =0x0+0+0] ] X * AppStatePtr asDefaultProfile; [ default: [ iconic ] ] X * Default values for <real> and <profile> states respectively. X * X * DEBUGGING FUNCTIONS -- X * char * X * asWinStateText(winState) X * WinState winState; X * Returns a string containing a description of "winState." X * This string is stored in a static buffer so it must *not* X * be freed and may be clobbered by subsequent calls to X * asWinStateText. X * X * char * X * asText(pState) X * AppStatePtr pState; X * Returns a string containing a description of "pState." X * This string is a static buffer so it must *not* be freed X * and may be clobbered by subsequent calls to asText. X * X * FUNCTIONS FOR DEALING WITH NEGATIVE SPECIFICATIONS OF X AND Y -- X * void X * asSetScreenSize(width,height) X * unsigned width,height; X * Set the screen size for future conversions to and from negative X * specifications of X and Y. X * X * Boolean X * asChangeProfileFlags(pReal,pProf,pNewFlags) X * AppStatePtr pReal,pProf; X * unsigned pNewFlags; X * Change the specification of "pProf" to contain all of (and only) X * the fields defined in pNewFlags, taking any missing values from X * pReal. "asChangeProfileFlags" will compute negative X and X * Y specifications if defined in "pNewFlags." X * asChangeProfileFlags ignores bolts. X * Returns True if it succeeds, False if pReal is not a legal X * <real> state or pProf is NullAppState or not a legal <profile> X * state. X * X * Boolean X * asGetScreenValues(pReal, pProf, pWinState, pX, pY, pWidth, pHeight) X * AppStatePtr pReal, pProf; X * WinState *pWinState; // RETURN X * int *pX,*pY; // RETURN X * unsigned *pWidth, *pHeight; // RETURN X * Computes the positive screen coordinates of "pProf" and returns X * the values in the return arguments pWinState, pX, pY, pWidth X * and pHeight. Any of the return arguments may be NULL without X * error if the calling function does not use the value of that X * field. X * Returns True for success, False if pReal is not a legal <real> X * state or pProf is not a legal <profile> state. X * X * FUNCTIONS TO CREATE AND DESTROY APPLICATION STATES -- X * AppStatePtr X * asCreate(flags, winState, x, y, width, height) X * unsigned flags; X * WinState winState; X * int x,y; X * unsigned width,height; X * Creates an AppState with the specified values. Does *not* X * compute negative X or Y. Returns NullAppState on allocation X * failure. X * X * AppStatePtr X * asDupFully(pState) X * Creates a faithful (i.e. unmodified) duplicate of "pState." X * All of fields and bolts that are set in "pState" will be set X * to the same values in the newly created AppState. X * Returns NullAppState on allocation failure. X * If "pState" is NullAppState, "asDupFully" returns a X * AppStatePtr with no values defined; it does *not* return X * NullAppState. X * X * AppStatePtr X * asDupReal(pReal, flags) X * AppStatePtr pReal; X * unsigned flags; X * Creates a duplicate of "pReal" (which *must* be a legal real X * AppState). The fields specified in "flags" will be set to X * the appropriate values from "pReal." Correct values for X * negative X and Y values *are* calculated. X * Use this function to create a new partial or negative X * specification from a real window state. X * Returns NullAppState on allocation failure or if "pReal" X * is not a legal <real> AppState. X * X * void X * asDestroy(pState) X * AppStatePtr pState; X * Destroys "pState." Attempts to use an AppState after it X * has been destroyed may be disastrous. No return value. X * X X * X * FUNCTIONS TO COPY, CONVERT, AND MODIFY APPLICATION STATES -- X * Boolean X * asCopyFully(pFrom, pInto) X * AppStatePtr pFrom, pInto; X * Faithfully (i.e. without conversion) copies "pFrom" into X * "pInto." Sets all of the fields and bolts that are defined X * in "pFrom" to their same values in "pInto." Former values X * of "pInto" are lost. X * If "pFrom" is NullAppState, "pInto" is changed to have X * no values defined, but the copy is successful. X * Returns True for a successful copy, False if "pInto" is X * NullAppState. X * X * Boolean X * asCopySelected(pFrom, pInto, flags) X * AppStatePtr pFrom,pInto; X * unsigned flags; X * Copies selected values from "pFrom" into "pInto." Only X * copies those values that are defined in both "pFrom" and X * "flags." Does not compute values for negative X or Y X * specifications in pFrom, but does copy the XNegative and X * YNegative flags if set in "flags." X * Returns True if the copy is successful, False if any of X * the fields specified in "flags" are not defined in "pFrom." X * X * Boolean X * asCopyRealToProfile(pRealFrom, pProfInto) X * AppStatePtr pRealFrom, pProfInto; X * Copies values from "pRealFrom" into "pProfInto." Only X * copies those values that are specified in "pProfInto," and X * are not bolted. Computes correct values for negative X or X * Y specifications in "pProfInto." X * Returns True for a successful copy, False if pRealFrom is X * not a legal <real> state, pProfInto is not a legal <profile> X * state, or pProfInto is NullAppState. X * X * Boolean X * asCopyProfileToReal(pProfFrom, pRealInto) X * AppStatePtr pProfFrom,pRealInto; X * Copies values from "pProfFrom" into "pRealInto." Only X * copies those values that are defined in "pProfFrom." X * Computes correct values for negative X or Y specifications in X * pProfFrom. X * Returns True if the copy is successful, False if pProfFrom X * is not a legal <profile> state or pRealInto is not a legal X * <real> state. X * X * Boolean X * asChangeSelected(pState, flags, winState, x, y, width, height) X * AppStatePtr pState; X * unsigned flags; X * WinState winState; X * int x,y; X * unsigned width,height; X * Changes selected values in "pState." Changes only values X * specified in "flags." Changes settings for X or Y Negative X * if both the Value *and* negative fields are set in "flags," X * but does *not* compute values for x or y. Values not X * specified in "flags" are unchanged. X * Returns True for success, False if "pState" is NullAppState. X * X * Boolean X * asChangeAll(pState, flags, winState, x, y, width, height ) X * AppStatePtr pState; X * unsigned flags; X * WinState winState; X * int x,y; X * unsigned width,height; X * Changes all values in "pState" to those specified in "flags." X * Does affect XNegative and YNegative, but does not compute X * values for X and Y (assumes it is called with correctly X * computed values). Old values from "pState" are lost. X * Returns True for suceessful change, False if "pState" X * is NullAppState. X * X * Boolean X * asBolt(pState,which) X * AppStatePtr pState; X * unsigned which; X * Bolts the fields specified by "which" in "pState." If X * any of the specified fields have loose bolts, those bolts X * are tightened. Fields that are already bolted are not X * affected. X * Returns True for success, False if "pState" is NullAppState. X * X * Boolean X * asUnbolt(pState,which) X * AppStatePtr pState; X * unsigned which; X * Unbolts the fields specified by "which" in "pState." If X * any of the specified fields have loose bolts, those bolts X * are fully removed. Fields without bolts are unaffected. X * Returns True for success, False if "pState" is NullAppState. X * X * Boolean X * asLoosenBolts(pState,which) X * AppStatePtr pState; X * unsigned which; X * Loosens (temporarily unbolts) the fields specified by "which" X * in pState. Fields without bolts or with loose bolts are X * unaffected. X * Returns True for success, False if "pState" is NullAppState. X * X * Boolean X * asTightenBolts(pState,which) X * AppStatePtr pState; X * unsigned which; X * Tightens (re-bolts fields that were temporarily unbolted) the X * fields specified by "which" in "pState." Fields without X * loose bolts are unaffected. X * Returns True for success, False if "pState" is NullAppState. X * X * Boolean X * asSetBolts(pState,which) X * AppStatePtr pState; X * unsigned which; X * Bolts only the fields specified by "which" in "pState." If X * any of the specified fields have loose bolts, those bolts X * are tightened. Fields that are previously bolted that are X * are not specified in "which" are unbolted. X * Returns True for success, False if "pState" is NullAppState. X * X * Boolean X * asSetLooseBolts(pState,which) X * AppStatePtr pState; X * unsigned which; X * Sets the loose bolts in "pState" to be only the fields X * specified by "which." Any of the specified fields which are X * bolted are loosened. Tightens the bolts of any fields that X * are not specified in "which" but have loose bolts. X * Returns True for success, False if "pState" is NullAppState. X * X * FUNCTIONS TO GET INFORMATION ABOUT APPLICATON STATES -- X * unsigned X * asValues(pState, pWinState, pX, pY, pWidth, pHeight) X * AppStatePtr pState; X * WinState *pWinState; X * int *pX,*pY; // RETURN X * unsigned *pWidth,*pHeight; // RETURN X * Use asValues to find out the value of any of the components X * of a AppState. Returns the fields defined and values of X * XNegative and YNegative for "pState". Stores the values of X * any defined fields in the return arguments "pWinState," "pX," X * "pY," "pWidth," and "pHeight." If x or y has a negative X * specification and width or height is defined, asValues will X * calculate the positive (left or top) value and will X * *not* return asXNegative or asYNegative. If the x or y X * specification is negative but width or height is not defined, X * the right or top side value is returned along wth asXNegative X * (asYNegative). X * Any of the return arguments may be NULL, and only those values X * defined in the AppState will be changed. X * Returns asNoValue if "pState" is NullAppState. X * X * WinState X * asWinState(pState) X * AppStatePtr pState; X * Returns in the window state of "pState," or asInactive if X * "pState" is NullAppState, or "pState" has no defined X * value for window state. X * X * unsigned X * asFlags(pState) X * AppStatePtr pState; X * Returns the fields defined and values for XNegative and X * YNegative of "pState." Returns asNoValue if "pState" is X * NullAppState. X * X * unsigned X * asBolts(pState) X * AppStatePtr pState; X * Returns a mask of the fields that are currently bolted in X * "pState." Does not report loose bolts. X * Returns asNoValue if "pState" is NullAppState. X * X * unsigned X * asLooseBolts(pState) X * AppStatePtr pState; X * Returns a mask of the fields that are currently temporarily X * unbolted in "pState." Does not return fields that are X * fully bolted or unbolted. X * Returns asNoValue if "pState" is NullAppState. X * X * FUNCTIONS TO COMPARE APPLICATION STATES -- X * Boolean X * asProfileCorrectWRToReal(pProf, pReal) X * AppStatePtr pProf,pReal; X * Returns True if "pProf" is correct with respect to X * "pReal." X * A <profile> AppState is correct WRT a <real> AppState X * IFF all of the values that are defined in the <profile> X * AppState and are *not* bolted match the corresponding values in X * the <real> AppState (i.e. undefined or bolted values in the X * <profile> AppState are always correct WRT the corresponding X * value in the <real> AppState). X * Window states asWithdrawn and asInactive in a <real> X * AppState match any state in a <profile> AppState. X * Values for X and Y match if they refer to the same point X * on the screen. Values for width and height must be the X * same if defined. For example: If the screen is 1000x1000, X * the <profile> AppStates [ Normal =-100-100 ] and X * [ =+800+800 ] both match the <real> AppState X * [ Normal =100x100+800+800 ]. X * Use this function to determine if the <profile> AppState X * "pProf" must be modified to match a change in the corresponding X * <real> AppState "pReal." X * NOTE: asProfileCorrectWRTReal and asRealMatchesProfile are X * *NOT* symmetric. X * X * Boolean X * asSelectedProfileCorrectWRToReal(pProf, pReal, which) X * AppStatePtr pProf,pReal; X * unsigned which; X * Like asProfileCorrectWRTToReal, but only compares X * fields specified in "which." X * X * Boolean X * asRealMatchesProfile(pReal,pProf) X * AppStatePtr pReal,pProf; X * Returns True if "pReal" matches "pProf." X * A <real> AppState matches a <profile> AppState IFF all of the X * values in the <real> AppState match those elements of the X * corresponding <profile> AppState that are defined. Undefined X * values in the profile AppState always match the corresponding X * value in the the <real> AppState. Bolts in the <profile> X * AppState do not affect matches. X * Window states and values for x, y, width, and height match as X * they do for asProfileCorrectWRTReal. X * Use this function to determine if the <real> AppState "pReal" X * must be changed to correspond to the <profile> AppState X * "pProf." X * NOTE: asRealMatchesProfile and asProfileCorrectWRTReal are X * *NOT* symmetric. X * X * Boolean X * asSelectedRealMatchProfile(pReal,pProf,which) X * AppStatePtr pReal,pProf; X * unsigned which; X * Like asRealMatchesProfile, but only compares fields specified X * in "which." X * X * Boolean X * asFullySame(pState1, pState2) X * AppStatePtr pState1,pState2; X * Returns True if "pState1" and "pState2" have the same fields X * and bolts defined, the same values for XNegative and X * YNegative, and all fields have the same value. X * X * Boolean X * asSelectedSame(pState1, pState2, which) X * AppStatePtr pState1,pState2; X * unsigned which; X * Returns True if all of the fields and bolts specified in X * "which" have the same values in "pState1" and "pState2." X * Does *not* compute positive values of X and Y. X * X * FUNCTIONS TO DETERMINE OTHER USEFUL THINGS ABOUT APPLICATION STATES X * Boolean X * asLegalReal(pState) X * AppStatePtr pState; X * Returns True if "pState" is a legal <real> AppState, False X * otherwise. NullAppState is not a legal <real> AppState. X * X * Boolean X * asLegalProfile(pState) X * AppStatePtr pState; X * Returns True if "pState" is a legal <profile> AppState, X * False otherwise. NullAppState is a legal <profile> AppState. X * X * Boolean asDontCare(pState) X * AppStatePtr pState; X * Returns True if "pState" is NullAppState or if none of the X * values in pState are defined. X * X \*/ X X/*\ X X\*/ X Xtypedef struct _AppStateRec *AppStatePtr; X#define NullAppState ((AppStatePtr)NULL) X X /*\ X * All of these flags except asWinStateValue must be the same as X * the corresponding value in X11/Xutil.h. X * asWinStateValue must not conflict with any of the flags in X * X11/Xutil.h X * X * these flags are used to determine which fields of an AppState X * are defined, and whether the X and Y values are positive or X * negative specifications. X \*/ X X#define asNoValue ((unsigned)0x0000) X#define asXValue ((unsigned)0x0001) X#define asYValue ((unsigned)0x0002) X#define asWidthValue ((unsigned)0x0004) X#define asHeightValue ((unsigned)0x0008) X X#define asWinStateValue ((unsigned)0x0100) X X#define asPosValues (asXValue|asYValue) X#define asSizeValues (asWidthValue|asHeightValue) X#define asGeomValues (asPosValues|asSizeValues) X#define asAllValues (asGeomValues|asWinStateValue) X X#define asXNegative ((unsigned)0x0010) X#define asYNegative ((unsigned)0x0020) X#define asSignFlags (asXNegative|asYNegative) X X#define asLegalFlags (asAllValues|asSignFlags) X X /*\ X * Most of these values are *not* arbitrary. asWithdrawn, X * asIconic, and asNormal *must* correspond to the ICCCM. X * The other values should not conflict with the ICCCM. X \*/ Xtypedef int WinState; X X#define asInactive ((WinState)-1) X#define asWithdrawn ((WinState)0) X#define asNormal ((WinState)1) X#define asIconic ((WinState)3) X Xextern unsigned int asDebug; Xextern AppStatePtr asDefaultReal; Xextern AppStatePtr asDefaultProfile; X Xextern char *asWinStateText(/* pState */); Xextern char *asText(/* pState */); X Xextern void asSetScreenSize( /*width, height*/ ); Xextern Boolean asChangeProfileFlags(/* pReal, pProf, pNewFlags */); Xextern Boolean asGetScreenValues(/*pReal,pProf,pWState,pX,pY,pW,pH*/); X Xextern AppStatePtr asCreate(/* flags, winState, x, y, width, height */); Xextern AppStatePtr asDupFully(/* pState */); Xextern AppStatePtr asDupReal(/* pReal, flags*/); Xextern void asDestroy(/* pState */); X Xextern Boolean asCopyFully(/* pOldAppState, pNewAppState */); Xextern Boolean asCopySelected(/*pFrom, pInto, flags*/); Xextern Boolean asCopyRealToProfile(/* pReal, pProf */); Xextern Boolean asCopyProfileToReal(/* pProf, pReal */); X Xextern Boolean asChangeSelected(/*pState,flags,winState,x,y,w,h*/); Xextern Boolean asChangeAll(/*pState,flags,winState,x,y,width,height*/); X Xextern Boolean asBolt(/*pState,which*/); Xextern Boolean asUnbolt(/*pState,which*/); Xextern Boolean asLoosenBolts(/*pState,which*/); Xextern Boolean asTightenBolts(/*pState,which*/); Xextern Boolean asSetBolts(/*pState,which*/); Xextern Boolean asSetLooseBolts(/*pState,which*/); X Xextern unsigned asValues(/* pState, pWState,pX, pY, pWidth, pHeight */); Xextern unsigned asFlags(/*pState*/); Xextern unsigned asBolts(/*pState*/); Xextern unsigned asLooseBolts(/*pState*/); X Xextern Boolean asProfileCorrectWRTReal(/* pProf, pReal */); Xextern Boolean asSelectedProfileCorrectWRTReal(/*pProf,pReal,which*/); Xextern Boolean asRealMatchesProfile(/* pReal, pProf */); Xextern Boolean asSelectedRealMatchProfile(/* pReal, pProf, which */); Xextern Boolean asFullySame(/* pState1, pState2 */); Xextern Boolean asSelectedSame(/* pState1, pState2, which */); X Xextern Boolean asLegalReal(/* pState */); Xextern Boolean asLegalProfile(/* pState */); Xextern Boolean asDontCare(/* pState */); X X#endif /* APPSTATE_H */ END_OF_FILE if test 20723 -ne `wc -c <'./lib/appstate.h'`; then echo shar: \"'./lib/appstate.h'\" unpacked with wrong size! fi # end of './lib/appstate.h' fi if test -f './xrooms/xrApp.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'./xrooms/xrApp.c'\" else echo shar: Extracting \"'./xrooms/xrApp.c'\" \(20206 characters\) sed "s/^X//" >'./xrooms/xrApp.c' <<'END_OF_FILE' X X /*\ X * $Header: xrApp.c,v 5.2 90/01/11 14:08:41 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/Xlib.h> X#include <X11/cursorfont.h> X#include <X11/Xutil.h> X X#define DEBUG_VAR xrAppDebug X#include "utils.h" X#include "hash.h" X#include "regex.h" X X#include "appstate.h" X#include "apps.h" X#include "nameprof.h" X X#include "xrDebug.h" X#include "xrXUtils.h" X#include "xrApp.h" X#include "xrooms.h" X X#include "xrGen.h" X XBoolean xraNonICCCM; XBoolean xraUseWindowNames; XBoolean xraDfltAppsTransient; XBoolean xraUseGeometries; XBoolean xraReopenForGeom; XBoolean xraUnmapForState,xraUnmapForGeom; XBoolean xraManageTransients; XBoolean xraManageWithdrawn; X XHashTablePtr xraXApps; X X/***====================================================================***/ X Xvoid XxraDebugPrint() X{ XOpaque istate; XGenKey key; XGenData data; XAppPtr pApp; XXAppInfoPtr pXInfo; X X if (xraXApps!=NullHashTable) { X htIterator(xraXApps,key,data,istate) { X pApp= (AppPtr)data; X pXInfo= (XAppInfoPtr)appGetOutputPriv(pApp); X uDebug("0x%x= %s\n",data,appText(pApp)); X if (data==(GenData)pXInfo->client) { X uDebug(" parent=0x%x,client=0x%x\n",pXInfo->parent, X pXInfo->client); X } X } X htEndIterator(istate); X } X return; X X} X X/***====================================================================***/ X XAppPtr XxraLookupWindowApp(win) XWindow win; X{ XAppPtr pApp; X uENTRY1("xraLookupWindowApp(0x%x)\n",win); X pApp= (AppPtr)htLookup(xraXApps,(GenKey)win); X uRETURN(pApp); X} X X/***====================================================================***/ X Xstatic Bool XxraFindMissingEvents(qDpy,pEvent,pXInfo) XDisplay *qDpy; XXEvent *pEvent; XXAppInfoPtr pXInfo; X{ XBoolean handled= False; X X uENTRY3("xraFindMissingEvents(0x%x,0x%x,0x%x)\n",qDpy,pEvent,pXInfo); X switch (pEvent->type) { X case ConfigureNotify: X if (pEvent->xconfigure.window==pXInfo->client) { X if ((pEvent->xconfigure.send_event)&& X WantsX(pXInfo,pEvent->xconfigure.x)&& X WantsY(pXInfo,pEvent->xconfigure.y)) { X GotX(pXInfo); X GotY(pXInfo); X uDEBUG2(WATCH_EVENTS,"sneaking away config pos=(%d,%d)\n", X pEvent->xconfigure.x,pEvent->xconfigure.y); X handled= True; X } X else if (WantsWidth(pXInfo,pEvent->xconfigure.width)&& X WantsHeight(pXInfo,pEvent->xconfigure.height)) { X GotWidth(pXInfo); X GotHeight(pXInfo); X uDEBUG2(WATCH_EVENTS,"sneaking away config size=(%d,%d)\n", X pEvent->xconfigure.width,pEvent->xconfigure.height); X handled= True; X } X } X break; X case PropertyNotify: X if ((pEvent->xproperty.window==pXInfo->client)&& X (pEvent->xproperty.atom == WM_STATE)) { X WinState winState= xruGetState(pXInfo->client,False); X if (WantsState(pXInfo,winState)) { X GotState(pXInfo); X handled= True; X } X } X break; X case ClientMessage: X if ((pEvent->xclient.window==pXInfo->client)&& X WantsX(pXInfo,pEvent->xclient.data.s[0])&& X WantsY(pXInfo,pEvent->xclient.data.s[1])) { X GotX(pXInfo); X GotY(pXInfo); X uDEBUG2(WATCH_EVENTS,"sneaking away msg pos=(%d,%d)\n", X pEvent->xclient.data.s[0],pEvent->xclient.data.s[1]); X handled= True; X } X break; X } X uRETURN(handled); X} X X#define MAX_TIMEOUT 2 X Xstatic Boolean XxraTryToClear(pXInfo) XXAppInfoPtr pXInfo; X{ XXEvent event; Xint timeout= 0; X X uENTRY1("xraTryToClear(0x%x)\n",pXInfo); X while (WantsAny(pXInfo)&&(timeout<MAX_TIMEOUT)) { X if (!XCheckIfEvent(xroomsDpy,&event,xraFindMissingEvents,pXInfo)) { X timeout++; X sleep(1); X } X } X uRETURN(!WantsAny(pXInfo)); X} X X/***====================================================================***/ X X/* ARGSUSED */ XBoolean XxraNonICCCMAppUpdate(pApp,pNewState,priv) XAppPtr pApp; XAppStatePtr pNewState; XOpaque priv; X{ XXAppInfoPtr pXInfo; XAppStatePtr pOldState; XBoolean geomChange; XBoolean reopenWin= False; X X uENTRY3("xraNonICCCMAppUpdate(%s,%s,0x%x)\n",appText(pApp), X asText(pNewState),priv); X X uDEBUG2(WATCH_APPS,"Reconfiguring %s\n to %s\n",appText(pApp), X asText(pNewState)); X pXInfo= (XAppInfoPtr)priv; X X#ifdef NOTDEF X if (WantsAny(pXInfo)&&(!xraTryToClear(pXInfo))) { X uWarning("app %s waiting for a change (0x%x)\n",appText(pApp), X pXInfo->wants.flags); X } X#endif X pOldState= pXInfo->pRealState; X uDEBUG1(WATCH_APPS," from %s\n",asText(pOldState)); X X geomChange= ((xraUseGeometries)&& X (!asSelectedSame(pOldState,pNewState,asGeomValues))); X reopenWin= xraReopenForGeom&&geomChange&& X (asWinState(pNewState)==asNormal); X X if ((reopenWin)|| X (asWinState(pOldState)==asNormal)&&(asWinState(pNewState)==asIconic)) { X XWMHints hints; X hints.flags= StateHint; X X uDEBUG(WATCH_APPS," iconifying\n"); X hints.initial_state= IconicState; X if (xraUnmapForState) X XUnmapWindow(xroomsDpy,pXInfo->client); X XSetWMHints(xroomsDpy,pXInfo->client,&hints); X if (xraUnmapForState) X XMapWindow(xroomsDpy,pXInfo->client); X XSync(xroomsDpy,False); X SetWantsState(pXInfo,asIconic); X } X if (geomChange) { X XSizeHints hints; X int x,y,oldX,oldY; X unsigned width,height,oldWidth,oldHeight; X X asValues(pOldState,(WinState *)NULL,&oldX,&oldY,&oldWidth,&oldHeight); X asValues(pNewState,(WinState *)NULL,&x,&y,&width,&height); X hints.flags= 0; X if ((oldX!=x)||(oldY!=y)) { X hints.flags|= PPosition; X hints.x= x; X hints.y= y; X uDEBUG(WATCH_APPS," position changed.\n"); X SetWantsPos(pXInfo,x,y); X } X if ((oldWidth!=width)||(oldHeight!=height)) { X hints.flags|= PSize; X hints.width= width; X hints.height= height; X uDEBUG(WATCH_APPS," size changed.\n"); X SetWantsSize(pXInfo,width,height); X } X if (hints.flags) { X uDEBUG(WATCH_APPS," telling X\n"); X X if ((xraUnmapForGeom)&&(asWinState(pNewState)!=asWithdrawn)) { X XGrabServer(xroomsDpy); X XUnmapWindow(xroomsDpy,pXInfo->client); X XSetNormalHints(xroomsDpy, pXInfo->client, &hints); X XMoveResizeWindow(xroomsDpy,pXInfo->client,x,y,width,height); X XMapWindow(xroomsDpy,pXInfo->client); X XUngrabServer(xroomsDpy); X } X else { X XSetNormalHints(xroomsDpy, pXInfo->client, &hints); X XMoveResizeWindow(xroomsDpy,pXInfo->client,x,y,width,height); X } X } X } X if (reopenWin||((asWinState(pOldState)==asIconic)&& X (asWinState(pNewState)==asNormal))) { X XWMHints hints; X hints.flags= StateHint; X uDEBUG(WATCH_APPS," deiconifying\n"); X hints.initial_state= NormalState; X if (xraUnmapForState) X XUnmapWindow(xroomsDpy,pXInfo->client); X XSetWMHints(xroomsDpy,pXInfo->client,&hints); X if (xraUnmapForState) X XMapWindow(xroomsDpy,pXInfo->client); X XSync(xroomsDpy,False); X SetWantsState(pXInfo,asNormal); X } X uRETURN(True); X} X X/***====================================================================***/ X X/* ARGSUSED */ XBoolean XxraAppUpdate(pApp,pNewState,priv) XAppPtr pApp; XAppStatePtr pNewState; XOpaque priv; X{ XXAppInfoPtr pXInfo; XAppStatePtr pOldState; X X uENTRY3("xraAppUpdate(%s,%s,0x%x)\n",appText(pApp),asText(pNewState),priv); X X uDEBUG2(WATCH_APPS,"Reconfiguring %s\n to %s\n",appText(pApp), X asText(pNewState)); X pXInfo= (XAppInfoPtr)priv; X X if (WantsAny(pXInfo)&&(!xraTryToClear(pXInfo))) { X uWarning("app %s waiting for a change (0x%x)\n",appText(pApp), X pXInfo->wants.flags); X } X pOldState= pXInfo->pRealState; X uDEBUG1(WATCH_APPS," from %s\n",asText(pOldState)); X X if ((asWinState(pOldState)==asNormal)&&(asWinState(pNewState)==asIconic)) { X XEvent event; X uDEBUG(WATCH_APPS," iconifying\n"); X event.xclient.type= ClientMessage; X event.xclient.display= xroomsDpy; X event.xclient.window= pXInfo->client; X event.xclient.message_type= WM_CHANGE_STATE; X event.xclient.format= 32; X event.xclient.data.l[0]= IconicState; X XSendEvent(xroomsDpy,xroomsRealRoot,False, X SubstructureRedirectMask|SubstructureNotifyMask, X &event); X SetWantsState(pXInfo,asIconic); X } X if (xraUseGeometries&&(!asSelectedSame(pOldState,pNewState,asGeomValues))) { X XSizeHints hints; X int x,y,oldX,oldY; X unsigned width,height,oldWidth,oldHeight; X X asValues(pOldState,(WinState *)NULL,&oldX,&oldY,&oldWidth,&oldHeight); X asValues(pNewState,(WinState *)NULL,&x,&y,&width,&height); X hints.flags= 0; X if ((oldX!=x)||(oldY!=y)) { X hints.flags|= PPosition; X hints.x= x; X hints.y= y; X uDEBUG(WATCH_APPS," position changed.\n"); X SetWantsPos(pXInfo,x,y); X } X if ((oldWidth!=width)||(oldHeight!=height)) { X hints.flags|= PSize; X hints.width= width; X hints.height= height; X uDEBUG(WATCH_APPS," size changed.\n"); X SetWantsSize(pXInfo,width,height); X } X if (hints.flags) { X uDEBUG(WATCH_APPS," telling X\n"); X XSetNormalHints(xroomsDpy, pXInfo->client, &hints); X XMoveResizeWindow(xroomsDpy,pXInfo->client,x,y,width,height); X } X } X if ((asWinState(pOldState)==asIconic)&&(asWinState(pNewState)==asNormal)) { X uDEBUG(WATCH_APPS," deiconifying\n"); X XMapWindow(xroomsDpy,pXInfo->client); X SetWantsState(pXInfo,asNormal); X } X XFlush(xroomsDpy); X uRETURN(True); X} X X/***====================================================================***/ X Xvoid XxraSetupModeApp(name,pApp,pRealState,win) Xchar *name; XAppPtr pApp; XAppStatePtr pRealState; XWindow win; X{ XAppStatePtr pState; X X uENTRY4("xraSetupModeApp(%s,%s,%s,0x%x)\n",uStringText(name),appText(pApp), X asText(pRealState),win); X if ((pApp!=NullApp)&&(!appIsPermanent(pApp))) { X pState= appGetDefault(pApp); X if (asWinState(pRealState)==asIconic) { X appRemoveAllRoomStates(pApp); X asCopyFully(pRealState,pState); X asChangeSelected(pState,asWinStateValue,asIconic,0,0,(unsigned)0, X (unsigned)0); X appSetPermanence(pApp,True); X } X else if ((win==xroomsMainWindow)|| X regexMatch(".*[xX]?rooms*",name,NULL)|| X regexMatch(".*[cC]lock.*",name,NULL)|| X regexMatch(".*[lL]oad.*",name,NULL)|| X regexMatch(".*[bB]iff.*",name,NULL)|| X regexMatch(".*[iI][cC][oO][nN][ ]*[bB][oO][xX].*",name,NULL)|| X regexMatch(".*[iI][cC][oO][nN][sS].*",name,NULL)) { X X if (pState!=NullAppState) { X asCopyFully(pRealState,pState); X appRemoveAllRoomStates(pApp); X appSetPermanence(pApp,True); X } X } X } X uVOIDRETURN; X} X X/***====================================================================***/ X Xvoid XxraAddApp(window) XWindow window; X{ XWindow client; Xint border_width, depth; XWindow winreturn; XAppPtr pApp; Xchar *name,*class; XStringToken nameToken; XWinState winState; XAppStatePtr pState= NullAppState; Xint x,y; Xunsigned width,height; XXAppInfoPtr pXInfo; X X uENTRY1("xraAddApp(0x%x)\n",window); X pApp= (AppPtr)htLookup(xraXApps,(GenKey)window); X if (pApp!=NullApp) { X uVOIDRETURN; X } X X if ((client=xruFindClientWindow(window, &winState))==NULL) { X uVOIDRETURN; X } X if ((!xraManageTransients)&&(xruIsTransient(client))) { X uVOIDRETURN; X } X X if ((pApp= (AppPtr)htLookup(xraXApps,(GenKey)client))!=NullApp) { X pXInfo= (XAppInfoPtr)appGetOutputPriv(pApp); X if (pXInfo->client==client) { X if (pXInfo->parent!=client) X htRemove(xraXApps,(GenKey)pXInfo->parent); X pXInfo->parent= window; X htAdd(xraXApps,(GenKey)window,(GenData)pApp); X uVOIDRETURN; X } X else pApp= NullApp; X } X else if (winState==asWithdrawn) { X uVOIDRETURN; X } X X xrnGetName(client,&name,&class); X uDEBUG3(WATCH_APPS,"got name %s (class %s) for window 0x%x\n", X uStringText(name),uStringText(class),client); X if (name==NullString) { X if (class==NullString) { X uVOIDRETURN; X } X else { X name= class; X class= NullString; X } X } X nameToken= stGetToken(name); X X XGetGeometry(xroomsDpy, client, &winreturn, &x, &y, &width, &height, X &border_width, &depth); X XTranslateCoordinates(xroomsDpy, client, xroomsRoot, X -border_width, -border_width, X &x, &y, &winreturn); X X pState= asCreate(asAllValues,winState,x,y,width,height); X if (pState==NullAppState) { X uVOIDRETURN; X } X pXInfo= uTypedAlloc(XAppInfoRec); X if (pXInfo==NullXAppInfo) { X asDestroy(pState); X uVOIDRETURN; X } X X pApp= GetApp(nameToken,True); X X if (xroomsSetupMode) { X if (winState!=asWithdrawn) X xraSetupModeApp(name,pApp,pState,client); X } X X if (pApp!=NullApp) { X uDEBUG4(WATCH_APPS,"New app \"%s\" %x (%x): (%s)\n", X appText(pApp), window, client, asText(pState)); X SetWantsNone(pXInfo); X pXInfo->parent= window; X pXInfo->client= client; X pXInfo->pRealState= pState; X XSelectInput(xroomsDpy, client, PropertyChangeMask|StructureNotifyMask); X if (xraNonICCCM) (void)appSetUpdateFunc(pApp,xraNonICCCMAppUpdate); X else (void)appSetUpdateFunc(pApp,xraAppUpdate); X (void)appSetOutputPriv(pApp,(Opaque)pXInfo); X (void)htAdd(xraXApps,(GenKey)client,(GenData)pApp); X if (window!=client) X (void)htAdd(xraXApps,(GenKey)window,(GenData)pApp); X if (!AppActivated(pApp,pState)) { X uWarning("couldn't activate app \"%s\"\n",appText(pApp)); X } X else { X xrnNoteAppName(client,appText(pApp)); X if (xroomsSetupMode) { X appSetPermanence(pApp,True); X } X } X } X else { X (void)uFree((Opaque)pXInfo); X uWarning("couldn't create app \"%s\"\n",stText(nameToken)); X } X if (name==NullString) (void)uFree((Opaque)name); X if (class==NullString) (void)uFree((Opaque)class); X X uVOIDRETURN; X} X X/***====================================================================***/ X Xvoid XxraClientResized(client,newW,newH) XWindow client; Xunsigned newW,newH; X{ XAppPtr pApp; XXAppInfoPtr pXInfo; XAppStatePtr pState; XBoolean realChange; Xunsigned oldW,oldH; X X uENTRY3("xraClientResized(0x%x,%d,%d)\n",client,newW,newH); X pApp= (AppPtr)htLookup(xraXApps,(GenKey)client); X X uDEBUG3(WATCH_EVENTS,"Got a resize notify for app %s (=%dx%d)\n", X appText(pApp),newW,newH); X X if (pApp==NullApp) { X xraAddApp(client); X pApp= (AppPtr)htLookup(xraXApps,(GenKey)client); X } X X if (pApp!=NullApp) { X pXInfo= (XAppInfoPtr)appGetOutputPriv(pApp); X if (pXInfo==NullXAppInfo) { X uInternalError("NULL X info in xraClientResized\n"); X uVOIDRETURN; X } X if (client!=pXInfo->client) { /* don't do WM top level windows */ X uVOIDRETURN; X } X X pState= pXInfo->pRealState; X asValues(pState,(WinState *)NULL,NULL,NULL,&oldW,&oldH); X if ((oldW!=newW)||(oldH!=newH)) { X asChangeSelected(pState,asWidthValue|asHeightValue,asWithdrawn,0,0, X newW,newH); X uDEBUG4(WATCH_EVENTS,"App %s (%x,%x) changed:\n %s [w,h,config]\n", X appText(pApp),pXInfo->parent,client, X asText(pState)); X if (WantsWidth(pXInfo,newW)&&WantsHeight(pXInfo,newH)) { X GotWidth(pXInfo); X GotHeight(pXInfo); X realChange= False; X } X else realChange= True; X } X else realChange= False; X X if (realChange) { X uDEBUG(WATCH_EVENTS," Looks like a real change\n"); X (void)AppStateChanged(pApp,pState); X } X else { X uDEBUG(WATCH_EVENTS," I was looking for this event\n"); X } X } X uVOIDRETURN; X} X X/***====================================================================***/ X Xvoid XxraClientMoved(client,newX,newY) XWindow client; Xint newX,newY; X{ XAppPtr pApp; XXAppInfoPtr pXInfo; XAppStatePtr pState; X X uENTRY3("xraClientMoved(0x%x,%d,%d)\n",client,newX,newY); X pApp= (AppPtr)htLookup(xraXApps,(GenKey)client); X if (pApp==NullApp) { X xraAddApp(client); X pApp= (AppPtr)htLookup(xraXApps,(GenKey)client); X } X if (pApp!=NullApp) { X int oldX,oldY; X X uDEBUG1(WATCH_EVENTS,"Got a client move for app %s\n",appText(pApp)); X pXInfo= (XAppInfoPtr)appGetOutputPriv(pApp); X if (pXInfo==NullXAppInfo) { X uInternalError("NULL X info or geom in ClientMoved\n"); X uVOIDRETURN; X } X if (client!=pXInfo->client) { X uVOIDRETURN; X } X pState= pXInfo->pRealState; X asValues(pState,(WinState *)NULL,&oldX,&oldY,NULL,NULL); X if ((oldX!=newX)||(oldY!=newY)) { X asChangeSelected(pState,asXValue|asYValue,asInactive, X newX,newY,(unsigned)0,(unsigned)0); X uDEBUG4(WATCH_EVENTS,"App %s (%x,%x) changed:\n (%s) [x,y,msg]\n", X appText(pApp), X pXInfo->parent,pXInfo->client, X asText(pState)); X } X if (WantsX(pXInfo,newX)&&WantsY(pXInfo,newY)) { X GotX(pXInfo); X GotY(pXInfo); X uDEBUG(WATCH_EVENTS," I was looking for this event\n"); X } X else { X uDEBUG(WATCH_EVENTS," Looks like a real event\n"); X AppStateChanged(pApp,pState); X } X } X uVOIDRETURN; X} X X/***====================================================================***/ X Xvoid XxraClientDestroyed(client) XWindow client; X{ XAppPtr pApp; XXAppInfoPtr pXInfo; XWindow parent= None; X X uENTRY1("xraClientDestroyed(0x%x)\n",client); X uDEBUG(WATCH_EVENTS,"Got a destroy client\n"); X pApp= (AppPtr)htLookup(xraXApps,(GenKey)client); X if (pApp!=NullApp) { X pXInfo= (XAppInfoPtr)appGetOutputPriv(pApp); X if (pXInfo!=NullXAppInfo) { X parent= pXInfo->parent; X (void)uFree((Opaque)pXInfo); X } X AppDeactivated(pApp); X htRemove(xraXApps,(GenKey)client); X htRemove(xraXApps,(GenKey)parent); X } X uVOIDRETURN; X} X X/***====================================================================***/ X Xvoid XxraStateChanged(client) XWindow client; X{ XAppPtr pApp; XWinState winState; XAppStatePtr pState= NullAppState; XXAppInfoPtr pXInfo; XBoolean myRequest= False; X X uENTRY1("xraStateChanged(0x%x)\n",client); X pApp= (AppPtr)htLookup(xraXApps,(GenKey)client); X X#ifdef PROPERTY_RACE_CONDITION X if (pApp==NullApp) { X uDEBUG1(WATCH_EVENTS,"Got a property notify for non-app 0x%x\n",client); X xraAddApp(client); X uVOIDRETURN; X } X#endif X uDEBUG1(WATCH_EVENTS,"Got a state change for app %s\n",appText(pApp)); X if (pApp!=NullApp) { X pXInfo= (XAppInfoPtr)appGetOutputPriv(pApp); X if (client!=pXInfo->client) { X uVOIDRETURN; X } X winState= xruGetState(client,False); X if (WantsState(pXInfo,winState)) { X GotState(pXInfo); X uDEBUG(WATCH_EVENTS,"I was looking for this event\n"); X myRequest= True; X } X uDEBUG2(WATCH_APPS,"%s -> %s\n",appText(pApp),asWinStateText(winState)); X if ((winState==asInactive)|| X ((winState==asWithdrawn)&&(!xraManageWithdrawn))) { X if (pXInfo!=NULL) X uFree((Opaque)pXInfo); X AppDeactivated(pApp); X } X else if (!myRequest) { X int x,y,border_width, depth; X unsigned width,height; X Window winreturn; X X XGetGeometry(xroomsDpy, client, &winreturn, &x, &y, &width, &height, X &border_width, &depth); X XTranslateCoordinates(xroomsDpy,client,xroomsRealRoot, X -border_width, -border_width, X &x, &y, &winreturn); X pState= pXInfo->pRealState; X asChangeSelected(pState,asAllValues,winState,x,y,width,height); X uDEBUG2(WATCH_APPS,"new state for %s is %s\n",appText(pApp), X asText(pState)); X AppStateChanged(pApp,pState); X } X else if ( asWinState(pXInfo->pRealState)!=asWithdrawn) { X asChangeSelected(pXInfo->pRealState,asWinStateValue,winState, X 0,0,0,0); X } X } X uVOIDRETURN; X} X X/***====================================================================***/ X Xvoid XxraInit() X{ X uENTRY("xraInit()\n"); X xraXApps= htCreate((unsigned)71,genIntegerKeyType,genPointerDataType); X if (xraXApps==NullHashTable) { X uFatalError("Couldn't create xraXApps\n"); X /* NOTREACHED */ X } X uVOIDRETURN; X} END_OF_FILE if test 20206 -ne `wc -c <'./xrooms/xrApp.c'`; then echo shar: \"'./xrooms/xrApp.c'\" unpacked with wrong size! fi # end of './xrooms/xrApp.c' fi echo shar: End of archive 11 \(of 14\). cp /dev/null ark11isdone 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