-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuwm.h
418 lines (373 loc) · 13.5 KB
/
uwm.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
/* $XConsortium: uwm.h,v 1.15 88/10/23 12:08:18 jim Exp $ */
/*
* Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
*
* All Rights Reserved
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted,
* provided that the above copyright notice appear in all copies and that
* both that copyright notice and this permission notice appear in
* supporting documentation, and that the name of Digital Equipment
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software without specific, written prior permission.
*
*
* DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
* DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
* ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
/* $XConsortium: copyright.h,v 1.5 89/12/22 16:11:28 rws Exp $ */
/*
Copyright 1985, 1986, 1987, 1988, 1989 by the
Massachusetts Institute of Technology
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation, and that the name of M.I.T. not be used in advertising or
publicity pertaining to distribution of the software without specific,
written prior permission. M.I.T. makes no representations about the
suitability of this software for any purpose. It is provided "as is"
without express or implied warranty.
*/
/*
* MODIFICATION HISTORY
*
* 000 -- M. Gancarz, DEC Ultrix Engineering Group
* 001 -- R. Kittell, DEC Storage A/D May 19, 1986
* Added global vars for warp options.
* 002 -- Loretta Guarino Reid, DEC Ultrix Engineering Group,
* Western Software Lab, Port to X11
*/
#include <errno.h>
#include <stdio.h>
#include <X11/Xos.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#define MIN(x, y) ((x) <= (y) ? (x) : (y))
#define MAX(x, y) ((x) >= (y) ? (x) : (y))
#define VOLUME_PERCENTAGE(x) ((x)*14)
#define ModMask 0xFF
#define ButtonMask(b) (((b)==Button1) ? Button1Mask : \
(((b)==Button2) ? Button2Mask : Button3Mask))
#define FALSE False
#define TRUE True
#define DEF_DELTA 1
#ifndef DEF_FONT
#define DEF_FONT "6x10"
#endif
#define DEF_FUNC GXcopy
#define DEF_ICON_BORDER_WIDTH 2
#define DEF_ICON_PADDING 4
#define DEF_POP_BORDER_WIDTH 2
#define DEF_POP_PADDING 4
#define DEF_MENU_BORDER_WIDTH 2
#define DEF_MENU_PADDING 4
#define DEF_VOLUME 4
#define DEF_PUSH 5
#define PTEXT_LENGTH 9
#define INIT_PTEXT {'0', '0', '0', '0', 'x', '0', '0', '0', '0'}
#ifndef TEMPFILE
#define TEMPFILE "/tmp/uwm.XXXXXX"
#endif
#ifndef SYSFILE
#define SYSFILE "/usr/lib/X11/uwm/system.uwmrc"
#endif
#define CURSOR_WIDTH 16
#define CURSOR_HEIGHT 16
#define MAX_ZAP_VECTORS 8
#define MAX_BOX_VECTORS 16
#define DRAW_WIDTH 0 /* use fastest hardware draw */
#define DRAW_VALUE 0xfd
#define DRAW_FUNC GXxor
#define DRAW_PLANES 1
#define ROOT 0x1
#define WINDOW 0x2
#define ICON 0x4
#define FAILURE 0
#define NAME_LEN 256 /* Maximum length of filenames. */
#define EVENTMASK (ButtonPressMask | ButtonReleaseMask)
#define DrawBox() XDrawSegments(dpy, RootWindow(dpy, scr),DrawGC,box,num_vectors)
#define DrawZap() XDrawSegments(dpy, RootWindow(dpy, scr),DrawGC,zap,num_vectors)
/*
* Keyword table entry.
*/
typedef struct _keyword {
char *name;
int type;
Bool *bptr;
int *nptr;
char *sptr;
Bool (*fptr)();
} Keyword;
/*
* Keyword table type entry.
*/
#define IsString 1
#define IsBoolTrue 2
#define IsBoolFalse 3
#define IsFunction 4
#define IsMenuMap 5
#define IsMenu 6
#define IsDownFunction 7
#define IsParser 8
#define IsNumeric 9
#define IsQuitFunction 10
/*
* Button/key binding type.
*/
typedef struct _binding {
struct _binding *next;
int context;
int mask;
int button;
Bool (*func)();
char *menuname;
struct _menuinfo *menu;
} Binding;
/*
* Key expression type.
*/
typedef struct _keyexpr {
char *name;
int mask;
} KeyExpr;
/*
* Context expression type.
*/
typedef struct _contexpr {
char *name;
int mask;
} ContExpr;
/*
* Button modifier type.
*/
typedef struct _buttonmodifier {
char *name;
int mask;
} ButtonModifier;
/*
* Button modifier mask definitions.
* bits 13 and 14 unused in key masks, according to X.h
* steal bit 15, since we don't use AnyModifier
*/
#define DeltaMotion (1<<13)
#define ButtonUp (1<<14)
#define ButtonDown AnyModifier
#define ButtonMods DeltaMotion+ButtonUp+ButtonDown
/*
* Button and mask redefinitions, for X11
*/
#define LeftMask Button1Mask
#define MiddleMask Button2Mask
#define RightMask Button3Mask
#define LeftButton Button1
#define MiddleButton Button2
#define RightButton Button3
/*
* WindowInfo data type.
*/
typedef struct _windowInfo {
Window window;
Colormap colormap; /* private to colormap.c */
Bool in_window; /* private to colormap.c */
long event_mask; /* combined event mask */
long uwm_event_mask; /* events uwm gets to see */
Bool been_mapped; /* true if have been mapped */
XSizeHints stashedhints; /* save a copy away */
} WindowInfo;
WindowInfo *getWindowInfo();
/*
* MenuInfo data type.
*/
typedef struct _menuinfo {
char *name; /* Name of this menu. */
Window w; /* Menu window. */
int iheight; /* Height of an item. */
int width; /* Width of this menu. */
int height; /* Height of this menu. */
Pixmap image; /* Saved image of the menu. */
char *foreground; /* Name of foreground color. */
char *background; /* Name of background color. */
char *fghighlight; /* Name of hightlight foreground color. */
char *bghighlight; /* Name of highlight background color. */
XColor fg; /* Foreground color definition. */
XColor bg; /* Background color definition. */
XColor hlfg; /* Foreground highlight color definition. */
XColor hlbg; /* Background highlight color definition. */
struct _menuline *line; /* Linked list of menu items. */
} MenuInfo;
/*
* Menu Line data type.
*/
typedef struct _menuline {
struct _menuline *next; /* Pointer to next line. */
char *name; /* Name of this line. */
int type; /* IsShellCommand, IsText, IsTextNL... */
Window w; /* Subwindow for this line. */
char *text; /* Text string to be acted upon. */
Bool (*func)(); /* Window manager function to be invoked. */
struct _menuinfo *menu; /* Menu to be invoked. */
char *foreground; /* Name of foreground color. */
char *background; /* Name of background color. */
XColor fg; /* Foreground color definition. */
XColor bg; /* Background color definition. */
} MenuLine;
/*
* MenuLine->type definitions.
*/
#define IsShellCommand 1
#define IsText 2
#define IsTextNL 3
#define IsUwmFunction 4
#define IsMenuFunction 5
#define IsImmFunction 6 /* Immediate (context-less) function. */
/*
* Menu Link data type. Used by the parser when creating a linked list
* of menus.
*/
typedef struct _menulink {
struct _menulink *next; /* Pointer to next MenuLink. */
struct _menuinfo *menu; /* Pointer to the menu in this link. */
} MenuLink;
typedef int Pixel;
/*
* External variable definitions.
*/
extern int errno;
extern Window Pop; /* Pop-up dimension display window. */
extern Window Frozen; /* Contains window id of "gridded" window. */
extern XFontStruct *IFontInfo; /* Icon text font information. */
extern XFontStruct *PFontInfo; /* Pop-up text font information. */
extern XFontStruct *MFontInfo; /* Menu text font information. */
extern Pixmap GrayPixmap; /* Gray pixmap. */
extern Pixel IBorder; /* Icon window border pixmap. */
extern Pixmap IBackground; /* Icon window background pixmap. */
extern Pixel PBorder; /* Pop-Up Window border pixmap. */
extern Pixel PBackground; /* Pop-up Window background pixmap. */
extern Pixel MBorder; /* Menu Window border pixmap. */
extern Pixel MBackground; /* Menu Window background pixmap. */
extern Cursor ArrowCrossCursor; /* Arrow cross cursor. */
extern Cursor TextCursor; /* Text cursor used in icon windows. */
extern Cursor IconCursor; /* Icon Cursor. */
extern Cursor MenuCursor; /* Menu cursor. */
extern Cursor MenuMaskCursor; /* Menu mask cursor. */
extern Cursor LeftButtonCursor; /* Left button main cursor. */
extern Cursor MiddleButtonCursor;/* Middle button main cursor. */
extern Cursor RightButtonCursor;/* Right button main cursor. */
extern Cursor TargetCursor; /* Target (select-a-window) cursor. */
extern int ScreenWidth; /* Display screen width. */
extern int ScreenHeight; /* Display screen height. */
extern int ITextForeground; /* Icon window text forground color. */
extern int ITextBackground; /* Icon window text background color. */
extern int IBorderWidth; /* Icon window border width. */
extern int PTextForeground; /* Pop-up window text forground color. */
extern int PTextBackground; /* Pop-up window text background color. */
extern int PWidth; /* Pop-up window width (including borders). */
extern int PHeight; /* Pop-up window height (including borders). */
extern int PBorderWidth; /* Pop-up window border width. */
extern int MTextForeground; /* Menu window text forground color. */
extern int MTextBackground; /* Menu window text background color. */
extern int MBorderWidth; /* Menu window border width. */
extern int PPadding; /* Pop-up window padding. */
extern int Delay; /* Delay between clicks of double click. */
extern int Delta; /* Mouse movement slop. */
extern int HIconPad; /* Icon horizontal padding. */
extern int VIconPad; /* Icon vertical padding. */
extern int HMenuPad; /* Menu horizontal padding. */
extern int VMenuPad; /* Menu vertical padding. */
extern int MaxColors; /* Maximum number of colors to use. */
extern int Pushval; /* Number of pixels to push window by. */
extern int Volume; /* Audible alarm volume. */
extern int status; /* Routine return status. */
extern int Maxfd; /* Maximum file descriptors for select(2). */
extern MenuLink *Menus; /* Linked list of menus. */
extern GC IconGC; /* graphics context for icon */
extern GC PopGC; /* graphics context for pop */
extern GC MenuGC; /* graphics context for menu */
extern GC MenuInvGC; /* graphics context for menu background */
extern GC DrawGC; /* graphics context for zap */
extern Bool Autoselect; /* Warp mouse to default menu selection? */
extern Bool Freeze; /* Freeze server during move/resize? */
extern Bool Grid; /* Should the m/r box contain a 9 seg. grid. */
extern Bool NWindow; /* Normalize windows? */
extern Bool NIcon; /* Normalize icons? */
extern Bool Push; /* Relative=TRUE, Absolute=FALSE. */
extern Bool ResizeRelative; /* Relative=TRUE, Absolute=FALSE. */
extern Bool Reverse; /* Reverse video? */
extern Bool WarpOnRaise; /* Warp to upper right corner on raise. */
extern Bool WarpOnIconify; /* Warp to icon center on iconify. */
extern Bool WarpOnDeIconify; /* Warp to upper right corner on de-iconify. */
extern Bool Zap; /* Should the the zap effect be used. */
extern Bool FocusSetByUser; /* True if f.focus called */
extern char PText[]; /* Pop-up window dummy text. */
extern int PTextSize; /* Pop-up window dummy text size. */
extern int Lineno; /* Line count for parser. */
extern Bool Startup_File_Error; /* Startup file error flag. */
extern char Startup_File[]; /* Startup file name. */
extern char IFontName[]; /* Icon font name. */
extern char PFontName[]; /* Pop-up font name. */
extern char MFontName[]; /* Menu font name. */
extern char PBackgroundName[]; /* name of color to use for popup */
extern char PForegroundName[]; /* name of color to use for popup */
extern char PBorderColor[]; /* name of color to use for popup */
extern char **Argv; /* Pointer to command line parameters. */
extern char **Environ; /* Pointer to environment. */
extern char *DefaultBindings[]; /* Default bindings string array. */
extern Keyword KeywordTable[]; /* Keyword lookup table. */
extern Binding *Blist; /* Button/key bindings list. */
extern KeyExpr KeyExprTbl[]; /* Key expression table. */
extern ContExpr ContExprTbl[]; /* Context expression table. */
extern ButtonModifier ButtModTbl[];/* Button modifier table. */
extern int scr;
extern Display *dpy; /* Display info pointer. */
#ifdef PROFIL
int ptrap();
#endif
/*
* External routine typing.
*/
extern Bool Beep();
extern Bool CircleDown();
extern Bool CircleUp();
extern Bool Continue();
extern Bool Focus();
extern Bool GetButton();
extern Bool Iconify();
extern Bool Kill();
extern Bool Lower();
extern Bool Menu();
extern Bool Move();
extern Bool MoveOpaque();
extern Bool NewIconify();
extern Bool Pause();
extern Bool PushDown();
extern Bool PushLeft();
extern Bool PushRight();
extern Bool PushUp();
extern Bool Quit();
extern Bool Raise();
extern Bool Redraw();
extern Bool Refresh();
extern Bool ResetBindings();
extern Bool ResetMenus();
extern Bool ResetVariables();
extern Bool Resize();
extern Bool Restart();
extern int StoreCursors();
extern int StoreBox();
extern int StoreGridBox();
extern int StoreZap();
extern int Error();
extern int XError();
extern int CreateMenus();
extern char *stash();
extern char *GetIconName();
extern Bool x_error_occurred;
extern XErrorEvent last_error_event;
#define clear_x_errors() (x_error_occurred = FALSE)