Debian Codegraph @

nx-X11/lib/src/Macros.c

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