toml@marvin.Solbourne.COM (Tom LaStrange) (08/30/90)
Submitted-by: toml@marvin.Solbourne.COM (Tom LaStrange) Posting-number: Volume 9, Issue 3 Archive-name: tvtwm/part02 #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting test in a file # 3. Execute the file with /bin/sh (not csh) to create the files: # #events.h #gc.c #gc.h #gram.y #iconmgr.c #iconmgr.h #icons.h #lex.l #list.h #move.h # # Created by toml () on Wed Aug 29 08:43:26 MDT 1990 # if test -f 'events.h' then echo shar: will not over-write existing file "events.h" else echo extracting "events.h" sed 's/^X//' >events.h <<'SHAR_EOF' X/*****************************************************************************/ X/** Copyright 1988 by Evans & Sutherland Computer Corporation, **/ X/** Salt Lake City, Utah **/ X/** Portions Copyright 1989 by the Massachusetts Institute of Technology **/ X/** Cambridge, Massachusetts **/ X/** **/ X/** All Rights Reserved **/ X/** **/ X/** Permission to use, copy, modify, and distribute this software and **/ X/** its documentation for any purpose and without fee is hereby **/ X/** granted, provided that the above copyright notice appear in all **/ X/** copies and that both that copyright notice and this permis- **/ X/** sion notice appear in supporting documentation, and that the **/ X/** names of Evans & Sutherland and M.I.T. not be used in advertising **/ X/** in publicity pertaining to distribution of the software without **/ X/** specific, written prior permission. **/ X/** **/ X/** EVANS & SUTHERLAND AND M.I.T. DISCLAIM ALL WARRANTIES WITH REGARD **/ X/** TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- **/ X/** ABILITY AND FITNESS, IN NO EVENT SHALL EVANS & SUTHERLAND OR **/ X/** M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAM- **/ X/** AGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA **/ X/** OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER **/ X/** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/ X/** OR PERFORMANCE OF THIS SOFTWARE. **/ X/*****************************************************************************/ X X X/*********************************************************************** X * X * $XConsortium: events.h,v 1.13 90/03/13 15:47:17 jim Exp $ X * X * twm event handler include file X * X * 17-Nov-87 Thomas E. LaStrange File created X * X ***********************************************************************/ X X#ifndef _EVENTS_ X#define _EVENTS_ X Xtypedef void (*event_proc)(); X Xextern void InitEvents(); Xextern Bool StashEventTime(); Xextern Time lastTimestamp; Xextern void SimulateMapRequest(); Xextern void AutoRaiseWindow(); X#define LastTimestamp() lastTimestamp Xextern Bool DispatchEvent(); Xextern void HandleEvents(); Xextern void HandleExpose(); Xextern void HandleDestroyNotify(); Xextern void HandleMapRequest(); Xextern void HandleMapNotify(); Xextern void HandleUnmapNotify(); Xextern void HandleMotionNotify(); Xextern void HandleButtonRelease(); Xextern void HandleButtonPress(); Xextern void HandleEnterNotify(); Xextern void HandleLeaveNotify(); Xextern void HandleConfigureRequest(); Xextern void HandleClientMessage(); Xextern void HandlePropertyNotify(); Xextern void HandleKeyPress(); Xextern void HandleColormapNotify(); Xextern void HandleVisibilityNotify(); Xextern void HandleUnknown(); X Xextern event_proc EventHandler[]; Xextern Window DragWindow; Xextern Window DragVirtual; Xextern int origDragX; Xextern int origDragY; Xextern int DragX; Xextern int DragY; Xextern int DragWidth; Xextern int DragHeight; Xextern int CurrentDragX; Xextern int CurrentDragY; X Xextern int ButtonPressed; Xextern int Cancel; X Xextern XEvent Event; X X#endif /* _EVENTS_ */ SHAR_EOF if test 3616 -ne "`wc -c < events.h`" then echo shar: error transmitting "events.h" '(should have been 3616 characters)' fi fi if test -f 'gc.c' then echo shar: will not over-write existing file "gc.c" else echo extracting "gc.c" sed 's/^X//' >gc.c <<'SHAR_EOF' X/*****************************************************************************/ X/** Copyright 1988 by Evans & Sutherland Computer Corporation, **/ X/** Salt Lake City, Utah **/ X/** Portions Copyright 1989 by the Massachusetts Institute of Technology **/ X/** Cambridge, Massachusetts **/ X/** **/ X/** All Rights Reserved **/ X/** **/ X/** Permission to use, copy, modify, and distribute this software and **/ X/** its documentation for any purpose and without fee is hereby **/ X/** granted, provided that the above copyright notice appear in all **/ X/** copies and that both that copyright notice and this permis- **/ X/** sion notice appear in supporting documentation, and that the **/ X/** names of Evans & Sutherland and M.I.T. not be used in advertising **/ X/** in publicity pertaining to distribution of the software without **/ X/** specific, written prior permission. **/ X/** **/ X/** EVANS & SUTHERLAND AND M.I.T. DISCLAIM ALL WARRANTIES WITH REGARD **/ X/** TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- **/ X/** ABILITY AND FITNESS, IN NO EVENT SHALL EVANS & SUTHERLAND OR **/ X/** M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAM- **/ X/** AGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA **/ X/** OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER **/ X/** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/ X/** OR PERFORMANCE OF THIS SOFTWARE. **/ X/*****************************************************************************/ X X X/********************************************************************** X * X * $XConsortium: gc.c,v 1.21 90/03/13 15:28:56 jim Exp $ X * X * Open the fonts and create the GCs X * X * 31-Mar-88 Tom LaStrange Initial Version. X * X **********************************************************************/ X X#if !defined(lint) && !defined(SABER) Xstatic char RCSinfo[]= X"$XConsortium: gc.c,v 1.21 90/03/13 15:28:56 jim Exp $"; X#endif X X#include <stdio.h> X#include "twm.h" X#include "util.h" X#include "screen.h" X X/*********************************************************************** X * X * Procedure: X * CreateGCs - open fonts and create all the needed GC's. I only X * want to do this once, hence the first_time flag. X * X *********************************************************************** X */ X Xvoid XCreateGCs() X{ X static ScreenInfo *prevScr = NULL; X XGCValues gcv; X unsigned long gcm; X X if (!Scr->FirstTime || prevScr == Scr) X return; X X prevScr = Scr; X X /* create GC's */ X X gcm = 0; X gcm |= GCFunction; gcv.function = GXxor; X gcm |= GCLineWidth; gcv.line_width = 0; X gcm |= GCForeground; gcv.foreground = Scr->XORvalue; X X Scr->PannerGC = XCreateGC(dpy, Scr->Root, gcm, &gcv); X X gcm = 0; X gcm |= GCFunction; gcv.function = GXxor; X gcm |= GCLineWidth; gcv.line_width = 0; X gcm |= GCForeground; gcv.foreground = Scr->XORvalue; X gcm |= GCSubwindowMode; gcv.subwindow_mode = IncludeInferiors; X X Scr->DrawGC = XCreateGC(dpy, Scr->Root, gcm, &gcv); X X gcm = 0; X gcm |= GCForeground; gcv.foreground = Scr->MenuC.fore; X gcm |= GCBackground; gcv.background = Scr->MenuC.back; X gcm |= GCFont; gcv.font = Scr->MenuFont.font->fid; X X Scr->MenuGC = XCreateGC(dpy, Scr->Root, gcm, &gcv); X X gcm = 0; X gcm |= GCPlaneMask; gcv.plane_mask = AllPlanes; X /* X * Prevent GraphicsExpose and NoExpose events. We'd only get NoExpose X * events anyway; they cause BadWindow errors from XGetWindowAttributes X * call in FindScreenInfo (events.c) (since drawable is a pixmap). X */ X gcm |= GCGraphicsExposures; gcv.graphics_exposures = False; X gcm |= GCLineWidth; gcv.line_width = 0; X X Scr->NormalGC = XCreateGC(dpy, Scr->Root, gcm, &gcv); X} SHAR_EOF if test 4345 -ne "`wc -c < gc.c`" then echo shar: error transmitting "gc.c" '(should have been 4345 characters)' fi fi if test -f 'gc.h' then echo shar: will not over-write existing file "gc.h" else echo extracting "gc.h" sed 's/^X//' >gc.h <<'SHAR_EOF' X/*****************************************************************************/ X/** Copyright 1988 by Evans & Sutherland Computer Corporation, **/ X/** Salt Lake City, Utah **/ X/** Portions Copyright 1989 by the Massachusetts Institute of Technology **/ X/** Cambridge, Massachusetts **/ X/** **/ X/** All Rights Reserved **/ X/** **/ X/** Permission to use, copy, modify, and distribute this software and **/ X/** its documentation for any purpose and without fee is hereby **/ X/** granted, provided that the above copyright notice appear in all **/ X/** copies and that both that copyright notice and this permis- **/ X/** sion notice appear in supporting documentation, and that the **/ X/** names of Evans & Sutherland and M.I.T. not be used in advertising **/ X/** in publicity pertaining to distribution of the software without **/ X/** specific, written prior permission. **/ X/** **/ X/** EVANS & SUTHERLAND AND M.I.T. DISCLAIM ALL WARRANTIES WITH REGARD **/ X/** TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- **/ X/** ABILITY AND FITNESS, IN NO EVENT SHALL EVANS & SUTHERLAND OR **/ X/** M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAM- **/ X/** AGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA **/ X/** OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER **/ X/** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/ X/** OR PERFORMANCE OF THIS SOFTWARE. **/ X/*****************************************************************************/ X X X/********************************************************************** X * X * $XConsortium: gc.h,v 1.5 89/10/27 14:01:17 jim Exp $ X * X * GC related externs X * X * 8-Apr-88 Tom LaStrange Initial Version. X * X **********************************************************************/ X X#ifndef _GC_ X#define _GC_ X Xextern void CreateGCs(); X X#endif /* _GC_ */ SHAR_EOF if test 2440 -ne "`wc -c < gc.h`" then echo shar: error transmitting "gc.h" '(should have been 2440 characters)' fi fi if test -f 'gram.y' then echo shar: will not over-write existing file "gram.y" else echo extracting "gram.y" sed 's/^X//' >gram.y <<'SHAR_EOF' X/*****************************************************************************/ X/** Copyright 1988 by Evans & Sutherland Computer Corporation, **/ X/** Salt Lake City, Utah **/ X/** Portions Copyright 1989 by the Massachusetts Institute of Technology **/ X/** Cambridge, Massachusetts **/ X/** **/ X/** All Rights Reserved **/ X/** **/ X/** Permission to use, copy, modify, and distribute this software and **/ X/** its documentation for any purpose and without fee is hereby **/ X/** granted, provided that the above copyright notice appear in all **/ X/** copies and that both that copyright notice and this permis- **/ X/** sion notice appear in supporting documentation, and that the **/ X/** names of Evans & Sutherland and M.I.T. not be used in advertising **/ X/** in publicity pertaining to distribution of the software without **/ X/** specific, written prior permission. **/ X/** **/ X/** EVANS & SUTHERLAND AND M.I.T. DISCLAIM ALL WARRANTIES WITH REGARD **/ X/** TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- **/ X/** ABILITY AND FITNESS, IN NO EVENT SHALL EVANS & SUTHERLAND OR **/ X/** M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAM- **/ X/** AGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA **/ X/** OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER **/ X/** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/ X/** OR PERFORMANCE OF THIS SOFTWARE. **/ X/*****************************************************************************/ X X X/*********************************************************************** X * X * $XConsortium: gram.y,v 1.88 90/03/16 12:12:06 jim Exp $ X * X * .twmrc command grammer X * X * 07-Jan-86 Thomas E. LaStrange File created X * X ***********************************************************************/ X X%{ X#include <stdio.h> X#include <ctype.h> X#include "twm.h" X#include "menus.h" X#include "list.h" X#include "util.h" X#include "screen.h" X#include "parse.h" X#include <X11/Xos.h> X#include <X11/Xmu/CharSet.h> X Xstatic char *Action = ""; Xstatic char *Name = ""; Xstatic MenuRoot *root, *pull = NULL; X Xstatic MenuRoot *GetRoot(); X Xstatic Bool CheckWarpScreenArg(), CheckWarpRingArg(); Xstatic Bool CheckColormapArg(); Xstatic void GotButton(), GotKey(), GotTitleButton(); Xstatic char *ptr; Xstatic name_list **list; Xstatic int cont = 0; Xstatic int color; Xint mods = 0; Xunsigned int mods_used = (ShiftMask | ControlMask | Mod1Mask); X Xextern int do_single_keyword(), do_string_keyword(), do_number_keyword(); Xextern name_list **do_colorlist_keyword(); Xextern int do_color_keyword(); Xextern int yylineno; X%} X X%union X{ X int num; X char *ptr; X}; X X%token <num> LB RB LP RP MENUS MENU BUTTON DEFAULT_FUNCTION PLUS MINUS X%token <num> ALL OR CURSORS PIXMAPS ICONS COLOR MONOCHROME FUNCTION X%token <num> ICONMGR_SHOW ICONMGR WINDOW_FUNCTION ZOOM ICONMGRS X%token <num> ICONMGR_GEOMETRY ICONMGR_NOSHOW MAKE_TITLE X%token <num> ICONIFY_BY_UNMAPPING DONT_ICONIFY_BY_UNMAPPING STICKY X%token <num> NO_TITLE AUTO_RAISE NO_HILITE ICON_REGION X%token <num> META SHIFT LOCK CONTROL WINDOW TITLE ICON ROOT FRAME X%token <num> COLON EQUALS SQUEEZE_TITLE DONT_SQUEEZE_TITLE X%token <num> START_ICONIFIED NO_TITLE_HILITE TITLE_HILITE X%token <num> MOVE RESIZE WAIT SELECT KILL LEFT_TITLEBUTTON RIGHT_TITLEBUTTON X%token <num> NUMBER KEYWORD NKEYWORD CKEYWORD CLKEYWORD FKEYWORD FSKEYWORD X%token <num> SKEYWORD DKEYWORD JKEYWORD WINDOW_RING WARP_CURSOR ERRORTOKEN X%token <num> NO_STACKMODE X%token <ptr> STRING X X%type <ptr> string X%type <num> action button number signed_number full fullkey X X%start twmrc X X%% Xtwmrc : stmts X ; X Xstmts : /* Empty */ X | stmts stmt X ; X Xstmt : error X | noarg X | sarg X | narg X | squeeze X | ICON_REGION string DKEYWORD DKEYWORD number number X { AddIconRegion($2, $3, $4, $5, $6); } X | ICONMGR_GEOMETRY string number { if (Scr->FirstTime) X { X Scr->iconmgr.geometry=$2; X Scr->iconmgr.columns=$3; X } X } X | ICONMGR_GEOMETRY string { if (Scr->FirstTime) X Scr->iconmgr.geometry = $2; X } X | ZOOM number { if (Scr->FirstTime) X { X Scr->DoZoom = TRUE; X Scr->ZoomCount = $2; X } X } X | ZOOM { if (Scr->FirstTime) X Scr->DoZoom = TRUE; } X | PIXMAPS pixmap_list {} X | CURSORS cursor_list {} X | ICONIFY_BY_UNMAPPING { list = &Scr->IconifyByUn; } X win_list X | ICONIFY_BY_UNMAPPING { if (Scr->FirstTime) X Scr->IconifyByUnmapping = TRUE; } X | LEFT_TITLEBUTTON string EQUALS action { X GotTitleButton ($2, $4, False); X } X | RIGHT_TITLEBUTTON string EQUALS action { X GotTitleButton ($2, $4, True); X } X | button string { root = GetRoot($2, NULLSTR, NULLSTR); X Scr->Mouse[$1][C_ROOT][0].func = F_MENU; X Scr->Mouse[$1][C_ROOT][0].menu = root; X } X | button action { Scr->Mouse[$1][C_ROOT][0].func = $2; X if ($2 == F_MENU) X { X pull->prev = NULL; X Scr->Mouse[$1][C_ROOT][0].menu = pull; X } X else X { X root = GetRoot(TWM_ROOT,NULLSTR,NULLSTR); X Scr->Mouse[$1][C_ROOT][0].item = X AddToMenu(root,"x",Action, X NULLSTR,$2,NULLSTR,NULLSTR); X } X Action = ""; X pull = NULL; X } X | string fullkey { GotKey($1, $2); } X | button full { GotButton($1, $2); } X | DONT_ICONIFY_BY_UNMAPPING { list = &Scr->DontIconify; } X win_list X | ICONMGR_NOSHOW { list = &Scr->IconMgrNoShow; } X win_list X | ICONMGR_NOSHOW { Scr->IconManagerDontShow = TRUE; } X | ICONMGRS { list = &Scr->IconMgrs; } X iconm_list X | ICONMGR_SHOW { list = &Scr->IconMgrShow; } X win_list X | NO_TITLE_HILITE { list = &Scr->NoTitleHighlight; } X win_list X | NO_TITLE_HILITE { if (Scr->FirstTime) X Scr->TitleHighlight = FALSE; } X | NO_HILITE { list = &Scr->NoHighlight; } X win_list X | NO_HILITE { if (Scr->FirstTime) X Scr->Highlight = FALSE; } X | NO_STACKMODE { list = &Scr->NoStackModeL; } X win_list X | NO_STACKMODE { if (Scr->FirstTime) X Scr->StackMode = FALSE; } X | NO_TITLE { list = &Scr->NoTitle; } X win_list X | NO_TITLE { if (Scr->FirstTime) X Scr->NoTitlebar = TRUE; } X | MAKE_TITLE { list = &Scr->MakeTitle; } X win_list X | START_ICONIFIED { list = &Scr->StartIconified; } X win_list X | AUTO_RAISE { list = &Scr->AutoRaise; } X win_list X | STICKY { list = &Scr->StickyL; } X win_list X | MENU string LP string COLON string RP { X root = GetRoot($2, $4, $6); } X menu { root->real_menu = TRUE;} X | MENU string { root = GetRoot($2, NULLSTR, NULLSTR); } X menu { root->real_menu = TRUE; } X | FUNCTION string { root = GetRoot($2, NULLSTR, NULLSTR); } X function X | ICONS { list = &Scr->IconNames; } X icon_list X | COLOR { color = COLOR; } X color_list X | MONOCHROME { color = MONOCHROME; } X color_list X | DEFAULT_FUNCTION action { Scr->DefaultFunction.func = $2; X if ($2 == F_MENU) X { X pull->prev = NULL; X Scr->DefaultFunction.menu = pull; X } X else X { X root = GetRoot(TWM_ROOT,NULLSTR,NULLSTR); X Scr->DefaultFunction.item = X AddToMenu(root,"x",Action, X NULLSTR,$2, NULLSTR, NULLSTR); X } X Action = ""; X pull = NULL; X } X | WINDOW_FUNCTION action { Scr->WindowFunction.func = $2; X root = GetRoot(TWM_ROOT,NULLSTR,NULLSTR); X Scr->WindowFunction.item = X AddToMenu(root,"x",Action, X NULLSTR,$2, NULLSTR, NULLSTR); X Action = ""; X pull = NULL; X } X | WARP_CURSOR { list = &Scr->WarpCursorL; } X win_list X | WARP_CURSOR { if (Scr->FirstTime) X Scr->WarpCursor = TRUE; } X | WINDOW_RING { list = &Scr->WindowRingL; } X win_list X ; X X Xnoarg : KEYWORD { if (!do_single_keyword ($1)) { X twmrc_error_prefix(); X fprintf (stderr, X "unknown singleton keyword %d\n", X $1); X ParseError = 1; X } X } X ; X Xsarg : SKEYWORD string { if (!do_string_keyword ($1, $2)) { X twmrc_error_prefix(); X fprintf (stderr, X "unknown string keyword %d (value \"%s\")\n", X $1, $2); X ParseError = 1; X } X } X ; X Xnarg : NKEYWORD number { if (!do_number_keyword ($1, $2)) { X twmrc_error_prefix(); X fprintf (stderr, X "unknown numeric keyword %d (value %d)\n", X $1, $2); X ParseError = 1; X } X } X ; X X X Xfull : EQUALS keys COLON contexts COLON action { $$ = $6; } X ; X Xfullkey : EQUALS keys COLON contextkeys COLON action { $$ = $6; } X ; X Xkeys : /* Empty */ X | keys key X ; X Xkey : META { mods |= Mod1Mask; } X | SHIFT { mods |= ShiftMask; } X | LOCK { mods |= LockMask; } X | CONTROL { mods |= ControlMask; } X | META number { if ($2 < 1 || $2 > 5) { X twmrc_error_prefix(); X fprintf (stderr, X "bad modifier number (%d), must be 1-5\n", X $2); X ParseError = 1; X } else { X mods |= (Mod1Mask << ($2 - 1)); X } X } X | OR { } X ; X Xcontexts : /* Empty */ X | contexts context X ; X Xcontext : WINDOW { cont |= C_WINDOW_BIT; } X | TITLE { cont |= C_TITLE_BIT; } X | ICON { cont |= C_ICON_BIT; } X | ROOT { cont |= C_ROOT_BIT; } X | FRAME { cont |= C_FRAME_BIT; } X | ICONMGR { cont |= C_ICONMGR_BIT; } X | META { cont |= C_ICONMGR_BIT; } X | ALL { cont |= C_ALL_BITS; } X | OR { } X ; X Xcontextkeys : /* Empty */ X | contextkeys contextkey X ; X Xcontextkey : WINDOW { cont |= C_WINDOW_BIT; } X | TITLE { cont |= C_TITLE_BIT; } X | ICON { cont |= C_ICON_BIT; } X | ROOT { cont |= C_ROOT_BIT; } X | FRAME { cont |= C_FRAME_BIT; } X | ICONMGR { cont |= C_ICONMGR_BIT; } X | META { cont |= C_ICONMGR_BIT; } X | ALL { cont |= C_ALL_BITS; } X | OR { } X | string { Name = $1; cont |= C_NAME_BIT; } X ; X X Xpixmap_list : LB pixmap_entries RB X ; X Xpixmap_entries : /* Empty */ X | pixmap_entries pixmap_entry X ; X Xpixmap_entry : TITLE_HILITE string { SetHighlightPixmap ($2); } X ; X X Xcursor_list : LB cursor_entries RB X ; X Xcursor_entries : /* Empty */ X | cursor_entries cursor_entry X ; X Xcursor_entry : FRAME string string { X NewBitmapCursor(&Scr->FrameCursor, $2, $3); } X | FRAME string { X NewFontCursor(&Scr->FrameCursor, $2); } X | TITLE string string { X NewBitmapCursor(&Scr->TitleCursor, $2, $3); } X | TITLE string { X NewFontCursor(&Scr->TitleCursor, $2); } X | ICON string string { X NewBitmapCursor(&Scr->IconCursor, $2, $3); } X | ICON string { X NewFontCursor(&Scr->IconCursor, $2); } X | ICONMGR string string { X NewBitmapCursor(&Scr->IconMgrCursor, $2, $3); } X | ICONMGR string { X NewFontCursor(&Scr->IconMgrCursor, $2); } X | BUTTON string string { X NewBitmapCursor(&Scr->ButtonCursor, $2, $3); } X | BUTTON string { X NewFontCursor(&Scr->ButtonCursor, $2); } X | MOVE string string { X NewBitmapCursor(&Scr->MoveCursor, $2, $3); } X | MOVE string { X NewFontCursor(&Scr->MoveCursor, $2); } X | RESIZE string string { X NewBitmapCursor(&Scr->ResizeCursor, $2, $3); } X | RESIZE string { X NewFontCursor(&Scr->ResizeCursor, $2); } X | WAIT string string { X NewBitmapCursor(&Scr->WaitCursor, $2, $3); } X | WAIT string { X NewFontCursor(&Scr->WaitCursor, $2); } X | MENU string string { X NewBitmapCursor(&Scr->MenuCursor, $2, $3); } X | MENU string { X NewFontCursor(&Scr->MenuCursor, $2); } X | SELECT string string { X NewBitmapCursor(&Scr->SelectCursor, $2, $3); } X | SELECT string { X NewFontCursor(&Scr->SelectCursor, $2); } X | KILL string string { X NewBitmapCursor(&Scr->DestroyCursor, $2, $3); } X | KILL string { X NewFontCursor(&Scr->DestroyCursor, $2); } X ; X Xcolor_list : LB color_entries RB X ; X Xcolor_entries : /* Empty */ X | color_entries color_entry X ; X Xcolor_entry : CLKEYWORD string { if (!do_colorlist_keyword ($1, color, X $2)) { X twmrc_error_prefix(); X fprintf (stderr, X "unhandled list color keyword %d (string \"%s\")\n", X $1, $2); X ParseError = 1; X } X } X | CLKEYWORD string { list = do_colorlist_keyword($1,color, X $2); X if (!list) { X twmrc_error_prefix(); X fprintf (stderr, X "unhandled color list keyword %d (string \"%s\")\n", X $1, $2); X ParseError = 1; X } X } X win_color_list X | CKEYWORD string { if (!do_color_keyword ($1, color, X $2)) { X twmrc_error_prefix(); X fprintf (stderr, X "unhandled color keyword %d (string \"%s\")\n", X $1, $2); X ParseError = 1; X } X } X ; X X Xwin_color_list : LB win_color_entries RB X ; X Xwin_color_entries : /* Empty */ X | win_color_entries win_color_entry X ; X Xwin_color_entry : string string { if (Scr->FirstTime && X color == Scr->Monochrome) X AddToList(list, $1, $2); } X ; X Xsqueeze : SQUEEZE_TITLE { X#ifdef SHAPE X if (HasShape) Scr->SqueezeTitle = TRUE; X#endif X } X | SQUEEZE_TITLE { list = &Scr->SqueezeTitleL; X#ifdef SHAPE X if (HasShape && Scr->SqueezeTitle == -1) X Scr->SqueezeTitle = TRUE; X#endif X } X LB win_sqz_entries RB X | DONT_SQUEEZE_TITLE { Scr->SqueezeTitle = FALSE; } X | DONT_SQUEEZE_TITLE { list = &Scr->DontSqueezeTitleL; } X win_list X ; X Xwin_sqz_entries : /* Empty */ X | win_sqz_entries string JKEYWORD signed_number number { X if (Scr->FirstTime) { X do_squeeze_entry (list, $2, $3, $4, $5); X } X } X ; X X Xiconm_list : LB iconm_entries RB X ; X Xiconm_entries : /* Empty */ X | iconm_entries iconm_entry X ; X Xiconm_entry : string string number { if (Scr->FirstTime) X AddToList(list, $1, (char *) X AllocateIconManager($1, NULLSTR, X $2,$3)); X } X | string string string number X { if (Scr->FirstTime) X AddToList(list, $1, (char *) X AllocateIconManager($1,$2, X $3, $4)); X } X ; X Xwin_list : LB win_entries RB X ; X Xwin_entries : /* Empty */ X | win_entries win_entry X ; X Xwin_entry : string { if (Scr->FirstTime) X AddToList(list, $1, 0); X } X ; X Xicon_list : LB icon_entries RB X ; X Xicon_entries : /* Empty */ X | icon_entries icon_entry X ; X Xicon_entry : string string { if (Scr->FirstTime) AddToList(list, $1, $2); } X ; X Xfunction : LB function_entries RB X ; X Xfunction_entries: /* Empty */ X | function_entries function_entry X ; X Xfunction_entry : action { AddToMenu(root, "", Action, NULLSTR, $1, X NULLSTR, NULLSTR); X Action = ""; X } X ; X Xmenu : LB menu_entries RB X ; X Xmenu_entries : /* Empty */ X | menu_entries menu_entry X ; X Xmenu_entry : string action { AddToMenu(root, $1, Action, pull, $2, X NULLSTR, NULLSTR); X Action = ""; X pull = NULL; X } X | string LP string COLON string RP action { X AddToMenu(root, $1, Action, pull, $7, X $3, $5); X Action = ""; X pull = NULL; X } X ; X Xaction : FKEYWORD { $$ = $1; } X | FSKEYWORD string { X $$ = $1; X Action = $2; X switch ($1) { X case F_MENU: X pull = GetRoot ($2, NULLSTR,NULLSTR); X pull->prev = root; X break; X case F_WARPRING: X if (!CheckWarpRingArg (Action)) { X twmrc_error_prefix(); X fprintf (stderr, X "ignoring invalid f.warptoring argument \"%s\"\n", X Action); X $$ = F_NOP; X } X case F_WARPTOSCREEN: X if (!CheckWarpScreenArg (Action)) { X twmrc_error_prefix(); X fprintf (stderr, X "ignoring invalid f.warptoscreen argument \"%s\"\n", X Action); X $$ = F_NOP; X } X break; X case F_COLORMAP: X if (CheckColormapArg (Action)) { X $$ = F_COLORMAP; X } else { X twmrc_error_prefix(); X fprintf (stderr, X "ignoring invalid f.colormap argument \"%s\"\n", X Action); X $$ = F_NOP; X } X break; X } /* end switch */ X } X ; X X Xsigned_number : number { $$ = $1; } X | PLUS number { $$ = $2; } X | MINUS number { $$ = -($2); } X ; X Xbutton : BUTTON number { $$ = $2; X if ($2 == 0) X yyerror("bad button 0"); X X if ($2 > MAX_BUTTONS) X { X $$ = 0; X yyerror("button number too large"); X } X } X ; X Xstring : STRING { ptr = (char *)malloc(strlen($1)+1); X strcpy(ptr, $1); X RemoveDQuote(ptr); X $$ = ptr; X } Xnumber : NUMBER { $$ = $1; } X ; X X%% Xyyerror(s) char *s; X{ X twmrc_error_prefix(); X fprintf (stderr, "error in input file: %s\n", s ? s : ""); X ParseError = 1; X} XRemoveDQuote(str) Xchar *str; X{ X register char *i, *o; X register n; X register count; X X for (i=str+1, o=str; *i && *i != '\"'; o++) X { X if (*i == '\\') X { X switch (*++i) X { X case 'n': X *o = '\n'; X i++; X break; X case 'b': X *o = '\b'; X i++; X break; X case 'r': X *o = '\r'; X i++; X break; X case 't': X *o = '\t'; X i++; X break; X case 'f': X *o = '\f'; X i++; X break; X case '0': X if (*++i == 'x') X goto hex; X else X --i; X case '1': case '2': case '3': X case '4': case '5': case '6': case '7': X n = 0; X count = 0; X while (*i >= '0' && *i <= '7' && count < 3) X { X n = (n<<3) + (*i++ - '0'); X count++; X } X *o = n; X break; X hex: X case 'x': X n = 0; X count = 0; X while (i++, count++ < 2) X { X if (*i >= '0' && *i <= '9') X n = (n<<4) + (*i - '0'); X else if (*i >= 'a' && *i <= 'f') X n = (n<<4) + (*i - 'a') + 10; X else if (*i >= 'A' && *i <= 'F') X n = (n<<4) + (*i - 'A') + 10; X else X break; X } X *o = n; X break; X case '\n': X i++; /* punt */ X o--; /* to account for o++ at end of loop */ X break; X case '\"': X case '\'': X case '\\': X default: X *o = *i++; X break; X } X } X else X *o = *i++; X } X *o = '\0'; X} X Xstatic MenuRoot *GetRoot(name, fore, back) Xchar *name; Xchar *fore, *back; X{ X MenuRoot *tmp; X X tmp = FindMenuRoot(name); X if (tmp == NULL) X tmp = NewMenuRoot(name); X X if (fore) X { X int save; X X save = Scr->FirstTime; X Scr->FirstTime = TRUE; X GetColor(COLOR, &tmp->hi_fore, fore); X GetColor(COLOR, &tmp->hi_back, back); X Scr->FirstTime = save; X } X X return tmp; X} X Xstatic void GotButton(butt, func) Xint butt, func; X{ X int i; X X for (i = 0; i < NUM_CONTEXTS; i++) X { X if ((cont & (1 << i)) == 0) X continue; X X Scr->Mouse[butt][i][mods].func = func; X if (func == F_MENU) X { X pull->prev = NULL; X Scr->Mouse[butt][i][mods].menu = pull; X } X else X { X root = GetRoot(TWM_ROOT, NULLSTR, NULLSTR); X Scr->Mouse[butt][i][mods].item = AddToMenu(root,"x",Action, X NULLSTR, func, NULLSTR, NULLSTR); X } X } X Action = ""; X pull = NULL; X cont = 0; X mods_used |= mods; X mods = 0; X} X Xstatic void GotKey(key, func) Xchar *key; Xint func; X{ X int i; X X for (i = 0; i < NUM_CONTEXTS; i++) X { X if ((cont & (1 << i)) == 0) X continue; X if (!AddFuncKey(key, i, mods, func, Name, Action)) X break; X } X X Action = ""; X pull = NULL; X cont = 0; X mods_used |= mods; X mods = 0; X} X X Xstatic void GotTitleButton (bitmapname, func, rightside) X char *bitmapname; X int func; X Bool rightside; X{ X if (!CreateTitleButton (bitmapname, func, Action, pull, rightside, True)) { X twmrc_error_prefix(); X fprintf (stderr, X "unable to create %s titlebutton \"%s\"\n", X rightside ? "right" : "left", bitmapname); X } X Action = ""; X pull = NULL; X} X Xstatic Bool CheckWarpScreenArg (s) X register char *s; X{ X XmuCopyISOLatin1Lowered (s, s); X X if (strcmp (s, WARPSCREEN_NEXT) == 0 || X strcmp (s, WARPSCREEN_PREV) == 0 || X strcmp (s, WARPSCREEN_BACK) == 0) X return True; X X for (; *s && isascii(*s) && isdigit(*s); s++) ; X return (*s ? False : True); X} X X Xstatic Bool CheckWarpRingArg (s) X register char *s; X{ X XmuCopyISOLatin1Lowered (s, s); X X if (strcmp (s, WARPSCREEN_NEXT) == 0 || X strcmp (s, WARPSCREEN_PREV) == 0) X return True; X X return False; X} X X Xstatic Bool CheckColormapArg (s) X register char *s; X{ X XmuCopyISOLatin1Lowered (s, s); X X if (strcmp (s, COLORMAP_NEXT) == 0 || X strcmp (s, COLORMAP_PREV) == 0 || X strcmp (s, COLORMAP_DEFAULT) == 0) X return True; X X return False; X} X X Xtwmrc_error_prefix () X{ X fprintf (stderr, "%s: line %d: ", ProgramName, yylineno); X} SHAR_EOF if test 20621 -ne "`wc -c < gram.y`" then echo shar: error transmitting "gram.y" '(should have been 20621 characters)' fi fi if test -f 'iconmgr.c' then echo shar: will not over-write existing file "iconmgr.c" else echo extracting "iconmgr.c" sed 's/^X//' >iconmgr.c <<'SHAR_EOF' X/* X * Copyright 1989 Massachusetts Institute of Technology 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 M.I.T. not be used in advertising X * or publicity pertaining to distribution of the software without specific, X * written prior permission. M.I.T. makes no representations about the X * suitability of this software for any purpose. It is provided "as is" X * without express or implied warranty. X * X * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T. X * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES X * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION X * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN X * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. X */ X X/*********************************************************************** X * X * $XConsortium: iconmgr.c,v 1.43 90/03/20 11:20:17 jim Exp $ X * X * Icon Manager routines X * X * 09-Mar-89 Tom LaStrange File Created X * X ***********************************************************************/ X X#include <stdio.h> X#include "twm.h" X#include "util.h" X#include "parse.h" X#include "screen.h" X#include "resize.h" X#include "add_window.h" X#include "siconify.bm" X#include "vdt.h" X#include <X11/Xos.h> X#include <X11/Xmu/CharSet.h> X Xint strcmp(); X Xint iconmgr_textx = siconify_width+11; XWList *Active = NULL; XWList *DownIconManager = NULL; Xint iconifybox_width = siconify_width; Xint iconifybox_height = siconify_height; X X/*********************************************************************** X * X * Procedure: X * CreateIconManagers - creat all the icon manager windows X * for this screen. X * X * Returned Value: X * none X * X * Inputs: X * none X * X *********************************************************************** X */ X Xvoid CreateIconManagers() X{ X IconMgr *p; X int mask; X char str[100]; X char str1[100]; X Pixel background; X char *icon_name; X X if (Scr->NoIconManagers) X return; X X if (Scr->siconifyPm == NULL) X { X Scr->siconifyPm = XCreatePixmapFromBitmapData(dpy, Scr->Root, X siconify_bits, siconify_width, siconify_height, 1, 0, 1); X } X X for (p = &Scr->iconmgr; p != NULL; p = p->next) X { X mask = XParseGeometry(p->geometry, &JunkX, &JunkY, X (unsigned int *) &p->width, (unsigned int *)&p->height); X X if (mask & XNegative) X JunkX = Scr->MyDisplayWidth - p->width - X (2 * Scr->BorderWidth) + JunkX; X X if (mask & YNegative) X JunkY = Scr->MyDisplayHeight - p->height - X (2 * Scr->BorderWidth) + JunkY; X X background = Scr->IconManagerC.back; X GetColorFromList(Scr->IconManagerBL, p->name, (XClassHint *)NULL, X &background); X X p->w = XCreateSimpleWindow(dpy, Scr->Root, X JunkX, JunkY, p->width, p->height, 1, X Scr->Black, background); X X sprintf(str, "%s Icon Manager", p->name); X sprintf(str1, "%s Icons", p->name); X if (p->icon_name) X icon_name = p->icon_name; X else X icon_name = str1; X X XSetStandardProperties(dpy, p->w, str, icon_name, None, NULL, 0, NULL); X X p->twm_win = AddWindow(p->w, TRUE, p); X SetMapStateProp (p->twm_win, WithdrawnState); X } X for (p = &Scr->iconmgr; p != NULL; p = p->next) X { X GrabButtons(p->twm_win); X GrabKeys(p->twm_win); X } X} X X/*********************************************************************** X * X * Procedure: X * AllocateIconManager - allocate a new icon manager X * X * Inputs: X * name - the name of this icon manager X * icon_name - the name of the associated icon X * geom - a geometry string to eventually parse X * columns - the number of columns this icon manager has X * X *********************************************************************** X */ X XIconMgr *AllocateIconManager(name, icon_name, geom, columns) X char *name; X char *geom; X char *icon_name; X int columns; X{ X IconMgr *p; X X#ifdef DEBUG_ICONMGR X fprintf(stderr, "AllocateIconManager\n"); X fprintf(stderr, " name=\"%s\" icon_name=\"%s\", geom=\"%s\", col=%d\n", X name, icon_name, geom, columns); X#endif X X if (Scr->NoIconManagers) X return NULL; X X p = (IconMgr *)malloc(sizeof(IconMgr)); X p->name = name; X p->icon_name = icon_name; X p->geometry = geom; X p->columns = columns; X p->first = NULL; X p->last = NULL; X p->active = NULL; X p->scr = Scr; X p->count = 0; X p->x = 0; X p->y = 0; X p->width = 150; X p->height = 10; X X Scr->iconmgr.lasti->next = p; X p->prev = Scr->iconmgr.lasti; X Scr->iconmgr.lasti = p; X p->next = NULL; X X return(p); X} X X/*********************************************************************** X * X * Procedure: X * MoveIconManager - move the pointer around in an icon manager X * X * Inputs: X * dir - one of the following: X * F_FORWICONMGR - forward in the window list X * F_BACKICONMGR - backward in the window list X * F_UPICONMGR - up one row X * F_DOWNICONMGR - down one row X * F_LEFTICONMGR - left one column X * F_RIGHTICONMGR - right one column X * X * Special Considerations: X * none X * X *********************************************************************** X */ X Xvoid MoveIconManager(dir) X int dir; X{ X IconMgr *ip; X WList *tmp = NULL; X int cur_row, cur_col, new_row, new_col; X int row_inc, col_inc; X int got_it; X X if (!Active) return; X X cur_row = Active->row; X cur_col = Active->col; X ip = Active->iconmgr; X X row_inc = 0; X col_inc = 0; X got_it = FALSE; X X switch (dir) X { X case F_FORWICONMGR: X if ((tmp = Active->next) == NULL) X tmp = ip->first; X got_it = TRUE; X break; X X case F_BACKICONMGR: X if ((tmp = Active->prev) == NULL) X tmp = ip->last; X got_it = TRUE; X break; X X case F_UPICONMGR: X row_inc = -1; X break; X X case F_DOWNICONMGR: X row_inc = 1; X break; X X case F_LEFTICONMGR: X col_inc = -1; X break; X X case F_RIGHTICONMGR: X col_inc = 1; X break; X } X X /* If got_it is FALSE ast this point then we got a left, right, X * up, or down, command. We will enter this loop until we find X * a window to warp to. X */ X new_row = cur_row; X new_col = cur_col; X X while (!got_it) X { X new_row += row_inc; X new_col += col_inc; X if (new_row < 0) X new_row = ip->cur_rows - 1; X if (new_col < 0) X new_col = ip->cur_columns - 1; X if (new_row >= ip->cur_rows) X new_row = 0; X if (new_col >= ip->cur_columns) X new_col = 0; X X /* Now let's go through the list to see if there is an entry with this X * new position X */ X for (tmp = ip->first; tmp != NULL; tmp = tmp->next) X { X if (tmp->row == new_row && tmp->col == new_col) X { X got_it = TRUE; X break; X } X } X } X X if (!got_it) X { X fprintf (stderr, X "%s: unable to find window (%d, %d) in icon manager\n", X ProgramName, new_row, new_col); X return; X } X X /* raise the frame so the icon manager is visible */ X if (ip->twm_win->mapped) { X RaiseFrame(ip->twm_win); X XWarpPointer(dpy, None, tmp->icon, 0,0,0,0, 5, 5); X } else { X if (tmp->twm->title_height) { X int tbx = Scr->TBInfo.titlex; X int x = tmp->twm->highlightx; X XWarpPointer (dpy, None, tmp->twm->title_w, 0, 0, 0, 0, X tbx + (x - tbx) / 2, X Scr->TitleHeight / 4); X } else { X XWarpPointer (dpy, None, tmp->twm->w, 0, 0, 0, 0, 5, 5); X } X } X} X X/*********************************************************************** X * X * Procedure: X * JumpIconManager - jump from one icon manager to another, X * possibly even on another screen X * X * Inputs: X * dir - one of the following: X * F_NEXTICONMGR - go to the next icon manager X * F_PREVICONMGR - go to the previous one X * X *********************************************************************** X */ X Xvoid JumpIconManager(dir) X register int dir; X{ X IconMgr *ip, *tmp_ip = NULL; X int got_it = FALSE; X ScreenInfo *sp; X int screen; X X if (!Active) return; X X X#define ITER(i) (dir == F_NEXTICONMGR ? (i)->next : (i)->prev) X#define IPOFSP(sp) (dir == F_NEXTICONMGR ? &(sp->iconmgr) : sp->iconmgr.lasti) X#define TEST(ip) if ((ip)->count != 0 && (ip)->twm_win->mapped) \ X { got_it = TRUE; break; } X X ip = Active->iconmgr; X for (tmp_ip = ITER(ip); tmp_ip; tmp_ip = ITER(tmp_ip)) { X TEST (tmp_ip); X } X X if (!got_it) { X int origscreen = ip->scr->screen; X int inc = (dir == F_NEXTICONMGR ? 1 : -1); X X for (screen = origscreen + inc; ; screen += inc) { X if (screen >= NumScreens) X screen = 0; X else if (screen < 0) X screen = NumScreens - 1; X X sp = ScreenList[screen]; X if (sp) { X for (tmp_ip = IPOFSP (sp); tmp_ip; tmp_ip = ITER(tmp_ip)) { X TEST (tmp_ip); X } X } X if (got_it || screen == origscreen) break; X } X } X X#undef ITER X#undef IPOFSP X#undef TEST X X if (!got_it) { X XBell (dpy, 0); X return; X } X X /* raise the frame so it is visible */ X RaiseFrame(tmp_ip->twm_win); X if (tmp_ip->active) X XWarpPointer(dpy, None, tmp_ip->active->icon, 0,0,0,0, 5, 5); X else X XWarpPointer(dpy, None, tmp_ip->w, 0,0,0,0, 5, 5); X} X X/*********************************************************************** X * X * Procedure: X * AddIconManager - add a window to an icon manager X * X * Inputs: X * tmp_win - the TwmWindow structure X * X *********************************************************************** X */ X XWList *AddIconManager(tmp_win) X TwmWindow *tmp_win; X{ X WList *tmp; X int h; X unsigned long valuemask; /* mask for create windows */ X XSetWindowAttributes attributes; /* attributes for create windows */ X IconMgr *ip; X X tmp_win->list = NULL; X X if (tmp_win->iconmgr || tmp_win->transient || Scr->NoIconManagers) X return NULL; X X if (LookInList(Scr->IconMgrNoShow, tmp_win->full_name, &tmp_win->class)) X return NULL; X if (Scr->IconManagerDontShow && X !LookInList(Scr->IconMgrShow, tmp_win->full_name, &tmp_win->class)) X return NULL; X if ((ip = (IconMgr *)LookInList(Scr->IconMgrs, tmp_win->full_name, X &tmp_win->class)) == NULL) X ip = &Scr->iconmgr; X X tmp = (WList *) malloc(sizeof(WList)); X tmp->iconmgr = ip; X tmp->next = NULL; X tmp->active = FALSE; X tmp->down = FALSE; X X InsertInIconManager(ip, tmp, tmp_win); X X tmp->twm = tmp_win; X X tmp->fore = Scr->IconManagerC.fore; X tmp->back = Scr->IconManagerC.back; X tmp->highlight = Scr->IconManagerHighlight; X X GetColorFromList(Scr->IconManagerFL, tmp_win->full_name, &tmp_win->class, X &tmp->fore); X GetColorFromList(Scr->IconManagerBL, tmp_win->full_name, &tmp_win->class, X &tmp->back); X GetColorFromList(Scr->IconManagerHighlightL, tmp_win->full_name, X &tmp_win->class, &tmp->highlight); X X h = Scr->IconManagerFont.height + 10; X if (h < (siconify_height + 4)) X h = siconify_height + 4; X X ip->height = h * ip->count; X tmp->me = ip->count; X tmp->x = -1; X tmp->y = -1; X X valuemask = (CWBackPixel | CWBorderPixel | CWEventMask | CWCursor); X attributes.background_pixel = tmp->back; X attributes.border_pixel = tmp->back; X attributes.event_mask = (KeyPressMask | ButtonPressMask | X ButtonReleaseMask | ExposureMask | X EnterWindowMask | LeaveWindowMask); X attributes.cursor = Scr->IconMgrCursor; X tmp->w = XCreateWindow (dpy, ip->w, 0, 0, (unsigned int) 1, X (unsigned int) h, (unsigned int) 0, X CopyFromParent, (unsigned int) CopyFromParent, X (Visual *) CopyFromParent, valuemask, &attributes); X X X valuemask = (CWBackPixel | CWBorderPixel | CWEventMask | CWCursor); X attributes.background_pixel = tmp->back; X attributes.border_pixel = Scr->Black; X attributes.event_mask = (ButtonReleaseMask| ButtonPressMask | X ExposureMask); X attributes.cursor = Scr->ButtonCursor; X tmp->icon = XCreateWindow (dpy, tmp->w, 5, (int) (h - siconify_height)/2, X (unsigned int) siconify_width, X (unsigned int) siconify_height, X (unsigned int) 0, CopyFromParent, X (unsigned int) CopyFromParent, X (Visual *) CopyFromParent, X valuemask, &attributes); X X ip->count += 1; X PackIconManager(ip); X XMapWindow(dpy, tmp->w); X X XSaveContext(dpy, tmp->w, IconManagerContext, (caddr_t) tmp); X XSaveContext(dpy, tmp->w, TwmContext, (caddr_t) tmp_win); X XSaveContext(dpy, tmp->w, ScreenContext, (caddr_t) Scr); X XSaveContext(dpy, tmp->icon, TwmContext, (caddr_t) tmp_win); X XSaveContext(dpy, tmp->icon, ScreenContext, (caddr_t) Scr); X tmp_win->list = tmp; X X if (!ip->twm_win->icon) X { X MapFrame(ip->twm_win); X } X X return (tmp); X} X X/*********************************************************************** X * X * Procedure: X * InsertInIconManager - put an allocated entry into an icon X * manager X * X * Inputs: X * ip - the icon manager pointer X * tmp - the entry to insert X * X *********************************************************************** X */ X Xvoid InsertInIconManager(ip, tmp, tmp_win) X IconMgr *ip; X WList *tmp; X TwmWindow *tmp_win; X{ X WList *tmp1; X int added; X int (*compar)() = (Scr->CaseSensitive ? strcmp : XmuCompareISOLatin1); X X added = FALSE; X if (ip->first == NULL) X { X ip->first = tmp; X tmp->prev = NULL; X ip->last = tmp; X added = TRUE; X } X else if (Scr->SortIconMgr) X { X for (tmp1 = ip->first; tmp1 != NULL; tmp1 = tmp1->next) X { X if ((*compar)(tmp_win->icon_name, tmp1->twm->icon_name) < 0) X { X tmp->next = tmp1; X tmp->prev = tmp1->prev; X tmp1->prev = tmp; X if (tmp->prev == NULL) X ip->first = tmp; X else X tmp->prev->next = tmp; X added = TRUE; X break; X } X } X } X X if (!added) X { X ip->last->next = tmp; X tmp->prev = ip->last; X ip->last = tmp; X } X} X Xvoid RemoveFromIconManager(ip, tmp) X IconMgr *ip; X WList *tmp; X{ X if (tmp->prev == NULL) X ip->first = tmp->next; X else X tmp->prev->next = tmp->next; X X if (tmp->next == NULL) X ip->last = tmp->prev; X else X tmp->next->prev = tmp->prev; X} X X/*********************************************************************** X * X * Procedure: X * RemoveIconManager - remove a window from the icon manager X * X * Inputs: X * tmp_win - the TwmWindow structure X * X *********************************************************************** X */ X Xvoid RemoveIconManager(tmp_win) X TwmWindow *tmp_win; X{ X IconMgr *ip; X WList *tmp; X X if (tmp_win->list == NULL) X return; X X tmp = tmp_win->list; X tmp_win->list = NULL; X ip = tmp->iconmgr; X X RemoveFromIconManager(ip, tmp); X X XDeleteContext(dpy, tmp->icon, TwmContext); X XDeleteContext(dpy, tmp->icon, ScreenContext); X XDestroyWindow(dpy, tmp->icon); X XDeleteContext(dpy, tmp->w, IconManagerContext); X XDeleteContext(dpy, tmp->w, TwmContext); X XDeleteContext(dpy, tmp->w, ScreenContext); X XDestroyWindow(dpy, tmp->w); X ip->count -= 1; X free((char *) tmp); X X PackIconManager(ip); X X if (ip->count == 0) X { X UnmapFrame(ip->twm_win); X } X X} X Xvoid ActiveIconManager(active) X WList *active; X{ X active->active = TRUE; X Active = active; X Active->iconmgr->active = active; X DrawIconManagerBorder(active); X} X Xvoid NotActiveIconManager(active) X WList *active; X{ X active->active = FALSE; X DrawIconManagerBorder(active); X} X Xvoid DrawIconManagerBorder(tmp) X WList *tmp; X{ X { X XSetForeground(dpy, Scr->NormalGC, tmp->fore); X XDrawRectangle(dpy, tmp->w, Scr->NormalGC, 2, 2, X tmp->width-5, tmp->height-5); X X if (tmp->active && Scr->Highlight) X XSetForeground(dpy, Scr->NormalGC, tmp->highlight); X else X XSetForeground(dpy, Scr->NormalGC, tmp->back); X X XDrawRectangle(dpy, tmp->w, Scr->NormalGC, 0, 0, X tmp->width-1, tmp->height-1); X XDrawRectangle(dpy, tmp->w, Scr->NormalGC, 1, 1, X tmp->width-3, tmp->height-3); X } X} X X/*********************************************************************** X * X * Procedure: X * SortIconManager - sort the dude X * X * Inputs: X * ip - a pointer to the icon manager struture X * X *********************************************************************** X */ X Xvoid SortIconManager(ip) X IconMgr *ip; X{ X WList *tmp1, *tmp2; X int done; X int (*compar)() = (Scr->CaseSensitive ? strcmp : XmuCompareISOLatin1); X X if (ip == NULL) X ip = Active->iconmgr; X X done = FALSE; X do X { X for (tmp1 = ip->first; tmp1 != NULL; tmp1 = tmp1->next) X { X if ((tmp2 = tmp1->next) == NULL) X { X done = TRUE; X break; X } X if ((*compar)(tmp1->twm->icon_name, tmp2->twm->icon_name) > 0) X { X /* take it out and put it back in */ X RemoveFromIconManager(ip, tmp2); X InsertInIconManager(ip, tmp2, tmp2->twm); X break; X } X } X } X while (!done); X PackIconManager(ip); X} X X/*********************************************************************** X * X * Procedure: X * PackIconManager - pack the icon manager windows following X * an addition or deletion X * X * Inputs: X * ip - a pointer to the icon manager struture X * X *********************************************************************** X */ X Xvoid PackIconManager(ip) X IconMgr *ip; X{ X int newwidth, i, row, col, maxcol, colinc, rowinc, wheight, wwidth; X int new_x, new_y; X int savewidth; X WList *tmp; X X wheight = Scr->IconManagerFont.height + 10; X if (wheight < (siconify_height + 4)) X wheight = siconify_height + 4; X X wwidth = ip->width / ip->columns; X X rowinc = wheight; X colinc = wwidth; X X row = 0; X col = ip->columns; X maxcol = 0; X for (i = 0, tmp = ip->first; tmp != NULL; i++, tmp = tmp->next) X { X tmp->me = i; X if (++col >= ip->columns) X { X col = 0; X row += 1; X } X if (col > maxcol) X maxcol = col; X X new_x = col * colinc; X new_y = (row-1) * rowinc; X X /* if the position or size has not changed, don't touch it */ X if (tmp->x != new_x || tmp->y != new_y || X tmp->width != wwidth || tmp->height != wheight) X { X XMoveResizeWindow(dpy, tmp->w, new_x, new_y, wwidth, wheight); X X tmp->row = row-1; X tmp->col = col; X tmp->x = new_x; X tmp->y = new_y; X tmp->width = wwidth; X tmp->height = wheight; X } X } X maxcol += 1; X X ip->cur_rows = row; X ip->cur_columns = maxcol; X ip->height = row * rowinc; X if (ip->height == 0) X ip->height = rowinc; X newwidth = maxcol * colinc; X if (newwidth == 0) X newwidth = colinc; X X XResizeWindow(dpy, ip->w, newwidth, ip->height); X X savewidth = ip->width; X if (ip->twm_win) X SetupWindow (ip->twm_win, X ip->twm_win->frame_x, ip->twm_win->frame_y, X newwidth, ip->height + ip->twm_win->title_height, -1); X ip->width = savewidth; X} SHAR_EOF if test 18716 -ne "`wc -c < iconmgr.c`" then echo shar: error transmitting "iconmgr.c" '(should have been 18716 characters)' fi fi if test -f 'iconmgr.h' then echo shar: will not over-write existing file "iconmgr.h" else echo extracting "iconmgr.h" sed 's/^X//' >iconmgr.h <<'SHAR_EOF' X/* X * Copyright 1989 Massachusetts Institute of Technology 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 M.I.T. not be used in advertising X * or publicity pertaining to distribution of the software without specific, X * written prior permission. M.I.T. makes no representations about the X * suitability of this software for any purpose. It is provided "as is" X * without express or implied warranty. X * X * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T. X * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES X * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION X * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN X * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. X */ X X/*********************************************************************** X * X * $XConsortium: iconmgr.h,v 1.11 89/12/10 17:47:02 jim Exp $ X * X * Icon Manager includes X * X * 09-Mar-89 Tom LaStrange File Created X * X ***********************************************************************/ X X#ifndef _ICONMGR_ X#define _ICONMGR_ X Xtypedef struct WList X{ X struct WList *next; X struct WList *prev; X struct TwmWindow *twm; X struct IconMgr *iconmgr; X Window w; X Window icon; X int x, y, width, height; X int row, col; X int me; X Pixel fore, back, highlight; X unsigned top, bottom; X short active; X short down; X} WList; X Xtypedef struct IconMgr X{ X struct IconMgr *next; /* pointer to the next icon manager */ X struct IconMgr *prev; /* pointer to the previous icon mgr */ X struct IconMgr *lasti; /* pointer to the last icon mgr */ X struct WList *first; /* first window in the list */ X struct WList *last; /* last window in the list */ X struct WList *active; /* the active entry */ X TwmWindow *twm_win; /* back pointer to the new parent */ X struct ScreenInfo *scr; /* the screen this thing is on */ X Window w; /* this icon manager window */ X char *geometry; /* geometry string */ X char *name; X char *icon_name; X int x, y, width, height; X int columns, cur_rows, cur_columns; X int count; X} IconMgr; X Xextern int iconmgr_textx; Xextern WList *DownIconManager; X Xextern void CreateIconManagers(); Xextern IconMgr *AllocateIconManager(); Xextern void MoveIconManager(); Xextern void JumpIconManager(); Xextern WList *AddIconManager(); Xextern void InsertInIconManager(); Xextern void RemoveFromIconManager(); Xextern void RemoveIconManager(); Xextern void ActiveIconManager(); Xextern void NotActiveIconManager(); Xextern void DrawIconManagerBorder(); Xextern void SortIconManager(); Xextern void PackIconManager(); X X X#endif /* _ICONMGR_ */ SHAR_EOF if test 3052 -ne "`wc -c < iconmgr.h`" then echo shar: error transmitting "iconmgr.h" '(should have been 3052 characters)' fi fi if test -f 'icons.h' then echo shar: will not over-write existing file "icons.h" else echo extracting "icons.h" sed 's/^X//' >icons.h <<'SHAR_EOF' X/* X * Copyright 1989 Massachusetts Institute of Technology 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 M.I.T. not be used in advertising X * or publicity pertaining to distribution of the software without specific, X * written prior permission. M.I.T. makes no representations about the X * suitability of this software for any purpose. It is provided "as is" X * without express or implied warranty. X * X * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T. X * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES X * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION X * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN X * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. X */ X X/********************************************************************** X * X * $XConsortium: icons.h,v 1.4 89/07/18 17:16:24 jim Exp $ X * X * Icon releated definitions X * X * 10-Apr-89 Tom LaStrange Initial Version. X * X **********************************************************************/ X X#ifndef ICONS_H X#define ICONS_H X Xtypedef struct IconRegion X{ X struct IconRegion *next; X int x, y, w, h; X int grav1, grav2; X int stepx, stepy; /* allocation granularity */ X struct IconEntry *entries; X} IconRegion; X Xtypedef struct IconEntry X{ X struct IconEntry *next; X int x, y, w, h; X TwmWindow *twm_win; X short used; X}IconEntry; X X#endif /* ICONS_H */ SHAR_EOF if test 1836 -ne "`wc -c < icons.h`" then echo shar: error transmitting "icons.h" '(should have been 1836 characters)' fi fi if test -f 'lex.l' then echo shar: will not over-write existing file "lex.l" else echo extracting "lex.l" sed 's/^X//' >lex.l <<'SHAR_EOF' X%{ X/*****************************************************************************/ X/** Copyright 1988 by Evans & Sutherland Computer Corporation, **/ X/** Salt Lake City, Utah **/ X/** Portions Copyright 1989 by the Massachusetts Institute of Technology **/ X/** Cambridge, Massachusetts **/ X/** **/ X/** All Rights Reserved **/ X/** **/ X/** Permission to use, copy, modify, and distribute this software and **/ X/** its documentation for any purpose and without fee is hereby **/ X/** granted, provided that the above copyright notice appear in all **/ X/** copies and that both that copyright notice and this permis- **/ X/** sion notice appear in supporting documentation, and that the **/ X/** names of Evans & Sutherland and M.I.T. not be used in advertising **/ X/** in publicity pertaining to distribution of the software without **/ X/** specific, written prior permission. **/ X/** **/ X/** EVANS & SUTHERLAND AND M.I.T. DISCLAIM ALL WARRANTIES WITH REGARD **/ X/** TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- **/ X/** ABILITY AND FITNESS, IN NO EVENT SHALL EVANS & SUTHERLAND OR **/ X/** M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAM- **/ X/** AGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA **/ X/** OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER **/ X/** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/ X/** OR PERFORMANCE OF THIS SOFTWARE. **/ X/*****************************************************************************/ X X/*********************************************************************** X * X * $XConsortium: lex.l,v 1.62 89/12/10 17:46:33 jim Exp $ X * X * .twmrc lex file X * X * 12-Nov-87 Thomas E. LaStrange File created X * X ***********************************************************************/ X X/* #include <stdio.h> */ /* lex already includes stdio.h */ X#include "gram.h" X#include "parse.h" Xextern char *ProgramName; X Xextern int ParseError; X X%} X Xstring \"([^"]|\\.)*\" Xnumber [0-9]+ X%% X"{" { return (LB); } X"}" { return (RB); } X"(" { return (LP); } X")" { return (RP); } X"=" { return (EQUALS); } X":" { return (COLON); } X"+" { return PLUS; } X"-" { return MINUS; } X"|" { return OR; } X X[a-zA-Z\.]+ { int token = parse_keyword (yytext, X &yylval.num); X if (token == ERRORTOKEN) { X twmrc_error_prefix(); X fprintf (stderr, X "ignoring unknown keyword: %s\n", X yytext); X ParseError = 1; X } else X return token; X } X X"!" { yylval.num = F_EXEC; return FSKEYWORD; } X"^" { yylval.num = F_CUT; return FSKEYWORD; } X X{string} { yylval.ptr = (char *)yytext; return STRING; } X{number} { (void)sscanf(yytext, "%d", &yylval.num); X return (NUMBER); X } X\#[^\n]*\n {;} X[\n\t ] {;} X. { X twmrc_error_prefix(); X fprintf (stderr, X "ignoring character \"%s\"\n", X yytext); X ParseError = 1; X } X%% Xyywrap() { return(1);} X X#undef unput X#undef input X#undef output X#undef feof X#define unput(c) twmUnput(c) X#define input() (*twmInputFunc)() X#define output(c) TwmOutput(c) X#define feof() (1) SHAR_EOF if test 3708 -ne "`wc -c < lex.l`" then echo shar: error transmitting "lex.l" '(should have been 3708 characters)' fi fi if test -f 'list.h' then echo shar: will not over-write existing file "list.h" else echo extracting "list.h" sed 's/^X//' >list.h <<'SHAR_EOF' X/*****************************************************************************/ X/** Copyright 1988 by Evans & Sutherland Computer Corporation, **/ X/** Salt Lake City, Utah **/ X/** Portions Copyright 1989 by the Massachusetts Institute of Technology **/ X/** Cambridge, Massachusetts **/ X/** **/ X/** All Rights Reserved **/ X/** **/ X/** Permission to use, copy, modify, and distribute this software and **/ X/** its documentation for any purpose and without fee is hereby **/ X/** granted, provided that the above copyright notice appear in all **/ X/** copies and that both that copyright notice and this permis- **/ X/** sion notice appear in supporting documentation, and that the **/ X/** names of Evans & Sutherland and M.I.T. not be used in advertising **/ X/** in publicity pertaining to distribution of the software without **/ X/** specific, written prior permission. **/ X/** **/ X/** EVANS & SUTHERLAND AND M.I.T. DISCLAIM ALL WARRANTIES WITH REGARD **/ X/** TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- **/ X/** ABILITY AND FITNESS, IN NO EVENT SHALL EVANS & SUTHERLAND OR **/ X/** M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAM- **/ X/** AGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA **/ X/** OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER **/ X/** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/ X/** OR PERFORMANCE OF THIS SOFTWARE. **/ X/*****************************************************************************/ X X X/********************************************************************** X * X * $XConsortium: list.h,v 1.11 89/10/27 14:01:23 jim Exp $ X * X * TWM list handling external definitions X * X * 11-Apr-88 Tom LaStrange Initial Version. X * X **********************************************************************/ X X#ifndef _LIST_ X#define _LIST_ X Xtypedef struct name_list name_list; X Xstruct name_list X{ X name_list *next; /* pointer to the next name */ X char *name; /* the name of the window */ X int namelen; /* strlen(name) */ X char *ptr; /* list dependent data */ X}; X X Xextern void AddToList(); Xextern char* LookInList(); Xextern char* LookInNameList(); X X#endif /* _LIST_ */ X SHAR_EOF if test 2769 -ne "`wc -c < list.h`" then echo shar: error transmitting "list.h" '(should have been 2769 characters)' fi fi if test -f 'move.h' then echo shar: will not over-write existing file "move.h" else echo extracting "move.h" sed 's/^X//' >move.h <<'SHAR_EOF' X/*****************************************************************************/ X/** Copyright 1990 by Solbourne Computer Inc. **/ X/** Longmont, Colorado **/ X/** **/ X/** All Rights Reserved **/ X/** **/ X/** Permission to use, copy, modify, and distribute this software and **/ X/** its documentation for any purpose and without fee is hereby **/ X/** granted, provided that the above copyright notice appear in all **/ X/** copies and that both that copyright notice and this permis- **/ X/** sion notice appear in supporting documentation, and that the **/ X/** name of Solbourne not be used in advertising **/ X/** in publicity pertaining to distribution of the software without **/ X/** specific, written prior permission. **/ X/** **/ X/** SOLBOURNE COMPUTER INC. DISCLAIMS ALL WARRANTIES WITH REGARD **/ X/** TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- **/ X/** ABILITY AND FITNESS, IN NO EVENT SHALL SOLBOURNE **/ X/** BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAM- **/ X/** AGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA **/ X/** OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER **/ X/** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/ X/** OR PERFORMANCE OF THIS SOFTWARE. **/ X/*****************************************************************************/ X X/********************************************************************** X * X * $XConsortium: move.h,v 1.140 90/03/23 11:42:33 jim Exp $ X * X * New window move code to allow interaction with the virtual desktop X * X * 23-Aug-90 Tom LaStrange Initial Version. X * X **********************************************************************/ X X#ifndef _MOVE_ X#define _MOVE_ X X#define IN_PANNER 0x80000 X#define OUT_PANNER 0x40000 X Xvoid DragFrame(); Xvoid DragIcon(); Xvoid StartMove(); X X#endif /* _MOVE_ */ X SHAR_EOF if test 2420 -ne "`wc -c < move.h`" then echo shar: error transmitting "move.h" '(should have been 2420 characters)' fi fi # end of shell archive exit 0 dan ---------------------------------------------------- O'Reilly && Associates argv@sun.com / argv@ora.com Opinions expressed reflect those of the author only.