ctwm.h revision 0bbfda8a
10bbfda8aSnia/* 20bbfda8aSnia * Copyright 1988 by Evans & Sutherland Computer Corporation, 30bbfda8aSnia * Salt Lake City, Utah 40bbfda8aSnia * Portions Copyright 1989 by the Massachusetts Institute of Technology 50bbfda8aSnia * Cambridge, Massachusetts 6645f5050Syouri * 70bbfda8aSnia * $XConsortium: twm.h,v 1.74 91/05/31 17:38:30 dave Exp $ 8645f5050Syouri * 90bbfda8aSnia * twm include file 10645f5050Syouri * 110bbfda8aSnia * 28-Oct-87 Thomas E. LaStrange File created 120bbfda8aSnia * 10-Oct-90 David M. Sternlicht Storeing saved colors on root 130bbfda8aSnia * 140bbfda8aSnia * Copyright 1992 Claude Lecommandeur. 150bbfda8aSnia */ 160bbfda8aSnia#ifndef _CTWM_CTWM_H 170bbfda8aSnia#define _CTWM_CTWM_H 180bbfda8aSnia 190bbfda8aSnia/* 200bbfda8aSnia * Include config first, before anything else. Including ctwm.h should 210bbfda8aSnia * be the first action of any of our files, so this happens before 220bbfda8aSnia * ANYthing else, anywhere. 230bbfda8aSnia */ 240bbfda8aSnia#include "ctwm_config.h" 250bbfda8aSnia 260bbfda8aSnia#ifdef DMALLOC 270bbfda8aSnia#include <dmalloc.h> 280bbfda8aSnia#endif 290bbfda8aSnia 300bbfda8aSnia#include <stdbool.h> 310bbfda8aSnia 320bbfda8aSnia/* 330bbfda8aSnia * Intrinsic.h is needed for at least the Pixel type, which we use in 340bbfda8aSnia * this file. And Intrinsic.h (always?) implicitly brings in Xlib.h 350bbfda8aSnia * anyway. 360bbfda8aSnia */ 370bbfda8aSnia//#include <X11/Xlib.h> 380bbfda8aSnia#include <X11/Intrinsic.h> 390bbfda8aSnia 400bbfda8aSnia#include "types.h" 410bbfda8aSnia#ifdef EWMH 420bbfda8aSnia#include "ewmh.h" 430bbfda8aSnia#endif 440bbfda8aSnia 450bbfda8aSnia/* 460bbfda8aSnia * This appears to be the standard way of testing this for portability, 470bbfda8aSnia * though calling it GNUC is sorta non-portable portability :) 480bbfda8aSnia */ 490bbfda8aSnia#ifndef __GNUC__ 500bbfda8aSnia#define __attribute__(x) /*NOTHING*/ 510bbfda8aSnia#endif 520bbfda8aSnia 530bbfda8aSnia/* signal(3) handlers have been void since c89 */ 540bbfda8aSnia#define SIGNAL_T void 550bbfda8aSnia 560bbfda8aSnia#define BW 2 /* border width */ 570bbfda8aSnia#define BW2 4 /* border width * 2 */ 580bbfda8aSnia 590bbfda8aSnia#define MAX_BUTTONS 11 /* max mouse buttons supported */ 600bbfda8aSnia 610bbfda8aSnia/* contexts for button presses */ 620bbfda8aSnia#define Alt1Mask (1<<8) 630bbfda8aSnia#define Alt2Mask (1<<9) 640bbfda8aSnia#define Alt3Mask (1<<10) 650bbfda8aSnia#define Alt4Mask (1<<11) 660bbfda8aSnia#define Alt5Mask (1<<12) 670bbfda8aSnia 680bbfda8aSnia#define C_NO_CONTEXT -1 690bbfda8aSnia#define C_WINDOW 0 700bbfda8aSnia#define C_TITLE 1 710bbfda8aSnia#define C_ICON 2 720bbfda8aSnia#define C_ROOT 3 730bbfda8aSnia#define C_FRAME 4 740bbfda8aSnia#define C_ICONMGR 5 750bbfda8aSnia#define C_NAME 6 760bbfda8aSnia#define C_IDENTIFY 7 770bbfda8aSnia#define C_ALTERNATE 8 780bbfda8aSnia#define C_WORKSPACE 9 790bbfda8aSnia#define NUM_CONTEXTS 10 800bbfda8aSnia 810bbfda8aSnia#define C_WINDOW_BIT (1 << C_WINDOW) 820bbfda8aSnia#define C_TITLE_BIT (1 << C_TITLE) 830bbfda8aSnia#define C_ICON_BIT (1 << C_ICON) 840bbfda8aSnia#define C_ROOT_BIT (1 << C_ROOT) 850bbfda8aSnia#define C_FRAME_BIT (1 << C_FRAME) 860bbfda8aSnia#define C_ICONMGR_BIT (1 << C_ICONMGR) 870bbfda8aSnia#define C_NAME_BIT (1 << C_NAME) 880bbfda8aSnia#define C_ALTER_BIT (1 << C_ALTERNATE) 890bbfda8aSnia#define C_WORKSPACE_BIT (1 << C_WORKSPACE) 900bbfda8aSnia 910bbfda8aSnia#define C_ALL_BITS (C_WINDOW_BIT | C_TITLE_BIT | C_ICON_BIT |\ 920bbfda8aSnia C_ROOT_BIT | C_FRAME_BIT | C_ICONMGR_BIT |\ 930bbfda8aSnia C_WORKSPACE_BIT) 940bbfda8aSnia 950bbfda8aSnia/* modifiers for button presses */ 960bbfda8aSnia#define MOD_SIZE ((ShiftMask | ControlMask | Mod1Mask \ 970bbfda8aSnia | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask) + 1) 980bbfda8aSnia 990bbfda8aSnia/* 1000bbfda8aSnia * Used for TwmWindow.zoomed. Var holds the number of the function that 1010bbfda8aSnia * caused zooming, if one has, else ZOOM_NONE. This mirror F_NOP 1020bbfda8aSnia * currently, but that's OK, because f.nop doesn't do anything, so it 1030bbfda8aSnia * can't be a real cause of zooming. 1040bbfda8aSnia */ 1050bbfda8aSnia#define ZOOM_NONE 0 1060bbfda8aSnia 1070bbfda8aSnia#define FBF(fix_fore, fix_back, fix_font)\ 1080bbfda8aSnia Gcv.foreground = fix_fore;\ 1090bbfda8aSnia Gcv.background = fix_back;\ 1100bbfda8aSnia Gcv.font = fix_font;\ 1110bbfda8aSnia XChangeGC(dpy, Scr->NormalGC, GCFont|GCForeground|GCBackground,&Gcv) 1120bbfda8aSnia 1130bbfda8aSnia#define FB(fix_fore, fix_back)\ 1140bbfda8aSnia Gcv.foreground = fix_fore;\ 1150bbfda8aSnia Gcv.background = fix_back;\ 1160bbfda8aSnia XChangeGC(dpy, Scr->NormalGC, GCForeground|GCBackground,&Gcv) 1170bbfda8aSnia 1180bbfda8aSnia#define MaxSize(a, b) (((a) < (b)) ? (b) : (a)) 1190bbfda8aSnia#define MinSize(a, b) (((a) > (b)) ? (b) : (a)) 1200bbfda8aSnia 1210bbfda8aSniastruct MyFont { 1220bbfda8aSnia char *basename; /* name of the font */ 1230bbfda8aSnia XFontSet font_set; 1240bbfda8aSnia int ascent; 1250bbfda8aSnia int descent; 1260bbfda8aSnia int height; /* height of the font */ 1270bbfda8aSnia int y; /* Y coordinate to draw characters */ 1280bbfda8aSnia /* Average height, maintained using the extra two auxiliary fields. */ 1290bbfda8aSnia unsigned int avg_height; 1300bbfda8aSnia float avg_fheight; 1310bbfda8aSnia unsigned int avg_count; 1320bbfda8aSnia}; 1330bbfda8aSnia 1340bbfda8aSniastruct ColorPair { 1350bbfda8aSnia Pixel fore, back, shadc, shadd; 1360bbfda8aSnia}; 1370bbfda8aSnia 1380bbfda8aSniastruct TitleButtonFunc { 1390bbfda8aSnia struct TitleButtonFunc *next; /* next in the list of function buttons */ 1400bbfda8aSnia int num; /* button number */ 1410bbfda8aSnia int mods; /* modifiers */ 1420bbfda8aSnia int func; /* function to execute */ 1430bbfda8aSnia char *action; /* optional action arg */ 1440bbfda8aSnia struct MenuRoot *menuroot; /* menu to pop on F_MENU */ 1450bbfda8aSnia}; 1460bbfda8aSnia 1470bbfda8aSniastruct TitleButton { 1480bbfda8aSnia struct TitleButton *next; /* next link in chain */ 1490bbfda8aSnia char *name; /* bitmap name in case of deferal */ 1500bbfda8aSnia Image *image; /* image to display in button */ 1510bbfda8aSnia int srcx, srcy; /* from where to start copying */ 1520bbfda8aSnia unsigned int width, height; /* size of pixmap */ 1530bbfda8aSnia int dstx, dsty; /* to where to start copying */ 1540bbfda8aSnia bool rightside; /* t: on right, f: on left */ 1550bbfda8aSnia TitleButtonFunc *funs; /* funcs assoc'd to each button */ 1560bbfda8aSnia}; 1570bbfda8aSnia 1580bbfda8aSniastruct TBWindow { 1590bbfda8aSnia Window window; /* which window in this frame */ 1600bbfda8aSnia Image *image; /* image to display in button */ 1610bbfda8aSnia TitleButton *info; /* description of this window */ 1620bbfda8aSnia}; 1630bbfda8aSnia 1640bbfda8aSnia 1650bbfda8aSniatypedef enum { 1660bbfda8aSnia SIJ_LEFT, 1670bbfda8aSnia SIJ_CENTER, 1680bbfda8aSnia SIJ_RIGHT, 1690bbfda8aSnia} SIJust; 1700bbfda8aSnia 1710bbfda8aSniastruct SqueezeInfo { 1720bbfda8aSnia SIJust justify; 1730bbfda8aSnia int num; /* signed pixel count or numerator */ 1740bbfda8aSnia int denom; /* 0 for pix count or denominator */ 1750bbfda8aSnia}; 1760bbfda8aSnia 1770bbfda8aSnia 1780bbfda8aSnia/* 1790bbfda8aSnia * Type for IconRegion alignment and config entries relating 1800bbfda8aSnia * 1810bbfda8aSnia * Misspeelt for hysterical raisins 1820bbfda8aSnia */ 1830bbfda8aSniatypedef enum { 1840bbfda8aSnia IRA_UNDEF, 1850bbfda8aSnia IRA_TOP, 1860bbfda8aSnia IRA_CENTER, 1870bbfda8aSnia IRA_BOTTOM, 1880bbfda8aSnia IRA_BORDER, 1890bbfda8aSnia} IRAlignement; 1900bbfda8aSnia 1910bbfda8aSnia/* 1920bbfda8aSnia * Justification for title stuff. Window titles (TitleJustification), 1930bbfda8aSnia * icon titles (IconJustification). _Not_ the same as for 1940bbfda8aSnia * IconRegionJustification. 1950bbfda8aSnia */ 1960bbfda8aSniatypedef enum { 1970bbfda8aSnia TJ_UNDEF, 1980bbfda8aSnia TJ_LEFT, 1990bbfda8aSnia TJ_CENTER, 2000bbfda8aSnia TJ_RIGHT, 2010bbfda8aSnia} TitleJust; 2020bbfda8aSnia 2030bbfda8aSnia/* 2040bbfda8aSnia * And IconRegion Justification's. 2050bbfda8aSnia */ 2060bbfda8aSniatypedef enum { 2070bbfda8aSnia IRJ_UNDEF, 2080bbfda8aSnia IRJ_LEFT, 2090bbfda8aSnia IRJ_CENTER, 2100bbfda8aSnia IRJ_RIGHT, 2110bbfda8aSnia IRJ_BORDER, 2120bbfda8aSnia} IRJust; 2130bbfda8aSnia 2140bbfda8aSnia 2150bbfda8aSnia/* 2160bbfda8aSnia * Gravity used by IconRegion and WindowRegion. Strictly, there should 2170bbfda8aSnia * probably be separate vertical/horizontal types, but it'll take some 2180bbfda8aSnia * nontrivial code reshuffling to make that possible because of how the 2190bbfda8aSnia * values are used in the split* functions. 2200bbfda8aSnia */ 2210bbfda8aSniatypedef enum { 2220bbfda8aSnia GRAV_NORTH, 2230bbfda8aSnia GRAV_EAST, 2240bbfda8aSnia GRAV_SOUTH, 2250bbfda8aSnia GRAV_WEST, 2260bbfda8aSnia} RegGravity; 2270bbfda8aSnia 2280bbfda8aSnia 2290bbfda8aSnia/* RandomPlacement bits */ 2300bbfda8aSniatypedef enum { 2310bbfda8aSnia RP_OFF, 2320bbfda8aSnia RP_ALL, 2330bbfda8aSnia RP_UNMAPPED, 2340bbfda8aSnia} RandPlac; 2350bbfda8aSnia 2360bbfda8aSnia/* UsePPosition */ 2370bbfda8aSniatypedef enum { 2380bbfda8aSnia PPOS_OFF, 2390bbfda8aSnia PPOS_ON, 2400bbfda8aSnia PPOS_NON_ZERO, 2410bbfda8aSnia /* 2420bbfda8aSnia * may eventually want an option for having the PPosition be the 2430bbfda8aSnia * initial location for the drag lines. 2440bbfda8aSnia */ 2450bbfda8aSnia} UsePPoss; 2460bbfda8aSnia 2470bbfda8aSnia 2480bbfda8aSnia/* Colormap window entry for each window in WM_COLORMAP_WINDOWS 2490bbfda8aSnia * ICCCM property. 2500bbfda8aSnia */ 2510bbfda8aSniastruct TwmColormap { 2520bbfda8aSnia Colormap c; /* Colormap id */ 2530bbfda8aSnia int state; /* install(ability) state */ 2540bbfda8aSnia unsigned long install_req; /* request number which installed it */ 2550bbfda8aSnia Window w; /* window causing load of color table */ 2560bbfda8aSnia int refcnt; 2570bbfda8aSnia}; 2580bbfda8aSnia 2590bbfda8aSnia/* TwmColormap.state bit definitions */ 2600bbfda8aSnia#define CM_INSTALLABLE 1 2610bbfda8aSnia#define CM_INSTALLED 2 2620bbfda8aSnia#define CM_INSTALL 4 2630bbfda8aSnia 2640bbfda8aSnia 2650bbfda8aSniastruct ColormapWindow { 2660bbfda8aSnia Window w; /* Window id */ 2670bbfda8aSnia TwmColormap *colormap; /* Colormap for this window */ 2680bbfda8aSnia int visibility; /* Visibility of this window */ 2690bbfda8aSnia int refcnt; 2700bbfda8aSnia}; 2710bbfda8aSnia 2720bbfda8aSniastruct Colormaps { 2730bbfda8aSnia ColormapWindow **cwins; /* current list of colormap windows */ 2740bbfda8aSnia int number_cwins; /* number of elements in current list */ 2750bbfda8aSnia char *scoreboard; /* conflicts between installable colortables */ 2760bbfda8aSnia}; 2770bbfda8aSnia 2780bbfda8aSnia#define ColormapsScoreboardLength(cm) ((cm)->number_cwins * \ 2790bbfda8aSnia ((cm)->number_cwins - 1) / 2) 2800bbfda8aSnia 2810bbfda8aSniastruct WindowRegion { 2820bbfda8aSnia struct WindowRegion *next; 2830bbfda8aSnia int x, y, w, h; 2840bbfda8aSnia RegGravity grav1, grav2; 2850bbfda8aSnia name_list *clientlist; 2860bbfda8aSnia struct WindowEntry *entries; 2870bbfda8aSnia}; 2880bbfda8aSnia 2890bbfda8aSniastruct WindowEntry { 2900bbfda8aSnia struct WindowEntry *next; 2910bbfda8aSnia int x, y, w, h; 2920bbfda8aSnia struct TwmWindow *twm_win; 2930bbfda8aSnia bool used; 2940bbfda8aSnia}; 2950bbfda8aSnia 2960bbfda8aSniastruct WindowBox { 2970bbfda8aSnia struct WindowBox *next; 2980bbfda8aSnia char *name; 2990bbfda8aSnia char *geometry; 3000bbfda8aSnia name_list *winlist; 3010bbfda8aSnia Window window; 3020bbfda8aSnia struct TwmWindow *twmwin; 3030bbfda8aSnia}; 3040bbfda8aSnia 3050bbfda8aSnia 3060bbfda8aSnia/* 3070bbfda8aSnia * Pull in struct TwmWindow. Moved to a separate file to ease scanning 3080bbfda8aSnia * through both it and the other stuff in here. 3090bbfda8aSnia */ 3100bbfda8aSnia#include "twm_window_struct.h" 3110bbfda8aSnia 3120bbfda8aSnia 3130bbfda8aSnia/* Flags for TwmWindow.protocols */ 3140bbfda8aSnia#define DoesWmTakeFocus (1L << 0) 3150bbfda8aSnia#define DoesWmSaveYourself (1L << 1) 3160bbfda8aSnia#define DoesWmDeleteWindow (1L << 2) 3170bbfda8aSnia 3180bbfda8aSnia 3190bbfda8aSniavoid Reborder(Time tim); 3200bbfda8aSniaSIGNAL_T Done(int signum) __attribute__((noreturn)); 3210bbfda8aSniavoid CreateFonts(ScreenInfo *scr); 3220bbfda8aSnia 3230bbfda8aSniavoid RestoreWithdrawnLocation(TwmWindow *tmp); 3240bbfda8aSniaextern char *ProgramName; 3250bbfda8aSniaextern Display *dpy; 3260bbfda8aSniaextern XtAppContext appContext; 3270bbfda8aSniaextern Window ResizeWindow; /* the window we are resizing */ 3280bbfda8aSniaextern bool HasShape; /* this server supports Shape extension */ 3290bbfda8aSniaextern int ShapeEventBase, ShapeErrorBase; 3300bbfda8aSnia 3310bbfda8aSniaextern int PreviousScreen; 3320bbfda8aSnia 3330bbfda8aSniaextern Cursor UpperLeftCursor; 3340bbfda8aSniaextern Cursor RightButt; 3350bbfda8aSniaextern Cursor MiddleButt; 3360bbfda8aSniaextern Cursor LeftButt; 3370bbfda8aSnia 3380bbfda8aSniaextern XClassHint NoClass; 3390bbfda8aSnia 3400bbfda8aSniaextern XContext TwmContext; 3410bbfda8aSniaextern XContext MenuContext; 3420bbfda8aSniaextern XContext ScreenContext; 3430bbfda8aSniaextern XContext ColormapContext; 3440bbfda8aSnia 3450bbfda8aSniaextern char *Home; 3460bbfda8aSniaextern int HomeLen; 3470bbfda8aSnia 3480bbfda8aSniaextern bool HandlingEvents; 3490bbfda8aSniaextern Cursor TopCursor, TopLeftCursor, LeftCursor, BottomLeftCursor, 3500bbfda8aSnia BottomCursor, BottomRightCursor, RightCursor, TopRightCursor; 3510bbfda8aSnia 3520bbfda8aSnia/* Junk vars; see comment in ctwm.c about usage */ 3530bbfda8aSniaextern Window JunkRoot, JunkChild; 3540bbfda8aSniaextern int JunkX, JunkY; 3550bbfda8aSniaextern unsigned int JunkWidth, JunkHeight, JunkBW, JunkDepth, JunkMask; 3560bbfda8aSnia 3570bbfda8aSniaextern XGCValues Gcv; 3580bbfda8aSniaextern int Argc; 3590bbfda8aSniaextern char **Argv; 3600bbfda8aSnia 3610bbfda8aSniaextern bool RestartPreviousState; 3620bbfda8aSnia 3630bbfda8aSniaextern bool RestartFlag; /* Flag that is set when SIGHUP is caught */ 3640bbfda8aSniavoid DoRestart(Time t); /* Function to perform a restart */ 3650bbfda8aSnia 3660bbfda8aSnia#define OCCUPY(w, b) ((b == NULL) ? 1 : (w->occupation & (1 << b->number))) 3670bbfda8aSnia 3680bbfda8aSnia 3690bbfda8aSnia/* 3700bbfda8aSnia * Command-line arg handling bits 3710bbfda8aSnia */ 3720bbfda8aSniatypedef struct _ctwm_cl_args { 3730bbfda8aSnia bool MultiScreen; // ! --single, grab multiple screens 3740bbfda8aSnia bool Monochrome; // --mono, force monochrome 3750bbfda8aSnia bool cfgchk; // --cfgchk, check config and exit 3760bbfda8aSnia char *InitFile; // --file, config filename 3770bbfda8aSnia char *display_name; // --display, X server display 3780bbfda8aSnia 3790bbfda8aSnia bool PrintErrorMessages; // --verbose, show more debug output 3800bbfda8aSnia bool ShowWelcomeWindow; // ! --nowelcome, show splash screen 3810bbfda8aSnia 3820bbfda8aSnia bool is_captive; // --window (flag), running captive 3830bbfda8aSnia Window capwin; // --window (arg), existing window to capture 3840bbfda8aSnia char *captivename; // --name, captive name 3850bbfda8aSnia 3860bbfda8aSnia#ifdef USEM4 3870bbfda8aSnia bool KeepTmpFile; // --keep-defs, keep generated m4 defs 3880bbfda8aSnia char *keepM4_filename; // --keep, keep m4 post-processed output 3890bbfda8aSnia bool GoThroughM4; // ! --nom4, do m4 processing 3900bbfda8aSnia#endif 3910bbfda8aSnia 3920bbfda8aSnia#ifdef EWMH 3930bbfda8aSnia bool ewmh_replace; // --replace, replacing running WM 3940bbfda8aSnia#endif 3950bbfda8aSnia 3960bbfda8aSnia char *client_id; // --clientId, session client id 3970bbfda8aSnia char *restore_filename; // --restore, session filename 3980bbfda8aSnia} ctwm_cl_args; 3990bbfda8aSniaextern ctwm_cl_args CLarg; 4000bbfda8aSnia 4010bbfda8aSnia 4020bbfda8aSnia#endif /* _CTWM_CTWM_H */ 403