home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume3 / awm2 / part06 / globals.c next >
Encoding:
C/C++ Source or Header  |  1989-02-20  |  14.7 KB  |  384 lines

  1.  
  2.  
  3.  
  4. #ifndef lint
  5. static char *rcsid_globals_c = "$Header: /usr/graph2/X11.3/contrib/windowmgrs/awm/RCS/globals.c,v 1.2 89/02/07 21:24:58 jkh Exp $";
  6. #endif  lint
  7.  
  8. #include "X11/copyright.h"
  9. /*
  10.  *
  11.  * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
  12.  *
  13.  * Copyright 1987 by Jordan Hubbard.
  14.  *
  15.  *
  16.  *                         All Rights Reserved
  17.  *
  18.  * Permission to use, copy, modify, and distribute this software and its
  19.  * documentation for any purpose and without fee is hereby granted,
  20.  * provided that the above copyright notice appear in all copies and that
  21.  * both that copyright notice and this permission notice appear in
  22.  * supporting documentation, and that the name of Ardent Computer
  23.  * Corporation or Jordan Hubbard not be used in advertising or publicity
  24.  * pertaining to distribution of the software without specific, written
  25.  * prior permission.
  26.  *
  27.  */
  28.  
  29. /*
  30.  * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
  31.  *
  32.  *               All Rights Reserved
  33.  *
  34.  * Permission to use, copy, modify, and distribute this software and its
  35.  * documentation for any purpose and without fee is hereby granted,
  36.  * provided that the above copyright notice appear in all copies and that
  37.  * both that copyright notice and this permission notice appear in
  38.  * supporting documentation, and that the name of Digital Equipment
  39.  * Corporation not be used in advertising or publicity pertaining to
  40.  * distribution of the software without specific, written prior permission.
  41.  *
  42.  *
  43.  * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  44.  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  45.  * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  46.  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  47.  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  48.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  49.  * SOFTWARE.
  50.  */
  51.  
  52.  
  53. /*
  54.  * MODIFICATION HISTORY
  55.  *
  56.  * 000 -- M. Gancarz, DEC Ultrix Engineering Group
  57.  * 001 -- R. Kittell, DEC Storage A/D May 19, 1986
  58.  *  Added global vars for warp options.
  59.  * 002 -- Loretta Guarino Reid, DEC Ultrix Engineering Group 
  60.  *  Western Software Lab. April 17, 1987
  61.  *  Convert to X11
  62.  * 003 -- Jordan Hubbard, U.C. Berkeley. Misc new vars.
  63.  * 1.4 -- Vars added for new icon stuff.
  64.  */
  65.  
  66. #include "awm.h"
  67. #include "X11/Xutil.h"
  68.  
  69. Window Pop;            /* Pop up dimension display window. */
  70. Window Frozen;            /* Contains window id of "gridded" window. */
  71. XFontStruct *IFontInfo;        /* Icon text font information. */
  72. XFontStruct *PFontInfo;        /* Pop-up text font information. */
  73. XFontStruct *TFontInfo;        /* Title text font information. */
  74. XFontStruct *TFontBoldInfo;    /* Title text (bold) font information. */
  75. XFontStruct *GFontInfo;        /* Gadget box text font */
  76. Pixmap GrayPixmap;        /* Gray pixmap. */
  77. Pixmap SolidPixmap;        /* Solid pixmap */
  78. Pixmap IBackPixmap;        /* Icon window background pixmap. */
  79. Pixmap IDefPixmap;        /* default icon pixmap for IconLabels */
  80. Pixel ForeColor;        /* Generic foreground color */
  81. Pixel BackColor;        /* Generic background color */
  82. Pixel IBorder;            /* Icon window border color. */
  83. Pixel PBackground;        /* Pop-up Window background color. */
  84. Pixel PForeground;        /* Pop-up Window foregrould color */
  85. Pixel PBorder;            /* Pop-Up Window border color. */
  86. Pixel IBackground;        /* Icon background (for pixmap) color */
  87. Pixel IForeground;        /* Icon foreground (for pixmap) color */
  88. Pixel ITextForeground;        /* Icon text foreground color */
  89. Pixel ITextBackground;        /* Icon text background color */
  90. char *Foreground;        /* foreground color (text) */
  91. char *Background;        /* background color (text) */
  92. char *WBorder;            /* Window border color */
  93. char *BBackground;        /* Border context background color */
  94. char *BForeground;        /* Border context foreground color */
  95. char *TBackground;        /* Titlebar background color */
  96. char *TForeground;        /* Titlebar foreground color */
  97. char *TTextBackground;        /* Titlebar text background color */
  98. char *TTextForeground;        /* Titlebar text foreground color */
  99. Cursor ArrowCrossCursor;    /* Arrow cross cursor. */
  100. Cursor TextCursor;        /* Text cursor used in icon windows. */
  101. Cursor IconCursor;        /* Icon Cursor. */
  102. Cursor LeftButtonCursor;    /* Left button main cursor. */
  103. Cursor MiddleButtonCursor;    /* Middle button main cursor. */
  104. Cursor RightButtonCursor;    /* Right button main cursor. */
  105. Cursor TargetCursor;        /* Target (select-a-window) cursor. */
  106. Cursor TitleCursor;        /* Titlebar cursor */
  107. Cursor FrameCursor;        /* Border context cursor */
  108. Cursor GumbyCursor;        /* Used in icons if not type-in */
  109. unsigned int GadgetBorder;    /* Width of gadget borders */
  110. int ScreenWidth;        /* Display screen width. */
  111. int ScreenHeight;        /* Display screen height. */
  112. int IBorderWidth;        /* Icon window border width. */
  113. int TitleHeight;        /* Height of title bar(s) (in pixels) */
  114. int titleHeight;        /* Derived height of title bar(s) in pixels */
  115. int gadgetHeight;        /* Height of highest gadget */
  116. int NameOffset;            /* Offset for window name */
  117. int TitlePad;            /* Padding for titles */
  118. int PWidth;            /* Pop-up window width. */
  119. int PHeight;            /* Pop-up window height. */
  120. unsigned int PBorderWidth;    /* Pop-up window border width. */
  121. int PPadding;            /* Pop-up window padding. */
  122. int Delta;            /* Mouse movement slop. */
  123. int HIconPad;            /* Icon horizontal padding. */
  124. int VIconPad;            /* Icon vertical padding. */
  125. int Pushval;            /* Number of pixels to push window by. */
  126. int BContext;            /* Border context area width (in pixels) */
  127. int RaiseDelay;            /* Number of milliseconds delay before autoraise */
  128. int NumGadgets;            /* Number of gadgets we're using */
  129. int GadgetPad;            /* Amount of padding for gadgets */
  130. int Volume;            /* Audible alarm volume. */
  131. int status;            /* Routine return status. */
  132. unsigned int BCursor;        /* Border context cursor */
  133. unsigned int TCursor;        /* Title context cursor */
  134. MenuLink *Menus;        /* Linked list of menus. */
  135. GC  IconGC;            /* graphics context for icon */
  136. GC  PopGC;            /* graphics context for pop */
  137. GC  DrawGC;            /* graphics context for drawing */
  138. Binding *Blist;            /* Button/key binding list. */
  139.  
  140. XContext AwmContext;        /* Main context for awm */
  141.  
  142. Boolean Autoselect;        /* Warp mouse to default menu selection? */
  143. Boolean Autoraise;        /* Raise window on input focus? */
  144. Boolean Borders;        /* Display border context areas? */
  145. Boolean ConstrainResize;    /* Don't resize until pointer leaves window */
  146. Boolean Freeze;            /* Freeze server during move/resize? */
  147. Boolean Grid;            /* Should the m/r box contain a 9 seg. grid. */
  148. Boolean ShowName;        /* If True, print window names in titlebars */
  149. Boolean Hilite;            /* Should we highlight titles on focus? */
  150. Boolean BorderHilite;        /* Should we highlight borders on focus? */
  151. Boolean InstallColormap;    /* Should we install colormaps for clients? */
  152. Boolean NWindow;        /* Normalize windows? */
  153. Boolean NIcon;            /* Normalize icons? */
  154. Boolean Push;            /* Relative=TRUE, Absolute=FALSE. */
  155. Boolean RootResizeBox;        /* Resize window is placed over sized window? */
  156. Boolean ResizeRelative;        /* resizes should be relative to window edge */
  157. Boolean Titles;            /* Title bar frob on windows? */
  158. Boolean IconLabels;        /* icon labels? */
  159. Boolean ILabelTop;        /* icon label on top? */
  160. Boolean UseGadgets;        /* Gadget boxes on titles? */
  161. Boolean FrameFocus;        /* Treat the frame as part of the window? */
  162. Boolean Reverse;        /* Reverse video? */
  163. Boolean SaveUnder;        /* Save unders? */
  164. Boolean PushDown;        /* Down=TRUE, Up=FALSE */
  165. Boolean Wall;            /* restrict to root window boundries? */
  166. Boolean WarpOnRaise;        /* Warp to upper right corner on raise. */
  167. Boolean WarpOnIconify;          /* Warp to icon center on iconify. */
  168. Boolean WarpOnDeIconify;        /* Warp to upper right corner on de-iconify. */
  169. Boolean FocusSetByUser;         /* True if f.focus called */
  170. Boolean FocusSetByWM;        /* True if awm set the focus */
  171. Boolean Zap;            /* Should the the zap effect be used. */
  172.  
  173. char PText[7] = INIT_PTEXT;    /* Pop-up window dummy text. */
  174. int PTextSize = sizeof(PText);    /* Pop-up window dummy text size. */
  175.  
  176. int Lineno = 1;            /* Line count for parser. */
  177. Boolean Startup_File_Error = FALSE;/* Startup file error flag. */
  178. char Startup_File[NAME_LEN] = "";/* Startup file name. */
  179. char *TBackPixmapData;        /* Bitmap data file title background */
  180. char *TBoldPixmapData;        /* ditto, except highlighted */
  181. char *BBackPixmapData;        /* Border context background pixmap data */
  182. char *BBoldPixmapData;        /* Border context bold pixmap data */
  183. char *awmPath;            /* Optional pathlist to search for pixmaps */
  184. char **Argv;            /* Pointer to command line parameters. */
  185. char **Environ;            /* Pointer to environment. */
  186.  
  187. char gray_bits[] = {
  188.      0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa,
  189.      0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa,
  190.      0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa,
  191.      0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa
  192. };
  193.  
  194. char solid_bits[] = {
  195.      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  196.      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  197.      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  198.      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
  199. };
  200.  
  201. char xlogo32_bits[] = {
  202.    0xff, 0x00, 0x00, 0xc0, 0xfe, 0x01, 0x00, 0xc0, 0xfc, 0x03, 0x00, 0x60,
  203.    0xf8, 0x07, 0x00, 0x30, 0xf8, 0x07, 0x00, 0x18, 0xf0, 0x0f, 0x00, 0x0c,
  204.    0xe0, 0x1f, 0x00, 0x06, 0xc0, 0x3f, 0x00, 0x06, 0xc0, 0x3f, 0x00, 0x03,
  205.    0x80, 0x7f, 0x80, 0x01, 0x00, 0xff, 0xc0, 0x00, 0x00, 0xfe, 0x61, 0x00,
  206.    0x00, 0xfe, 0x31, 0x00, 0x00, 0xfc, 0x33, 0x00, 0x00, 0xf8, 0x1b, 0x00,
  207.    0x00, 0xf0, 0x0d, 0x00, 0x00, 0xf0, 0x0e, 0x00, 0x00, 0x60, 0x1f, 0x00,
  208.    0x00, 0xb0, 0x3f, 0x00, 0x00, 0x98, 0x7f, 0x00, 0x00, 0x98, 0x7f, 0x00,
  209.    0x00, 0x0c, 0xff, 0x00, 0x00, 0x06, 0xfe, 0x01, 0x00, 0x03, 0xfc, 0x03,
  210.    0x80, 0x01, 0xfc, 0x03, 0xc0, 0x00, 0xf8, 0x07, 0xc0, 0x00, 0xf0, 0x0f,
  211.    0x60, 0x00, 0xe0, 0x1f, 0x30, 0x00, 0xe0, 0x1f, 0x18, 0x00, 0xc0, 0x3f,
  212.    0x0c, 0x00, 0x80, 0x7f, 0x06, 0x00, 0x00, 0xff};
  213.  
  214. int scr;
  215. Display *dpy;
  216.  
  217. #ifdef WMSTATE
  218. Atom wm_state_atom;
  219. #endif
  220.  
  221. #ifdef NEATEN
  222. int AbsMinWidth;
  223. int AbsMinHeight;
  224. Boolean RetainSize;
  225. Boolean KeepOpen;
  226. Boolean Fill;
  227. Boolean UsePriorities;
  228. Boolean FixTopOfStack;
  229. char *PrimaryIconPlacement;
  230. char *SecondaryIconPlacement;
  231. #endif
  232.  
  233. /*
  234.  * Keyword lookup table for parser.
  235.  */
  236. Keyword KeywordTable[] =
  237. {
  238.     { "autoselect",    IsBoolean,    &Autoselect, 0 },
  239.     { "autoraise",    IsBoolean,    &Autoraise, 0 },
  240.     { "freeze",        IsBoolean,    &Freeze, 0 },
  241.     { "hilite",        IsBoolean,    &Hilite, 0 },
  242.     { "rootResizeBox",    IsBoolean,    &RootResizeBox, 0 },
  243.     { "titles",        IsBoolean,    &Titles, 0 },
  244.     { "gadgets",    IsBoolean,    &UseGadgets, 0 },
  245.     { "grid",        IsBoolean,    &Grid, 0 },
  246.     { "showName",    IsBoolean,    &ShowName, 0,},
  247.     { "normali",    IsBoolean,    &NIcon, 0 },
  248.     { "normalw",    IsBoolean,    &NWindow, 0 },
  249.     { "pushRelative",    IsBoolean,    &Push, 0 },
  250.     { "reverse",    IsBoolean,    &Reverse, 0 },
  251.     { "wall",        IsBoolean,    &Wall, 0 },
  252.     { "frameFocus",    IsBoolean,    &FrameFocus, 0 },
  253.     { "warpOnIconify",    IsBoolean,    &WarpOnIconify, 0 },
  254.     { "warpOnDeIconify",IsBoolean,    &WarpOnDeIconify, 0 },
  255.     { "warpOnRaise",    IsBoolean,    &WarpOnRaise, 0 },
  256. #ifdef NEATEN
  257.     { "retainSize",    IsBoolean,    &RetainSize, 0 },
  258.     { "keepOpen",    IsBoolean,    &KeepOpen, 0 },
  259.     { "fill",        IsBoolean,    &Fill, 0 },
  260.     { "usePriorities",    IsBoolean,    &UsePriorities },
  261.     { "fixTopOfStack",    IsBoolean,    &FixTopOfStack },
  262. #endif
  263.     { "zap",        IsBoolean,    &Zap, 0 },
  264.     { "gadget",        IsGadget,    0, 0 },
  265.     { "f.beep",        IsImmFunction,    0, Beep },
  266.     { "f.circledown",    IsImmFunction,    0, CircleDown },
  267.     { "f.circleup",    IsImmFunction,    0, CircleUp },
  268.     { "f.continue",    IsImmFunction,    0, Continue },
  269.     { "f.decorate",    IsFunction,    0, FDecorate },
  270.     { "f.exit",        IsQuitFunction,    0, Quit },
  271.     { "f.focus",    IsFunction,    0, Focus },
  272.     { "f.unfocus",    IsImmFunction,    0, UnFocus },
  273.     { "f.iconify",    IsFunction,    0, Iconify },
  274.     { "f.lower",    IsFunction,    0, Lower },
  275.     { "f.menu",        IsMenuMap,    0, DoMenu },
  276.     { "f.action",    IsAction,    0, DoAction },
  277.     { "f.move",        IsDownFunction,    0, Move },
  278.     { "f.moveopaque",    IsDownFunction,    0, MoveOpaque },
  279.     { "f.newiconify",    IsDownFunction,    0, NewIconify },
  280.     { "f.neaten",    IsImmFunction,    0, Neaten },
  281.     { "f.pause",    IsImmFunction,    0, Pause },
  282.     { "f.pushdown",    IsFunction,    0, ShoveDown },
  283.     { "f.pushleft",    IsFunction,    0, ShoveLeft },
  284.     { "f.pushright",    IsFunction,    0, ShoveRight },
  285.     { "f.pushup",    IsFunction,    0, ShoveUp },
  286.     { "f.raise",    IsFunction,    0, Raise },
  287.     { "f.redraw",    IsDownFunction,    0, Redraw },
  288.     { "f.refresh",    IsImmFunction,    0, Refresh },
  289.     { "f.resize",    IsDownFunction,    0, Resize },
  290.     { "f.restart",    IsQuitFunction,    0, Restart },
  291.     { "f.destroy",      IsDownFunction, 0, DestroyClient },
  292.     { "f.nodecorate",   IsFunction,     0, FNoDecorate },
  293.     { "f.lock",       IsImmFunction,  0, Lock },
  294.     { "menu",        IsMenu,        0, 0 },
  295.     { "resetbindings",    IsParser,    0, ResetBindings },
  296.     { "resetmenus",    IsParser,    0, ResetMenus },
  297.     { "resetgadgets",    IsParser,    0, ResetGadgets },
  298.     { NULL,        NULL,        NULL, NULL }
  299. };
  300.  
  301. /*
  302.  * Key expression table for parser.
  303.  */
  304. KeyExpr KeyExprTbl[] = {
  305.     { "ctrl", ControlMask },
  306.     { "c", ControlMask },
  307.     { "lock", LockMask },
  308.     { "l", LockMask },
  309.     { "meta", Mod1Mask },
  310.     { "m", Mod1Mask },
  311.     { "shift", ShiftMask },
  312.     { "s", ShiftMask },
  313.     { "mod1", Mod1Mask },
  314.     { "mod2", Mod2Mask },
  315.     { "mod3", Mod3Mask },
  316.     { "mod4", Mod4Mask },
  317.     { "mod5", Mod5Mask },
  318.     { NULL, NULL }
  319. };
  320.  
  321. /*
  322.  * Context expression table for parser.
  323.  */
  324. ContExpr ContExprTbl[] = {
  325.     { "icon", ICON },
  326.     { "i", ICON },
  327.     { "root", ROOT },
  328.     { "r", ROOT },
  329.     { "window", WINDOW },
  330.     { "w", WINDOW },
  331.     { "t", TITLE },
  332.     { "title", TITLE },
  333.     { "g", GADGET },
  334.     { "gadget", GADGET },
  335.     { "border", BORDER },
  336.     { "b", BORDER },
  337.     { NULL, NULL }
  338. };
  339.  
  340. /*
  341.  * Gravity expressions for parser.
  342.  */
  343. GravityExpr GravityExprTbl[] = {
  344.     { "noGravity", NoGadgetGravity },
  345.     { "nogravity", NoGadgetGravity },
  346.     { "NoGravity", NoGadgetGravity },
  347.     { "leftGravity", LeftGadgetGravity },
  348.     { "leftgravity", LeftGadgetGravity },
  349.     { "LeftGravity", LeftGadgetGravity },
  350.     { "rightGravity", RightGadgetGravity },
  351.     { "rightgravity", RightGadgetGravity },
  352.     { "RightGravity", RightGadgetGravity },
  353.     { "centerGravity", CenterGadgetGravity },
  354.     { "centerGravity", CenterGadgetGravity },
  355.     { "CenterGravity", CenterGadgetGravity },
  356.     { NULL, NULL}
  357. };
  358.  
  359. /*
  360.  * Button expression table for parser.
  361.  */
  362. ButtonModifier ButtModTbl[] = {
  363.     { "left", LeftMask },
  364.     { "leftbutton", LeftMask },
  365.     { "l", LeftMask },
  366.     { "middle", MiddleMask },
  367.     { "middlebutton", MiddleMask },
  368.     { "m", MiddleMask },
  369.     { "right", RightMask },
  370.     { "rightbutton", RightMask },
  371.     { "r", RightMask },
  372.     { "move", DeltaMotion },
  373.     { "motion", DeltaMotion },
  374.     { "delta", DeltaMotion },
  375.     { "boogie", DeltaMotion },
  376.     { "truckin", DeltaMotion }, /* it's been a silly day... */
  377.     { "down", ButtonDown },
  378.     { "d", ButtonDown },
  379.     { "up", ButtonUp },
  380.     { "u", ButtonUp },
  381.     { NULL, NULL }
  382. };
  383.  
  384.