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