Commit | Line | Data |
---|---|---|
805e021f CE |
1 | /* |
2 | * Copyright 2000, International Business Machines Corporation and others. | |
3 | * All Rights Reserved. | |
4 | * | |
5 | * This software has been released under the terms of the IBM Public | |
6 | * License. For details, see the LICENSE file in the top-level source | |
7 | * directory or online at http://www.openafs.org/dl/license10.html | |
8 | */ | |
9 | ||
10 | /* | |
11 | * gator_X11windows.c | |
12 | * | |
13 | * Description: | |
14 | * Implementation of the gator X11 window facility. | |
15 | * | |
16 | *------------------------------------------------------------------------*/ | |
17 | ||
18 | #include <afsconfig.h> | |
19 | #include <afs/param.h> | |
20 | ||
21 | #include <roken.h> | |
22 | ||
23 | #include "gtxX11win.h" /*Interface definition */ | |
24 | ||
25 | int X11_debug; /*Is debugging turned on? */ | |
26 | static char mn[] = "gator_X11windows"; /*Module name */ | |
27 | ||
28 | /* | |
29 | * Version of standard operations for a X11 window. | |
30 | */ | |
31 | struct gwinops X11_gwinops = { | |
32 | gator_X11gwin_box, | |
33 | gator_X11gwin_clear, | |
34 | gator_X11gwin_destroy, | |
35 | gator_X11gwin_display, | |
36 | gator_X11gwin_drawline, | |
37 | gator_X11gwin_drawrectangle, | |
38 | gator_X11gwin_drawchar, | |
39 | gator_X11gwin_drawstring, | |
40 | gator_X11gwin_invert, | |
41 | gator_X11gwin_getchar, | |
42 | gator_X11gwin_getdimensions, | |
43 | gator_X11gwin_wait, | |
44 | }; | |
45 | ||
46 | struct gwinbaseops gator_X11_gwinbops = { | |
47 | gator_X11gwin_create, | |
48 | gator_X11gwin_cleanup | |
49 | }; | |
50 | ||
51 | /* | |
52 | * Macros to map pixel positions to row & column positions. | |
53 | * (Note: for now, they are the identity function!!) | |
54 | */ | |
55 | #define GATOR_MAP_X_TO_COL(w, x) (x) | |
56 | #define GATOR_MAP_Y_TO_LINE(w, y) (y) | |
57 | ||
58 | /*------------------------------------------------------------------------ | |
59 | * gator_X11gwin_init | |
60 | * | |
61 | * Description: | |
62 | * Initialize the X11 window package. | |
63 | * | |
64 | * Arguments: | |
65 | * int adebug: Is debugging turned on? | |
66 | * | |
67 | * Returns: | |
68 | * 0 on success, | |
69 | * Error value otherwise. | |
70 | * | |
71 | * Environment: | |
72 | * Nothing interesting. | |
73 | * | |
74 | * Side Effects: | |
75 | * As advertised. | |
76 | *------------------------------------------------------------------------*/ | |
77 | ||
78 | int | |
79 | gator_X11gwin_init(int adebug) | |
80 | { /*gator_X11gwin_init */ | |
81 | ||
82 | static char rn[] = "gator_X11gwin_init"; /*Routine name */ | |
83 | ||
84 | /* | |
85 | * Remember if we'll be doing debugging, init X11 and clear the | |
86 | * standard screen. | |
87 | */ | |
88 | X11_debug = adebug; | |
89 | ||
90 | if (X11_debug) | |
91 | fprintf(stderr, "[%s:%s] Called\n", mn, rn); | |
92 | ||
93 | /* | |
94 | * We return success, fill this routine it at some point. | |
95 | */ | |
96 | return (0); | |
97 | ||
98 | } /*gator_X11gwin_init */ | |
99 | ||
100 | /*------------------------------------------------------------------------ | |
101 | * gator_X11gwin_create | |
102 | * | |
103 | * Description: | |
104 | * Create a X11 window. | |
105 | * | |
106 | * Arguments: | |
107 | * struct gator_X11gwin_params *params : Ptr to creation parameters. | |
108 | * | |
109 | * Returns: | |
110 | * Ptr to the created X11 window if successful, | |
111 | * Null ptr otherwise. | |
112 | * | |
113 | * Environment: | |
114 | * Nothing interesting. | |
115 | * | |
116 | * Side Effects: | |
117 | * As advertised. | |
118 | *------------------------------------------------------------------------*/ | |
119 | ||
120 | struct gwin * | |
121 | gator_X11gwin_create(void *rock) | |
122 | { /*gator_X11gwin_create */ | |
123 | ||
124 | static char rn[] = "gator_X11gwin_create"; /*Routine name */ | |
125 | ||
126 | if (X11_debug) | |
127 | fprintf(stderr, "[%s:%s] Called\n", mn, rn); | |
128 | ||
129 | return (NULL); | |
130 | ||
131 | } /*gator_X11gwin_create */ | |
132 | ||
133 | /*------------------------------------------------------------------------ | |
134 | * gator_X11gwin_cleanup | |
135 | * | |
136 | * Description: | |
137 | * Create a X11 window. | |
138 | * | |
139 | * Arguments: | |
140 | * struct gwin *gwp : Ptr to base window. | |
141 | * | |
142 | * Returns: | |
143 | * 0 on success, | |
144 | * Error value otherwise. | |
145 | * | |
146 | * Environment: | |
147 | * Nothing interesting. | |
148 | * | |
149 | * Side Effects: | |
150 | * As advertised. | |
151 | *------------------------------------------------------------------------*/ | |
152 | ||
153 | int | |
154 | gator_X11gwin_cleanup(struct gwin *gwp) | |
155 | { /*gator_X11gwin_cleanup */ | |
156 | ||
157 | static char rn[] = "gator_X11gwin_cleanup"; /*Routine name */ | |
158 | ||
159 | if (X11_debug) | |
160 | fprintf(stderr, "[%s:%s] Called\n", mn, rn); | |
161 | ||
162 | return (0); | |
163 | ||
164 | } /*gator_X11gwin_cleanup */ | |
165 | ||
166 | /*------------------------------------------------------------------------ | |
167 | * gator_X11gwin_box | |
168 | * | |
169 | * Description: | |
170 | * Draw a box around the given X11 window. | |
171 | * | |
172 | * Arguments: | |
173 | * struct gwin *gwp : Ptr to the X11 window to draw | |
174 | * a box around. | |
175 | * | |
176 | * Returns: | |
177 | * 0 on success, | |
178 | * Error value otherwise. | |
179 | * | |
180 | * Environment: | |
181 | * Nothing interesting. | |
182 | * | |
183 | * Side Effects: | |
184 | * As advertised. | |
185 | *------------------------------------------------------------------------*/ | |
186 | ||
187 | int | |
188 | gator_X11gwin_box(struct gwin *gwp) | |
189 | { /*gator_X11gwin_box */ | |
190 | ||
191 | static char rn[] = "gator_X11gwin_box"; /*Routine name */ | |
192 | ||
193 | if (X11_debug) | |
194 | fprintf(stderr, "[%s:%s] Called\n", mn, rn); | |
195 | ||
196 | return (0); | |
197 | ||
198 | } /*gator_X11gwin_box */ | |
199 | ||
200 | /*------------------------------------------------------------------------ | |
201 | * gator_X11gwin_clear | |
202 | * | |
203 | * Description: | |
204 | * Clear out the given X11 window. | |
205 | * | |
206 | * Arguments: | |
207 | * struct gwin *gwp : Ptr to the X11 window to clear out. | |
208 | * | |
209 | * Returns: | |
210 | * 0 on success, | |
211 | * Error value otherwise. | |
212 | * | |
213 | * Environment: | |
214 | * Nothing interesting. | |
215 | * | |
216 | * Side Effects: | |
217 | * As advertised. | |
218 | *------------------------------------------------------------------------*/ | |
219 | ||
220 | int | |
221 | gator_X11gwin_clear(struct gwin *gwp) | |
222 | { /*gator_X11gwin_clear */ | |
223 | ||
224 | static char rn[] = "gator_X11gwin_clear"; /*Routine name */ | |
225 | ||
226 | if (X11_debug) | |
227 | fprintf(stderr, "[%s:%s] Called\n", mn, rn); | |
228 | ||
229 | return (0); | |
230 | ||
231 | } /*gator_X11gwin_clear */ | |
232 | ||
233 | /*------------------------------------------------------------------------ | |
234 | * gator_X11gwin_destroy | |
235 | * | |
236 | * Description: | |
237 | * Destroy the given X11 window. | |
238 | * | |
239 | * Arguments: | |
240 | * struct gwin *gwp : Ptr to the X11 window to destroy. | |
241 | * | |
242 | * Returns: | |
243 | * 0 on success, | |
244 | * Error value otherwise. | |
245 | * | |
246 | * Environment: | |
247 | * Nothing interesting. | |
248 | * | |
249 | * Side Effects: | |
250 | * As advertised. | |
251 | *------------------------------------------------------------------------*/ | |
252 | ||
253 | int | |
254 | gator_X11gwin_destroy(struct gwin *gwp) | |
255 | { /*gator_X11gwin_destroy */ | |
256 | ||
257 | static char rn[] = "gator_X11gwin_destroy"; /*Routine name */ | |
258 | ||
259 | if (X11_debug) | |
260 | fprintf(stderr, "[%s:%s] Called\n", mn, rn); | |
261 | ||
262 | return (0); | |
263 | ||
264 | } /*gator_X11gwin_destroy */ | |
265 | ||
266 | /*------------------------------------------------------------------------ | |
267 | * gator_X11gwin_display | |
268 | * | |
269 | * Description: | |
270 | * Display/redraw the given X11 window. | |
271 | * | |
272 | * Arguments: | |
273 | * struct gwin *gwp : Ptr to the X11 window to draw. | |
274 | * | |
275 | * Returns: | |
276 | * 0 on success, | |
277 | * Error value otherwise. | |
278 | * | |
279 | * Environment: | |
280 | * Nothing interesting. | |
281 | * | |
282 | * Side Effects: | |
283 | * As advertised. | |
284 | *------------------------------------------------------------------------*/ | |
285 | ||
286 | int | |
287 | gator_X11gwin_display(struct gwin *gwp) | |
288 | { /*gator_X11gwin_display */ | |
289 | ||
290 | static char rn[] = "gator_X11gwin_display"; /*Routine name */ | |
291 | ||
292 | if (X11_debug) | |
293 | fprintf(stderr, "[%s:%s] Called\n", mn, rn); | |
294 | ||
295 | return (0); | |
296 | ||
297 | } /*gator_X11gwin_display */ | |
298 | ||
299 | /*------------------------------------------------------------------------ | |
300 | * gator_X11gwin_drawline | |
301 | * | |
302 | * Description: | |
303 | * Draw a line between two points in the given X11 | |
304 | * window. | |
305 | * | |
306 | * Arguments: | |
307 | * struct gwin *gwp : Ptr to the X11 window in which | |
308 | * the line is to be drawn. | |
309 | * struct gwin_lineparams *params : Ptr to other params. | |
310 | * | |
311 | * Returns: | |
312 | * 0 on success, | |
313 | * Error value otherwise. | |
314 | * | |
315 | * Environment: | |
316 | * Nothing interesting. | |
317 | * | |
318 | * Side Effects: | |
319 | * As advertised. | |
320 | *------------------------------------------------------------------------*/ | |
321 | ||
322 | int | |
323 | gator_X11gwin_drawline(struct gwin *gwp, struct gwin_lineparams *params) | |
324 | { /*gator_X11gwin_drawline */ | |
325 | ||
326 | static char rn[] = "gator_X11gwin_drawline"; /*Routine name */ | |
327 | ||
328 | if (X11_debug) | |
329 | fprintf(stderr, "[%s:%s] This routine is currently a no-op\n", mn, | |
330 | rn); | |
331 | ||
332 | return (0); | |
333 | ||
334 | } /*gator_X11gwin_drawline */ | |
335 | ||
336 | /*------------------------------------------------------------------------ | |
337 | * gator_X11gwin_drawrectangle | |
338 | * | |
339 | * Description: | |
340 | * Draw a rectangle in the given X11 window. | |
341 | * | |
342 | * Arguments: | |
343 | * struct gwin *gwp : Ptr to the X11 window in which | |
344 | * the rectangle is to be drawn. | |
345 | * struct gwin_rectparams *params : Ptr to other params. | |
346 | * | |
347 | * Returns: | |
348 | * 0 on success, | |
349 | * Error value otherwise. | |
350 | * | |
351 | * Environment: | |
352 | * Nothing interesting. | |
353 | * | |
354 | * Side Effects: | |
355 | * As advertised. | |
356 | *------------------------------------------------------------------------*/ | |
357 | ||
358 | int | |
359 | gator_X11gwin_drawrectangle(struct gwin *gwp, struct gwin_rectparams *params) | |
360 | { /*gator_X11gwin_drawrectangle */ | |
361 | ||
362 | static char rn[] = "gator_X11gwin_drawrectangle"; /*Routine name */ | |
363 | ||
364 | if (X11_debug) | |
365 | fprintf(stderr, "[%s:%s] This routine is currently a no-op\n", mn, | |
366 | rn); | |
367 | ||
368 | return (0); | |
369 | ||
370 | } /*gator_X11gwin_drawrectangle */ | |
371 | ||
372 | /*------------------------------------------------------------------------ | |
373 | * gator_X11gwin_drawchar | |
374 | * | |
375 | * Description: | |
376 | * Draw a character in the given X11 window. | |
377 | * | |
378 | * Arguments: | |
379 | * struct gwin *gwp : Ptr to the X11 window in which | |
380 | * the character is to be drawn. | |
381 | * struct gwin_charparams *params : Ptr to other params. | |
382 | * | |
383 | * Returns: | |
384 | * 0 on success, | |
385 | * Error value otherwise. | |
386 | * | |
387 | * Environment: | |
388 | * Nothing interesting. | |
389 | * | |
390 | * Side Effects: | |
391 | * As advertised. | |
392 | *------------------------------------------------------------------------*/ | |
393 | ||
394 | int | |
395 | gator_X11gwin_drawchar(struct gwin *gwp, struct gwin_charparams *params) | |
396 | { /*gator_X11gwin_drawchar */ | |
397 | ||
398 | static char rn[] = "gator_X11gwin_drawchar"; /*Routine name */ | |
399 | ||
400 | if (X11_debug) | |
401 | fprintf(stderr, "[%s:%s] Called\n", mn, rn); | |
402 | ||
403 | return (0); | |
404 | ||
405 | } /*gator_X11gwin_drawchar */ | |
406 | ||
407 | /*------------------------------------------------------------------------ | |
408 | * gator_X11gwin_drawstring | |
409 | * | |
410 | * Description: | |
411 | * Draw a string in the given X11 window. | |
412 | * | |
413 | * Arguments: | |
414 | * struct gwin *gwp : Ptr to the X11 window in which | |
415 | * the string is to be drawn. | |
416 | * struct gwin_strparams *params : Ptr to other params. | |
417 | * | |
418 | * Returns: | |
419 | * 0 on success, | |
420 | * Error value otherwise. | |
421 | * | |
422 | * Environment: | |
423 | * Nothing interesting. | |
424 | * | |
425 | * Side Effects: | |
426 | * As advertised. | |
427 | *------------------------------------------------------------------------*/ | |
428 | ||
429 | int | |
430 | gator_X11gwin_drawstring(struct gwin *gwp, struct gwin_strparams *params) | |
431 | { /*gator_X11gwin_drawstring */ | |
432 | ||
433 | static char rn[] = "gator_X11gwin_drawstring"; /*Routine name */ | |
434 | ||
435 | if (X11_debug) | |
436 | fprintf(stderr, "[%s:%s] Called\n", mn, rn); | |
437 | ||
438 | return (0); | |
439 | ||
440 | } /*gator_X11gwin_drawstring */ | |
441 | ||
442 | /*------------------------------------------------------------------------ | |
443 | * gator_X11gwin_invert | |
444 | * | |
445 | * Description: | |
446 | * Invert a region in the given X11 window. | |
447 | * | |
448 | * Arguments: | |
449 | * struct gwin *gwp : Ptr to the X11 window in which | |
450 | * the inverted region lies. | |
451 | * struct gwin_invparams *params : Ptr to other params. | |
452 | * | |
453 | * Returns: | |
454 | * 0 on success, | |
455 | * Error value otherwise. | |
456 | * | |
457 | * Environment: | |
458 | * Nothing interesting. | |
459 | * | |
460 | * Side Effects: | |
461 | * As advertised. | |
462 | *------------------------------------------------------------------------*/ | |
463 | ||
464 | int | |
465 | gator_X11gwin_invert(struct gwin *gwp, struct gwin_invparams *params) | |
466 | { /*gator_X11gwin_invert */ | |
467 | ||
468 | static char rn[] = "gator_X11gwin_invert"; /*Routine name */ | |
469 | ||
470 | if (X11_debug) | |
471 | fprintf(stderr, "[%s:%s] This routine is currently a no-op\n", mn, | |
472 | rn); | |
473 | ||
474 | return (0); | |
475 | ||
476 | } /*gator_X11gwin_invert */ | |
477 | ||
478 | /*------------------------------------------------------------------------ | |
479 | * gator_X11gwin_getchar | |
480 | * | |
481 | * Description: | |
482 | * Pick up a character from the given window. | |
483 | * | |
484 | * Arguments: | |
485 | * struct gwin *gwp : Ptr to the X11 window to listen to. | |
486 | * | |
487 | * Returns: | |
488 | * Value of the character read, | |
489 | * -1 otherwise. | |
490 | * | |
491 | * Environment: | |
492 | * Nothing interesting. | |
493 | * | |
494 | * Side Effects: | |
495 | * As advertised. | |
496 | *------------------------------------------------------------------------*/ | |
497 | ||
498 | int | |
499 | gator_X11gwin_getchar(struct gwin *gwp) | |
500 | { /*gator_X11gwin_getchar */ | |
501 | ||
502 | static char rn[] = "gator_X11gwin_getchar"; /*Routine name */ | |
503 | ||
504 | if (X11_debug) | |
505 | fprintf(stderr, "[%s:%s] This routine is currently a no-op\n", mn, | |
506 | rn); | |
507 | ||
508 | return (-1); | |
509 | ||
510 | } /*gator_X11gwin_getchar */ | |
511 | ||
512 | /*------------------------------------------------------------------------ | |
513 | * gator_X11gwin_getdimensions | |
514 | * | |
515 | * Description: | |
516 | * Get the window's X,Y dimensions. | |
517 | * | |
518 | * Arguments: | |
519 | * struct gwin *gwp : Ptr to the X11 window to examine. | |
520 | * struct gwin_sizeparams *aparms : Ptr to size params to set. | |
521 | * | |
522 | * Returns: | |
523 | * 0 if successful, | |
524 | * -1 otherwise. | |
525 | * | |
526 | * Environment: | |
527 | * Nothing interesting. | |
528 | * | |
529 | * Side Effects: | |
530 | * As advertised. | |
531 | *------------------------------------------------------------------------*/ | |
532 | ||
533 | int | |
534 | gator_X11gwin_getdimensions(struct gwin *gwp, struct gwin_sizeparams *aparms) | |
535 | { /*gator_X11gwin_getdimensions */ | |
536 | ||
537 | static char rn[] = "gator_X11gwin_getdimensions"; /*Routine name */ | |
538 | ||
539 | if (X11_debug) | |
540 | fprintf(stderr, "[%s:%s] This routine is currently a no-op\n", mn, | |
541 | rn); | |
542 | ||
543 | return (-1); | |
544 | ||
545 | } /*gator_X11gwin_getdimensions */ | |
546 | ||
547 | /*------------------------------------------------------------------------ | |
548 | * gator_X11gwin_wait | |
549 | * | |
550 | * Description: | |
551 | * Wait until input is available. | |
552 | * | |
553 | * Arguments: | |
554 | * struct gwin *gwp : Ptr to the X11 window to wait on. | |
555 | * | |
556 | * Returns: | |
557 | * 0 if successful, | |
558 | * -1 otherwise. | |
559 | * | |
560 | * Environment: | |
561 | * Nothing interesting. | |
562 | * | |
563 | * Side Effects: | |
564 | * As advertised. | |
565 | *------------------------------------------------------------------------*/ | |
566 | ||
567 | int | |
568 | gator_X11gwin_wait(struct gwin *gwp) | |
569 | { /*gator_X11gwin_wait */ | |
570 | ||
571 | static char rn[] = "gator_X11gwin_wait"; /*Routine name */ | |
572 | ||
573 | if (X11_debug) | |
574 | fprintf(stderr, "[%s:%s] This routine is currently a no-op\n", mn, | |
575 | rn); | |
576 | ||
577 | return (-1); | |
578 | ||
579 | } /*gator_X11gwin_wait */ |