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