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