|
|
1.1 root 1: #include "copyright.h"
2:
3: /* $Header: Xlibint.h,v 11.40 87/06/24 11:32:42 swick Exp $ */
4: /* Copyright 1984, 1985, 1987 Massachusetts Institute of Technology */
5:
6: /*
7: * XlibInternal.h - Header definition and support file for the internal
8: * support routines (XlibInternal) used by the C subroutine interface
9: * library (Xlib) to the X Window System.
10: *
11: */
12: #ifndef NEED_EVENTS
13: #define _XEVENT_
14: #endif
15: #include <sys/types.h>
16: #include <X11/Xlib.h>
17: #include <X11/Xproto.h>
18: #include "Xlibos.h"
19: #include <errno.h>
20:
21: #ifndef NULL
22: #define NULL 0
23: #endif
24: #define LOCKED 1
25: #define UNLOCKED 0
26:
27: extern int errno; /* Internal system error number. */
28: extern void bcopy();
29:
30: extern (*_XIOErrorFunction)(); /* X system error reporting routine. */
31: extern (*_XErrorFunction)(); /* X_Error event reporting routine. */
32: extern char *_XAllocScratch(); /* fast memory allocator */
33: extern Visual *_XVIDtoVisual(); /* given visual id, find structure */
34:
35: #define BUFSIZE 2048 /* X output buffer size. */
36: #define EPERBATCH 8 /* when batching, how many elements */
37: #define CURSORFONT "cursor" /* standard cursor fonts */
38:
39: /*
40: * X Protocol packetizing macros.
41: */
42:
43:
44: /*
45: * GetReq - Get the next avilable X request packet in the buffer and
46: * return it.
47: *
48: * "name" is the name of the request, e.g. CreatePixmap, OpenFont, etc.
49: * "req" is the name of the request pointer.
50: *
51: */
52:
53: #define GetReq(name, req) \
54: if ((dpy->bufptr + sizeof(x/**/name/**/Req)) > dpy->bufmax)\
55: _XFlush(dpy);\
56: req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
57: req->reqType = X_/**/name;\
58: req->length = (sizeof(x/**/name/**/Req))>>2;\
59: dpy->bufptr += sizeof(x/**/name/**/Req);\
60: dpy->request++
61:
62: /* GetReqExtra is the same as GetReq, but allocates "n" additional
63: bytes after the request. "n" must be a multiple of 4! */
64:
65:
66: #define GetReqExtra(name, n, req) \
67: if ((dpy->bufptr + sizeof(x/**/name/**/Req) + n) > dpy->bufmax)\
68: _XFlush(dpy);\
69: req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
70: req->reqType = X_/**/name;\
71: req->length = (sizeof(x/**/name/**/Req) + n)>>2;\
72: dpy->bufptr += sizeof(x/**/name/**/Req) + n;\
73: dpy->request++
74:
75: /*
76: * GetResReq is for those requests that have a resource ID
77: * (Window, Pixmap, GContext, etc.) as their single argument.
78: * "rid" is the name of the resource.
79: */
80:
81: #define GetResReq(name, rid, req) \
82: if ((dpy->bufptr + sizeof(xResourceReq)) > dpy->bufmax)\
83: _XFlush(dpy);\
84: req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\
85: req->reqType = X_/**/name;\
86: req->length = 2;\
87: req->id = (rid);\
88: dpy->bufptr += sizeof(xResourceReq);\
89: dpy->request++
90:
91: /*
92: * GetEmptyReq is for those requests that have no arguments
93: * at all.
94: */
95:
96: #define GetEmptyReq(name, req) \
97: if ((dpy->bufptr + sizeof(xReq)) > dpy->bufmax)\
98: _XFlush(dpy);\
99: req = (xReq *) (dpy->last_req = dpy->bufptr);\
100: req->reqType = X_/**/name;\
101: req->length = 1;\
102: dpy->bufptr += sizeof(xReq);\
103: dpy->request++
104:
105: #define SyncHandle() \
106: if (dpy->synchandler) (*dpy->synchandler)(dpy)
107:
108: #define FlushGC(dpy, gc) \
109: if ((gc)->dirty) _XFlushGCCache((dpy), (gc))
110: /*
111: * Data - Place data in the buffer and pad the end to provide
112: * 32 bit word alignment. Transmit if the buffer fills.
113: *
114: * "dpy" is a pointer to a Display.
115: * "data" is a pinter to a data buffer.
116: * "len" is the length of the data buffer.
117: * we can presume buffer less than 2^16 bytes, so bcopy can be used safely.
118: */
119: #define Data(dpy, data, len) \
120: if (dpy->bufptr + (len) <= dpy->bufmax) {\
121: bcopy(data, dpy->bufptr, (int)len);\
122: dpy->bufptr += ((len) + 3) & ~3;\
123: } else\
124: _XSend(dpy, data, len)
125:
126:
127: /* Allocate bytes from the buffer. No padding is done, so if
128: * the length is not a multiple of 4, the caller must be
129: * careful to leave the buffer aligned after sending the
130: * current request.
131: *
132: * "type" is the type of the pointer being assigned to.
133: * "ptr" is the pointer being assigned to.
134: * "n" is the number of bytes to allocate.
135: *
136: * Example:
137: * xTextElt *elt;
138: * BufAlloc (xTextElt *, elt, nbytes)
139: */
140:
141: #define BufAlloc(type, ptr, n) \
142: if (dpy->bufptr + (n) > dpy->bufmax) \
143: _XFlush (dpy); \
144: ptr = (type) dpy->bufptr; \
145: dpy->bufptr += (n);
146:
147: #ifndef BIGSHORTS
148: #define PackData(dpy, data, len) Data(dpy, data, len)
149: #define PackShorts(f, t, n) bcopy(f, t, n)
150: #endif
151:
152: #define min(a,b) (((a) < (b)) ? (a) : (b))
153: #define max(a,b) (((a) > (b)) ? (a) : (b))
154:
155: #define CI_NONEXISTCHAR 0x4000 /* required because QueryFont represents
156: a non-existant character with zero-value
157: metrics, but requires drivers to output
158: the default char in their place. */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.