v09i007: TWM with a virtual root window, Part06/09
Tom LaStrange
toml at marvin.Solbourne.COM
Thu Aug 30 05:33:38 AEST 1990
Submitted-by: toml at marvin.Solbourne.COM (Tom LaStrange)
Posting-number: Volume 9, Issue 7
Archive-name: tvtwm/part06
#! /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:
#
#screen.h
#ssetroot.c
#twm.c
#twm.h
#
# Created by toml () on Wed Aug 29 08:43:36 MDT 1990
#
if test -f 'screen.h'
then
echo shar: will not over-write existing file "screen.h"
else
echo extracting "screen.h"
sed 's/^X//' >screen.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: screen.h,v 1.61 90/03/15 14:23:04 jim Exp $
X *
X * twm per-screen data include file
X *
X * 11-3-88 Dave Payne, Apple Computer File created
X *
X ***********************************************************************/
X
X#ifndef _SCREEN_
X#define _SCREEN_
X
X#include <X11/Xlib.h>
X#include <X11/Xutil.h>
X#include <X11/cursorfont.h>
X#include "list.h"
X#include "menus.h"
X#include "iconmgr.h"
X
Xtypedef struct _StdCmap {
X struct _StdCmap *next; /* next link in chain */
X Atom atom; /* property from which this came */
X int nmaps; /* number of maps below */
X XStandardColormap *maps; /* the actual maps */
X} StdCmap;
X
X#define SIZE_HINDENT 10
X#define SIZE_VINDENT 2
X
Xtypedef struct _TitlebarPixmaps {
X Pixmap xlogo;
X Pixmap resize;
X Pixmap question;
X Pixmap menu;
X} TitlebarPixmaps;
X
Xtypedef struct ScreenInfo
X{
X int screen; /* the default screen */
X int d_depth; /* copy of DefaultDepth(dpy, screen) */
X Visual *d_visual; /* copy of DefaultVisual(dpy, screen) */
X int Monochrome; /* is the display monochrome ? */
X int MyDisplayWidth; /* my copy of DisplayWidth(dpy, screen) */
X int MyDisplayHeight; /* my copy of DisplayHeight(dpy, screen) */
X int MaxWindowWidth; /* largest window to allow */
X int MaxWindowHeight; /* ditto */
X
X TwmWindow TwmRoot; /* the head of the twm window list */
X
X Window Root; /* the root window */
X Window SizeWindow; /* the resize dimensions window */
X Window InfoWindow; /* the information window */
X Window VirtualDesktop; /* the virtual root window */
X Window Panner; /* the panner window */
X int vdtWidth; /* width of the virtual desktop */
X int vdtHeight; /* height of the virtual desktop */
X int vdtPositionX; /* where the virtual desktop is currently positioned */
X int vdtPositionY; /* where the virtual desktop is currently positioned */
X
X name_list *Icons; /* list of icon pixmaps */
X TitlebarPixmaps tbpm; /* titlebar pixmaps */
X Pixmap UnknownPm; /* the unknown icon pixmap */
X Pixmap siconifyPm; /* the icon manager iconify pixmap */
X Pixmap pullPm; /* pull right menu arrow */
X Pixmap hilitePm; /* focus highlight window background */
X Pixmap rootWeave; /* root weave pixmap */
X int hilite_pm_width, hilite_pm_height; /* cache the size */
X
X MenuRoot *MenuList; /* head of the menu list */
X MenuRoot *LastMenu; /* the last menu (mostly unused?) */
X MenuRoot *Windows; /* the TwmWindows menu */
X
X TwmWindow *Ring; /* one of the windows in window ring */
X TwmWindow *RingLeader; /* current winodw in ring */
X
X MouseButton Mouse[MAX_BUTTONS+1][NUM_CONTEXTS][MOD_SIZE];
X MouseButton DefaultFunction;
X MouseButton WindowFunction;
X
X struct {
X Colormaps *cmaps; /* current list of colormap windows */
X int maxCmaps; /* maximum number of installed colormaps */
X unsigned long first_req; /* seq # for first XInstallColormap() req in
X pass thru loading a colortable list */
X int root_pushes; /* current push level to install root
X colormap windows */
X TwmWindow *pushed_window; /* saved window to install when pushes drops
X to zero */
X } cmapInfo;
X
X struct {
X StdCmap *head, *tail; /* list of maps */
X StdCmap *mru; /* most recently used in list */
X int mruindex; /* index of mru in entry */
X } StdCmapInfo;
X
X struct {
X int nleft, nright; /* numbers of buttons in list */
X TitleButton *head; /* start of list */
X int border; /* button border */
X int pad; /* button-padding */
X int width; /* width of single button & border */
X int leftx; /* start of left buttons */
X int titlex; /* start of title string */
X int rightoff; /* offset back from right edge */
X } TBInfo;
X ColorPair BorderTileC; /* border tile colors */
X ColorPair TitleC; /* titlebar colors */
X ColorPair MenuC; /* menu colors */
X ColorPair MenuTitleC; /* menu title colors */
X ColorPair IconC; /* icon colors */
X ColorPair IconManagerC; /* icon manager colors */
X ColorPair DefaultC; /* default colors */
X ColorPair vdtC; /* virtual desktop colors */
X ColorPair PannerC; /* Panner colors */
X Pixel BorderColor; /* color of window borders */
X Pixel MenuShadowColor; /* menu shadow color */
X Pixel IconBorderColor; /* icon border color */
X Pixel IconManagerHighlight; /* icon manager highlight */
X
X Cursor TitleCursor; /* title bar cursor */
X Cursor FrameCursor; /* frame cursor */
X Cursor IconCursor; /* icon cursor */
X Cursor IconMgrCursor; /* icon manager cursor */
X Cursor ButtonCursor; /* title bar button cursor */
X Cursor MoveCursor; /* move cursor */
X Cursor ResizeCursor; /* resize cursor */
X Cursor WaitCursor; /* wait a while cursor */
X Cursor MenuCursor; /* menu cursor */
X Cursor SelectCursor; /* dot cursor for f.move, etc. from menus */
X Cursor DestroyCursor; /* skull and cross bones, f.destroy */
X
X name_list *BorderColorL;
X name_list *IconBorderColorL;
X name_list *BorderTileForegroundL;
X name_list *BorderTileBackgroundL;
X name_list *TitleForegroundL;
X name_list *TitleBackgroundL;
X name_list *IconForegroundL;
X name_list *IconBackgroundL;
X name_list *IconManagerFL;
X name_list *IconManagerBL;
X name_list *IconMgrs;
X name_list *NoTitle; /* list of window names with no title bar */
X name_list *MakeTitle; /* list of window names with title bar */
X name_list *AutoRaise; /* list of window names to auto-raise */
X name_list *IconNames; /* list of window names and icon names */
X name_list *NoHighlight; /* list of windows to not highlight */
X name_list *NoStackModeL; /* windows to ignore stack mode requests */
X name_list *NoTitleHighlight;/* list of windows to not highlight the TB*/
X name_list *DontIconify; /* don't iconify by unmapping */
X name_list *IconMgrNoShow; /* don't show in the icon manager */
X name_list *IconMgrShow; /* show in the icon manager */
X name_list *IconifyByUn; /* windows to iconify by unmapping */
X name_list *StartIconified; /* windows to start iconic */
X name_list *IconManagerHighlightL; /* icon manager highlight colors */
X name_list *SqueezeTitleL; /* windows of which to squeeze title */
X name_list *DontSqueezeTitleL; /* windows of which not to squeeze */
X name_list *WindowRingL; /* windows in ring */
X name_list *WarpCursorL; /* windows to warp cursor to on deiconify */
X name_list *StickyL; /* windows that should be sticky */
X
X GC NormalGC; /* normal GC for everything */
X GC MenuGC; /* gc for menus */
X GC DrawGC; /* GC to draw lines for move and resize */
X GC PannerGC; /* GC for the panner outline */
X
X unsigned long Black;
X unsigned long White;
X unsigned long XORvalue; /* number to use when drawing xor'ed */
X MyFont TitleBarFont; /* title bar font structure */
X MyFont MenuFont; /* menu font structure */
X MyFont IconFont; /* icon font structure */
X MyFont SizeFont; /* resize font structure */
X MyFont IconManagerFont; /* window list font structure */
X MyFont DefaultFont;
X IconMgr iconmgr; /* default icon manager */
X struct IconRegion *FirstRegion; /* pointer to icon regions */
X struct IconRegion *LastRegion; /* pointer to the last icon region */
X char *IconDirectory; /* icon directory to search */
X int SizeStringOffset; /* x offset in size window for drawing */
X int SizeStringWidth; /* minimum width of size window */
X int BorderWidth; /* border width of twm windows */
X int IconBorderWidth; /* border width of icon windows */
X int UnknownWidth; /* width of the unknown icon */
X int UnknownHeight; /* height of the unknown icon */
X int TitleHeight; /* height of the title bar window */
X TwmWindow *Focus; /* the twm window that has focus */
X int EntryHeight; /* menu entry height */
X int FramePadding; /* distance between decorations and border */
X int TitlePadding; /* distance between items in titlebar */
X int ButtonIndent; /* amount to shrink buttons on each side */
X int NumAutoRaises; /* number of autoraise windows on screen */
X short NoDefaults; /* do not add in default UI stuff */
X short UsePPosition; /* what do with PPosition, see values below */
X short AutoRelativeResize; /* start resize relative to position in quad */
X short FocusRoot; /* is the input focus on the root ? */
X short WarpCursor; /* warp cursor on de-iconify ? */
X short ForceIcon; /* force the icon to the user specified */
X short NoGrabServer; /* don't do server grabs */
X short NoRaiseMove; /* don't raise window following move */
X short NoRaiseResize; /* don't raise window following resize */
X short NoRaiseDeicon; /* don't raise window on deiconify */
X short NoRaiseWarp; /* don't raise window on warp */
X short DontMoveOff; /* don't allow windows to be moved off */
X short DoZoom; /* zoom in and out of icons */
X short TitleFocus; /* focus on window in title bar ? */
X short NoTitlebar; /* put title bars on windows */
X short DecorateTransients; /* put title bars on transients */
X short IconifyByUnmapping; /* simply unmap windows when iconifying */
X short ShowIconManager; /* display the window list */
X short IconManagerDontShow; /* show nothing in the icon manager */
X short BackingStore; /* use backing store for menus */
X short SaveUnder; /* use save under's for menus */
X short RandomPlacement; /* randomly place windows that no give hints */
X short OpaqueMove; /* move the window rather than outline */
X short Highlight; /* should we highlight the window borders */
X short StackMode; /* should we honor stack mode requests */
X short TitleHighlight; /* should we highlight the titlebar */
X short MoveDelta; /* number of pixels before f.move starts */
X short ZoomCount; /* zoom outline count */
X short SortIconMgr; /* sort entries in the icon manager */
X short Shadow; /* show the menu shadow */
X short InterpolateMenuColors;/* make pretty menus */
X short NoIconManagers; /* Don't create any icon managers */
X short ClientBorderWidth; /* respect client window border width */
X short SqueezeTitle; /* make title as small as possible */
X short HaveFonts; /* set if fonts have been loaded */
X short FirstTime; /* first time we've read .twmrc */
X short CaseSensitive; /* be case-sensitive when sorting names */
X short WarpUnmapped; /* allow warping to unmapped windows */
X short PannerState; /* the initial state of the panner */
X short PannerScale; /* scale of the panner */
X char *PannerGeometry; /* geometry of the panner */
X int PannerOutlineWidth;
X int PannerOutlineHeight;
X int PannerOutlineX;
X int PannerOutlineY;
X int PannerWidth;
X int PannerHeight;
X short vdtBackgroundSet; /* vdt background color has been set */
X char *vdtPixmap; /* vdt pixmap */
X short PannerBackgroundSet; /* background of panner is set */
X char *PannerPixmap; /* Panner pixmap */
X
X FuncKey FuncKeyRoot;
X} ScreenInfo;
X
Xextern int MultiScreen;
Xextern int NumScreens;
Xextern ScreenInfo **ScreenList;
Xextern ScreenInfo *Scr;
Xextern int FirstScreen;
X
X#define PPOS_OFF 0
X#define PPOS_ON 1
X#define PPOS_NON_ZERO 2
X/* may eventually want an option for having the PPosition be the initial
X location for the drag lines */
X
X#endif /* _SCREEN_ */
SHAR_EOF
if test 12618 -ne "`wc -c < screen.h`"
then
echo shar: error transmitting "screen.h" '(should have been 12618 characters)'
fi
fi
if test -f 'ssetroot.c'
then
echo shar: will not over-write existing file "ssetroot.c"
else
echo extracting "ssetroot.c"
sed 's/^X//' >ssetroot.c <<'SHAR_EOF'
X/* Copyright 1987, Massachusetts Institute of Technology */
X
X#include <X11/Xlib.h>
X#include <X11/Xutil.h>
X#include <X11/Xatom.h>
X#include <stdio.h>
X#include "X11/bitmaps/gray"
X#include "X11/bitmaps/root_weave"
X
X/*
X * xsetroot.c MIT Project Athena, X Window system root window
X * parameter setting utility. This program will set
X * various parameters of the X root window.
X *
X * Modified: Tom LaStrange, Solbourne Computer 9/28/89
X * Changed to work with swm virtual root and "proper"
X * colormap.
X *
X * Author: Mark Lillibridge, MIT Project Athena
X * 11-Jun-87
X */
X
Xchar *index();
X
X#define Dynamic 1
X
XAtom __SWM_VROOT = None;
Xchar *program_name;
XDisplay *dpy;
XColormap colormap;
Xint screen;
XWindow root;
Xchar *fore_color = NULL;
Xchar *back_color = NULL;
Xint reverse = 0;
Xint save_colors = 0;
Xint unsave_past = 0;
XPixmap save_pixmap = (Pixmap)None;
X
Xusage()
X{
X fprintf(stderr, "usage: %s [options]\n", program_name);
X fprintf(stderr, " where options are:\n");
X fprintf(stderr, " -display <display> or -d <display>\n");
X fprintf(stderr, " -fg <color> or -foreground <color>\n");
X fprintf(stderr, " -bg <color> or -background <color>\n");
X fprintf(stderr, " -rv or -reverse\n");
X fprintf(stderr, " -help\n");
X fprintf(stderr, " -def or -default\n");
X fprintf(stderr, " -name <string>\n");
X fprintf(stderr, " -cursor <cursor file> <mask file>\n");
X fprintf(stderr, " -solid <color>\n");
X fprintf(stderr, " -gray or -grey\n");
X fprintf(stderr, " -bitmap <filename>\n");
X fprintf(stderr, " -mod <x> <y>\n");
X exit(1);
X /*NOTREACHED*/
X}
X
XPixmap MakeModulaBitmap(), ReadBitmapFile();
XXColor NameToXColor();
Xunsigned long NameToPixel();
X
Xmain(argc, argv)
X int argc;
X char **argv;
X{
X int excl = 0;
X int nonexcl = 0;
X int restore_defaults = 0;
X char *display_name = NULL;
X char *name = NULL;
X char *cursor_file = NULL;
X char *cursor_mask = NULL;
X char *solid_color = NULL;
X Cursor cursor;
X int gray = 0;
X char *bitmap_file = NULL;
X int mod_x = 0;
X int mod_y = 0;
X register int i;
X unsigned int ww, hh;
X Pixmap bitmap;
X Window rootReturn, parentReturn, *children;
X unsigned int numChildren;
X XWindowAttributes attr;
X
X program_name=argv[0];
X
X for (i = 1; i < argc; i++) {
X if (!strcmp ("-display", argv[i]) || !strcmp ("-d", argv[i])) {
X if (++i>=argc) usage ();
X display_name = argv[i];
X continue;
X }
X if (!strcmp("-help", argv[i])) {
X usage();
X }
X if (!strcmp("-def", argv[i]) || !strcmp("-default", argv[i])) {
X restore_defaults = 1;
X continue;
X }
X if (!strcmp("-name", argv[i])) {
X if (++i>=argc) usage();
X name = argv[i];
X nonexcl++;
X continue;
X }
X if (!strcmp("-cursor", argv[i])) {
X if (++i>=argc) usage();
X cursor_file = argv[i];
X if (++i>=argc) usage();
X cursor_mask = argv[i];
X nonexcl++;
X continue;
X }
X if (!strcmp("-fg",argv[i]) || !strcmp("-foreground",argv[i])) {
X if (++i>=argc) usage();
X fore_color = argv[i];
X continue;
X }
X if (!strcmp("-bg",argv[i]) || !strcmp("-background",argv[i])) {
X if (++i>=argc) usage();
X back_color = argv[i];
X continue;
X }
X if (!strcmp("-solid", argv[i])) {
X if (++i>=argc) usage();
X solid_color = argv[i];
X excl++;
X continue;
X }
X if (!strcmp("-gray", argv[i]) || !strcmp("-grey", argv[i])) {
X gray = 1;
X excl++;
X continue;
X }
X if (!strcmp("-bitmap", argv[i])) {
X if (++i>=argc) usage();
X bitmap_file = argv[i];
X excl++;
X continue;
X }
X if (!strcmp("-mod", argv[i])) {
X if (++i>=argc) usage();
X mod_x = atoi(argv[i]);
X if (mod_x <= 0) mod_x = 1;
X if (++i>=argc) usage();
X mod_y = atoi(argv[i]);
X if (mod_y <= 0) mod_y = 1;
X excl++;
X continue;
X }
X if (!strcmp("-rv",argv[i]) || !strcmp("-reverse",argv[i])) {
X reverse = 1;
X continue;
X }
X usage();
X }
X
X /* Check for multiple use of exclusive options */
X if (excl > 1) {
X fprintf(stderr, "%s: choose only one of {solid, gray, bitmap, mod}\n",
X program_name);
X usage();
X }
X
X dpy = XOpenDisplay(display_name);
X if (!dpy) {
X fprintf(stderr, "%s: unable to open display '%s'\n",
X program_name, XDisplayName (display_name));
X usage ();
X }
X screen = DefaultScreen(dpy);
X root = RootWindow(dpy, screen);
X
X /* use the colormap of the root window instead of DefaultColormap */
X XGetWindowAttributes(dpy, root, &attr);
X colormap = attr.colormap;
X
X /* go look for a virtual root */
X __SWM_VROOT = XInternAtom(dpy, "__SWM_VROOT", False);
X XQueryTree(dpy, root, &rootReturn, &parentReturn, &children, &numChildren);
X for (i = 0; i < numChildren; i++)
X {
X Atom actual_type;
X int actual_format;
X long nitems, bytesafter;
X Window *newRoot = NULL;
X
X if (XGetWindowProperty (dpy, children[i], __SWM_VROOT,0,1,
X False, XA_WINDOW, &actual_type, &actual_format, &nitems, &bytesafter,
X (unsigned char **) &newRoot) == Success && newRoot)
X {
X root = *newRoot;
X break;
X }
X }
X
X /* If there are no arguments then restore defaults. */
X if (!excl && !nonexcl)
X restore_defaults = 1;
X
X /* Handle a cursor file */
X if (cursor_file) {
X cursor = CreateCursorFromFiles(cursor_file, cursor_mask);
X XDefineCursor(dpy, root, cursor);
X XFreeCursor(dpy, cursor);
X }
X
X /* Handle -gray and -grey options */
X if (gray) {
X bitmap = XCreateBitmapFromData(dpy, root, gray_bits,
X gray_width, gray_height);
X SetBackgroundToBitmap(bitmap, gray_width, gray_height);
X }
X
X /* Handle -solid option */
X if (solid_color) {
X XSetWindowBackground(dpy, root, NameToPixel(solid_color,
X BlackPixel(dpy, screen)));
X XClearWindow(dpy, root);
X unsave_past = 1;
X }
X
X /* Handle -bitmap option */
X if (bitmap_file) {
X bitmap = ReadBitmapFile(bitmap_file, &ww, &hh, (int *)NULL, (int *)NULL);
X SetBackgroundToBitmap(bitmap, ww, hh);
X }
X
X /* Handle set background to a modula pattern */
X if (mod_x) {
X bitmap = MakeModulaBitmap(mod_x, mod_y);
X SetBackgroundToBitmap(bitmap, 16, 16);
X }
X
X#ifdef NOT_ALLOWED
X /* Handle set name */
X if (name)
X XStoreName(dpy, root, name);
X#endif NOT_ALLOWED
X
X /* Handle restore defaults */
X if (restore_defaults) {
X if (root == RootWindow(dpy, screen)) {
X if (!cursor_file)
X XUndefineCursor(dpy, root);
X if (!excl) {
X XSetWindowBackgroundPixmap(dpy, root, (Pixmap) None);
X XClearWindow(dpy, root);
X unsave_past = 1;
X }
X }
X else
X {
X if (!cursor_file)
X XUndefineCursor(dpy, root);
X if (!excl) {
X bitmap = XCreateBitmapFromData(dpy, root, root_weave_bits,
X root_weave_width, root_weave_height);
X SetBackgroundToBitmap(bitmap, root_weave_width, root_weave_height);
X unsave_past = 1;
X }
X }
X }
X
X FixupState();
X XCloseDisplay(dpy);
X exit (0);
X}
X
X
X/* Free past incarnation if needed, and retain state if needed. */
XFixupState()
X{
X Atom prop, type;
X int format;
X unsigned long length, after;
X unsigned char *data;
X
X if (!(DefaultVisual(dpy, screen)->class & Dynamic))
X unsave_past = 0;
X if (!unsave_past && !save_colors)
X return;
X prop = XInternAtom(dpy, "_XSETROOT_ID", False);
X if (unsave_past) {
X (void)XGetWindowProperty(dpy, root, prop, 0L, 1L, True, AnyPropertyType,
X &type, &format, &length, &after, &data);
X if ((type == XA_PIXMAP) && (format == 32) &&
X (length == 1) && (after == 0))
X XKillClient(dpy, *((Pixmap *)data));
X else if (type != None)
X fprintf(stderr, "%s: warning: _XSETROOT_ID property is garbage\n",
X program_name);
X }
X if (save_colors) {
X if (!save_pixmap)
X save_pixmap = XCreatePixmap(dpy, root, 1, 1, 1);
X XChangeProperty(dpy, root, prop, XA_PIXMAP, 32, PropModeReplace,
X (unsigned char *) &save_pixmap, 1);
X XSetCloseDownMode(dpy, RetainPermanent);
X }
X}
X
X/*
X * SetBackgroundToBitmap: Set the root window background to a caller supplied
X * bitmap.
X */
XSetBackgroundToBitmap(bitmap, width, height)
X Pixmap bitmap;
X unsigned int width, height;
X{
X Pixmap pix;
X GC gc;
X XGCValues gc_init;
X
X gc_init.foreground = NameToPixel(fore_color, BlackPixel(dpy, screen));
X gc_init.background = NameToPixel(back_color, WhitePixel(dpy, screen));
X if (reverse) {
X unsigned long temp=gc_init.foreground;
X gc_init.foreground=gc_init.background;
X gc_init.background=temp;
X }
X gc = XCreateGC(dpy, root, GCForeground|GCBackground, &gc_init);
X pix = XCreatePixmap(dpy, root, width, height,
X (unsigned int)DefaultDepth(dpy, screen));
X XCopyPlane(dpy, bitmap, pix, gc, 0, 0, width, height, 0, 0, (unsigned long)1);
X XSetWindowBackgroundPixmap(dpy, root, pix);
X XFreeGC(dpy, gc);
X XFreePixmap(dpy, bitmap);
X if (save_colors)
X save_pixmap = pix;
X else
X XFreePixmap(dpy, pix);
X XClearWindow(dpy, root);
X unsave_past = 1;
X}
X
X
X/*
X * CreateCursorFromFiles: make a cursor of the right colors from two bitmap
X * files.
X */
X#define BITMAP_HOT_DEFAULT 8
X
XCreateCursorFromFiles(cursor_file, mask_file)
X char *cursor_file, *mask_file;
X{
X Pixmap cursor_bitmap, mask_bitmap;
X unsigned int width, height, ww, hh;
X int x_hot, y_hot;
X Cursor cursor;
X XColor fg, bg, temp;
X
X fg = NameToXColor(fore_color, BlackPixel(dpy, screen));
X bg = NameToXColor(back_color, WhitePixel(dpy, screen));
X if (reverse) {
X temp = fg; fg = bg; bg = temp;
X }
X
X cursor_bitmap = ReadBitmapFile(cursor_file, &width, &height, &x_hot, &y_hot);
X mask_bitmap = ReadBitmapFile(mask_file, &ww, &hh, (int *)NULL, (int *)NULL);
X
X if (width != ww || height != hh) {
X fprintf(stderr,
X"%s: dimensions of cursor bitmap and cursor mask bitmap are different\n",
X program_name);
X exit(1);
X /*NOTREACHED*/
X }
X
X if ((x_hot == -1) && (y_hot == -1)) {
X x_hot = BITMAP_HOT_DEFAULT;
X y_hot = BITMAP_HOT_DEFAULT;
X }
X if ((x_hot < 0) || (x_hot >= width) ||
X (y_hot < 0) || (y_hot >= height)) {
X fprintf(stderr, "%s: hotspot is outside cursor bounds\n", program_name);
X exit(1);
X /*NOTREACHED*/
X }
X
X cursor = XCreatePixmapCursor(dpy, cursor_bitmap, mask_bitmap, &fg, &bg,
X (unsigned int)x_hot, (unsigned int)y_hot);
X XFreePixmap(dpy, cursor_bitmap);
X XFreePixmap(dpy, mask_bitmap);
X
X return(cursor);
X}
X
X
X/*
X * MakeModulaBitmap: Returns a modula bitmap based on an x & y mod.
X */
XPixmap MakeModulaBitmap(mod_x, mod_y)
X int mod_x, mod_y;
X{
X int i;
X long pattern_line = 0;
X char modula_data[16*16/8];
X
X for (i=0; i<16; i++) {
X pattern_line <<=1;
X if ((i % mod_x) == 0) pattern_line |= 0x0001;
X }
X for (i=0; i<16; i++) {
X if ((i % mod_y) == 0) {
X modula_data[i*2] = 0xff;
X modula_data[i*2+1] = 0xff;
X } else {
X modula_data[i*2] = pattern_line & 0xff;
X modula_data[i*2+1] = (pattern_line>>8) & 0xff;
X }
X }
X
X return(XCreateBitmapFromData(dpy, root, modula_data, 16, 16));
X}
X
X
X/*
X * NameToXColor: Convert the name of a color to its Xcolor value.
X */
XXColor NameToXColor(name, pixel)
X char *name;
X unsigned long pixel;
X{
X XColor c;
X
X if (!name || !*name) {
X c.pixel = pixel;
X XQueryColor(dpy, colormap, &c);
X } else if (!XParseColor(dpy, colormap, name, &c)) {
X fprintf(stderr, "%s: unknown color or bad color format: %s\n",
X program_name, name);
X exit(1);
X /*NOTREACHED*/
X }
X return(c);
X}
X
Xstatic Atom colormaps[] = {
XXA_RGB_COLOR_MAP,
XXA_RGB_BEST_MAP,
XXA_RGB_BLUE_MAP,
XXA_RGB_DEFAULT_MAP,
XXA_RGB_GRAY_MAP,
XXA_RGB_GREEN_MAP,
XXA_RGB_RED_MAP };
X
Xstatic int nummaps = sizeof(colormaps) / sizeof(Atom);
X
Xunsigned long NameToPixel(name, pixel)
X char *name;
X unsigned long pixel;
X{
X static XStandardColormap last = {0,0,0,0,0,0,0,0};
X XColor ecolor;
X
X if (!name || !*name)
X return pixel;
X if (!XParseColor(dpy,colormap,name,&ecolor)) {
X fprintf(stderr,"%s: unknown color \"%s\"\n",program_name,name);
X exit(1);
X /*NOTREACHED*/
X }
X if (!XAllocColor(dpy, colormap,&ecolor))
X {
X /* check to see if this is one of the standard colormaps */
X if (last.colormap != colormap)
X {
X int i;
X for (i = 0; i < nummaps; i++)
X {
X if (XGetStandardColormap(dpy, RootWindow(dpy, screen), &last, colormaps[i]))
X {
X if (last.colormap == colormap)
X break;
X }
X }
X if (last.colormap != colormap)
X last.colormap = 0;
X }
X if (last.colormap)
X {
X ecolor.pixel = last.base_pixel +
X (unsigned long)((ecolor.red / 65535.0) * last.red_max + 0.5) * last.red_mult +
X (unsigned long)((ecolor.green /65535.0) * last.green_max + 0.5)* last.green_mult +
X (unsigned long)((ecolor.blue / 65535.0) * last.blue_max + 0.5)* last.blue_mult;
X }
X else
X {
X fprintf(stderr, "%s: unable to allocate color for \"%s\"\n",
X program_name, name);
X exit(1);
X /*NOTREACHED*/
X }
X }
X if ((ecolor.pixel != BlackPixel(dpy, screen)) &&
X (ecolor.pixel != WhitePixel(dpy, screen)) &&
X (DefaultVisual(dpy, screen)->class & Dynamic))
X save_colors = 1;
X return(ecolor.pixel);
X}
X
XPixmap ReadBitmapFile(filename, width, height, x_hot, y_hot)
X char *filename;
X unsigned int *width, *height;
X int *x_hot, *y_hot;
X{
X Pixmap bitmap;
X int status;
X
X status = XReadBitmapFile(dpy, root, filename, width,
X height, &bitmap, x_hot, y_hot);
X if (status == BitmapSuccess)
X return(bitmap);
X else if (status == BitmapOpenFailed)
X fprintf(stderr, "%s: can't open file: %s\n", program_name, filename);
X else if (status == BitmapFileInvalid)
X fprintf(stderr, "%s: bad bitmap format file: %s\n",
X program_name, filename);
X else
X fprintf(stderr, "%s: insufficient memory for bitmap: %s",
X program_name, filename);
X exit(1);
X /*NOTREACHED*/
X}
SHAR_EOF
if test 13651 -ne "`wc -c < ssetroot.c`"
then
echo shar: error transmitting "ssetroot.c" '(should have been 13651 characters)'
fi
fi
if test -f 'twm.c'
then
echo shar: will not over-write existing file "twm.c"
else
echo extracting "twm.c"
sed 's/^X//' >twm.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: twm.c,v 1.111 90/03/23 13:23:34 jim Exp $
X *
X * twm - "Tom's Window Manager"
X *
X * 27-Oct-87 Thomas E. LaStrange File created
X *
X ***********************************************************************/
X
X#if !defined(lint) && !defined(SABER)
Xstatic char RCSinfo[] =
X"$XConsortium: twm.c,v 1.111 90/03/23 13:23:34 jim Exp $";
X#endif
X
X#include <stdio.h>
X#include <signal.h>
X#include <fcntl.h>
X#include "twm.h"
X#include "add_window.h"
X#include "gc.h"
X#include "parse.h"
X#include "version.h"
X#include "menus.h"
X#include "events.h"
X#include "util.h"
X#include "gram.h"
X#include "screen.h"
X#include "iconmgr.h"
X#include <X11/Xproto.h>
X#include <X11/bitmaps/root_weave>
X#include "vdt.h"
X
XDisplay *dpy; /* which display are we talking to */
XWindow ResizeWindow; /* the window we are resizing */
X
Xint MultiScreen = TRUE; /* try for more than one screen? */
Xint NumScreens; /* number of screens in ScreenList */
X#ifdef SHAPE
Xint HasShape; /* server supports shape extension? */
Xint ShapeEventBase, ShapeErrorBase;
X#endif
XScreenInfo **ScreenList; /* structures for each screen */
XScreenInfo *Scr = NULL; /* the cur and prev screens */
Xint PreviousScreen; /* last screen that we were on */
Xint FirstScreen; /* TRUE ==> first screen of display */
XBool PrintErrorMessages = False; /* controls error messages */
Xstatic int RedirectError; /* TRUE ==> another window manager running */
Xstatic int CatchRedirectError(); /* for settting RedirectError */
Xstatic int TwmErrorHandler(); /* for everything else */
Xchar Info[INFO_LINES][INFO_SIZE]; /* info strings to print */
Xint InfoLines;
Xchar *InitFile = NULL;
X
XCursor UpperLeftCursor; /* upper Left corner cursor */
XCursor RightButt;
XCursor MiddleButt;
XCursor LeftButt;
X
XXContext VirtualContext; /* context for virtual windows */
XXContext TwmContext; /* context for twm windows */
XXContext MenuContext; /* context for all menu windows */
XXContext IconManagerContext; /* context for all window list windows */
XXContext ScreenContext; /* context to get screen data */
XXContext ColormapContext; /* context for colormap operations */
X
XXClassHint NoClass; /* for applications with no class */
X
XXGCValues Gcv;
X
Xchar *Home; /* the HOME environment variable */
Xint HomeLen; /* length of Home */
Xint ParseError; /* error parsing the .twmrc file */
X
Xint HandlingEvents = FALSE; /* are we handling events yet? */
X
XWindow JunkRoot; /* junk window */
XWindow JunkChild; /* junk window */
Xint JunkX; /* junk variable */
Xint JunkY; /* junk variable */
Xunsigned int JunkWidth, JunkHeight, JunkBW, JunkDepth, JunkMask;
X
Xchar *ProgramName;
Xint Argc;
Xchar **Argv;
Xchar **Environ;
X
XBool RestartPreviousState = False; /* try to restart in previous state */
X
Xunsigned long black, white;
X
X/***********************************************************************
X *
X * Procedure:
X * main - start of twm
X *
X ***********************************************************************
X */
X
Xmain(argc, argv, environ)
X int argc;
X char **argv;
X char **environ;
X{
X Window root, parent, *children;
X unsigned int nchildren;
X int i, j;
X char *display_name = NULL;
X unsigned long valuemask; /* mask for create windows */
X XSetWindowAttributes attributes; /* attributes for create windows */
X SigProc old_handler;
X int numManaged, firstscrn, lastscrn, scrnum;
X extern ColormapWindow *CreateColormapWindow();
X
X ProgramName = argv[0];
X Argc = argc;
X Argv = argv;
X Environ = environ;
X
X for (i = 1; i < argc; i++) {
X if (argv[i][0] == '-') {
X switch (argv[i][1]) {
X case 'd': /* -display dpy */
X if (++i >= argc) goto usage;
X display_name = argv[i];
X continue;
X case 's': /* -single */
X MultiScreen = FALSE;
X continue;
X case 'f': /* -file twmrcfilename */
X if (++i >= argc) goto usage;
X InitFile = argv[i];
X continue;
X case 'v': /* -verbose */
X PrintErrorMessages = True;
X continue;
X case 'q': /* -quiet */
X PrintErrorMessages = False;
X continue;
X }
X }
X usage:
X fprintf (stderr,
X "usage: %s [-display dpy] [-f file] [-s] [-q] [-v]\n",
X ProgramName);
X exit (1);
X }
X
X old_handler = signal(SIGINT, SIG_IGN);
X if (old_handler != SIG_IGN)
X signal(SIGINT, Done);
X
X old_handler = signal(SIGHUP, SIG_IGN);
X if (old_handler != SIG_IGN)
X signal(SIGHUP, Done);
X
X signal(SIGQUIT, Done);
X signal(SIGTERM, Done);
X
X Home = getenv("HOME");
X if (Home == NULL)
X Home = "./";
X
X HomeLen = strlen(Home);
X
X NoClass.res_name = NoName;
X NoClass.res_class = NoName;
X
X if (!(dpy = XOpenDisplay(display_name))) {
X fprintf (stderr, "%s: unable to open display \"%s\"\n",
X ProgramName, XDisplayName(display_name));
X exit (1);
X }
X
X /* XSynchronize(dpy, True); /* */
X
X if (fcntl(ConnectionNumber(dpy), F_SETFD, 1) == -1) {
X fprintf (stderr,
X "%s: unable to mark display connection as close-on-exec\n",
X ProgramName);
X exit (1);
X }
X
X#ifdef SHAPE
X HasShape = XShapeQueryExtension (dpy, &ShapeEventBase, &ShapeErrorBase);
X#endif
X VirtualContext = XUniqueContext();
X TwmContext = XUniqueContext();
X MenuContext = XUniqueContext();
X IconManagerContext = XUniqueContext();
X ScreenContext = XUniqueContext();
X ColormapContext = XUniqueContext();
X
X InternUsefulAtoms ();
X InitVirtualDesktop();
X
X /* Set up the per-screen global information. */
X
X NumScreens = ScreenCount(dpy);
X
X if (MultiScreen)
X {
X firstscrn = 0;
X lastscrn = NumScreens - 1;
X }
X else
X {
X firstscrn = lastscrn = DefaultScreen(dpy);
X }
X
X InfoLines = 0;
X
X /* for simplicity, always allocate NumScreens ScreenInfo struct pointers */
X ScreenList = (ScreenInfo **) calloc (NumScreens, sizeof (ScreenInfo *));
X numManaged = 0;
X PreviousScreen = DefaultScreen(dpy);
X FirstScreen = TRUE;
X for (scrnum = firstscrn ; scrnum <= lastscrn; scrnum++)
X {
X RedirectError = FALSE;
X XSetErrorHandler(CatchRedirectError);
X XSelectInput(dpy, RootWindow (dpy, scrnum),
X ColormapChangeMask | EnterWindowMask | PropertyChangeMask |
X SubstructureRedirectMask | KeyPressMask |
X ButtonPressMask | ButtonReleaseMask);
X XSync(dpy, 0);
X XSetErrorHandler(TwmErrorHandler);
X
X if (RedirectError)
X {
X fprintf (stderr, "%s: another window manager is already running",
X ProgramName);
X if (MultiScreen && NumScreens > 0)
X fprintf(stderr, " on screen %d?\n", scrnum);
X else
X fprintf(stderr, "?\n");
X continue;
X }
X
X numManaged ++;
X
X /* Note: ScreenInfo struct is calloc'ed to initialize to zero. */
X Scr = ScreenList[scrnum] =
X (ScreenInfo *) calloc(1, sizeof(ScreenInfo));
X
X /* initialize list pointers, remember to put an initialization
X * in InitVariables also
X */
X Scr->BorderColorL = NULL;
X Scr->IconBorderColorL = NULL;
X Scr->BorderTileForegroundL = NULL;
X Scr->BorderTileBackgroundL = NULL;
X Scr->TitleForegroundL = NULL;
X Scr->TitleBackgroundL = NULL;
X Scr->IconForegroundL = NULL;
X Scr->IconBackgroundL = NULL;
X Scr->NoTitle = NULL;
X Scr->MakeTitle = NULL;
X Scr->AutoRaise = NULL;
X Scr->IconNames = NULL;
X Scr->NoHighlight = NULL;
X Scr->NoStackModeL = NULL;
X Scr->NoTitleHighlight = NULL;
X Scr->DontIconify = NULL;
X Scr->IconMgrNoShow = NULL;
X Scr->IconMgrShow = NULL;
X Scr->IconifyByUn = NULL;
X Scr->IconManagerFL = NULL;
X Scr->IconManagerBL = NULL;
X Scr->IconMgrs = NULL;
X Scr->StartIconified = NULL;
X Scr->SqueezeTitleL = NULL;
X Scr->DontSqueezeTitleL = NULL;
X Scr->WindowRingL = NULL;
X Scr->WarpCursorL = NULL;
X Scr->StickyL = NULL;
X /* remember to put an initialization in InitVariables also
X */
X
X Scr->screen = scrnum;
X Scr->d_depth = DefaultDepth(dpy, scrnum);
X Scr->d_visual = DefaultVisual(dpy, scrnum);
X Scr->Root = RootWindow(dpy, scrnum);
X XSaveContext (dpy, Scr->Root, ScreenContext, (caddr_t) Scr);
X Scr->VirtualDesktop = None;
X Scr->Panner = None;
X Scr->PannerScale = DEFAULT_PANNER_SCALE;
X Scr->PannerState = NormalState;
X Scr->PannerGeometry = DEFAULT_PANNER_GEOMETRY;
X
X Scr->TwmRoot.cmaps.number_cwins = 1;
X Scr->TwmRoot.cmaps.cwins =
X (ColormapWindow **) malloc(sizeof(ColormapWindow *));
X Scr->TwmRoot.cmaps.cwins[0] =
X CreateColormapWindow(Scr->Root, True, False);
X Scr->TwmRoot.cmaps.cwins[0]->visibility = VisibilityPartiallyObscured;
X
X Scr->cmapInfo.cmaps = NULL;
X Scr->cmapInfo.maxCmaps =
X MaxCmapsOfScreen(ScreenOfDisplay(dpy, Scr->screen));
X Scr->cmapInfo.root_pushes = 0;
X InstallWindowColormaps(0, &Scr->TwmRoot);
X
X Scr->StdCmapInfo.head = Scr->StdCmapInfo.tail =
X Scr->StdCmapInfo.mru = NULL;
X Scr->StdCmapInfo.mruindex = 0;
X LocateStandardColormaps();
X
X Scr->TBInfo.nleft = Scr->TBInfo.nright = 0;
X Scr->TBInfo.head = NULL;
X Scr->TBInfo.border = 1;
X Scr->TBInfo.width = 0;
X Scr->TBInfo.leftx = 0;
X Scr->TBInfo.titlex = 0;
X
X Scr->MyDisplayWidth = DisplayWidth(dpy, scrnum);
X Scr->MyDisplayHeight = DisplayHeight(dpy, scrnum);
X Scr->MaxWindowWidth = 32767 - Scr->MyDisplayWidth;
X Scr->MaxWindowHeight = 32767 - Scr->MyDisplayHeight;
X
X Scr->XORvalue = (((unsigned long) 1) << Scr->d_depth) - 1;
X
X if (DisplayCells(dpy, scrnum) < 3)
X Scr->Monochrome = MONOCHROME;
X else
X Scr->Monochrome = COLOR;
X
X /* setup default colors */
X Scr->FirstTime = TRUE;
X GetColor(Scr->Monochrome, &black, "black");
X Scr->Black = black;
X GetColor(Scr->Monochrome, &white, "white");
X Scr->White = white;
X
X if (FirstScreen)
X {
X SetFocus ((TwmWindow *)NULL);
X
X /* define cursors */
X
X NewFontCursor(&UpperLeftCursor, "top_left_corner");
X NewFontCursor(&RightButt, "rightbutton");
X NewFontCursor(&LeftButt, "leftbutton");
X NewFontCursor(&MiddleButt, "middlebutton");
X }
X
X Scr->iconmgr.x = 0;
X Scr->iconmgr.y = 0;
X Scr->iconmgr.width = 150;
X Scr->iconmgr.height = 5;
X Scr->iconmgr.next = NULL;
X Scr->iconmgr.prev = NULL;
X Scr->iconmgr.lasti = &(Scr->iconmgr);
X Scr->iconmgr.first = NULL;
X Scr->iconmgr.last = NULL;
X Scr->iconmgr.active = NULL;
X Scr->iconmgr.scr = Scr;
X Scr->iconmgr.columns = 1;
X Scr->iconmgr.count = 0;
X Scr->iconmgr.name = "TWM";
X Scr->iconmgr.icon_name = "Icons";
X
X Scr->IconDirectory = NULL;
X
X Scr->siconifyPm = None;
X Scr->pullPm = None;
X Scr->hilitePm = None;
X Scr->tbpm.xlogo = None;
X Scr->tbpm.resize = None;
X Scr->tbpm.question = None;
X Scr->tbpm.menu = None;
X
X Scr->rootWeave = XCreatePixmapFromBitmapData(dpy, Scr->Root,
X root_weave_bits, root_weave_width, root_weave_height,
X Scr->Black, Scr->White, Scr->d_depth);
X
X InitVariables();
X InitMenus();
X
X /* Parse it once for each screen. */
X ParseTwmrc(InitFile);
X if (Scr->SqueezeTitle == -1) Scr->SqueezeTitle = FALSE;
X if (!Scr->HaveFonts) CreateFonts();
X CreateGCs();
X MakeMenus();
X
X Scr->TitleBarFont.y += Scr->FramePadding;
X Scr->TitleHeight = Scr->TitleBarFont.height + Scr->FramePadding * 2;
X /* make title height be odd so buttons look nice and centered */
X if (!(Scr->TitleHeight & 1)) Scr->TitleHeight++;
X
X InitTitlebarButtons (); /* menus are now loaded! */
X
X XGrabServer(dpy);
X XSync(dpy, 0);
X
X if (Scr->VirtualDesktop) {
X MakeVirtualDesktop(Scr->vdtWidth, Scr->vdtHeight);
X MakePanner();
X SetSWM_VERSION();
X XMapRaised(dpy, Scr->VirtualDesktop);
X }
X
X JunkX = 0;
X JunkY = 0;
X
X XQueryTree(dpy, Scr->Root, &root, &parent, &children, &nchildren);
X CreateIconManagers();
X if (!Scr->NoIconManagers)
X Scr->iconmgr.twm_win->icon = TRUE;
X
X /*
X * weed out icon windows
X */
X for (i = 0; i < nchildren; i++) {
X if (children[i]) {
X XWMHints *wmhintsp = XGetWMHints (dpy, children[i]);
X
X if (wmhintsp) {
X if (wmhintsp->flags & IconWindowHint) {
X for (j = 0; j < nchildren; j++) {
X if (children[j] == wmhintsp->icon_window) {
X children[j] = None;
X break;
X }
X }
X }
X XFree ((char *) wmhintsp);
X }
X }
X }
X
X /*
X * map all of the non-override windows
X */
X for (i = 0; i < nchildren; i++)
X {
X if (children[i] && MappedNotOverride(children[i]))
X {
X XUnmapWindow(dpy, children[i]);
X SimulateMapRequest(children[i]);
X }
X }
X
X if (Scr->ShowIconManager && !Scr->NoIconManagers)
X {
X Scr->iconmgr.twm_win->icon = FALSE;
X if (Scr->iconmgr.count)
X {
X SetMapStateProp (Scr->iconmgr.twm_win, NormalState);
X MapFrame(Scr->iconmgr.twm_win);
X }
X }
X
X
X attributes.border_pixel = Scr->DefaultC.fore;
X attributes.background_pixel = Scr->DefaultC.back;
X attributes.event_mask = (ExposureMask |
X KeyPressMask | ButtonPressMask);
X attributes.backing_store = NotUseful;
X attributes.cursor = XCreateFontCursor (dpy, XC_hand2);
X valuemask = (CWBorderPixel | CWBackPixel | CWEventMask |
X CWBackingStore | CWCursor);
X Scr->InfoWindow = XCreateWindow (dpy, Scr->Root, 0, 0,
X (unsigned int) 5, (unsigned int) 5,
X (unsigned int) BW, 0,
X (unsigned int) CopyFromParent,
X (Visual *) CopyFromParent,
X valuemask, &attributes);
X
X Scr->SizeStringWidth = XTextWidth (Scr->SizeFont.font,
X " 8888 x 8888 ", 13);
X valuemask = (CWBorderPixel | CWBackPixel | CWBitGravity);
X attributes.bit_gravity = NorthWestGravity;
X Scr->SizeWindow = XCreateWindow (dpy, Scr->Root, 0, 0,
X (unsigned int) Scr->SizeStringWidth,
X (unsigned int) (Scr->SizeFont.height +
X SIZE_VINDENT*2),
X (unsigned int) BW, 0,
X (unsigned int) CopyFromParent,
X (Visual *) CopyFromParent,
X valuemask, &attributes);
X
X XUngrabServer(dpy);
X
X FirstScreen = FALSE;
X Scr->FirstTime = FALSE;
X } /* for */
X
X if (numManaged == 0) {
X if (MultiScreen && NumScreens > 0)
X fprintf (stderr, "%s: unable to find any unmanaged screens\n",
X ProgramName);
X exit (1);
X }
X
X RestartPreviousState = False;
X HandlingEvents = TRUE;
X InitEvents();
X HandleEvents();
X}
X
X/***********************************************************************
X *
X * Procedure:
X * InitVariables - initialize twm variables
X *
X ***********************************************************************
X */
X
XInitVariables()
X{
X FreeList(&Scr->BorderColorL);
X FreeList(&Scr->IconBorderColorL);
X FreeList(&Scr->BorderTileForegroundL);
X FreeList(&Scr->BorderTileBackgroundL);
X FreeList(&Scr->TitleForegroundL);
X FreeList(&Scr->TitleBackgroundL);
X FreeList(&Scr->IconForegroundL);
X FreeList(&Scr->IconBackgroundL);
X FreeList(&Scr->IconManagerFL);
X FreeList(&Scr->IconManagerBL);
X FreeList(&Scr->IconMgrs);
X FreeList(&Scr->NoTitle);
X FreeList(&Scr->MakeTitle);
X FreeList(&Scr->AutoRaise);
X FreeList(&Scr->IconNames);
X FreeList(&Scr->NoHighlight);
X FreeList(&Scr->NoStackModeL);
X FreeList(&Scr->NoTitleHighlight);
X FreeList(&Scr->DontIconify);
X FreeList(&Scr->IconMgrNoShow);
X FreeList(&Scr->IconMgrShow);
X FreeList(&Scr->IconifyByUn);
X FreeList(&Scr->StartIconified);
X FreeList(&Scr->IconManagerHighlightL);
X FreeList(&Scr->SqueezeTitleL);
X FreeList(&Scr->DontSqueezeTitleL);
X FreeList(&Scr->WindowRingL);
X FreeList(&Scr->WarpCursorL);
X FreeList(&Scr->StickyL);
X
X NewFontCursor(&Scr->FrameCursor, "top_left_arrow");
X NewFontCursor(&Scr->TitleCursor, "top_left_arrow");
X NewFontCursor(&Scr->IconCursor, "top_left_arrow");
X NewFontCursor(&Scr->IconMgrCursor, "top_left_arrow");
X NewFontCursor(&Scr->MoveCursor, "fleur");
X NewFontCursor(&Scr->ResizeCursor, "fleur");
X NewFontCursor(&Scr->MenuCursor, "sb_left_arrow");
X NewFontCursor(&Scr->ButtonCursor, "hand2");
X NewFontCursor(&Scr->WaitCursor, "watch");
X NewFontCursor(&Scr->SelectCursor, "dot");
X NewFontCursor(&Scr->DestroyCursor, "pirate");
X
X Scr->Ring = NULL;
X Scr->RingLeader = NULL;
X
X Scr->vdtC.fore = black;
X Scr->vdtC.back = white;
X Scr->PannerC.fore = black;
X Scr->PannerC.back = white;
X Scr->DefaultC.fore = black;
X Scr->DefaultC.back = white;
X Scr->BorderColor = black;
X Scr->BorderTileC.fore = black;
X Scr->BorderTileC.back = white;
X Scr->TitleC.fore = black;
X Scr->TitleC.back = white;
X Scr->MenuC.fore = black;
X Scr->MenuC.back = white;
X Scr->MenuTitleC.fore = black;
X Scr->MenuTitleC.back = white;
X Scr->MenuShadowColor = black;
X Scr->IconC.fore = black;
X Scr->IconC.back = white;
X Scr->IconBorderColor = black;
X Scr->IconManagerC.fore = black;
X Scr->IconManagerC.back = white;
X Scr->IconManagerHighlight = black;
X
X Scr->FramePadding = 2; /* values that look "nice" on */
X Scr->TitlePadding = 8; /* 75 and 100dpi displays */
X Scr->ButtonIndent = 1;
X Scr->SizeStringOffset = 0;
X Scr->BorderWidth = BW;
X Scr->IconBorderWidth = BW;
X Scr->UnknownWidth = 0;
X Scr->UnknownHeight = 0;
X Scr->NumAutoRaises = 0;
X Scr->NoDefaults = FALSE;
X Scr->UsePPosition = PPOS_OFF;
X Scr->FocusRoot = TRUE;
X Scr->Focus = NULL;
X Scr->WarpCursor = FALSE;
X Scr->ForceIcon = FALSE;
X Scr->NoGrabServer = FALSE;
X Scr->NoRaiseMove = FALSE;
X Scr->NoRaiseResize = FALSE;
X Scr->NoRaiseDeicon = FALSE;
X Scr->NoRaiseWarp = FALSE;
X Scr->DontMoveOff = FALSE;
X Scr->DoZoom = FALSE;
X Scr->TitleFocus = TRUE;
X Scr->NoTitlebar = FALSE;
X Scr->DecorateTransients = FALSE;
X Scr->IconifyByUnmapping = FALSE;
X Scr->ShowIconManager = FALSE;
X Scr->IconManagerDontShow =FALSE;
X Scr->BackingStore = TRUE;
X Scr->SaveUnder = TRUE;
X Scr->RandomPlacement = FALSE;
X Scr->OpaqueMove = FALSE;
X Scr->Highlight = TRUE;
X Scr->StackMode = TRUE;
X Scr->TitleHighlight = TRUE;
X Scr->MoveDelta = 0;
X Scr->ZoomCount = 8;
X Scr->SortIconMgr = FALSE;
X Scr->Shadow = TRUE;
X Scr->InterpolateMenuColors = FALSE;
X Scr->NoIconManagers = FALSE;
X Scr->ClientBorderWidth = FALSE;
X Scr->SqueezeTitle = -1;
X Scr->FirstRegion = NULL;
X Scr->LastRegion = NULL;
X Scr->FirstTime = TRUE;
X Scr->HaveFonts = FALSE; /* i.e. not loaded yet */
X Scr->CaseSensitive = TRUE;
X Scr->WarpUnmapped = FALSE;
X
X /* setup default fonts; overridden by defaults from system.twmrc */
X#define DEFAULT_NICE_FONT "variable"
X#define DEFAULT_FAST_FONT "fixed"
X
X Scr->TitleBarFont.font = NULL;
X Scr->TitleBarFont.name = DEFAULT_NICE_FONT;
X Scr->MenuFont.font = NULL;
X Scr->MenuFont.name = DEFAULT_NICE_FONT;
X Scr->IconFont.font = NULL;
X Scr->IconFont.name = DEFAULT_NICE_FONT;
X Scr->SizeFont.font = NULL;
X Scr->SizeFont.name = DEFAULT_FAST_FONT;
X Scr->IconManagerFont.font = NULL;
X Scr->IconManagerFont.name = DEFAULT_NICE_FONT;
X Scr->DefaultFont.font = NULL;
X Scr->DefaultFont.name = DEFAULT_FAST_FONT;
X
X}
X
X
XCreateFonts ()
X{
X GetFont(&Scr->TitleBarFont);
X GetFont(&Scr->MenuFont);
X GetFont(&Scr->IconFont);
X GetFont(&Scr->SizeFont);
X GetFont(&Scr->IconManagerFont);
X GetFont(&Scr->DefaultFont);
X Scr->HaveFonts = TRUE;
X}
X
X
XRestoreWithdrawnLocation (tmp)
X TwmWindow *tmp;
X{
X int gravx, gravy;
X unsigned int bw, mask;
X XWindowChanges xwc;
X
X if (XGetGeometry (dpy, tmp->w, &JunkRoot, &xwc.x, &xwc.y,
X &JunkWidth, &JunkHeight, &bw, &JunkDepth)) {
X
X GetGravityOffsets (tmp, &gravx, &gravy);
X if (gravy < 0) xwc.y -= tmp->title_height;
X
X if (bw != tmp->old_bw) {
X int xoff, yoff;
X
X if (!Scr->ClientBorderWidth) {
X xoff = gravx;
X yoff = gravy;
X } else {
X xoff = 0;
X yoff = 0;
X }
X
X xwc.x -= (xoff + 1) * tmp->old_bw;
X xwc.y -= (yoff + 1) * tmp->old_bw;
X }
X if (!Scr->ClientBorderWidth) {
X xwc.x += gravx * tmp->frame_bw;
X xwc.y += gravy * tmp->frame_bw;
X }
X
X mask = (CWX | CWY);
X if (bw != tmp->old_bw) {
X xwc.border_width = tmp->old_bw;
X mask |= CWBorderWidth;
X }
X
X XConfigureWindow (dpy, tmp->w, mask, &xwc);
X
X if (tmp->wmhints && (tmp->wmhints->flags & IconWindowHint)) {
X XUnmapWindow (dpy, tmp->wmhints->icon_window);
X }
X
X }
X}
X
X
X/***********************************************************************
X *
X * Procedure:
X * Done - cleanup and exit twm
X *
X * Returned Value:
X * none
X *
X * Inputs:
X * none
X *
X * Outputs:
X * none
X *
X * Special Considerations:
X * none
X *
X ***********************************************************************
X */
X
Xvoid Reborder ()
X{
X TwmWindow *tmp; /* temp twm window structure */
X int scrnum;
X extern Atom XA_SWM_ROOT;
X
X /* put a border back around all windows */
X
X XGrabServer (dpy);
X for (scrnum = 0; scrnum < NumScreens; scrnum++)
X {
X if ((Scr = ScreenList[scrnum]) == NULL)
X continue;
X
X RemoveSWM_VERSION();
X InstallWindowColormaps (0, &Scr->TwmRoot); /* force reinstall */
X for (tmp = Scr->TwmRoot.next; tmp != NULL; tmp = tmp->next)
X {
X RestoreWithdrawnLocation (tmp);
X XDeleteProperty(dpy, tmp->w, XA_SWM_ROOT);
X XMapWindow (dpy, tmp->w);
X }
X
X /* cleanup all windows on the virtual root */
X if (Scr->VirtualDesktop)
X {
X Window root_return,parent_return,*children;
X unsigned int num_children;
X int i;
X int x, y;
X unsigned int width, height, bw, depth;
X
X XQueryTree(dpy, Scr->VirtualDesktop, &root_return,&parent_return, &children, &num_children);
X
X for (i = 0; i < num_children; i++)
X {
X XGetGeometry(dpy, children[i], &root_return, &x, &y, &width, &height, &bw, &depth);
X XReparentWindow(dpy, children[i], Scr->Root, x, y);
X XRemoveFromSaveSet(dpy, children[i]);
X }
X }
X }
X
X XUngrabServer (dpy);
X SetFocus ((TwmWindow*)NULL);
X}
X
Xvoid Done()
X{
X Reborder ();
X XCloseDisplay(dpy);
X exit(0);
X}
X
X
X/*
X * Error Handlers. If a client dies, we'll get a BadWindow error (except for
X * GetGeometry which returns BadDrawable) for most operations that we do before
X * manipulating the client's window.
X */
X
XBool ErrorOccurred = False;
XXErrorEvent LastErrorEvent;
X
Xstatic int TwmErrorHandler(dpy, event)
X Display *dpy;
X XErrorEvent *event;
X{
X LastErrorEvent = *event;
X ErrorOccurred = True;
X
X if (PrintErrorMessages && /* don't be too obnoxious */
X event->error_code != BadWindow && /* watch for dead puppies */
X (event->request_code != X_GetGeometry && /* of all styles */
X event->error_code != BadDrawable))
X XmuPrintDefaultErrorMessage (dpy, event, stderr);
X return 0;
X}
X
X
X/* ARGSUSED*/
Xstatic int CatchRedirectError(dpy, event)
X Display *dpy;
X XErrorEvent *event;
X{
X RedirectError = TRUE;
X LastErrorEvent = *event;
X ErrorOccurred = True;
X return 0;
X}
X
X
XAtom _XA_WM_CHANGE_STATE;
XAtom _XA_WM_STATE;
XAtom _XA_WM_COLORMAP_WINDOWS;
XAtom _XA_WM_PROTOCOLS;
XAtom _XA_WM_TAKE_FOCUS;
XAtom _XA_WM_SAVE_YOURSELF;
XAtom _XA_WM_DELETE_WINDOW;
XAtom _XA_TWM_FLAGS;
X
XInternUsefulAtoms ()
X{
X _XA_WM_CHANGE_STATE = XInternAtom (dpy, "WM_CHANGE_STATE", False);
X _XA_WM_STATE = XInternAtom (dpy, "WM_STATE", False);
X _XA_WM_COLORMAP_WINDOWS = XInternAtom (dpy, "WM_COLORMAP_WINDOWS", False);
X _XA_WM_PROTOCOLS = XInternAtom (dpy, "WM_PROTOCOLS", False);
X _XA_WM_TAKE_FOCUS = XInternAtom (dpy, "WM_TAKE_FOCUS", False);
X _XA_WM_SAVE_YOURSELF = XInternAtom (dpy, "WM_SAVE_YOURSELF", False);
X _XA_WM_DELETE_WINDOW = XInternAtom (dpy, "WM_DELETE_WINDOW", False);
X _XA_TWM_FLAGS = XInternAtom (dpy, "_TWM_FLAGS", False);
X}
SHAR_EOF
if test 25011 -ne "`wc -c < twm.c`"
then
echo shar: error transmitting "twm.c" '(should have been 25011 characters)'
fi
fi
if test -f 'twm.h'
then
echo shar: will not over-write existing file "twm.h"
else
echo extracting "twm.h"
sed 's/^X//' >twm.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: twm.h,v 1.62 90/03/22 09:39:08 jim Exp $
X *
X * twm include file
X *
X * 28-Oct-87 Thomas E. LaStrange File created
X *
X ***********************************************************************/
X
X#ifndef _TWM_
X#define _TWM_
X
X#include <X11/Xlib.h>
X#include <X11/Xutil.h>
X#include <X11/cursorfont.h>
X#ifdef SHAPE
X#include <X11/extensions/shape.h>
X#endif
X
X#ifndef WithdrawnState
X#define WithdrawnState 0
X#endif
X
Xtypedef unsigned long Pixel;
X
X#ifdef SIGNALRETURNSINT
Xtypedef int (*SigProc)(); /* type of function returned by signal() */
X#else
Xtypedef void (*SigProc)(); /* type of function returned by signal() */
X#endif
X
X
X#define BW 2 /* border width */
X#define BW2 4 /* border width * 2 */
X
X#ifndef TRUE
X#define TRUE 1
X#define FALSE 0
X#endif
X
X#define NULLSTR ((char *) NULL)
X
X#define MAX_BUTTONS 5 /* max mouse buttons supported */
X
X/* info stings defines */
X#define INFO_LINES 30
X#define INFO_SIZE 200
X
X/* contexts for button presses */
X#define C_NO_CONTEXT -1
X#define C_WINDOW 0
X#define C_TITLE 1
X#define C_ICON 2
X#define C_ROOT 3
X#define C_FRAME 4
X#define C_ICONMGR 5
X#define C_NAME 6
X#define NUM_CONTEXTS 7
X
X#define C_WINDOW_BIT (1 << C_WINDOW)
X#define C_TITLE_BIT (1 << C_TITLE)
X#define C_ICON_BIT (1 << C_ICON)
X#define C_ROOT_BIT (1 << C_ROOT)
X#define C_FRAME_BIT (1 << C_FRAME)
X#define C_ICONMGR_BIT (1 << C_ICONMGR)
X#define C_NAME_BIT (1 << C_NAME)
X
X#define C_ALL_BITS (C_WINDOW_BIT | C_TITLE_BIT | C_ICON_BIT |\
X C_ROOT_BIT | C_FRAME_BIT | C_ICONMGR_BIT)
X
X/* modifiers for button presses */
X#define MOD_SIZE ((ShiftMask | ControlMask | Mod1Mask) + 1)
X
X#define TITLE_BAR_SPACE 1 /* 2 pixel space bordering chars */
X#define TITLE_BAR_FONT_HEIGHT 15 /* max of 15 pixel high chars */
X#define TITLE_BAR_HEIGHT (TITLE_BAR_FONT_HEIGHT+(2*TITLE_BAR_SPACE))
X
X/* defines for zooming/unzooming */
X#define ZOOM_NONE 0
X
X#define FBF(fix_fore, fix_back, fix_font)\
X Gcv.foreground = fix_fore;\
X Gcv.background = fix_back;\
X Gcv.font = fix_font;\
X XChangeGC(dpy, Scr->NormalGC, GCFont|GCForeground|GCBackground,&Gcv)
X
X#define FB(fix_fore, fix_back)\
X Gcv.foreground = fix_fore;\
X Gcv.background = fix_back;\
X XChangeGC(dpy, Scr->NormalGC, GCForeground|GCBackground,&Gcv)
X
Xtypedef struct MyFont
X{
X char *name; /* name of the font */
X XFontStruct *font; /* font structure */
X int height; /* height of the font */
X int y; /* Y coordinate to draw characters */
X} MyFont;
X
Xtypedef struct ColorPair
X{
X Pixel fore, back;
X} ColorPair;
X
Xtypedef struct _TitleButton {
X struct _TitleButton *next; /* next link in chain */
X char *name; /* bitmap name in case of deferal */
X Pixmap bitmap; /* image to display in button */
X int srcx, srcy; /* from where to start copying */
X unsigned int width, height; /* size of pixmap */
X int dstx, dsty; /* to where to start copying */
X int func; /* function to execute */
X char *action; /* optional action arg */
X struct MenuRoot *menuroot; /* menu to pop on F_MENU */
X Bool rightside; /* t: on right, f: on left */
X} TitleButton;
X
Xtypedef struct _TBWindow {
X Window window; /* which window in this frame */
X TitleButton *info; /* description of this window */
X} TBWindow;
X
Xtypedef struct _SqueezeInfo {
X int justify; /* left, center, right */
X int num; /* signed pixel count or numerator */
X int denom; /* 0 for pix count or denominator */
X} SqueezeInfo;
X
X#define J_LEFT 1
X#define J_CENTER 2
X#define J_RIGHT 3
X
X/* Colormap window entry for each window in WM_COLORMAP_WINDOWS
X * ICCCM property.
X */
Xtypedef struct TwmColormap
X{
X Colormap c; /* Colormap id */
X int state; /* install(ability) state */
X unsigned long install_req; /* request number which installed it */
X Window w; /* window causing load of color table */
X int refcnt;
X} TwmColormap;
X
X#define CM_INSTALLABLE 1
X#define CM_INSTALLED 2
X#define CM_INSTALL 4
X
Xtypedef struct ColormapWindow
X{
X Window w; /* Window id */
X TwmColormap *colormap; /* Colormap for this window */
X int visibility; /* Visibility of this window */
X int refcnt;
X} ColormapWindow;
X
Xtypedef struct Colormaps
X{
X ColormapWindow **cwins; /* current list of colormap windows */
X int number_cwins; /* number of elements in current list */
X char *scoreboard; /* conflicts between installable colortables */
X} Colormaps;
X
X#define ColormapsScoreboardLength(cm) ((cm)->number_cwins * \
X ((cm)->number_cwins - 1) / 2)
X
X/* Bit definitions for the _TWM_FLAGS property. This property
X * will be used to store state information to be used if
X * RestartPreviousState is set
X */
X#define TWM_FLAGS_STICKY (1 << 0)
X
X/* for each window that is on the display, one of these structures
X * is allocated and linked into a list
X */
Xtypedef struct TwmWindow
X{
X struct TwmWindow *next; /* next twm window */
X struct TwmWindow *prev; /* previous twm window */
X Window w; /* the child window */
X Window root; /* its idea of the root window */
X Window virtualWindow; /* small panner prepresentation */
X Window virtualIcon; /* small panner prepresentation */
X unsigned long flags; /* _TWM_FLAGS property value */
X int old_bw; /* border width before reparenting */
X Window frame; /* the frame window */
X Window title_w; /* the title bar window */
X Window hilite_w; /* the hilite window */
X Pixmap gray;
X Window icon_w; /* the icon window */
X Window icon_bm_w; /* the icon bitmap window */
X int frame_x; /* x position of frame */
X int frame_y; /* y position of frame */
X int frame_width; /* width of frame */
X int frame_height; /* height of frame */
X int frame_bw; /* borderwidth of frame */
X int title_x;
X int title_y;
X int icon_loc_x; /* icon x coordinate */
X int icon_loc_y; /* icon y coordiante */
X int icon_x; /* icon text x coordinate */
X int icon_y; /* icon text y coordiante */
X int icon_w_width; /* width of the icon window */
X int icon_w_height; /* height of the icon window */
X int icon_width; /* width of the icon bitmap */
X int icon_height; /* height of the icon bitmap */
X int title_height; /* height of the title bar */
X int title_width; /* width of the title bar */
X char *full_name; /* full name of the window */
X char *name; /* name of the window */
X char *icon_name; /* name of the icon */
X int name_width; /* width of name text */
X int highlightx; /* start of highlight window */
X int rightx; /* start of right buttons */
X XWindowAttributes attr; /* the child window attributes */
X XSizeHints hints; /* normal hints */
X XWMHints *wmhints; /* WM hints */
X Window group; /* group ID */
X XClassHint class;
X struct WList *list;
X /***********************************************************************
X * color definitions per window
X **********************************************************************/
X Pixel border; /* border color */
X Pixel icon_border; /* border color */
X ColorPair border_tile;
X ColorPair title;
X ColorPair iconc;
X short iconified; /* has the window ever been iconified? */
X short icon; /* is the window an icon now ? */
X short icon_on; /* is the icon visible */
X short mapped; /* is the window mapped ? */
X short auto_raise; /* should we auto-raise this window ? */
X short forced; /* has had an icon forced upon it */
X short icon_not_ours; /* icon pixmap or window supplied to us */
X short icon_moved; /* user explicitly moved the icon */
X short highlight; /* should highlight this window */
X short stackmode; /* honor stackmode requests */
X short iconify_by_unmapping; /* unmap window to iconify it */
X short iconmgr; /* this is an icon manager window */
X short transient; /* this is a transient window */
X short titlehighlight; /* should I highlight the title bar */
X short sticky; /* is the window sticky */
X struct IconMgr *iconmgrp; /* pointer to it if this is an icon manager */
X int save_frame_x; /* x position of frame */
X int save_frame_y; /* y position of frame */
X int save_frame_width; /* width of frame */
X int save_frame_height; /* height of frame */
X short zoomed; /* is the window zoomed? */
X#ifdef SHAPE
X short wShaped; /* this window has a bounding shape */
X#endif
X unsigned long protocols; /* which protocols this window handles */
X Colormaps cmaps; /* colormaps for this application */
X TBWindow *titlebuttons;
X SqueezeInfo *squeeze_info; /* should the title be squeezed? */
X struct {
X struct TwmWindow *next, *prev;
X Bool cursor_valid;
X int curs_x, curs_y;
X } ring;
X} TwmWindow;
X
X#define DoesWmTakeFocus (1L << 0)
X#define DoesWmSaveYourself (1L << 1)
X#define DoesWmDeleteWindow (1L << 2)
X
X#define TBPM_XLOGO ":xlogo" /* name of titlebar pixmap for xlogo */
X#define TBPM_ICONIFY ":iconify" /* same image as xlogo */
X#define TBPM_RESIZE ":resize" /* name of titlebar pixmap for resize button */
X#define TBPM_QUESTION ":question" /* name of unknown titlebar pixmap */
X#define TBPM_MENU ":menu" /* name of titlebar pixmap for menus */
X
Xextern char *malloc(), *calloc(), *realloc(), *getenv();
Xextern void free();
Xextern void Reborder(), Done();
Xvoid ComputeCommonTitleOffsets();
Xvoid ComputeWindowTitleOffsets(), ComputeTitleLocation();
Xextern char *ProgramName;
Xextern Display *dpy;
Xextern Window ResizeWindow; /* the window we are resizing */
X#ifdef SHAPE
Xextern int HasShape; /* this server supports Shape extension */
X#endif
X
Xextern int PreviousScreen;
X
Xextern Cursor UpperLeftCursor;
Xextern Cursor RightButt;
Xextern Cursor MiddleButt;
Xextern Cursor LeftButt;
X
Xextern XClassHint NoClass;
X
Xextern XContext VirtualContext;
Xextern XContext TwmContext;
Xextern XContext MenuContext;
Xextern XContext IconManagerContext;
Xextern XContext ScreenContext;
Xextern XContext ColormapContext;
X
Xextern char *Home;
Xextern int HomeLen;
Xextern int ParseError;
X
Xextern int HandlingEvents;
X
Xextern Window JunkRoot;
Xextern Window JunkChild;
Xextern int JunkX;
Xextern int JunkY;
Xextern unsigned int JunkWidth, JunkHeight, JunkBW, JunkDepth, JunkMask;
Xextern XGCValues Gcv;
Xextern int InfoLines;
Xextern char Info[][INFO_SIZE];
Xextern int Argc;
Xextern char **Argv;
Xextern char **Environ;
Xextern void NewFontCursor();
X
Xextern Bool ErrorOccurred;
Xextern XErrorEvent LastErrorEvent;
X
X#define ResetError() (ErrorOccurred = False)
X
Xextern Bool RestartPreviousState;
Xextern Bool GetWMState();
X
Xextern Atom _XA_WM_CHANGE_STATE;
Xextern Atom _XA_WM_STATE;
Xextern Atom _XA_WM_COLORMAP_WINDOWS;
Xextern Atom _XA_WM_PROTOCOLS;
Xextern Atom _XA_WM_TAKE_FOCUS;
Xextern Atom _XA_WM_SAVE_YOURSELF;
Xextern Atom _XA_WM_DELETE_WINDOW;
Xextern Atom _XA_TWM_FLAGS;
X
X#endif /* _TWM_ */
SHAR_EOF
if test 12901 -ne "`wc -c < twm.h`"
then
echo shar: error transmitting "twm.h" '(should have been 12901 characters)'
fi
fi
# end of shell archive
exit 0
dan
----------------------------------------------------
O'Reilly && Associates argv at sun.com / argv at ora.com
Opinions expressed reflect those of the author only.
More information about the Comp.sources.x
mailing list