1: #include <X/mit-copyright.h> 2: 3: /* Copyright Massachusetts Institute of Technology 1985 */ 4: /* $Header: Xint.h,v 10.8 86/02/01 15:15:27 tony Rel $ */ 5: 6: /* Internal definitions for X server */ 7: 8: #include <sys/param.h> 9: #include <stdio.h> 10: #include "X.h" 11: #include "Xproto.h" 12: #include "vsinput.h" 13: #include "Xdev.h" 14: 15: #define funclim 16 /* max GXfunction + 1 */ 16: 17: #define maxsocks (NOFILE - 1) /* maximum open sockets */ 18: #define mskcnt ((maxsocks + 31) / 32) /* size of bit array */ 19: 20: #if (mskcnt==1) 21: #define copybits(src, dst) dst[0] = src[0] 22: #define clearbits(buf) buf[0] = 0 23: #endif 24: #if (mskcnt==2) 25: #define copybits(src, dst) dst[0] = src[0]; dst[1] = src[1] 26: #define clearbits(buf) buf[0] = 0; buf[1] = 0 27: #endif 28: #if (mskcnt==3) 29: #define copybits(src, dst) dst[0] = src[0]; dst[1] = src[1]; dst[2] = src[2]; 30: #define clearbits(buf) buf[0] = 0; buf[1] = 0; buf[2] = 0 31: #endif 32: #if (mskcnt>3) 33: #define copybits(src, dst) bcopy((caddr_t) src, (caddr_t) dst, sizeof (src)) 34: #define clearbits(buf) bzero((caddr_t) buf, sizeof (buf)) 35: #endif 36: 37: #if (mskcnt==1) 38: #define bitmask(i) (1 << (i)) 39: #define maskidx(i) 0 40: #endif 41: #if (mskcnt>1) 42: #define bitmask(i) (1 << ((i) & 31)) 43: #define maskidx(i) ((i) >> 5) 44: #endif 45: 46: #define maskword(buf, i) buf[maskidx(i)] 47: #define bitset(buf, i) maskword(buf, i) |= bitmask(i) 48: #define bitclear(buf, i) maskword(buf, i) &= ~bitmask(i) 49: #define getbit(buf, i) (maskword(buf, i) & bitmask(i)) 50: 51: #if (mskcnt==1) 52: #define singlebit(buf, i) maskword(buf, i) = bitmask(i) 53: #endif 54: #if (mskcnt>1) 55: #define singlebit(buf, i) clearbits(buf); bitset(buf, i) 56: #endif 57: 58: typedef struct _resource { 59: struct _resource *next, *prev; /* chain pointers */ 60: caddr_t value; /* the object */ 61: char type; /* RT_* */ 62: long id; /* resource id */ 63: } RESOURCE; 64: 65: #define RT_FREE 0 66: #define RT_WINDOW 1 67: #define RT_FONT 2 68: #define RT_BITMAP 3 69: #define RT_PIXMAP 4 70: #define RT_CURSOR 5 71: 72: #define RESIDX(id) ((id) & 0xffff) /* index in low 16 bits */ 73: 74: /* Now define the rectangle types and the rectangle itself */ 75: 76: #define contents_rec 0 77: #define new_rec 1 78: #define border_rec 2 79: 80: /* The first 4 components must match RASTER */ 81: 82: typedef struct rec { 83: short bottom; /* not inclusive */ 84: short right; /* not inclusive */ 85: short left; 86: short top; 87: short type; /* one of *_rec types above */ 88: short internal; /* 1: not head of malloc() area */ 89: struct rec *next; /* chain pointer */ 90: } RECTANGLE; 91: 92: typedef struct { /* components must match REGION */ 93: short bottom; /* not inclusive */ 94: short right; /* not inclusive */ 95: short left; 96: short top; 97: } RASTER; 98: 99: typedef struct { /* component order dictated by protocol */ 100: short height; 101: short width; 102: short left; 103: short top; 104: } REGION; 105: 106: /* A window */ 107: /* If mapped is true, coords are absolute (i.e. relative only to the root 108: * window). Otherwise, they are relative to the parent window's origin. 109: */ 110: 111: typedef struct wnode { 112: RASTER full; /* Inside dimensions not clipped by parent */ 113: RASTER vs; /* Inside dimensions clipped by parent */ 114: RASTER ovs; /* Outside dimensions clipped by parent */ 115: CLIP clip; /* vs as clipping rectangle */ 116: struct wnode *parent; /* Who contains this window */ 117: struct wnode *next_sib; /* Other windows it contains */ 118: struct wnode *prev_sib; /* (linked two ways) */ 119: struct wnode *first_child; /* Bottom-most window this contains */ 120: struct wnode *last_child; /* Top-most window it contains */ 121: RECTANGLE *visible; /* List of visible rectangles */ 122: RECTANGLE *cmvisible; /* List of visible rectangles when clipmode */ 123: ushort level; /* The level in the window hierarchy */ 124: /* child.level = parent.level + 1 */ 125: char unobscured; /* 0: obscured, 1: unobscured (3 temp), OB_* */ 126: char kind; /* 0: transparent, 1: opaque, 2: icon */ 127: char clipmode; /* 0: clipped, 1: draw-thru */ 128: char tilemode; /* 0: absolute, 1: relative */ 129: char mapped; /* 0: unmapped, 1: mapped */ 130: char should_be_mapped; /* 0: unmapped, 1: should be mapped */ 131: CURSOR *cursor; /* The cursor information */ 132: PIXMAP *tile; /* The background tile */ 133: PIXMAP *border; /* The border tile */ 134: short bwidth; /* The border width */ 135: char bgrabs; /* Button grab count */ 136: char internal; /* 1: not head of malloc() area */ 137: long mask; /* The input event mask */ 138: int client; /* Client asking for events */ 139: long rid; /* Resource identifier */ 140: short width0; /* Minimum width */ 141: short widthinc; /* Width increment */ 142: short height0; /* Minimum height */ 143: short heightinc; /* Height increment */ 144: char *name; /* Window name */ 145: struct wnode *icon; /* Icon or normal window */ 146: struct wnode *next; /* mapped_list chain pointers */ 147: struct wnode *prev; 148: } WINDOW; 149: 150: #define OB_NOT 0 151: #define OB_YES 1 152: #define OB_TMP 3 /* not 2, for lsb test */ 153: 154: #define max(x,y) ((x) >= (y) ? (x) : (y)) 155: #define min(x,y) ((x) <= (y) ? (x) : (y)) 156: 157: /* create a new rectangle */ 158: #define NEWRECT(r,lf,rt,tp,bt,ty) if ((r = free_rectangles) == NULL)\ 159: r = Alloc_rectangle ();\ 160: free_rectangles = r->next;\ 161: r->left = lf; r->right = rt;\ 162: r->top = tp; r->bottom = bt;\ 163: r->type = ty 164: 165: /* create a new rectangle from a raster */ 166: #define RASTRECT(r,rs,ty) if ((r = free_rectangles) == NULL)\ 167: r = Alloc_rectangle ();\ 168: free_rectangles = r->next;\ 169: *(RASTER *) r = rs;\ 170: r->type = ty 171: 172: /* free a rectangle */ 173: #define FREERECT(r) r->next = free_rectangles; free_rectangles = r 174: 175: #define BytePad(n) (((n) + 3) & ~3) 176: #define WordPad(n) (((n) + 3) & ~3) 177: 178: /* byte swap a long literal */ 179: #define lswapl(x) ((((x) & 0xff) << 24) |\ 180: (((x) & 0xff00) << 8) |\ 181: (((x) & 0xff000) >> 8) |\ 182: (((x) >> 24) & 0xff)) 183: /* byte swap a short literal */ 184: #define lswaps(x) ((((x) & 0xff) << 8) | (((x) >> 8) & 0xff)) 185: /* byte swap a long */ 186: #define swapl(x) n = ((char *) (x))[0];\ 187: ((char *) (x))[0] = ((char *) (x))[3];\ 188: ((char *) (x))[3] = n;\ 189: n = ((char *) (x))[1];\ 190: ((char *) (x))[1] = ((char *) (x))[2];\ 191: ((char *) (x))[2] = n 192: /* byte swap a short */ 193: #define swaps(x) n = ((char *) (x))[0];\ 194: ((char *) (x))[0] = ((char *) (x))[1];\ 195: ((char *) (x))[1] = n 196: /* byte swap a long parameter */ 197: #define pswapl(x, i) n = (x)->param.b[4*(i)];\ 198: (x)->param.b[4*(i)] = (x)->param.b[4*(i)+3];\ 199: (x)->param.b[4*(i)+3] = n;\ 200: n = (x)->param.b[4*(i)+1];\ 201: (x)->param.b[4*(i)+1] = (x)->param.b[4*(i)+2];\ 202: (x)->param.b[4*(i)+2] = n 203: /* byte swap a short parameter */ 204: #define pswaps(x, i) n = (x)->param.b[2*(i)];\ 205: (x)->param.b[2*(i)] = (x)->param.b[2*(i)+1];\ 206: (x)->param.b[2*(i)+1] = n 207: 208: #ifdef vax 209: #define swaptype int 210: #else 211: #define swaptype char 212: #endif 213: 214: #ifdef vax 215: #define TRUE(b) ((b) & 1) 216: #define FALSE(b) (!((b) & 1)) 217: #else 218: #define TRUE(b) (b) 219: #define FALSE(b) (!(b)) 220: #endif