twm.h revision 3e747e6d
1/*****************************************************************************/ 2/** Copyright 1988 by Evans & Sutherland Computer Corporation, **/ 3/** Salt Lake City, Utah **/ 4/** **/ 5/** All Rights Reserved **/ 6/** **/ 7/** Permission to use, copy, modify, and distribute this software and **/ 8/** its documentation for any purpose and without fee is hereby **/ 9/** granted, provided that the above copyright notice appear in all **/ 10/** copies and that both that copyright notice and this permis- **/ 11/** sion notice appear in supporting documentation, and that the **/ 12/** names of Evans & Sutherland not be used in advertising **/ 13/** in publicity pertaining to distribution of the software without **/ 14/** specific, written prior permission. **/ 15/** **/ 16/** EVANS & SUTHERLAND AND DISCLAIMS ALL WARRANTIES WITH REGARD **/ 17/** TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- **/ 18/** ABILITY AND FITNESS, IN NO EVENT SHALL EVANS & SUTHERLAND **/ 19/** BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES **/ 20/** OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA **/ 21/** OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER **/ 22/** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/ 23/** OR PERFORMANCE OF THIS SOFTWARE. **/ 24/*****************************************************************************/ 25/* 26 27Portions Copyright 1989, 1998 The Open Group 28 29Permission to use, copy, modify, distribute, and sell this software and its 30documentation for any purpose is hereby granted without fee, provided that 31the above copyright notice appear in all copies and that both that 32copyright notice and this permission notice appear in supporting 33documentation. 34 35The above copyright notice and this permission notice shall be included 36in all copies or substantial portions of the Software. 37 38THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 39OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 40MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 41IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR 42OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 43ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 44OTHER DEALINGS IN THE SOFTWARE. 45 46Except as contained in this notice, the name of The Open Group shall 47not be used in advertising or otherwise to promote the sale, use or 48other dealings in this Software without prior written authorization 49from The Open Group. 50 51*/ 52 53 54/*********************************************************************** 55 * 56 * $Xorg: twm.h,v 1.4 2001/02/09 02:05:37 xorgcvs Exp $ 57 * 58 * twm include file 59 * 60 * 28-Oct-87 Thomas E. LaStrange File created 61 * 10-Oct-90 David M. Sternlicht Storeing saved colors on root 62 ***********************************************************************/ 63/* $XFree86: xc/programs/twm/twm.h,v 3.12 2001/12/14 20:01:10 dawes Exp $ */ 64 65#ifndef _TWM_ 66#define _TWM_ 67 68#include <X11/Xlib.h> 69#include <X11/Xutil.h> 70#include <X11/cursorfont.h> 71#include <X11/extensions/shape.h> 72#include <X11/Xfuncs.h> 73#include <X11/StringDefs.h> 74#include <X11/Intrinsic.h> 75 76#ifndef WithdrawnState 77#define WithdrawnState 0 78#endif 79 80#define PIXEL_ALREADY_TYPEDEFED /* for Xmu/Drawing.h */ 81 82#ifdef SIGNALRETURNSINT 83#define SIGNAL_T int 84#define SIGNAL_RETURN return 0 85#else 86#define SIGNAL_T void 87#define SIGNAL_RETURN return 88#endif 89 90typedef SIGNAL_T (*SigProc)(int); /* type of function returned by signal() */ 91 92#define BW 2 /* border width */ 93#define BW2 4 /* border width * 2 */ 94 95#ifndef TRUE 96#define TRUE 1 97#define FALSE 0 98#endif 99 100#define NULLSTR ((char *) NULL) 101 102#define MAX_BUTTONS 16 /* max mouse buttons supported */ 103 104/* info stings defines */ 105#define INFO_LINES 30 106#define INFO_SIZE 200 107 108/* contexts for button presses */ 109#define C_NO_CONTEXT -1 110#define C_WINDOW 0 111#define C_TITLE 1 112#define C_ICON 2 113#define C_ROOT 3 114#define C_FRAME 4 115#define C_ICONMGR 5 116#define C_NAME 6 117#define C_IDENTIFY 7 118#define NUM_CONTEXTS 8 119 120#define C_WINDOW_BIT (1 << C_WINDOW) 121#define C_TITLE_BIT (1 << C_TITLE) 122#define C_ICON_BIT (1 << C_ICON) 123#define C_ROOT_BIT (1 << C_ROOT) 124#define C_FRAME_BIT (1 << C_FRAME) 125#define C_ICONMGR_BIT (1 << C_ICONMGR) 126#define C_NAME_BIT (1 << C_NAME) 127 128#define C_ALL_BITS (C_WINDOW_BIT | C_TITLE_BIT | C_ICON_BIT |\ 129 C_ROOT_BIT | C_FRAME_BIT | C_ICONMGR_BIT) 130 131/* modifiers for button presses */ 132#define MOD_SIZE ((ShiftMask | ControlMask | Mod1Mask \ 133 | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask) + 1) 134 135#define TITLE_BAR_SPACE 1 /* 2 pixel space bordering chars */ 136#define TITLE_BAR_FONT_HEIGHT 15 /* max of 15 pixel high chars */ 137#define TITLE_BAR_HEIGHT (TITLE_BAR_FONT_HEIGHT+(2*TITLE_BAR_SPACE)) 138 139/* defines for zooming/unzooming */ 140#define ZOOM_NONE 0 141 142#define FB(fix_fore, fix_back)\ 143 Gcv.foreground = fix_fore;\ 144 Gcv.background = fix_back;\ 145 XChangeGC(dpy, Scr->NormalGC, GCForeground|GCBackground,&Gcv) 146 147typedef struct MyFont 148{ 149 char *name; /* name of the font */ 150 XFontStruct *font; /* font structure */ 151 XFontSet fontset; /* fontset structure */ 152 int height; /* height of the font */ 153 int y; /* Y coordinate to draw characters */ 154 int ascent; 155 int descent; 156} MyFont; 157 158typedef struct ColorPair 159{ 160 Pixel fore, back; 161} ColorPair; 162 163typedef struct _TitleButton { 164 struct _TitleButton *next; /* next link in chain */ 165 char *name; /* bitmap name in case of deferal */ 166 Pixmap bitmap; /* image to display in button */ 167 int srcx, srcy; /* from where to start copying */ 168 unsigned int width, height; /* size of pixmap */ 169 int dstx, dsty; /* to where to start copying */ 170 int func; /* function to execute */ 171 char *action; /* optional action arg */ 172 struct MenuRoot *menuroot; /* menu to pop on F_MENU */ 173 Bool rightside; /* t: on right, f: on left */ 174} TitleButton; 175 176typedef struct _TBWindow { 177 Window window; /* which window in this frame */ 178 TitleButton *info; /* description of this window */ 179} TBWindow; 180 181typedef struct _SqueezeInfo { 182 int justify; /* left, center, right */ 183 int num; /* signed pixel count or numerator */ 184 int denom; /* 0 for pix count or denominator */ 185} SqueezeInfo; 186 187#define J_LEFT 1 188#define J_CENTER 2 189#define J_RIGHT 3 190 191/* Colormap window entry for each window in WM_COLORMAP_WINDOWS 192 * ICCCM property. 193 */ 194typedef struct TwmColormap 195{ 196 Colormap c; /* Colormap id */ 197 int state; /* install(ability) state */ 198 unsigned long install_req; /* request number which installed it */ 199 Window w; /* window causing load of color table */ 200 int refcnt; 201} TwmColormap; 202 203#define CM_INSTALLABLE 1 204#define CM_INSTALLED 2 205#define CM_INSTALL 4 206 207typedef struct ColormapWindow 208{ 209 Window w; /* Window id */ 210 TwmColormap *colormap; /* Colormap for this window */ 211 int visibility; /* Visibility of this window */ 212 int refcnt; 213} ColormapWindow; 214 215typedef struct Colormaps 216{ 217 ColormapWindow **cwins; /* current list of colormap windows */ 218 int number_cwins; /* number of elements in current list */ 219 char *scoreboard; /* conflicts between installable colortables */ 220} Colormaps; 221 222#define ColormapsScoreboardLength(cm) ((cm)->number_cwins * \ 223 ((cm)->number_cwins - 1) / 2) 224 225/* for each window that is on the display, one of these structures 226 * is allocated and linked into a list 227 */ 228typedef struct TwmWindow 229{ 230 struct TwmWindow *next; /* next twm window */ 231 struct TwmWindow *prev; /* previous twm window */ 232 Window w; /* the child window */ 233 int old_bw; /* border width before reparenting */ 234 Window frame; /* the frame window */ 235 Window title_w; /* the title bar window */ 236 Window hilite_w; /* the hilite window */ 237 Pixmap gray; 238 Window icon_w; /* the icon window */ 239 Window icon_bm_w; /* the icon bitmap window */ 240 int frame_x; /* x position of frame */ 241 int frame_y; /* y position of frame */ 242 int frame_width; /* width of frame */ 243 int frame_height; /* height of frame */ 244 int frame_bw; /* borderwidth of frame */ 245 int title_x; 246 int title_y; 247 int icon_x; /* icon text x coordinate */ 248 int icon_y; /* icon text y coordiante */ 249 int icon_w_width; /* width of the icon window */ 250 int icon_w_height; /* height of the icon window */ 251 int icon_width; /* width of the icon bitmap */ 252 int icon_height; /* height of the icon bitmap */ 253 int title_height; /* height of the title bar */ 254 int title_width; /* width of the title bar */ 255 char *full_name; /* full name of the window */ 256 char *name; /* name of the window */ 257 char *icon_name; /* name of the icon */ 258 int name_width; /* width of name text */ 259 int highlightx; /* start of highlight window */ 260 int rightx; /* start of right buttons */ 261 XWindowAttributes attr; /* the child window attributes */ 262 XSizeHints hints; /* normal hints */ 263 XWMHints *wmhints; /* WM hints */ 264 Window group; /* group ID */ 265 XClassHint class; 266 struct WList *list; 267 /*********************************************************************** 268 * color definitions per window 269 **********************************************************************/ 270 Pixel border; /* border color */ 271 Pixel icon_border; /* border color */ 272 ColorPair border_tile; 273 ColorPair title; 274 ColorPair iconc; 275 short iconified; /* has the window ever been iconified? */ 276 short icon; /* is the window an icon now ? */ 277 short icon_on; /* is the icon visible */ 278 short mapped; /* is the window mapped ? */ 279 short auto_raise; /* should we auto-raise this window ? */ 280 short forced; /* has had an icon forced upon it */ 281 short icon_not_ours; /* icon pixmap or window supplied to us */ 282 short icon_moved; /* user explicitly moved the icon */ 283 short highlight; /* should highlight this window */ 284 short stackmode; /* honor stackmode requests */ 285 short iconify_by_unmapping; /* unmap window to iconify it */ 286 short iconmgr; /* this is an icon manager window */ 287 short transient; /* this is a transient window */ 288 Window transientfor; /* window contained in XA_XM_TRANSIENT_FOR */ 289 short titlehighlight; /* should I highlight the title bar */ 290 struct IconMgr *iconmgrp; /* pointer to it if this is an icon manager */ 291 int save_frame_x; /* x position of frame */ 292 int save_frame_y; /* y position of frame */ 293 int save_frame_width; /* width of frame */ 294 int save_frame_height; /* height of frame */ 295 short zoomed; /* is the window zoomed? */ 296 short wShaped; /* this window has a bounding shape */ 297 unsigned long protocols; /* which protocols this window handles */ 298 Colormaps cmaps; /* colormaps for this application */ 299 TBWindow *titlebuttons; 300 SqueezeInfo *squeeze_info; /* should the title be squeezed? */ 301 struct { 302 struct TwmWindow *next, *prev; 303 Bool cursor_valid; 304 int curs_x, curs_y; 305 } ring; 306 307 Bool nameChanged; /* did WM_NAME ever change? */ 308 309 /* did the user ever change the width/height? {yes, no, or unknown} */ 310 311 Bool widthEverChangedByUser; 312 Bool heightEverChangedByUser; 313 314} TwmWindow; 315 316 317typedef struct TWMWinConfigEntry 318{ 319 struct TWMWinConfigEntry *next; 320 int tag; 321 char *client_id; 322 char *window_role; 323 XClassHint class; 324 char *wm_name; 325 int wm_command_count; 326 char **wm_command; 327 short x, y; 328 unsigned short width, height; 329 short icon_x, icon_y; 330 Bool iconified; 331 Bool icon_info_present; 332 Bool width_ever_changed_by_user; 333 Bool height_ever_changed_by_user; 334} TWMWinConfigEntry; 335 336 337#define DoesWmTakeFocus (1L << 0) 338#define DoesWmSaveYourself (1L << 1) 339#define DoesWmDeleteWindow (1L << 2) 340 341#define TBPM_DOT ":dot" /* name of titlebar pixmap for dot */ 342#define TBPM_ICONIFY ":iconify" /* same image as dot */ 343#define TBPM_RESIZE ":resize" /* name of titlebar pixmap for resize button */ 344#define TBPM_XLOGO ":xlogo" /* name of titlebar pixmap for xlogo */ 345#define TBPM_DELETE ":delete" /* same image as xlogo */ 346#define TBPM_MENU ":menu" /* name of titlebar pixmap for menus */ 347#define TBPM_QUESTION ":question" /* name of unknown titlebar pixmap */ 348 349#include <X11/Xosdefs.h> 350#include <stdlib.h> 351extern void InitVariables ( void ); 352extern void CreateFonts ( void ); 353extern void RestoreWithdrawnLocation ( TwmWindow *tmp ); 354extern void Reborder( Time time); 355extern void Done( XtPointer, XtSignalId * ); 356extern void ComputeCommonTitleOffsets ( void ); 357extern void ComputeTitleLocation ( TwmWindow *tmp ); 358extern void ComputeWindowTitleOffsets ( TwmWindow *tmp_win, int width, Bool squeeze ); 359extern char *ProgramName; 360extern Display *dpy; 361extern XtAppContext appContext; 362extern Window ResizeWindow; /* the window we are resizing */ 363extern int HasShape; /* this server supports Shape extension */ 364extern int HasSync; /* this server supports SYNC extension */ 365 366extern int PreviousScreen; 367 368extern Cursor UpperLeftCursor; 369extern Cursor RightButt; 370extern Cursor MiddleButt; 371extern Cursor LeftButt; 372 373extern XClassHint NoClass; 374 375extern XContext TwmContext; 376extern XContext MenuContext; 377extern XContext IconManagerContext; 378extern XContext ScreenContext; 379extern XContext ColormapContext; 380 381extern char *Home; 382extern int HomeLen; 383extern int ParseError; 384 385extern int HandlingEvents; 386 387extern Window JunkRoot; 388extern Window JunkChild; 389extern int JunkX; 390extern int JunkY; 391extern unsigned int JunkWidth, JunkHeight, JunkBW, JunkDepth, JunkMask; 392extern XGCValues Gcv; 393extern int InfoLines; 394extern char Info[][INFO_SIZE]; 395extern int Argc; 396extern char **Argv; 397extern void NewFontCursor ( Cursor *cp, char *str ); 398extern void NewBitmapCursor ( Cursor *cp, char *source, char *mask ); 399extern Pixmap CreateMenuIcon ( int height, unsigned int *widthp, unsigned int *heightp ); 400 401extern Bool ErrorOccurred; 402extern XErrorEvent LastErrorEvent; 403 404#define ResetError() (ErrorOccurred = False) 405 406extern Bool RestartPreviousState; 407extern Bool GetWMState ( Window w, int *statep, Window *iwp ); 408 409extern void twmrc_error_prefix ( void ); 410 411extern int yyparse ( void ); 412extern int yylex ( void ); 413extern void yyerror ( char *s ); 414extern int doinput ( char *buf, int size ); 415extern void RemoveDQuote ( char *str ); 416 417extern Atom TwmAtoms[]; 418 419extern Bool use_fontset; 420 421extern int ShapeEventBase; 422extern int ShapeErrorBase; 423 424#define _XA_MIT_PRIORITY_COLORS TwmAtoms[0] 425#define _XA_WM_CHANGE_STATE TwmAtoms[1] 426#define _XA_WM_STATE TwmAtoms[2] 427#define _XA_WM_COLORMAP_WINDOWS TwmAtoms[3] 428#define _XA_WM_PROTOCOLS TwmAtoms[4] 429#define _XA_WM_TAKE_FOCUS TwmAtoms[5] 430#define _XA_WM_SAVE_YOURSELF TwmAtoms[6] 431#define _XA_WM_DELETE_WINDOW TwmAtoms[7] 432#define _XA_SM_CLIENT_ID TwmAtoms[8] 433#define _XA_WM_CLIENT_LEADER TwmAtoms[9] 434#define _XA_WM_WINDOW_ROLE TwmAtoms[10] 435 436#endif /* _TWM_ */ 437