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