Macros.c revision 61b2299d
1/* $Xorg: Macros.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
2/*
3
4Copyright 1987, 1998  The Open Group
5
6Permission to use, copy, modify, distribute, and sell this software and its
7documentation for any purpose is hereby granted without fee, provided that
8the above copyright notice appear in all copies and that both that
9copyright notice and this permission notice appear in supporting
10documentation.
11
12The above copyright notice and this permission notice shall be included in
13all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
18OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22Except as contained in this notice, the name of The Open Group shall not be
23used in advertising or otherwise to promote the sale, use or other dealings
24in this Software without prior written authorization from The Open Group.
25
26*/
27/* $XFree86: xc/lib/X11/Macros.c,v 1.4 2001/12/14 19:54:02 dawes Exp $ */
28
29#ifdef HAVE_CONFIG_H
30#include <config.h>
31#endif
32#include "Xlibint.h"
33#define XUTIL_DEFINE_FUNCTIONS
34#include "Xutil.h"
35
36/*
37 * This file makes full definitions of routines for each macro.
38 * We do not expect C programs to use these, but other languages may
39 * need them.
40 */
41
42int XConnectionNumber(Display *dpy) { return (ConnectionNumber(dpy)); }
43
44Window XRootWindow (Display *dpy, int scr)
45{
46    return (RootWindow(dpy,scr));
47}
48
49int XDefaultScreen(Display *dpy) { return (DefaultScreen(dpy)); }
50
51Window XDefaultRootWindow (Display *dpy)
52{
53    return (RootWindow(dpy,DefaultScreen(dpy)));
54}
55
56Visual *XDefaultVisual(Display *dpy, int scr)
57{
58    return (DefaultVisual(dpy, scr));
59}
60
61GC XDefaultGC(Display *dpy, int scr)
62{
63    return (DefaultGC(dpy,scr));
64}
65
66unsigned long XBlackPixel(Display *dpy, int scr)
67{
68    return (BlackPixel(dpy, scr));
69}
70
71unsigned long XWhitePixel(Display *dpy, int scr)
72{
73    return (WhitePixel(dpy,scr));
74}
75
76unsigned long XAllPlanes(void) { return AllPlanes; }
77
78int XQLength(Display *dpy) { return (QLength(dpy)); }
79
80int XDisplayWidth(Display *dpy, int scr)
81{
82    return (DisplayWidth(dpy,scr));
83}
84
85int XDisplayHeight(Display *dpy, int scr)
86{
87    return (DisplayHeight(dpy, scr));
88}
89
90int XDisplayWidthMM(Display *dpy, int scr)
91{
92    return (DisplayWidthMM(dpy, scr));
93}
94
95int XDisplayHeightMM(Display *dpy, int scr)
96{
97    return (DisplayHeightMM(dpy, scr));
98}
99
100int XDisplayPlanes(Display *dpy, int scr)
101{
102    return (DisplayPlanes(dpy, scr));
103}
104
105int XDisplayCells(Display *dpy, int scr)
106{
107    return (DisplayCells (dpy, scr));
108}
109
110int XScreenCount(Display *dpy) { return (ScreenCount(dpy)); }
111
112char *XServerVendor(Display *dpy) { return (ServerVendor(dpy)); }
113
114int XProtocolVersion(Display *dpy) { return (ProtocolVersion(dpy)); }
115
116int XProtocolRevision(Display *dpy) { return (ProtocolRevision(dpy));}
117
118int XVendorRelease(Display *dpy) { return (VendorRelease(dpy)); }
119
120char *XDisplayString(Display *dpy) { return (DisplayString(dpy)); }
121
122int XDefaultDepth(Display *dpy, int scr)
123{
124    return(DefaultDepth(dpy, scr));
125}
126
127Colormap XDefaultColormap(Display *dpy, int scr)
128{
129    return (DefaultColormap(dpy, scr));
130}
131
132int XBitmapUnit(Display *dpy) { return (BitmapUnit(dpy)); }
133
134int XBitmapBitOrder(Display *dpy) { return (BitmapBitOrder(dpy)); }
135
136int XBitmapPad(Display *dpy) { return (BitmapPad(dpy)); }
137
138int XImageByteOrder(Display *dpy) { return (ImageByteOrder(dpy)); }
139
140unsigned long XNextRequest(Display *dpy)
141{
142#ifdef WORD64
143    WORD64ALIGN
144    return dpy->request + 1;
145#else
146    return (NextRequest(dpy));
147#endif
148}
149
150unsigned long XLastKnownRequestProcessed(Display *dpy)
151{
152    return (LastKnownRequestProcessed(dpy));
153}
154
155/* screen oriented macros (toolkit) */
156Screen *XScreenOfDisplay(Display *dpy, int scr)
157{
158    return (ScreenOfDisplay(dpy, scr));
159}
160
161Screen *XDefaultScreenOfDisplay(Display *dpy)
162{
163    return (DefaultScreenOfDisplay(dpy));
164}
165
166Display *XDisplayOfScreen(Screen *s) { return (DisplayOfScreen(s)); }
167
168Window XRootWindowOfScreen(Screen *s) { return (RootWindowOfScreen(s)); }
169
170unsigned long XBlackPixelOfScreen(Screen *s)
171{
172    return (BlackPixelOfScreen(s));
173}
174
175unsigned long XWhitePixelOfScreen(Screen *s)
176{
177    return (WhitePixelOfScreen(s));
178}
179
180Colormap XDefaultColormapOfScreen(Screen *s)
181{
182    return (DefaultColormapOfScreen(s));
183}
184
185int XDefaultDepthOfScreen(Screen *s)
186{
187    return (DefaultDepthOfScreen(s));
188}
189
190GC XDefaultGCOfScreen(Screen *s)
191{
192    return (DefaultGCOfScreen(s));
193}
194
195Visual *XDefaultVisualOfScreen(Screen *s)
196{
197    return (DefaultVisualOfScreen(s));
198}
199
200int XWidthOfScreen(Screen *s) { return (WidthOfScreen(s)); }
201
202int XHeightOfScreen(Screen *s) { return (HeightOfScreen(s)); }
203
204int XWidthMMOfScreen(Screen *s) { return (WidthMMOfScreen(s)); }
205
206int XHeightMMOfScreen(Screen *s) { return (HeightMMOfScreen(s)); }
207
208int XPlanesOfScreen(Screen *s) { return (PlanesOfScreen(s)); }
209
210int XCellsOfScreen(Screen *s) { return (CellsOfScreen(s)); }
211
212int XMinCmapsOfScreen(Screen *s) { return (MinCmapsOfScreen(s)); }
213
214int XMaxCmapsOfScreen(Screen *s) { return (MaxCmapsOfScreen(s)); }
215
216Bool XDoesSaveUnders(Screen *s) { return (DoesSaveUnders(s)); }
217
218int XDoesBackingStore(Screen *s) { return (DoesBackingStore(s)); }
219
220long XEventMaskOfScreen(Screen *s) { return (EventMaskOfScreen(s)); }
221
222int XScreenNumberOfScreen (register Screen *scr)
223{
224    register Display *dpy = scr->display;
225    register Screen *dpyscr = dpy->screens;
226    register int i;
227
228    for (i = 0; i < dpy->nscreens; i++, dpyscr++) {
229	if (scr == dpyscr) return i;
230    }
231    return -1;
232}
233
234/*
235 * These macros are used to give some sugar to the image routines so that
236 * naive people are more comfortable with them.
237 */
238#undef XDestroyImage
239int
240XDestroyImage(
241	XImage *ximage)
242{
243	return((*((ximage)->f.destroy_image))((ximage)));
244}
245#undef XGetPixel
246unsigned long XGetPixel(
247	XImage *ximage,
248	int x, int y)
249{
250	return ((*((ximage)->f.get_pixel))((ximage), (x), (y)));
251}
252#undef XPutPixel
253int XPutPixel(
254	XImage *ximage,
255	int x, int y,
256	unsigned long pixel)
257{
258	return((*((ximage)->f.put_pixel))((ximage), (x), (y), (pixel)));
259}
260#undef XSubImage
261XImage *XSubImage(
262	XImage *ximage,
263	int x, int y,
264	unsigned int width, unsigned int height)
265{
266	return((*((ximage)->f.sub_image))((ximage), (x),
267		(y), (width), (height)));
268}
269#undef XAddPixel
270int XAddPixel(
271	XImage *ximage,
272	long value)
273{
274	return((*((ximage)->f.add_pixel))((ximage), (value)));
275}
276
277
278int
279XNoOp (register Display *dpy)
280{
281    register xReq *req;
282
283    LockDisplay(dpy);
284    GetEmptyReq(NoOperation, req);
285
286    UnlockDisplay(dpy);
287    SyncHandle();
288    return 1;
289}
290