1 /*****************************************************************************/
2 /** Copyright 1988 by Evans & Sutherland Computer Corporation, **/
3 /** Salt Lake City, Utah **/
4 /** Portions Copyright 1989 by the Massachusetts Institute of Technology **/
5 /** Cambridge, Massachusetts **/
7 /** All Rights Reserved **/
9 /** Permission to use, copy, modify, and distribute this software and **/
10 /** its documentation for any purpose and without fee is hereby **/
11 /** granted, provided that the above copyright notice appear in all **/
12 /** copies and that both that copyright notice and this permis- **/
13 /** sion notice appear in supporting documentation, and that the **/
14 /** names of Evans & Sutherland and M.I.T. not be used in advertising **/
15 /** in publicity pertaining to distribution of the software without **/
16 /** specific, written prior permission. **/
18 /** EVANS & SUTHERLAND AND M.I.T. DISCLAIM ALL WARRANTIES WITH REGARD **/
19 /** TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- **/
20 /** ABILITY AND FITNESS, IN NO EVENT SHALL EVANS & SUTHERLAND OR **/
21 /** M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAM- **/
22 /** AGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA **/
23 /** OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER **/
24 /** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/
25 /** OR PERFORMANCE OF THIS SOFTWARE. **/
26 /*****************************************************************************/
29 /***********************************************************************
31 * $XConsortium: twm.h,v 1.74 91/05/31 17:38:30 dave Exp $
35 * 28-Oct-87 Thomas E. LaStrange File created
36 * 10-Oct-90 David M. Sternlicht Storeing saved colors on root
37 ***********************************************************************/
43 #include <X11/Xutil.h>
44 #include <X11/cursorfont.h>
45 #include <X11/extensions/shape.h>
46 #ifdef NEVER /* stay X11R4 compatable; X11R5,6 doesn't seem to mind! */
47 #include <X11/Xfuncs.h>
51 * This accomodates systems that simply cannot handle the
52 * duplicate typedef declaration of 'Pixel'. On the other hand,
53 * if your make halts with complaints of an unknown datatype
54 * 'Pixel', add "EXTRA_DEFINES=-DNEED_PIXEL_T" to the make
55 * command. Submitted by Nelson H. F. Beebe
57 #include <X11/Intrinsic.h>
59 typedef unsigned long Pixel;
61 #define PIXEL_ALREADY_TYPEDEFED /* for Xmu/Drawing.h */
65 #ifndef WithdrawnState
66 #define WithdrawnState 0
69 #ifdef SIGNALRETURNSINT
71 #define SIGNAL_RETURN return 0
74 #define SIGNAL_RETURN return
77 typedef SIGNAL_T (*SigProc)(); /* type of function returned by signal() */
79 #define BW 2 /* border width */
80 #define BW2 4 /* border width * 2 */
87 #define NULLSTR ((char *) NULL)
89 #define MAX_BUTTONS 5 /* max mouse buttons supported */
91 /* info stings defines */
95 /* contexts for button presses */
96 #define C_NO_CONTEXT -1
106 #define C_VIRTUAL_WIN 9
108 #define NUM_CONTEXTS 11
110 #define C_WINDOW_BIT (1 << C_WINDOW)
111 #define C_TITLE_BIT (1 << C_TITLE)
112 #define C_ICON_BIT (1 << C_ICON)
113 #define C_ROOT_BIT (1 << C_ROOT)
114 #define C_FRAME_BIT (1 << C_FRAME)
115 #define C_ICONMGR_BIT (1 << C_ICONMGR)
116 #define C_NAME_BIT (1 << C_NAME)
117 #define C_VIRTUAL_BIT (1 << C_VIRTUAL)
118 #define C_VIRTUAL_WIN_BIT (1 << C_VIRTUAL_WIN)
119 #define C_DOOR_BIT (1 << C_DOOR)
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 C_VIRTUAL_BIT | C_VIRTUAL_WIN_BIT | C_DOOR_BIT)
125 /* modifiers for button presses */
126 /* added "LockMask" - djhjr - 9/10/03 */
127 #define MOD_SIZE ((ShiftMask | LockMask | ControlMask | Mod1Mask \
128 | Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask) + 1)
130 /* definitions from MwmUtil.h - submitted by Jonathan Paisley - 11/8/02 */
131 #define MWM_HINTS_FUNCTIONS (1L << 0)
132 #define MWM_HINTS_DECORATIONS (1L << 1)
133 #define MWM_HINTS_INPUT_MODE (1L << 2)
134 #define MWM_HINTS_STATUS (1L << 3)
136 #define MWM_FUNC_ALL (1L << 0)
137 #define MWM_FUNC_RESIZE (1L << 1)
138 #define MWM_FUNC_MOVE (1L << 2)
139 #define MWM_FUNC_MINIMIZE (1L << 3)
140 #define MWM_FUNC_MAXIMIZE (1L << 4)
141 #define MWM_FUNC_CLOSE (1L << 5)
143 #define MWM_DECOR_ALL (1L << 0)
144 #define MWM_DECOR_BORDER (1L << 1)
145 #define MWM_DECOR_RESIZEH (1L << 2)
146 #define MWM_DECOR_TITLE (1L << 3)
147 #define MWM_DECOR_MENU (1L << 4)
148 #define MWM_DECOR_MINIMIZE (1L << 5)
149 #define MWM_DECOR_MAXIMIZE (1L << 6)
151 #define MWM_INPUT_MODELESS 0
152 #define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1
153 #define MWM_INPUT_SYSTEM_MODAL 2
154 #define MWM_INPUT_FULL_APPLICATION_MODAL 3
155 #define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL
157 #define MWM_TEAROFF_WINDOW (1L<<0)
159 /* submitted by Jonathan Paisley - 11/8/02 */
169 #define TITLE_BAR_SPACE 1 /* 2 pixel space bordering chars */
170 #define TITLE_BAR_FONT_HEIGHT 15 /* max of 15 pixel high chars */
171 #define TITLE_BAR_HEIGHT (TITLE_BAR_FONT_HEIGHT+(2*TITLE_BAR_SPACE))
173 /* defines for zooming/unzooming */
176 /* djhjr - 9/14/03 */
177 #ifndef NO_I18N_SUPPORT
178 #define FBF(fix_fore, fix_back, fix_font)\
179 MyFont_ChangeGC(fix_fore, fix_back, &fix_font)
181 #define FBF(fix_fore, fix_back, fix_font)\
182 Gcv.foreground = fix_fore;\
183 Gcv.background = fix_back;\
184 Gcv.font = fix_font.font->fid;\
185 XChangeGC(dpy, Scr->NormalGC, GCFont|GCForeground|GCBackground,&Gcv)
188 #define FB(fix_fore, fix_back)\
189 Gcv.foreground = fix_fore;\
190 Gcv.background = fix_back;\
191 XChangeGC(dpy, Scr->NormalGC, GCForeground|GCBackground,&Gcv)
193 typedef enum {on, off} ButtonState;
195 typedef struct MyFont
197 char *name; /* name of the font */
198 XFontStruct *font; /* font structure */
199 /* djhjr - 9/14/03 */
200 #ifndef NO_I18N_SUPPORT
203 int height; /* height of the font */
204 int y; /* Y coordinate to draw characters */
209 typedef struct ColorPair
213 /* djhjr - 4/19/96 */
217 typedef struct _TitleButton {
218 struct _TitleButton *next; /* next link in chain */
219 char *name; /* bitmap name in case of deferal */
221 /* don't need either anymore - djhjr - 10/30/02
222 * might not need 'bitmap anymore... djhjr - 4/19/96 *
223 Image *image; * image to display in button *
224 *Pixmap bitmap;* * image to display in button *
227 int srcx, srcy; /* from where to start copying */
228 unsigned int width, height; /* size of pixmap */
229 int dstx, dsty; /* to where to start copying */
230 int func; /* function to execute */
231 char *action; /* optional action arg */
232 struct MenuRoot *menuroot; /* menu to pop on F_MENU */
233 Bool rightside; /* t: on right, f: on left */
236 typedef struct _TBWindow {
237 Window window; /* which window in this frame */
240 Image *image; * image to display in button *
243 TitleButton *info; /* description of this window */
246 typedef struct _SqueezeInfo {
247 int justify; /* left, center, right */
248 int num; /* signed pixel count or numerator */
249 int denom; /* 0 for pix count or denominator */
256 /* Colormap window entry for each window in WM_COLORMAP_WINDOWS
259 typedef struct TwmColormap
261 Colormap c; /* Colormap id */
262 int state; /* install(ability) state */
263 unsigned long install_req; /* request number which installed it */
264 Window w; /* window causing load of color table */
268 #define CM_INSTALLABLE 1
269 #define CM_INSTALLED 2
272 typedef struct ColormapWindow
274 Window w; /* Window id */
275 TwmColormap *colormap; /* Colormap for this window */
276 int visibility; /* Visibility of this window */
280 typedef struct Colormaps
282 ColormapWindow **cwins; /* current list of colormap windows */
283 int number_cwins; /* number of elements in current list */
284 char *scoreboard; /* conflicts between installable colortables */
287 #define ColormapsScoreboardLength(cm) ((cm)->number_cwins * \
288 ((cm)->number_cwins - 1) / 2)
290 /* for each window that is on the display, one of these structures
291 * is allocated and linked into a list
293 typedef struct TwmWindow
295 struct TwmWindow *next; /* next twm window */
296 struct TwmWindow *prev; /* previous twm window */
297 Window w; /* the child window */
298 Window VirtualDesktopDisplayWindow; /* the representation of this window in the vd display */
299 int old_bw; /* border width before reparenting */
300 Window frame; /* the frame window */
301 Window title_w; /* the title bar window */
302 Window hilite_w; /* the hilite window */
304 Window icon_w; /* the icon window */
305 Window icon_bm_w; /* the icon bitmap window */
306 int frame_x; /* x position of frame */
307 int frame_y; /* y position of frame */
308 int virtual_frame_x; /* virtual x position of frame */
309 int virtual_frame_y; /* virtual y position of frame */
310 int frame_width; /* width of frame */
311 int frame_height; /* height of frame */
312 int frame_bw; /* borderwidth of frame */
314 /* djhjr - 4/18/96 */
315 int frame_bw3D; /* 3D borderwidth of frame */
319 int virtual_title_x; /* virtual x position of title */
320 int virtual_title_y; /* virtual y position of title */
321 int icon_x; /* icon text x coordinate */
322 int icon_y; /* icon text y coordiante */
323 int virtual_icon_x; /* virtual x position of icon */
324 int virtual_icon_y; /* virtual y position of icon */
325 int icon_w_width; /* width of the icon window */
326 int icon_w_height; /* height of the icon window */
327 int icon_width; /* width of the icon bitmap */
328 int icon_height; /* height of the icon bitmap */
329 int title_height; /* height of the title bar */
330 int title_width; /* width of the title bar */
331 char *full_name; /* full name of the window */
332 char *name; /* name of the window */
333 char *icon_name; /* name of the icon */
334 int name_width; /* width of name text */
335 int highlightx; /* start of highlight window */
336 int rightx; /* start of right buttons */
337 XWindowAttributes attr; /* the child window attributes */
338 XSizeHints hints; /* normal hints */
339 XWMHints *wmhints; /* WM hints */
340 MotifWmHints mwmhints; /* MWM hints - by Jonathan Paisley - 11/8/02 */
341 Window group; /* group ID */
344 /***********************************************************************
345 * color definitions per window
346 **********************************************************************/
347 Pixel icon_border; /* border color */
350 Pixel border; * border color *
352 ColorPair border; /* border color */
354 ColorPair border_tile;
359 short mapped; /* is the window mapped ? */
360 short zoomed; /* is the window zoomed? */
361 short highlight; /* should highlight this window */
362 short iconmgr; /* this is an icon manager window */
363 short icon; /* is the window an icon now ? */
365 /* 5/17/96 - djhjr */
366 #ifdef ORIGINAL_SHORTS
367 short iconified; /* has the window ever been iconified? */
368 short icon_on; /* is the icon visible */
369 short auto_raise; /* should we auto-raise this window ? */
370 short forced; /* has had an icon forced upon it */
371 short icon_not_ours; /* icon pixmap or window supplied to us */
372 short icon_moved; /* user explicitly moved the icon */
373 short stackmode; /* honor stackmode requests */
374 short iconify_by_unmapping; /* unmap window to iconify it */
375 short transient; /* this is a transient window */
376 short titlehighlight; /* should I highlight the title bar */
377 short wShaped; /* this window has a bounding shape */
378 short nailed; /* is this window nailed ? */
379 short showindesktopdisplay; /* should i show this in the desktop display ? */
388 unsigned int iconified : 1;
389 unsigned int icon_on : 1;
390 unsigned int auto_raise : 1;
391 unsigned int forced : 1;
392 unsigned int icon_not_ours : 1;
393 unsigned int icon_moved : 1;
394 unsigned int stackmode : 1;
395 unsigned int iconify_by_unmapping : 1;
396 unsigned int transient : 1;
397 unsigned int titlehighlight : 1;
398 unsigned int wShaped : 1;
399 unsigned int nailed : 1;
400 unsigned int showindesktopdisplay : 1;
403 unsigned int opaque_move : 1;
404 unsigned int opaque_resize : 1;
407 #define iconified twmflags.iconified
408 #define icon_on twmflags.icon_on
409 #define auto_raise twmflags.auto_raise
410 #define forced twmflags.forced
411 #define icon_not_ours twmflags.icon_not_ours
412 #define icon_moved twmflags.icon_moved
413 #define stackmode twmflags.stackmode
414 #define iconify_by_unmapping twmflags.iconify_by_unmapping
415 #define transient twmflags.transient
416 #define titlehighlight twmflags.titlehighlight
417 #define wShaped twmflags.wShaped
418 #define nailed twmflags.nailed
419 #define showindesktopdisplay twmflags.showindesktopdisplay
422 #define opaque_move twmflags.opaque_move
423 #define opaque_resize twmflags.opaque_resize
427 Window transientfor; /* window contained in XA_XM_TRANSIENT_FOR */
428 struct IconMgr *iconmgrp; /* pointer to it if this is an icon manager */
429 int save_frame_x; /* x position of frame */
430 int save_frame_y; /* y position of frame */
431 int save_frame_width; /* width of frame */
432 int save_frame_height; /* height of frame */
433 unsigned long protocols; /* which protocols this window handles */
434 Colormaps cmaps; /* colormaps for this application */
435 TBWindow *titlebuttons;
436 SqueezeInfo *squeeze_info; /* should the title be squeezed? */
438 struct TwmWindow *next, *prev;
439 #ifdef ORIGINAL_WARPRINGCOORDINATES /* djhjr - 5/11/98 */
446 #define DoesWmTakeFocus (1L << 0)
447 #define DoesWmSaveYourself (1L << 1)
448 #define DoesWmDeleteWindow (1L << 2)
450 #define TBPM_DOT ":dot" /* name of titlebar pixmap for dot */
451 #define TBPM_ICONIFY ":iconify" /* same image as dot */
452 #define TBPM_RESIZE ":resize" /* name of titlebar pixmap for resize button */
453 #define TBPM_XLOGO ":xlogo" /* name of titlebar pixmap for xlogo */
454 #define TBPM_DELETE ":delete" /* same image as xlogo */
455 #define TBPM_MENU ":menu" /* name of titlebar pixmap for menus */
456 #define TBPM_QUESTION ":question" /* name of unknown titlebar pixmap */
459 #define TBPM_RARROW ":rarrow" /* name of right arrow pixmap */
460 #define TBPM_DARROW ":darrow" /* name of down arrow pixmap */
462 /* djhjr - 4/18/96 */
463 #define TBPM_3DDOT ":xpm:dot" /* name of titlebar pixmap for dot */
464 #define TBPM_3DRESIZE ":xpm:resize" /* name of titlebar pixmap for resize button */
465 #define TBPM_3DMENU ":xpm:menu" /* name of titlebar pixmap for menus */
466 #define TBPM_3DZOOM ":xpm:zoom"
467 #define TBPM_3DBAR ":xpm:bar"
470 #define TBPM_3DRARROW ":xpm:rarrow" /* name of right arrow pixmap */
471 #define TBPM_3DDARROW ":xpm:darrow" /* name of down arrow pixmap */
473 /* djhjr - 10/25/02 */
474 #define TBPM_3DRAISEDBOX ":xpm:raisedbox" /* name of raised box highlight pixmap */
475 #define TBPM_3DSUNKENBOX ":xpm:sunkenbox" /* name of sunken box highlight pixmap */
476 #define TBPM_3DRAISEDLINES ":xpm:raisedlines" /* name of raised lines highlight pixmap */
477 #define TBPM_3DSUNKENLINES ":xpm:sunkenlines" /* name of sunken lines highlight pixmap */
479 /* djhjr - 10/30/02 */
480 #define TBPM_3DBOX ":xpm:box" /* name of box pixmap */
481 #define TBPM_3DLINES ":xpm:lines" /* name of lines pixmap */
483 #ifdef NEVER /* stay X11R4 compatable; X11R5,6 doesn't seem to mind! */
484 #include <X11/Xosdefs.h>
486 #ifndef X_NOT_STDC_ENV
489 extern char *malloc(), *calloc(), *realloc(), *getenv();
492 extern void Reborder();
494 /* djhjr - 6/22/01 */
495 #ifndef NO_SOUND_SUPPORT
496 extern SIGNAL_T PlaySoundDone();
499 extern SIGNAL_T Done();
502 void ComputeCommonTitleOffsets();
503 void ComputeWindowTitleOffsets(), ComputeTitleLocation();
505 extern char *ProgramName;
507 extern Window ResizeWindow; /* the window we are resizing */
508 extern int HasShape; /* this server supports Shape extension */
510 extern int PreviousScreen;
512 extern Cursor UpperLeftCursor;
513 extern Cursor RightButt;
514 extern Cursor MiddleButt;
515 extern Cursor LeftButt;
517 extern XClassHint NoClass;
519 extern XContext TwmContext;
520 extern XContext MenuContext;
521 extern XContext IconManagerContext;
522 extern XContext VirtualContext;
523 extern XContext ScreenContext;
524 extern XContext ColormapContext;
525 extern XContext DoorContext;
529 extern int ParseError;
531 extern int HandlingEvents;
533 extern Window JunkRoot;
534 extern Window JunkChild;
537 extern unsigned int JunkWidth, JunkHeight, JunkBW, JunkDepth, JunkMask;
538 extern XGCValues Gcv;
539 extern int InfoLines;
540 extern char Info[][INFO_SIZE];
543 extern char **Environ;
545 extern void NewFontCursor();
546 extern Pixmap CreateMenuIcon();
547 extern void RestoreWithdrawnLocation();
548 extern void CreateFonts();
550 /* djhjr - 4/18/96 */
551 extern Pixmap Create3DMenuIcon();
552 extern Pixmap Create3DIconManagerIcon();
553 extern void Draw3DBorder();
555 extern Bool ErrorOccurred;
556 extern XErrorEvent LastErrorEvent;
558 #define ResetError() (ErrorOccurred = False)
560 extern Bool RestartPreviousState;
561 extern Bool GetWMState();
563 /* djhjr - 9/14/03 */
564 #ifndef NO_I18N_SUPPORT
565 extern Bool use_fontset;
568 extern Atom _XA_MIT_PRIORITY_COLORS;
569 extern Atom _XA_WM_CHANGE_STATE;
570 extern Atom _XA_WM_STATE;
571 extern Atom _XA_WM_COLORMAP_WINDOWS;
572 extern Atom _XA_WM_PROTOCOLS;
573 extern Atom _XA_WM_TAKE_FOCUS;
574 extern Atom _XA_WM_SAVE_YOURSELF;
575 extern Atom _XA_WM_DELETE_WINDOW;
577 /* djhjr - 7/31/98 */
578 extern Atom _XA_TWM_RESTART;