1 /* -*- Mode: C; tab-width: 4 -*- */
2 /* Xapi --- mapped X API calls */
3
4 #if 0
5 static const char sccsid[] = "@(#)Xapi.c 4.07 98/04/16 xlockmore";
6
7 #endif
8
9 #ifdef WIN32
10
11 #include <stdlib.h>
12 #include <math.h>
13 #include "xlock.h"
14
15 #define NUMBER_GC (1024)
16 #define NUMBER_BITMAP (1024)
17 #define WINDOW_DEPTH (8) /* incorrect, but we'll set it to 8 */
18
19 typedef struct {
20 unsigned long background;
21 unsigned long foreground;
22 } TColor;
23
24 typedef struct {
25 int hasFillRule;
26 int value;
27 } TFillRule;
28
29 typedef struct {
30 int hasFillStyle;
31 int value;
32 } TFillStyle;
33
34 typedef struct {
35 int hasFont;
36 Font value;
37 } TFont;
38
39 typedef struct {
40 int hasFunction;
41 int value;
42 } TFunction;
43
44 typedef struct {
45 int hasLineAttributes;
46 unsigned int width;
47 int lineStyle;
48 int capStyle;
49 int joinStyle;
50 } TLineAttributes;
51
52 typedef struct {
53 int hasStipple;
54 Pixmap graphic;
55 } TStipple;
56
57 typedef struct {
58 int hasOrigin;
59 int x;
60 int y;
61 } TTSOrigin;
62
63 typedef struct {
64 int isActive;
65 int needsReset;
66 int depth;
67 TColor color;
68 TFillRule fillRule;
69 TFillStyle fillStyle;
70 TFunction function;
71 TLineAttributes lineAttributes;
72 TTSOrigin tsorigin;
73 TStipple stipple;
74 TFont font;
75 } TGCInfo;
76
77 typedef struct {
78 int isActive;
79 int type;
80 int width;
81 int height;
82 HBITMAP bitmap;
83 } TBMInfo;
84
85
86 /* -------------------------------------------------------------------- */
87
88 int GCCreate(Drawable d);
89 HDC GCGetDC(Drawable d, GC gc);
90 int BMInfoCreate(void);
91 HBITMAP DrawableGetBitmap(Drawable d);
92
93 /* -------------------------------------------------------------------- */
94
95 /*-
96 * global variables
97 */
98 HWND hwnd; /* window handle */
99 HDC hdc; /* device context */
100 HGDIOBJ noPen = NULL; /* no pen used in fills */
101 int cred, cgreen, cblue; /* color reference of the pen */
102 unsigned char *red, *green, *blue; /* holds a list of colors */
103 int colorcount; /* number of colors used */
104 unsigned int randommode; /* number of mode to index */
105 RECT rc; /* coords of the screen */
106
107 HANDLE thread; /* thread handle */
108 DWORD thread_id; /* thread id number */
109
110 int numGCInfo = 0; /* number of GC Info */
111 TGCInfo gcInfo[NUMBER_GC + 1] = { {0} }; /* information about GCs. Allow
112 NUMBER_GC GC's, + 1 as a spill
113 over for any modes that need
114 more */
115 int numBMInfo = 0; /* number of Bitmap Info */
116 TBMInfo bmInfo[NUMBER_BITMAP + 1] = { {0} }; /* information about Bitmaps/Pixmaps */
117
118 double
pow(double x,double y)119 pow(double x, double y)
120 {
121 return exp(y * log(x));
122 }
123
124 /* -------------------------------------------------------------------- */
125
126 /* the following functions are used to build up a graphic to display in
127 WIN32
128 */
129
SetByte(LPBYTE lpBMData,BYTE val,int loc,int maxLoc)130 void SetByte(LPBYTE lpBMData, BYTE val, int loc, int maxLoc)
131 {
132 if (loc < maxLoc)
133 {
134 lpBMData[loc] = val ^ 0xFF;
135 }
136 }
137
SetGraphic(LPBYTE lpBMData,XImage * image)138 void SetGraphic(LPBYTE lpBMData, XImage *image)
139 {
140 const int w32bb = 4 * 8;
141 /*const int xbmbb = 1 * 8;*/
142 BYTE xbmval;
143 BYTE w32val;
144 int lineBitCnt = 0;
145 int w32BitsRemain;
146 int i, j, k;
147 int bmSize;
148 int loc = 0;
149 int actBytesPerLine;
150 int maxLoc;
151
152 // initialise
153 actBytesPerLine = (image->width + 7) / 8;
154 bmSize = actBytesPerLine * image->height;
155 maxLoc = (actBytesPerLine + ((4 - (actBytesPerLine % 4)) % 4)) *
156 image->height;
157
158 // for each byte in the xbm bit array
159 for (i=0; i<bmSize; i++)
160 {
161 xbmval = (image->data)[i];
162 w32val = 0;
163
164 // for each bit in the byte
165 for (j=0; j<8; j++)
166 {
167 w32val = (w32val << 1) | ((xbmval >> j) & 0x1);
168
169 if (j == 7) /* we have processed all bits */
170 {
171 SetByte(lpBMData, w32val, loc, maxLoc);
172 loc++;
173 }
174
175 // check for a line of graphic
176 if (++lineBitCnt == image->width)
177 {
178 w32BitsRemain = (w32bb - (lineBitCnt % w32bb)) % w32bb;
179
180 if (w32BitsRemain % 8)
181 {
182 w32val = w32val << (w32BitsRemain % 8);
183 SetByte(lpBMData, w32val, loc, maxLoc);
184 loc++;
185 }
186 if (w32BitsRemain / 8)
187 {
188 for (k=0; k<(w32BitsRemain / 8); k++)
189 {
190 SetByte(lpBMData, 0, loc, maxLoc);
191 loc++;
192 }
193 }
194 lineBitCnt = 0;
195 break;
196 }
197 }
198 }
199 }
200
201 void
LCreateBitmap(XImage * image,HBITMAP * hBitmap,HPALETTE * hPalette)202 LCreateBitmap(XImage *image, HBITMAP *hBitmap, HPALETTE *hPalette)
203 {
204 BYTE palette[2][3];
205 LPBITMAPINFO lpbi;
206 HDC hScreenDC;
207 LPVOID lpBMData;
208 LPLOGPALETTE lpLogPal;
209 int i;
210
211 /* setup color palette */
212 palette[0][0] = 255; /* red */
213 palette[0][1] = 255; /* green */
214 palette[0][2] = 255; /* blue */
215
216 palette[1][0] = 000; /* red */
217 palette[1][1] = 000; /* green */
218 palette[1][2] = 000; /* blue */
219
220 /* allocate memory for the bitmap header */
221 lpbi = (LPBITMAPINFO)LocalAlloc(LPTR,
222 sizeof(BITMAPINFOHEADER) + (2 * sizeof(RGBQUAD)));
223 if (lpbi == NULL)
224 {
225 return;
226 }
227
228 /* set bitmap header info */
229 lpbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
230 lpbi->bmiHeader.biWidth = image->width;
231 lpbi->bmiHeader.biHeight = -1 * image->height;
232 lpbi->bmiHeader.biPlanes = 1;
233 lpbi->bmiHeader.biBitCount = 1;
234 lpbi->bmiHeader.biCompression = BI_RGB;
235
236 /* fill in bitmap palette */
237 for (i=0; i<2; i++)
238 {
239 lpbi->bmiColors[i].rgbRed = palette[i][0];
240 lpbi->bmiColors[i].rgbGreen = palette[i][1];
241 lpbi->bmiColors[i].rgbBlue = palette[i][2];
242 }
243
244 /* create bitmap area */
245 hScreenDC = CreateCompatibleDC(hdc);
246 *hBitmap = CreateDIBSection(hScreenDC, lpbi, DIB_RGB_COLORS,
247 &lpBMData, NULL, 0);
248
249 if (*hBitmap == NULL && lpBMData == NULL)
250 {
251 DeleteDC(hScreenDC);
252 LocalFree(lpbi);
253 return;
254 }
255
256 DeleteDC(hScreenDC);
257 if (LocalFree(lpbi) != NULL)
258 return;
259
260 /* copy XBM to bitmap */
261 SetGraphic(lpBMData, image);
262
263 /* create logical palette header */
264 lpLogPal = (LPLOGPALETTE)LocalAlloc(LPTR,
265 sizeof(LOGPALETTE) + (1 * sizeof(PALETTEENTRY)));
266 if (lpLogPal == NULL)
267 {
268 return;
269 }
270
271 /* set logical palette info */
272 lpLogPal->palVersion = 0x0300;
273 lpLogPal->palNumEntries = 2;
274 for (i=0; i < 2; i++)
275 {
276 lpLogPal->palPalEntry[i].peRed = palette[i][0];
277 lpLogPal->palPalEntry[i].peGreen = palette[i][1];
278 lpLogPal->palPalEntry[i].peBlue = palette[i][2];
279 }
280
281 /* create palette */
282 *hPalette = CreatePalette(lpLogPal);
283 if (*hPalette == NULL)
284 {
285 return;
286 }
287
288 /* clean up palette creation data */
289 LocalFree(lpLogPal);
290 }
291
292 /* -------------------------------------------------------------------- */
293
294 /* the following functions to create, destroy, modify and access the
295 GC Info structure
296 */
GCCreate(Drawable d)297 int GCCreate(Drawable d)
298 {
299 int retVal = 0;
300
301 for (retVal=0; retVal<NUMBER_GC; retVal++)
302 {
303 if (gcInfo[retVal].isActive == FALSE)
304 {
305 numGCInfo++;
306 break;
307 }
308 }
309
310 gcInfo[retVal].isActive = TRUE;
311 gcInfo[retVal].needsReset = TRUE;
312 gcInfo[retVal].depth =
313 d > 0 && d < NUMBER_BITMAP ? bmInfo[d].type : WINDOW_DEPTH;
314 gcInfo[retVal].color.background = NUMCOLORS+1;
315 gcInfo[retVal].color.foreground = NUMCOLORS;
316 gcInfo[retVal].fillRule.hasFillRule = FALSE;
317 gcInfo[retVal].fillRule.value = 0;
318 gcInfo[retVal].fillStyle.hasFillStyle = FALSE;
319 gcInfo[retVal].fillStyle.value = 0;
320 gcInfo[retVal].function.hasFunction = FALSE;
321 gcInfo[retVal].function.value = 0;
322 gcInfo[retVal].lineAttributes.hasLineAttributes = FALSE;
323 gcInfo[retVal].lineAttributes.width = 0;
324 gcInfo[retVal].lineAttributes.lineStyle = 0;
325 gcInfo[retVal].lineAttributes.capStyle = 0;
326 gcInfo[retVal].lineAttributes.joinStyle = 0;
327 gcInfo[retVal].tsorigin.hasOrigin = FALSE;
328 gcInfo[retVal].tsorigin.x = 0;
329 gcInfo[retVal].tsorigin.y = 0;
330 gcInfo[retVal].stipple.hasStipple = FALSE;
331 gcInfo[retVal].stipple.graphic = -1;
332
333 return retVal;
334 }
335
336 /* -------------------------------------------------------------------- */
GCGetDC(Drawable d,GC gc)337 HDC GCGetDC(Drawable d, GC gc)
338 {
339 HGDIOBJ brush;
340 int fillfunc;
341 int fillrule;
342 int i;
343 LOGBRUSH lb;
344 LPLOGPALETTE lpLogPal;
345 BYTE palarray[2][3];
346 HPALETTE palette;
347 HGDIOBJ pen;
348 DWORD penstyle;
349 HBITMAP stipple;
350 HDC lhdc;
351 char message[80];
352
353 static GC lastGc = -1;
354 static HDC sbhdc = NULL;
355 static HDC dbhdc = NULL;
356
357 if (gc < 0 || gc >= numGCInfo)
358 {
359 sprintf(message, "GC passed in not in range 0..%d, gc=%d",
360 numGCInfo-1, gc);
361 xlockmore_set_debug(message);
362 return NULL;
363 }
364
365 /* get DC - try and determine if its a window or bitmap */
366 if (d > 0 && d < NUMBER_BITMAP)
367 {
368 if (dbhdc == NULL)
369 /* create a compatible DC from the saved initial DC. To draw
370 to this DC we still need to put a HBITMAP into it (not
371 done in this function)
372 */
373 if ((dbhdc = CreateCompatibleDC(hdc)) == NULL)
374 {
375 sprintf(message, "CreateCompatibleDC() returned NULL");
376 xlockmore_set_debug(message);
377 return NULL;
378 }
379 lhdc = dbhdc;
380 }
381 else
382 {
383 if (sbhdc == NULL)
384 /* create a DC for the window. We don't (and cannot) put
385 * a HBITMAP into this. It is ready to draw to (straight to
386 * the screen)
387 */
388 if ((sbhdc = GetDC(hwnd)) == NULL)
389 {
390 sprintf(message, "GetDC() returned NULL");
391 xlockmore_set_debug(message);
392 return NULL;
393 }
394 lhdc = sbhdc;
395 }
396
397 /* check if we have already set up the DC in a previous call */
398 if (lastGc == gc && gcInfo[gc].needsReset == FALSE)
399 return lhdc;
400
401 /* set the current color constants */
402 cred = red[gcInfo[gc].color.foreground];
403 cgreen = green[gcInfo[gc].color.foreground];
404 cblue = blue[gcInfo[gc].color.foreground];
405
406 /* set the text color */
407 if (SetTextColor(lhdc, RGB(cred,cgreen,cblue)) == CLR_INVALID)
408 {
409 sprintf(message, "text: SetTextColor() returned CLR_INVALID [%d %d %d]", cred, cgreen, cblue);
410 xlockmore_set_debug(message);
411 return NULL;
412 }
413 if (SetBkColor(lhdc, RGB(red[gcInfo[gc].color.background],
414 green[gcInfo[gc].color.background],
415 blue[gcInfo[gc].color.background])) == CLR_INVALID)
416 {
417 sprintf(message, "text: SetBkColor() returned CLR_INVALID");
418 xlockmore_set_debug(message);
419 return NULL;
420 }
421
422 /* set the pen to the new color and line attributes */
423 if (gcInfo[gc].lineAttributes.hasLineAttributes == FALSE)
424 {
425 /* no line attributes, just create solid pen and put into the DC*/
426 if ((pen = CreatePen(PS_SOLID, 0, RGB(cred, cgreen, cblue))) == NULL)
427 {
428 sprintf(message, "pen: CreatePen() returned NULL");
429 xlockmore_set_debug(message);
430 return NULL;
431 }
432 else
433 {
434 if ((pen = SelectObject(lhdc, pen)) == NULL)
435 {
436 sprintf(message, "pen: Failed to select pen into DC");
437 xlockmore_set_debug(message);
438 return NULL;
439 }
440 /* remove the old pen */
441 if (DeleteObject(pen) == 0)
442 {
443 sprintf(message, "pen: Failed to delete old pen");
444 xlockmore_set_debug(message);
445 return NULL;
446 }
447 }
448 }
449 else
450 {
451 /* line attributes need to be set, create a more complex pen */
452
453 /* set the brush info */
454 lb.lbStyle = BS_SOLID;
455 lb.lbColor = RGB(cred, cgreen, cblue);
456 lb.lbHatch = 0;
457
458 /* set the pen style */
459 penstyle = PS_GEOMETRIC;
460
461 switch (gcInfo[gc].lineAttributes.lineStyle)
462 {
463 case LineSolid:
464 penstyle |= PS_SOLID; break;
465 case LineOnOffDash:
466 penstyle |= PS_DASH; break;
467 case LineDoubleDash:
468 penstyle |= PS_DOT; break;
469 }
470
471 switch (gcInfo[gc].lineAttributes.capStyle)
472 {
473 case CapNotLast:
474 penstyle |= PS_ENDCAP_FLAT; break;
475 case CapButt:
476 penstyle |= PS_ENDCAP_FLAT; break;
477 case CapRound:
478 penstyle |= PS_ENDCAP_ROUND; break;
479 case CapProjecting:
480 penstyle |= PS_ENDCAP_SQUARE; break;
481 }
482
483 switch (gcInfo[gc].lineAttributes.joinStyle)
484 {
485 case JoinMiter:
486 penstyle |= PS_JOIN_MITER; break;
487 case JoinRound:
488 penstyle |= PS_JOIN_ROUND; break;
489 case JoinBevel:
490 penstyle |= PS_JOIN_BEVEL; break;
491 }
492
493 /* create the pen, putting it in the DC */
494 pen = SelectObject(lhdc,
495 ExtCreatePen(penstyle, gcInfo[gc].lineAttributes.width,
496 &lb, 0, NULL));
497 /* remove the old pen */
498 DeleteObject(pen);
499 }
500
501 /* set the palette to the new colors */
502 palarray[0][0] = cred; /* red */
503 palarray[0][1] = cgreen; /* green */
504 palarray[0][2] = cblue; /* blue */
505
506 palarray[1][0] = red[gcInfo[gc].color.background]; /* red */
507 palarray[1][1] = green[gcInfo[gc].color.background]; /* green */
508 palarray[1][2] = blue[gcInfo[gc].color.background]; /* blue */
509
510 /* create logical palette header */
511 lpLogPal = (LPLOGPALETTE)LocalAlloc(LPTR,
512 sizeof(LOGPALETTE) + (1 * sizeof(PALETTEENTRY)));
513 if (lpLogPal == NULL)
514 {
515 sprintf(message, "palette: Cannot alloacte memory for logical palette");
516 xlockmore_set_debug(message);
517 return NULL;
518 }
519
520 /* set logical palette info */
521 lpLogPal->palVersion = 0x0300;
522 lpLogPal->palNumEntries = 2;
523 for (i=0; i < 2; i++)
524 {
525 lpLogPal->palPalEntry[i].peRed = palarray[i][0];
526 lpLogPal->palPalEntry[i].peGreen = palarray[i][1];
527 lpLogPal->palPalEntry[i].peBlue = palarray[i][2];
528 }
529
530 /* create palette */
531 palette = CreatePalette(lpLogPal);
532 if (palette == NULL)
533 {
534 sprintf(message, "palette: CreatePalette() returned NULL");
535 xlockmore_set_debug(message);
536 LocalFree(lpLogPal);
537 return NULL;
538 }
539
540 /* set palette color */
541 palette = SelectPalette(lhdc, palette, FALSE);
542
543 /* clean up palette creation data */
544 DeleteObject(palette);
545 LocalFree(lpLogPal);
546
547 /* set brush origin */
548 if (gcInfo[gc].tsorigin.hasOrigin == TRUE)
549 {
550 if (SetBrushOrgEx(lhdc, gcInfo[gc].tsorigin.x,
551 gcInfo[gc].tsorigin.y, NULL) == 0)
552 {
553 sprintf(message, "brush origin: SetBrushOrgEx() failed");
554 xlockmore_set_debug(message);
555 return NULL;
556 }
557 }
558
559 /* check if we need a pattern brush or solid brush */
560 if (gcInfo[gc].stipple.hasStipple == FALSE ||
561 (gcInfo[gc].fillStyle.hasFillStyle == TRUE &&
562 gcInfo[gc].fillStyle.value == FillSolid))
563 {
564 /* solid brush */
565 brush = SelectObject(lhdc,
566 CreateSolidBrush(RGB(cred, cgreen, cblue)));
567 DeleteObject(brush);
568 }
569 /* check if we need to FillStippled, and if so don't make a
570 * brush, we will deal with this later (see XFillRectangle)
571 */
572 else if (gcInfo[gc].stipple.graphic != -1 &&
573 ! (gcInfo[gc].fillStyle.hasFillStyle == TRUE &&
574 gcInfo[gc].fillStyle.value == FillStippled))
575 {
576 /* pattern brush */
577 HBRUSH oldBrush;
578 HBRUSH brush;
579 HDC hStippleDC;
580 HBITMAP hOldBitmap;
581 RGBQUAD rgbQuad = { cblue, cgreen, cred, 0 };
582
583 if ((stipple = DrawableGetBitmap(gcInfo[gc].stipple.graphic)) == NULL)
584 {
585 sprintf(message, "pattern brush: DrawableGetBitmap() returned NULL");
586 xlockmore_set_debug(message);
587 return NULL;
588 }
589
590 /* create a device context for setting the stipples color */
591 if ((hStippleDC = CreateCompatibleDC(lhdc)) == NULL)
592 {
593 sprintf(message, "pattern brush: CreateCompatibleDC() returned NULL");
594 xlockmore_set_debug(message);
595 return NULL;
596 }
597
598 /* put the stipple into the DC */
599 if ((hOldBitmap = (HBITMAP)SelectObject(hStippleDC, stipple)) == NULL)
600 {
601 sprintf(message, "pattern brush: cannot select stipple in stippleDC");
602 xlockmore_set_debug(message);
603 DeleteDC(hStippleDC);
604 return NULL;
605 }
606
607 /* set the correct color table */
608 SetDIBColorTable(hStippleDC, 0, 1, &rgbQuad);
609
610 /* get the stipple back from the DC with the correct color table */
611 if ((stipple = (HBITMAP)SelectObject(hStippleDC, hOldBitmap)) == NULL)
612 {
613 sprintf(message, "pattern brush: cannot select stipple out of stippleDC");
614 xlockmore_set_debug(message);
615 DeleteDC(hStippleDC);
616 return NULL;
617 }
618
619 /* create a pattern brush out of it */
620 if ((brush = CreatePatternBrush(stipple)) == NULL)
621 {
622 sprintf(message, "pattern brush: CreatePatternBrush() returned NULL");
623 xlockmore_set_debug(message);
624 DeleteDC(hStippleDC);
625 return NULL;
626 }
627
628 /* put the pattern brush into the DC */
629 if ((oldBrush = SelectObject(lhdc, brush)) == NULL)
630 {
631 sprintf(message, "pattern brush: cannot select brush into DC");
632 xlockmore_set_debug(message);
633 DeleteDC(hStippleDC);
634 return NULL;
635 }
636
637 /* clean up and return */
638 DeleteDC(hStippleDC);
639 DeleteObject(oldBrush);
640 }
641
642 /* check if we need to set the fill function */
643 if (gcInfo[gc].function.hasFunction == TRUE)
644 {
645 switch (gcInfo[gc].function.value)
646 {
647 case GXclear: fillfunc = R2_BLACK; break;
648 case GXand: fillfunc = R2_MERGEPEN; break;
649 case GXandReverse: fillfunc = R2_MERGEPENNOT; break;
650 case GXcopy: fillfunc = R2_COPYPEN; break;
651 case GXandInverted: fillfunc = R2_MERGENOTPEN; break;
652 case GXnoop: fillfunc = R2_NOP; break;
653 case GXxor: fillfunc = R2_XORPEN; break;
654 case GXor: fillfunc = R2_MASKPEN; break;
655 case GXnor: fillfunc = R2_NOTMERGEPEN; break;
656 case GXequiv: fillfunc = R2_NOTXORPEN; break;
657 case GXinvert: fillfunc = R2_NOT; break;
658 case GXorReverse: fillfunc = R2_MASKPENNOT; break;
659 case GXcopyInverted: fillfunc = R2_NOTCOPYPEN; break;
660 case GXorInverted: fillfunc = R2_MASKNOTPEN; break;
661 case GXnand: fillfunc = R2_NOTMASKPEN; break;
662 case GXset: fillfunc = R2_WHITE; break;
663 default: fillfunc = R2_COPYPEN; break;
664 }
665
666 SetROP2(lhdc, fillfunc);
667 }
668
669 /* set fill rule */
670 if (gcInfo[gc].fillRule.hasFillRule == TRUE)
671 {
672 switch (gcInfo[gc].fillRule.value)
673 {
674 case EvenOddRule: fillrule = ALTERNATE; break;
675 case WindingRule: fillrule = WINDING; break;
676 default: fillrule = WINDING; break;
677 }
678 if (SetPolyFillMode(lhdc, fillrule) == 0)
679 {
680 sprintf(message, "fill rule: cannot set fill mode in DC");
681 xlockmore_set_debug(message);
682 return NULL;
683 }
684 }
685
686 /*
687 * if we call this function again and there is no change to the DC
688 * that needs to be done, we want to just return the DC that had
689 * already been set up. Set the information to allow this
690 */
691 gcInfo[gc].needsReset = FALSE;
692 lastGc = gc;
693
694 /* ignoring setting font for now */
695 /* TODO: font */
696
697 /* return the DC */
698 return lhdc;
699 }
700
701
702 /* the following functions to create, destroy, modify and access the
703 BM Info structure
704 */
BMInfoCreate(void)705 int BMInfoCreate(void)
706 {
707 int retVal = 0;
708
709 /* start at 1, not 0 as this will be None */
710 for (retVal=1; retVal<NUMBER_BITMAP; retVal++)
711 {
712 if (bmInfo[retVal].isActive == FALSE)
713 {
714 numBMInfo++;
715 break;
716 }
717 }
718
719 if (retVal == NUMBER_BITMAP)
720 return -1;
721
722 /* set the bitmap info */
723 bmInfo[retVal].isActive = TRUE;
724 bmInfo[retVal].width = 0;
725 bmInfo[retVal].height = 0;
726 bmInfo[retVal].bitmap = NULL;
727
728 return retVal;
729 }
730
DrawableGetBitmap(Drawable d)731 HBITMAP DrawableGetBitmap(Drawable d)
732 {
733 char message[80];
734
735 if (d < 0 || d >= NUMBER_BITMAP)
736 {
737 sprintf(message, "Drawable passed in not in range 0..%d, d=%d",
738 numBMInfo-1, d);
739 xlockmore_set_debug(message);
740 return NULL;
741 }
742
743 /* check for id of 0 */
744 if (d == None)
745 {
746 sprintf(message, "Drawable is None");
747 xlockmore_set_debug(message);
748 return NULL;
749 }
750
751 if (bmInfo[d].isActive == FALSE)
752 {
753 sprintf(message, "Drawable not active, d=%d", d);
754 xlockmore_set_debug(message);
755 return NULL;
756 }
757
758 return bmInfo[d].bitmap;
759 }
760
761 /* -------------------------------------------------------------------- */
762
763 /* the following are functions in UNIX but not WIN32 */
764
765 /*-
766 * nice
767 */
nice(int level)768 int nice(int level)
769 {
770 return 1;
771 }
772
773 /*-
774 * sleep
775 */
sleep(int sec)776 void sleep(int sec)
777 {
778 }
779
780 /*-
781 * sigmask
782 */
sigmask(int signum)783 int sigmask(int signum)
784 {
785 return 0;
786 }
787
788
789 /* the following are macros in X, but I have implemented as functions */
790
791 /*-
792 * BlackPixel
793 * returns the color cell of Black
794 * NOTE: this is currently set to the end of the color
795 * palette table,
796 */
BlackPixel(Display * display,int screen_number)797 unsigned long BlackPixel(Display *display, int screen_number)
798 {
799 return colorcount+1;
800 }
801
802 /*-
803 * WhitePixel
804 * returns the color cell of White
805 * NOTE: this is currently set to the end of the color
806 * palette table - 1
807 */
WhitePixel(Display * display,int screen_number)808 unsigned long WhitePixel(Display *display, int screen_number)
809 {
810 return colorcount;
811 }
812
813 /*-
814 * BlackPixelOfScreen
815 * returns the color cell of Black
816 * NOTE: currently is fixed to color array + 2
817 */
BlackPixelOfScreen(Screen * screen)818 int BlackPixelOfScreen(Screen *screen)
819 {
820 return NUMCOLORS+1;
821 }
822
823 /*-
824 * WhitePixelOfScreen
825 * returns the color cell of White
826 * NOTE: currently is fixed to color array + 1
827 */
WhitePixelOfScreen(Screen * screen)828 int WhitePixelOfScreen(Screen *screen)
829 {
830 return NUMCOLORS;
831 }
832
833 /*-
834 * CellsOfScreen
835 * returns number of entries the colormap can hold
836 */
CellsOfScreen(Screen * screen)837 int CellsOfScreen(Screen *screen)
838 {
839 return colorcount;
840 }
841
842 /*-
843 * DefaultColormap
844 * not currently used, returns 0
845 */
DefaultColormap(Display * display,int screen_number)846 Colormap DefaultColormap(Display *display, int screen_number)
847 {
848 return 0;
849 }
850
851 /*-
852 * DefaultColormapOfScreen
853 * not currently used, returns 0
854 */
DefaultColormapOfScreen(Screen * screen)855 Colormap DefaultColormapOfScreen(Screen *screen)
856 {
857 return 0;
858 }
859
860 /*-
861 * DefaultVisual
862 * not currently used, returns NULL
863 */
DefaultVisual(Display * display,int screen_number)864 Visual *DefaultVisual(Display *display, int screen_number)
865 {
866 return NULL;
867 }
868
869 /*-
870 * DisplayPlanes
871 * not currently used, returns 0
872 */
DisplayPlanes(Display * display,int screen_number)873 int DisplayPlanes(Display *display, int screen_number)
874 {
875 return 0;
876 }
877
878 /*-
879 * DisplayString
880 * not currently used, returns NULL
881 */
DisplayString(Display * display)882 char *DisplayString(Display *display)
883 {
884 return NULL;
885 }
886
887 /*-
888 * RootWindow
889 * not currently used, returns 0
890 */
RootWindow(Display * display,int screen_number)891 Window RootWindow(Display *display, int screen_number)
892 {
893 return 0;
894 }
895
896 /*-
897 * ScreenCount
898 * not correct, just return 1
899 */
ScreenCount(Display * display)900 int ScreenCount(Display *display)
901 {
902 return 1;
903 }
904
905 /*-
906 * ScreenOfDisplay
907 * not currently used, returns NULL
908 */
ScreenOfDisplay(Display * display,int screen_number)909 Screen *ScreenOfDisplay(Display *display, int screen_number)
910 {
911 return NULL;
912 }
913
914 /* -------------------------------------------------------------------- */
915
916 /* X function mappings */
917
918 /*-
919 * XAddHosts
920 * not currently used
921 */
XAddHosts(Display * display,XHostAddress * hosts,int num_hosts)922 void XAddHosts(Display *display, XHostAddress *hosts, int num_hosts)
923 {
924 }
925
926 /*-
927 * XAllocColor
928 * not currently used
929 */
XAllocColor(Display * display,Colormap colormap,XColor * screen_in_out)930 Status XAllocColor(Display *display, Colormap colormap,
931 XColor *screen_in_out)
932 {
933 screen_in_out->pixel = 0;
934 return 1;
935 }
936
937 /*-
938 * XAllocColorCells
939 * not currently used
940 */
XAllocColorCells(Display * display,Colormap colormap,Bool contig,unsigned long plane_masks_return[],unsigned int nplanes,unsigned long pixels_return[],unsigned int npixels)941 Status XAllocColorCells(Display *display, Colormap colormap,
942 Bool contig, unsigned long plane_masks_return[],
943 unsigned int nplanes, unsigned long pixels_return[],
944 unsigned int npixels)
945 {
946 return 0;
947 }
948
949 /*-
950 * XAllocNamedColor
951 * not currently used
952 */
XAllocNamedColor(Display * display,Colormap colormap,char * color_name,XColor * screen_def_return,XColor * exact_def_return)953 Status XAllocNamedColor(Display *display, Colormap colormap,
954 char *color_name, XColor *screen_def_return,
955 XColor *exact_def_return)
956 {
957 return 0;
958 }
959
960 /*-
961 * XBell
962 * not currently used
963 */
XBell(Display * display,int percent)964 void XBell(Display *display, int percent)
965 {
966 }
967
968 /*-
969 * XChangeGC
970 * changes values of the graphics context
971 */
XChangeGC(Display * display,GC gc,unsigned long valuemask,XGCValues * values)972 void XChangeGC(Display *display, GC gc, unsigned long valuemask,
973 XGCValues *values)
974 {
975 if (valuemask & GCBackground)
976 {
977 XSetBackground(display, gc, values->background);
978 }
979 if (valuemask & GCFillRule)
980 {
981 XSetFillRule(display, gc, values->fill_rule);
982 }
983 if (valuemask & GCFillStyle)
984 {
985 XSetFillStyle(display, gc, values->fill_style);
986 }
987 if (valuemask & GCForeground)
988 {
989 XSetForeground(display, gc, values->foreground);
990 }
991 if (valuemask & GCFunction)
992 {
993 XSetFunction(display, gc, values->function);
994 }
995 if (valuemask & GCLineWidth)
996 {
997 XSetLineAttributes(display, gc,
998 values->line_width,
999 gcInfo[gc].lineAttributes.lineStyle,
1000 gcInfo[gc].lineAttributes.capStyle,
1001 gcInfo[gc].lineAttributes.joinStyle);
1002 }
1003 if (valuemask & GCLineStyle)
1004 {
1005 XSetLineAttributes(display, gc,
1006 gcInfo[gc].lineAttributes.width,
1007 values->line_style,
1008 gcInfo[gc].lineAttributes.capStyle,
1009 gcInfo[gc].lineAttributes.joinStyle);
1010 }
1011 if (valuemask & GCCapStyle)
1012 {
1013 XSetLineAttributes(display, gc,
1014 gcInfo[gc].lineAttributes.width,
1015 gcInfo[gc].lineAttributes.lineStyle,
1016 values->cap_style,
1017 gcInfo[gc].lineAttributes.joinStyle);
1018 }
1019 if (valuemask & GCJoinStyle)
1020 {
1021 XSetLineAttributes(display, gc,
1022 gcInfo[gc].lineAttributes.width,
1023 gcInfo[gc].lineAttributes.lineStyle,
1024 gcInfo[gc].lineAttributes.capStyle,
1025 values->join_style);
1026 }
1027 if (valuemask & GCStipple)
1028 {
1029 XSetStipple(display, gc, values->stipple);
1030 }
1031 if (valuemask & GCFont)
1032 {
1033 XSetFont(display, gc, values->font);
1034 }
1035 if (valuemask & GCTileStipXOrigin)
1036 {
1037 XSetTSOrigin(display, gc, values->ts_x_origin, gcInfo[gc].tsorigin.y);
1038 }
1039 if (valuemask & GCTileStipYOrigin)
1040 {
1041 XSetTSOrigin(display, gc, gcInfo[gc].tsorigin.x, values->ts_y_origin);
1042 }
1043
1044 /* the above are the only attributes we can set at this stage */
1045 }
1046
1047
1048 /*-
1049 * XCheckMaskEvent
1050 * not currently used, return True
1051 */
XCheckMaskEvent(Display * display,long event_mask,XEvent * event_return)1052 Bool XCheckMaskEvent(Display *display, long event_mask,
1053 XEvent *event_return)
1054 {
1055 return True;
1056 }
1057
1058 /*-
1059 * XClearArea
1060 * clears a rectangular area in a window/screen
1061 */
XClearArea(Display * display,Window w,int x,int y,unsigned int width,unsigned int height,Bool exposures)1062 void XClearArea(Display *display, Window w, int x, int y,
1063 unsigned int width, unsigned int height, Bool exposures)
1064 {
1065 RECT lrc;
1066
1067 lrc.left = x;
1068 lrc.top = y;
1069 lrc.right = x + width;
1070 lrc.bottom = y + height;
1071
1072 FillRect(hdc, &lrc, (struct HBRUSH__ *)GetStockObject(BLACK_BRUSH));
1073 }
1074
1075 /*-
1076 * XClearWindow
1077 * sets the base window/screen to black
1078 */
XClearWindow(Display * display,Window w)1079 void XClearWindow(Display *display, Window w)
1080 {
1081 FillRect(hdc, &rc, (struct HBRUSH__ *)GetStockObject(BLACK_BRUSH));
1082 }
1083
1084 /*-
1085 * XCloseDisplay
1086 * not currently used
1087 */
XCloseDisplay(Display * display)1088 void XCloseDisplay(Display *display)
1089 {
1090 }
1091
1092 /*-
1093 * XConfigureWindow
1094 * not currently used
1095 */
XConfigureWindow(Display * display,Window w,unsigned int value_mask,XWindowChanges * values)1096 void XConfigureWindow(Display *display, Window w,
1097 unsigned int value_mask,
1098 XWindowChanges *values)
1099 {
1100 }
1101
1102 /*-
1103 * XCopyArea
1104 * copies one drawable to another
1105 */
XCopyArea(Display * display,Drawable src,Drawable dest,GC gc,int src_x,int src_y,unsigned int width,unsigned height,int dest_x,int dest_y)1106 int XCopyArea(Display *display, Drawable src, Drawable dest, GC gc,
1107 int src_x, int src_y, unsigned int width, unsigned height,
1108 int dest_x, int dest_y)
1109 {
1110 HBITMAP hBitmap;
1111 HBITMAP hOldBitmapS = NULL;
1112 HBITMAP hOldBitmapD = NULL;
1113 HDC hDestDC;
1114 HDC hSrcDC;
1115
1116 /* create the destination resource */
1117 if ((hDestDC = GCGetDC(dest, gc)) == NULL)
1118 {
1119 xlockmore_set_debug("XCopyArea: Failed to get destination DC");
1120 return BadGC;
1121 }
1122
1123 if (dest > 0 && dest < NUMBER_BITMAP)
1124 if (bmInfo[dest].isActive == TRUE)
1125 hOldBitmapD = SelectObject(hDestDC, DrawableGetBitmap(dest));
1126
1127 /* create the source resource */
1128 if (src > 0 && src <= numBMInfo)
1129 {
1130 /* source is a bitmap */
1131 if ((hBitmap = DrawableGetBitmap(src)) == NULL)
1132 {
1133 xlockmore_set_debug("XCopyArea: Failed to get bitmap");
1134 return BadDrawable;
1135 }
1136
1137 if ((hSrcDC = CreateCompatibleDC(hdc)) == NULL)
1138 {
1139 xlockmore_set_debug("XCopyArea: Failed to create compatible DC");
1140 return BadDrawable;
1141 }
1142
1143 hOldBitmapS = SelectObject(hSrcDC, hBitmap);
1144 }
1145 else
1146 {
1147 /* source is a window */
1148 if ((hSrcDC = GetDC((HWND)src)) == NULL)
1149 {
1150 xlockmore_set_debug("XCopyArea: Failed to get source DC");
1151 return BadDrawable;
1152 }
1153 }
1154
1155 /* copy src to destination */
1156 if (BitBlt(hDestDC, dest_x, dest_y, width, height, hSrcDC,
1157 src_x, src_y, SRCCOPY) == 0)
1158 {
1159 xlockmore_set_debug("XCopyArea: BitBlt() failed");
1160 }
1161
1162 /* clean up */
1163 if (hOldBitmapS)
1164 SelectObject(hSrcDC, hOldBitmapS);
1165 if (hOldBitmapD)
1166 SelectObject(hSrcDC, hOldBitmapD);
1167 if (src > 0 && src <= numBMInfo)
1168 DeleteDC(hSrcDC);
1169 else
1170 ReleaseDC((HWND)src, hSrcDC);
1171 return Success;
1172 }
1173
1174 /*-
1175 * XCopyColormapAndFree
1176 * not currently used, returns 0
1177 */
XCopyColormapAndFree(Display * display,Colormap colormap)1178 Colormap XCopyColormapAndFree(Display *display, Colormap colormap)
1179 {
1180 return 0;
1181 }
1182
1183 /*-
1184 * XCopyPlane
1185 * copies a single plane of one drawable to another
1186 */
XCopyPlane(Display * display,Drawable src,Drawable dest,GC gc,int src_x,int src_y,unsigned width,int height,int dest_x,int dest_y,unsigned long plane)1187 int XCopyPlane(Display *display, Drawable src, Drawable dest, GC gc,
1188 int src_x, int src_y, unsigned width, int height,
1189 int dest_x, int dest_y, unsigned long plane)
1190 {
1191 return XCopyArea(display, src, dest, gc,
1192 src_x, src_y, width, height, dest_x, dest_y);
1193 }
1194
1195 /*-
1196 * XCreateBitmapFromData
1197 * used to create a bitmap
1198 */
XCreateBitmapFromData(Display * display,Drawable drawable,char * data,unsigned int width,unsigned int height)1199 Pixmap XCreateBitmapFromData(Display *display, Drawable drawable,
1200 char *data, unsigned int width,
1201 unsigned int height)
1202 {
1203 XImage image;
1204 HBITMAP hBitmap;
1205 HPALETTE hPalette;
1206 Pixmap pm;
1207
1208 pm = BMInfoCreate();
1209 if (pm < 0 || pm >= NUMBER_BITMAP)
1210 return None;
1211
1212 image.width = width;
1213 image.height = height;
1214 image.data = data;
1215
1216 LCreateBitmap(&image, &hBitmap, &hPalette);
1217 DeleteObject(hPalette); /* we don't need the palette */
1218
1219 if (hBitmap == NULL)
1220 {
1221 bmInfo[pm].isActive = FALSE;
1222 return None;
1223 }
1224
1225 bmInfo[pm].bitmap = hBitmap;
1226 bmInfo[pm].type = 1;
1227 bmInfo[pm].width = width;
1228 bmInfo[pm].height = height;
1229 return pm;
1230 }
1231
1232 /*-
1233 * XCreateColormap
1234 * used to create the colormap
1235 */
XCreateColormap(Display * display,Window w,Visual * visual,int alloc)1236 Colormap XCreateColormap(Display *display, Window w,
1237 Visual *visual, int alloc)
1238 {
1239 return None;
1240 }
1241
1242 /*-
1243 * XCreateFontCursor
1244 * not currently used, returns 0
1245 */
XCreateFontCursor(Display * display,unsigned int shape)1246 Cursor XCreateFontCursor(Display *display, unsigned int shape)
1247 {
1248 return 0;
1249 }
1250
1251 /*-
1252 * XCreateGC
1253 * creates a copy of the GC
1254 */
XCreateGC(Display * display,Drawable drawable,unsigned long valuemask,XGCValues * values)1255 GC XCreateGC(Display *display, Drawable drawable,
1256 unsigned long valuemask, XGCValues *values)
1257 {
1258 GC newGc;
1259 char message[80];
1260
1261 if ((newGc = GCCreate(drawable)) == -1)
1262 {
1263 sprintf(message, "Failed to create a GC");
1264 xlockmore_set_debug(message);
1265 }
1266 else
1267 {
1268 XChangeGC(display, newGc, valuemask, values);
1269 }
1270
1271 return newGc;
1272 }
1273
1274 /*-
1275 * XCreateImage
1276 * creates an XImage structure and populates it
1277 */
XCreateImage(Display * display,Visual * visual,unsigned int depth,int format,int offset,char * data,unsigned int width,unsigned int height,int bitmap_pad,int bytes_per_line)1278 XImage *XCreateImage(Display *display, Visual *visual,
1279 unsigned int depth, int format, int offset,
1280 char *data, unsigned int width,
1281 unsigned int height, int bitmap_pad,
1282 int bytes_per_line)
1283 {
1284 XImage *newImage;
1285
1286 if ((newImage = malloc(sizeof(XImage))) == NULL)
1287 return NULL;
1288
1289 memset(newImage, 0, sizeof(XImage));
1290
1291 newImage->width = width;
1292 newImage->height = height;
1293 newImage->xoffset = offset;
1294 newImage->format = format;
1295 newImage->data = data;
1296 newImage->bitmap_pad = bitmap_pad;
1297 newImage->depth = depth;
1298 newImage->bytes_per_line = (bytes_per_line != 0) ? bytes_per_line : (width + 7) / 8;
1299
1300 return newImage;
1301 }
1302
1303 /*-
1304 * XCreatePixmap
1305 * creates a pixmap
1306 */
XCreatePixmap(Display * display,Drawable d,unsigned int width,unsigned int height,unsigned int depth)1307 Pixmap XCreatePixmap(Display *display, Drawable d, unsigned int width,
1308 unsigned int height, unsigned int depth)
1309 {
1310 Pixmap pm;
1311 HBITMAP hBitmap;
1312
1313 pm = BMInfoCreate();
1314 if (pm < 0 || pm >= NUMBER_BITMAP)
1315 return None;
1316
1317 /* create the bitmap */
1318 if ((hBitmap =
1319 (depth == 1) ? CreateBitmap(width, height, depth, 1, NULL) :
1320 CreateCompatibleBitmap(hdc, width, height)) == NULL)
1321 {
1322 bmInfo[pm].isActive = FALSE;
1323 return None;
1324 }
1325
1326 bmInfo[pm].bitmap = hBitmap;
1327 bmInfo[pm].type = depth;
1328 bmInfo[pm].width = width;
1329 bmInfo[pm].height = height;
1330
1331 return pm;
1332 }
1333
1334 /*-
1335 * XCreatePixmapCursor
1336 * not currently used, returns 0
1337 */
XCreatePixmapCursor(Display * display,Pixmap source,Pixmap mask,XColor * foreground_color,XColor * background_color,unsigned int x_hot,unsigned int y_hot)1338 Cursor XCreatePixmapCursor(Display *display,
1339 Pixmap source, Pixmap mask,
1340 XColor *foreground_color, XColor *background_color,
1341 unsigned int x_hot, unsigned int y_hot)
1342 {
1343 return None;
1344 }
1345
1346 /*-
1347 * XCreatePixmapFromBitmapData
1348 * Creates a pixmap from bitmap data
1349 */
XCreatePixmapFromBitmapData(Display * display,Drawable drawable,char * data,unsigned int width,unsigned int height,unsigned long fg,unsigned long bg,unsigned int depth)1350 Pixmap XCreatePixmapFromBitmapData(Display *display, Drawable drawable,
1351 char *data, unsigned int width, unsigned int height,
1352 unsigned long fg, unsigned long bg, unsigned int depth)
1353 {
1354 HDC hBitmapDC;
1355 HBITMAP hOldBitmap;
1356 Pixmap pm;
1357 RGBQUAD rgbQuad[2] = { {0} };
1358
1359 /* create the bitmap */
1360 if ((pm = XCreateBitmapFromData(display, drawable, data, width, height)) == None)
1361 {
1362 return None;
1363 }
1364
1365 /* if depth is 1 create the bitmap using black and white */
1366 if (depth == 1)
1367 {
1368 fg = 257;
1369 bg = 256;
1370 }
1371
1372 /* set the correct colors in the color table */
1373 rgbQuad[0].rgbRed = red[fg];
1374 rgbQuad[0].rgbGreen = green[fg];
1375 rgbQuad[0].rgbBlue = blue[fg];
1376 rgbQuad[0].rgbReserved = 0;
1377 rgbQuad[1].rgbRed = red[bg];
1378 rgbQuad[1].rgbGreen = green[bg];
1379 rgbQuad[1].rgbBlue = blue[bg];
1380 rgbQuad[1].rgbReserved = 0;
1381
1382 /* create a DC so we can set the bitmaps colortable */
1383 hBitmapDC = CreateCompatibleDC(hdc);
1384 hOldBitmap = SelectObject(hBitmapDC, DrawableGetBitmap(pm));
1385
1386 /* set the colortable */
1387 SetDIBColorTable(hBitmapDC, 0, 2, rgbQuad);
1388
1389 /* clean up */
1390 SelectObject(hBitmapDC, hOldBitmap);
1391 DeleteDC(hBitmapDC);
1392
1393 return pm;
1394 }
1395
1396 /*
1397 * XDefineCursor
1398 * not currently used
1399 */
XDefineCursor(Display * display,Window window,Cursor cursor)1400 void XDefineCursor(Display *display, Window window, Cursor cursor)
1401 {
1402 }
1403
1404 /*-
1405 * XDestroyImage
1406 * not currently used
1407 */
XDestroyImage(XImage * ximage)1408 void XDestroyImage(XImage *ximage)
1409 {
1410 }
1411
1412 /*-
1413 * XDisableAccessControl
1414 * not currently used
1415 */
XDisableAccessControl(Display * display)1416 void XDisableAccessControl(Display *display)
1417 {
1418 }
1419
1420 /*-
1421 * XDrawArc
1422 * draws an arc
1423 */
XDrawArc(Display * display,Drawable d,GC gc,int x,int y,unsigned int width,unsigned int height,int angle1,int angle2)1424 void XDrawArc(Display *display, Drawable d, GC gc, int x, int y,
1425 unsigned int width, unsigned int height,
1426 int angle1, int angle2)
1427 {
1428 int xa1, ya1;
1429 int xa2, ya2;
1430 int cx, cy;
1431 double a1, a2;
1432 double rx, ry;
1433 double ang_inc = M_PI * 2.0 / 23040.0;
1434 HDC dc;
1435 HBITMAP hOldBitmap = NULL;
1436
1437 rx = width/2.0;
1438 ry = height/2.0;
1439 cx = x + width/2 + 2;
1440 cy = y + height/2 + 2;
1441
1442 a1 = (23040 - (angle1 % 23040)) * ang_inc;
1443
1444 xa1 = (int)((rx * cos(a1)) + cx);
1445 ya1 = (int)((ry * sin(a1)) + cy);
1446
1447 if (angle2 == 0) {
1448 /* Special case - In X this is a point but Arc in Windows would
1449 do a complete ellipse! Draw a (thick) line instead. */
1450
1451 XDrawLine(display, d, gc, xa1, ya1, xa1, ya1);
1452
1453 } else {
1454
1455 a2 = (23040 - ((angle1 + angle2) % 23040)) * ang_inc;
1456
1457 xa2 = (int)((rx * cos(a2)) + cx);
1458 ya2 = (int)((ry * sin(a2)) + cy);
1459
1460 if ((dc = GCGetDC(d, gc)) == NULL)
1461 return;
1462
1463 if (d > 0 && d < NUMBER_BITMAP)
1464 if (bmInfo[d].isActive == TRUE)
1465 hOldBitmap = SelectObject(dc, DrawableGetBitmap(d));
1466
1467 Arc(dc, x, y, x + width, y + height, xa1, ya1, xa2, ya2);
1468
1469 if (hOldBitmap)
1470 SelectObject(dc, hOldBitmap);
1471 }
1472 }
1473
1474 /*-
1475 * XDrawImageString
1476 * not currently used
1477 */
XDrawImageString(Display * display,Drawable d,GC gc,int x,int y,char * string,int length)1478 void XDrawImageString(Display *display, Drawable d, GC gc,
1479 int x, int y, char *string, int length)
1480 {
1481 }
1482
1483 /*-
1484 * XDrawLine
1485 * draws a line on the screen in the current pen color
1486 */
XDrawLine(Display * display,Drawable d,GC gc,int x1,int y1,int x2,int y2)1487 void XDrawLine(Display *display, Drawable d, GC gc,
1488 int x1, int y1, int x2, int y2)
1489 {
1490 HDC dc;
1491 HBITMAP hOldBitmap = NULL;
1492
1493 if ((dc = GCGetDC(d, gc)) == NULL)
1494 return;
1495
1496 if (d > 0 && d < NUMBER_BITMAP)
1497 if (bmInfo[d].isActive == TRUE)
1498 hOldBitmap = SelectObject(dc, DrawableGetBitmap(d));
1499
1500 MoveToEx(dc, x1, y1, NULL);
1501 LineTo(dc, x2, y2);
1502
1503 if (hOldBitmap)
1504 SelectObject(dc, hOldBitmap);
1505 }
1506
1507 /*-
1508 * XDrawLines
1509 * draws a series of lines on the screen. Liness may be
1510 * specified as being (1) relative to the origin, or
1511 * (2) relative to the previous line (with the first line
1512 * relative to the origin).
1513 */
XDrawLines(Display * display,Drawable d,GC gc,XPoint * points,int npoints,int mode)1514 void XDrawLines(Display *display, Drawable d, GC gc,
1515 XPoint *points, int npoints, int mode)
1516 {
1517 int i;
1518 int tx, ty;
1519 HDC dc;
1520 HBITMAP hOldBitmap = NULL;
1521 POINT *lppt;
1522 BYTE *lpbTypes;
1523
1524 if ((dc = GCGetDC(d, gc)) == NULL)
1525 return;
1526
1527 if (d > 0 && d < NUMBER_BITMAP)
1528 if (bmInfo[d].isActive == TRUE)
1529 hOldBitmap = SelectObject(dc, DrawableGetBitmap(d));
1530
1531 if (npoints > 1) {
1532 lppt = (POINT*)malloc(npoints * sizeof(POINT));
1533 lpbTypes = (BYTE*)malloc(npoints * sizeof(BYTE));
1534
1535 lpbTypes[0] = PT_MOVETO;
1536 lppt[0].x = points[0].x;
1537 lppt[0].y = points[0].y;
1538
1539 if (mode == CoordModeOrigin) {
1540 for (i=1; i<npoints; i++) {
1541 lpbTypes[i] = PT_LINETO;
1542 lppt[i].x = points[i].x;
1543 lppt[i].y = points[i].y;
1544 }
1545 } else if (mode == CoordModePrevious) {
1546 tx = points[0].x;
1547 ty = points[0].y;
1548 for (i=1; i<npoints; i++) {
1549 tx += points[i].x;
1550 ty += points[i].y;
1551 lpbTypes[i] = PT_LINETO;
1552 lppt[i].x = tx;
1553 lppt[i].y = ty;
1554 }
1555 }
1556 PolyDraw(dc, lppt, lpbTypes, npoints);
1557 free(lppt);
1558 free(lpbTypes);
1559 }
1560
1561 if (hOldBitmap)
1562 SelectObject(dc, hOldBitmap);
1563 }
1564
1565 /*-
1566 * XDrawPoint
1567 * draws a point on the screen
1568 */
XDrawPoint(Display * display,Drawable d,GC gc,int x,int y)1569 void XDrawPoint(Display *display, Drawable d, GC gc, int x, int y)
1570 {
1571 HDC dc;
1572 HBITMAP hOldBitmap = NULL;
1573
1574 if ((dc = GCGetDC(d, gc)) == NULL)
1575 return;
1576
1577 if (d > 0 && d < NUMBER_BITMAP)
1578 if (bmInfo[d].isActive == TRUE)
1579 hOldBitmap = SelectObject(dc, DrawableGetBitmap(d));
1580
1581 SetPixelV(dc, x, y, RGB(cred, cgreen, cblue));
1582
1583 if (hOldBitmap)
1584 SelectObject(dc, hOldBitmap);
1585 }
1586
1587 /*-
1588 * XDrawPoints
1589 * draws a series of points on the screen. Points may be
1590 * specified as being (1) relative to the origin, or
1591 * (2) relative to the previous point (with the first point
1592 * relative to the origin).
1593 */
XDrawPoints(Display * display,Drawable d,GC gc,XPoint * pts,int numpts,int mode)1594 void XDrawPoints(Display *display, Drawable d, GC gc,
1595 XPoint *pts, int numpts, int mode)
1596 {
1597 int i;
1598 int tx, ty;
1599 HDC dc;
1600 HBITMAP hOldBitmap = NULL;
1601
1602 if ((dc = GCGetDC(d, gc)) == NULL)
1603 return;
1604
1605 if (d > 0 && d < NUMBER_BITMAP)
1606 if (bmInfo[d].isActive == TRUE)
1607 hOldBitmap = SelectObject(dc, DrawableGetBitmap(d));
1608
1609 if (mode == CoordModeOrigin)
1610 {
1611 for (i=0; i<numpts; i++)
1612 {
1613 SetPixelV(dc, pts[i].x, pts[i].y, RGB(cred, cgreen, cblue));
1614 }
1615 }
1616 else if (mode == CoordModePrevious)
1617 {
1618 if (numpts > 0)
1619 {
1620 tx = pts[0].x;
1621 ty = pts[0].y;
1622 SetPixelV(dc, tx, ty, RGB(cred, cgreen, cblue));
1623 for (i=1; i<numpts; i++)
1624 {
1625 tx += pts[i].x;
1626 ty += pts[i].y;
1627 SetPixelV(dc, tx, ty, RGB(cred, cgreen, cblue));
1628 }
1629 }
1630 }
1631
1632 if (hOldBitmap)
1633 SelectObject(dc, hOldBitmap);
1634 }
1635
1636 /*-
1637 * XDrawRectangle
1638 * Draws an outline of a rectangle.
1639 * Uses PolyDraw as Rectangle fills rectangle with brush
1640 */
XDrawRectangle(Display * display,Drawable d,GC gc,int x,int y,unsigned int width,unsigned int height)1641 void XDrawRectangle(Display *display, Drawable d, GC gc, int x, int y,
1642 unsigned int width, unsigned int height)
1643 {
1644 BYTE lpbTypes[6];
1645 POINT lppt[6];
1646 HDC dc;
1647 HBITMAP hOldBitmap = NULL;
1648
1649 if ((dc = GCGetDC(d, gc)) == NULL)
1650 return;
1651
1652 if (d > 0 && d < NUMBER_BITMAP)
1653 if (bmInfo[d].isActive == TRUE)
1654 hOldBitmap = SelectObject(dc, DrawableGetBitmap(d));
1655
1656 lpbTypes[0] = PT_MOVETO;
1657 lppt[0].x = x, lppt[0].y = y;
1658 lpbTypes[1] = PT_LINETO;
1659 lppt[1].x = x + width, lppt[1].y = y;
1660 lpbTypes[2] = PT_LINETO;
1661 lppt[2].x = x + width, lppt[2].y = y + height;
1662 lpbTypes[3] = PT_LINETO;
1663 lppt[3].x = x, lppt[3].y = y + height;
1664 lpbTypes[4] = PT_LINETO;
1665 lppt[4].x = x, lppt[4].y = y;
1666 /* overkill but need better closure */
1667 lpbTypes[5] = PT_LINETO;
1668 lppt[5].x = x + width, lppt[5].y = y;
1669 PolyDraw(dc, lppt, lpbTypes, 6);
1670
1671 if (hOldBitmap)
1672 SelectObject(dc, hOldBitmap);
1673 }
1674
1675 /*-
1676 * XDrawSegments
1677 * draws multiple disjoint lines. Lines do not have to be
1678 * connected as each segment is one line.
1679 */
XDrawSegments(Display * display,Drawable d,GC gc,XSegment * segs,int numsegs)1680 void XDrawSegments(Display *display, Drawable d, GC gc,
1681 XSegment *segs, int numsegs)
1682 {
1683 int i;
1684 HDC dc;
1685 HBITMAP hOldBitmap = NULL;
1686 POINT *lppt;
1687 BYTE *lpbTypes;
1688 int cCount = 0;
1689
1690 if ((dc = GCGetDC(d, gc)) == NULL)
1691 return;
1692
1693 if (d > 0 && d < NUMBER_BITMAP)
1694 if (bmInfo[d].isActive == TRUE)
1695 hOldBitmap = SelectObject(dc, DrawableGetBitmap(d));
1696
1697 lppt = (POINT*)malloc(numsegs * 2 * sizeof(POINT));
1698 lpbTypes = (BYTE*)malloc(numsegs * 2 * sizeof(BYTE));
1699
1700 for (i=0; i<numsegs; i++) {
1701 lpbTypes[cCount] = PT_MOVETO;
1702 lppt[cCount].x = segs[i].x1;
1703 lppt[cCount].y = segs[i].y1;
1704 cCount++;
1705 lpbTypes[cCount] = PT_LINETO;
1706 lppt[cCount].x = segs[i].x2;
1707 lppt[cCount].y = segs[i].y2;
1708 cCount++;
1709 }
1710
1711 PolyDraw(dc, lppt, lpbTypes, cCount);
1712
1713 free(lppt);
1714 free(lpbTypes);
1715
1716 if (hOldBitmap)
1717 SelectObject(dc, hOldBitmap);
1718 }
1719
1720 /*-
1721 * XDrawString
1722 * Draws a string of characters at specified location
1723 */
XDrawString(Display * display,Drawable d,GC gc,int x,int y,char * string,int length)1724 void XDrawString(Display *display, Drawable d, GC gc, int x, int y,
1725 char *string, int length)
1726 {
1727 int prevMode;
1728 HDC dc;
1729 HBITMAP hOldBitmap = NULL;
1730
1731 if ((dc = GCGetDC(d, gc)) == NULL)
1732 return;
1733
1734 if (d > 0 && d < NUMBER_BITMAP)
1735 if (bmInfo[d].isActive == TRUE)
1736 hOldBitmap = SelectObject(dc, DrawableGetBitmap(d));
1737
1738 prevMode = GetBkMode(dc);
1739 SetBkMode(dc, TRANSPARENT);
1740 TextOut(dc, x + 3, y - 15, string, length);
1741 SetBkMode(dc, prevMode);
1742
1743 if (hOldBitmap)
1744 SelectObject(dc, hOldBitmap);
1745 }
1746
1747 /*-
1748 * XEnableAccessControl
1749 * not currently used
1750 */
XEnableAccessControl(Display * display)1751 void XEnableAccessControl(Display *display)
1752 {
1753 }
1754
1755 /*-
1756 * XFillArc
1757 * draws a filled arc on screen
1758 */
XFillArc(Display * display,Drawable d,GC gc,int x,int y,unsigned int width,unsigned int height,int angle1,int angle2)1759 void XFillArc(Display *display, Drawable d, GC gc, int x, int y,
1760 unsigned int width, unsigned int height,
1761 int angle1, int angle2)
1762 {
1763 int xa1, ya1;
1764 int xa2, ya2;
1765 int cx, cy;
1766 double a1, a2;
1767 double rx, ry;
1768 double ang_inc = M_PI * 2.0 / 23040.0;
1769 HPEN oldPen;
1770 HDC dc;
1771 HBITMAP hOldBitmap = NULL;
1772
1773 /* set the size of the arc a little larger because
1774 we won't be drawing a border around it */
1775 width++;
1776 height++;
1777
1778 rx = width/2.0;
1779 ry = height/2.0;
1780 cx = x + width/2;
1781 cy = y + height/2;
1782
1783 a1 = (23040 - (angle1 % 23040)) * ang_inc;
1784
1785 xa1 = (int)((rx * cos(a1)) + cx);
1786 ya1 = (int)((ry * sin(a1)) + cy);
1787
1788 if (angle2 == 0) {
1789 /* Special case - In X this is a point but Arc in Windows would
1790 do a complete ellipse! Draw a (thick) line instead. */
1791
1792 XDrawLine(display, d, gc, cx, cy, xa1, ya1);
1793
1794 } else {
1795 if ((dc = GCGetDC(d, gc)) == NULL)
1796 return;
1797
1798 if (d > 0 && d < NUMBER_BITMAP)
1799 if (bmInfo[d].isActive == TRUE)
1800 hOldBitmap = SelectObject(dc, DrawableGetBitmap(d));
1801
1802 a2 = (23040 - ((angle1 + angle2) % 23040)) * ang_inc;
1803
1804 xa2 = (int)((rx * cos(a2)) + cx);
1805 ya2 = (int)((ry * sin(a2)) + cy);
1806
1807 /* set the pen draw width to 1, and because its null it won't
1808 use it, hence the reason we made the arc larger before */
1809 if (noPen == NULL)
1810 if ((noPen = CreatePen(PS_NULL, 0, RGB(0,0,0))) == NULL)
1811 {
1812 xlockmore_set_debug("Failed to create pen");
1813 return;
1814 }
1815 oldPen = SelectObject(dc, noPen);
1816
1817 /* should check for a pie or chord filled arc type, but
1818 currently assuming pie filled arc */
1819 Pie(dc, x, y, x + width, y + height, xa1, ya1, xa2, ya2);
1820
1821 /* reset back and clean up */
1822 SelectObject(dc, oldPen);
1823 if (hOldBitmap)
1824 SelectObject(dc, hOldBitmap);
1825 }
1826 }
1827
1828 /*-
1829 * XFillArcs
1830 * draws a number of filled arcs on screen
1831 */
XFillArcs(Display * display,Drawable d,GC gc,XArc * arcs,int narcs)1832 void XFillArcs(Display *display, Drawable d, GC gc,
1833 XArc *arcs, int narcs)
1834 {
1835 int i;
1836 int xa1, ya1;
1837 int xa2, ya2;
1838 int cx, cy;
1839 double a1, a2;
1840 double rx, ry;
1841 const double ang_inc = M_PI * 2.0 / 23040.0;
1842 HDC dc;
1843 HBITMAP hOldBitmap = NULL;
1844
1845 if ((dc = GCGetDC(d, gc)) == NULL)
1846 return;
1847
1848 for (i=0; i<narcs; i++) {
1849 rx = arcs[i].width/2.0;
1850 ry = arcs[i].height/2.0;
1851 cx = arcs[i].x + arcs[i].width/2;
1852 cy = arcs[i].y + arcs[i].height/2;
1853
1854 a1 = (23040 - (arcs[i].angle1 % 23040)) * ang_inc;
1855
1856 xa1 = (int)((rx * cos(a1)) + cx);
1857 ya1 = (int)((ry * sin(a1)) + cy);
1858
1859 if (arcs[i].angle2 == 0) {
1860 /* Special case - In X this is a point but Arc in Windows would
1861 do a complete ellipse! Draw a (thick) line instead. */
1862
1863 XDrawLine(display, d, gc, cx, cy, xa1, ya1);
1864
1865 } else {
1866
1867 if (d > 0 && d < NUMBER_BITMAP)
1868 if (bmInfo[d].isActive == TRUE)
1869 hOldBitmap = SelectObject(dc, DrawableGetBitmap(d));
1870
1871 a2 = (23040 - ((arcs[i].angle1 + arcs[i].angle2) % 23040)) * ang_inc;
1872 xa2 = (int)((rx * cos(a2)) + cx);
1873 ya2 = (int)((ry * sin(a2)) + cy);
1874
1875 /* should check for a pie or chord filled arc type, but
1876 currently assuming pie filled arc */
1877 Pie(dc, arcs[i].x, arcs[i].y, arcs[i].x + arcs[i].width,
1878 arcs[i].y + arcs[i].height, xa1, ya1, xa2, ya2);
1879
1880 if (hOldBitmap)
1881 SelectObject(dc, hOldBitmap);
1882 }
1883 }
1884 }
1885
1886
1887 /*-
1888 * XFillPolygon
1889 * draws a filled polygon on screen. Points can be specified as
1890 * being relative to the origin, or relative to the previous
1891 * point (with the first point relative to the origin)
1892 */
XFillPolygon(Display * display,Drawable d,GC gc,XPoint * points,int npoints,int shape,int mode)1893 void XFillPolygon(Display *display, Drawable d, GC gc, XPoint *points,
1894 int npoints, int shape, int mode)
1895 {
1896 int i;
1897 int tx, ty;
1898 POINT *pts;
1899 HDC dc;
1900 HBITMAP hOldBitmap = NULL;
1901
1902 if ((dc = GCGetDC(d, gc)) == NULL)
1903 return;
1904
1905 if (npoints <= 0)
1906 return;
1907
1908 if (d > 0 && d < NUMBER_BITMAP)
1909 if (bmInfo[d].isActive == TRUE)
1910 hOldBitmap = SelectObject(dc, DrawableGetBitmap(d));
1911
1912 /* allocate memory */
1913 pts = calloc(npoints, sizeof(POINT));
1914
1915 if (mode == CoordModeOrigin) {
1916 for (i=0; i<npoints; i++) {
1917 pts[i].x = points[i].x;
1918 pts[i].y = points[i].y;
1919 }
1920 }
1921 else if (mode == CoordModePrevious) {
1922 tx = pts[0].x = points[0].x;
1923 ty = pts[0].y = points[0].y;
1924 for (i=1; i<npoints; i++){
1925 tx += points[i].x;
1926 ty += points[i].y;
1927 pts[i].x = tx;
1928 pts[i].y = ty;
1929 }
1930 }
1931
1932 Polygon(dc, pts, npoints);
1933
1934 /* free memory */
1935 free(pts);
1936
1937 if (hOldBitmap)
1938 SelectObject(dc, hOldBitmap);
1939 }
1940
1941 /*-
1942 * XFillRectangle
1943 * draws a filled rectangle on screen
1944 */
XFillRectangle(Display * display,Drawable d,GC gc,int x,int y,unsigned int width,unsigned int height)1945 void XFillRectangle(Display *display, Drawable d, GC gc, int x, int y,
1946 unsigned int width, unsigned int height)
1947 {
1948 HPEN oldPen;
1949 HDC dc;
1950 HBITMAP hOldBitmap = NULL;
1951
1952 if ((dc = GCGetDC(d, gc)) == NULL)
1953 return;
1954
1955 if (d > 0 && d < NUMBER_BITMAP)
1956 if (bmInfo[d].isActive == TRUE)
1957 hOldBitmap = SelectObject(dc, DrawableGetBitmap(d));
1958
1959 /* check if we are doing a FillStippled fill or a normal rectangle */
1960 if (gcInfo[gc].fillStyle.hasFillStyle == TRUE &&
1961 gcInfo[gc].fillStyle.value == FillStippled)
1962 {
1963 HBITMAP hOldBitmapS = NULL;
1964 HBITMAP hStipple = NULL;
1965 HDC hStippleDC;
1966 int i, j;
1967 RGBQUAD rgbQuad = { cblue, cgreen, cred, 0 };
1968 int sHeight;
1969 int sWidth;
1970
1971 /* FillStippled fill */
1972 if ((hStipple = DrawableGetBitmap(gcInfo[gc].stipple.graphic)) == NULL)
1973 {
1974 xlockmore_set_debug("XFillRectangle: Failed to get stipple");
1975 if (hOldBitmap)
1976 SelectObject(dc, hOldBitmap);
1977 return;
1978 }
1979 sWidth = bmInfo[gcInfo[gc].stipple.graphic].width;
1980 sHeight = bmInfo[gcInfo[gc].stipple.graphic].height;
1981 if ((hStippleDC = CreateCompatibleDC(hdc)) == NULL)
1982 {
1983 xlockmore_set_debug("XFillRectangle: Failed to create stipple DC");
1984 if (hOldBitmap)
1985 SelectObject(dc, hOldBitmap);
1986 return;
1987 }
1988 hOldBitmapS = SelectObject(hStippleDC, hStipple);
1989
1990 /* set the correct color table */
1991 SetDIBColorTable(hStippleDC, 0, 1, &rgbQuad);
1992
1993 for (i=y; i<y+height; i+=sHeight)
1994 for (j=x; j<x+width; j+=sWidth)
1995 if (MaskBlt(dc, j, i, sWidth, sHeight, hStippleDC, 0, 0, hStipple, 0, 0,
1996 MAKEROP4(0x00AA0029, SRCCOPY)) == 0)
1997 xlockmore_set_debug("XFillRectangle: MaskBlt() failed");
1998
1999 /* clean up */
2000 if (hOldBitmapS)
2001 SelectObject(hStippleDC, hOldBitmapS);
2002 DeleteDC(hStippleDC);
2003 }
2004 else
2005 {
2006 /* normal rectangle */
2007 if (width == 1 && height == 1)
2008 {
2009 SetPixelV(dc, x, y, RGB(cred, cgreen, cblue));
2010 }
2011 else
2012 {
2013 if (noPen == NULL)
2014 if ((noPen = CreatePen(PS_NULL, 0, RGB(0,0,0))) == NULL)
2015 {
2016 xlockmore_set_debug("XFillRectangle: Failed to create pen");
2017 if (hOldBitmap)
2018 SelectObject(dc, hOldBitmap);
2019 return;
2020 }
2021
2022 oldPen = SelectObject(dc, noPen);
2023 Rectangle(dc, x, y, x + width + 1, y + height + 1);
2024 SelectObject(dc, oldPen);
2025 }
2026 }
2027
2028 if (hOldBitmap)
2029 SelectObject(dc, hOldBitmap);
2030 }
2031
2032 /*-
2033 * XFillRectangles
2034 * draws a number of filled rectangles on screen
2035 */
XFillRectangles(Display * display,Drawable d,GC gc,XRectangle * rectangles,int nrectangles)2036 void XFillRectangles(Display *display, Drawable d, GC gc,
2037 XRectangle *rectangles, int nrectangles)
2038 {
2039 int i;
2040
2041 for (i=0; i<nrectangles; i++) {
2042 XFillRectangle(display, d, gc, rectangles[i].x, rectangles[i].y,
2043 rectangles[i].width, rectangles[i].height);
2044 }
2045 }
2046
2047 /*-
2048 * XFlush
2049 * not currently used
2050 */
XFlush(Display * display)2051 void XFlush(Display *display)
2052 {
2053 }
2054
2055 /*-
2056 * XFree
2057 * not currently used
2058 */
XFree(void * data)2059 void XFree(void *data)
2060 {
2061 }
2062
2063 /*-
2064 * XFreeColormap
2065 * not currently used
2066 */
XFreeColormap(Display * display,Colormap colormap)2067 void XFreeColormap(Display *display, Colormap colormap)
2068 {
2069 }
2070
2071 /*-
2072 * XFreeColors
2073 * not currently used
2074 */
XFreeColors(Display * display,Colormap colormap,unsigned long pixels[],int npixels,unsigned long planes)2075 void XFreeColors(Display *display, Colormap colormap,
2076 unsigned long pixels[], int npixels,
2077 unsigned long planes)
2078 {
2079 }
2080
2081 /*-
2082 * XFreeCursor
2083 * not currently used
2084 */
XFreeCursor(Display * display,Cursor cursor)2085 void XFreeCursor(Display *display, Cursor cursor)
2086 {
2087 }
2088
2089 /*-
2090 * XFreeFont
2091 * not currently used
2092 */
XFreeFont(Display * display,XFontStruct * font_struct)2093 int XFreeFont(Display *display, XFontStruct *font_struct)
2094 {
2095 return 0;
2096 }
2097
2098 /*-
2099 * XFreeFontInfo
2100 * not currently used
2101 */
XFreeFontInfo(char ** names,XFontStruct * free_info,int actual_count)2102 int XFreeFontInfo(char** names, XFontStruct* free_info, int actual_count)
2103 {
2104 return 0;
2105 }
2106
2107 /*-
2108 * XFreeGC
2109 * Free the memory for a GC (HDC)
2110 */
XFreeGC(Display * display,GC gc)2111 void XFreeGC(Display *display, GC gc)
2112 {
2113 if (gc >= 0 && gc < numGCInfo && gcInfo[gc].isActive == TRUE)
2114 gcInfo[gc].isActive = FALSE;
2115 }
2116
2117 /*-
2118 * XFreePixmap
2119 * Free the memory allocated to a pixmap
2120 */
XFreePixmap(Display * display,Pixmap pixmap)2121 void XFreePixmap(Display *display, Pixmap pixmap)
2122 {
2123 if (pixmap < 0 || pixmap >= NUMBER_BITMAP)
2124 return;
2125
2126 if (bmInfo[pixmap].isActive == FALSE)
2127 return;
2128
2129 if (bmInfo[pixmap].bitmap != NULL)
2130 {
2131 DeleteObject(bmInfo[pixmap].bitmap);
2132 bmInfo[pixmap].isActive = FALSE;
2133 bmInfo[pixmap].bitmap = NULL;
2134 bmInfo[pixmap].width = 0;
2135 bmInfo[pixmap].height = 0;
2136 }
2137 }
2138
2139 /*-
2140 * XGetGCValues
2141 * not currently used
2142 */
XGetGCValues(Display * display,GC gc,unsigned long valuemask,XGCValues * values_return)2143 Status XGetGCValues(Display* display, GC gc,
2144 unsigned long valuemask, XGCValues* values_return)
2145 {
2146 return None;
2147 }
2148
2149 /*-
2150 * XGContextFromGC
2151 * not currently used
2152 */
XGContextFromGC(GC gc)2153 GContext XGContextFromGC(GC gc)
2154 {
2155 return None;
2156 }
2157 /*-
2158 * XGetVisualInfo
2159 * not currently used
2160 */
XGetVisualInfo(Display * display,long vinfo_mask,XVisualInfo * vinfo_template,int * nitems_return)2161 XVisualInfo *XGetVisualInfo(Display *display, long vinfo_mask,
2162 XVisualInfo *vinfo_template,
2163 int *nitems_return)
2164 {
2165 return NULL;
2166 }
2167
2168 /*-
2169 * XGetWindowAttributes
2170 * retrieves info about the window
2171 */
XGetWindowAttributes(Display * display,Window w,XWindowAttributes * window_attr_return)2172 Status XGetWindowAttributes(Display *display, Window w,
2173 XWindowAttributes *window_attr_return)
2174 {
2175 memset(window_attr_return, 0, sizeof(XWindowAttributes));
2176
2177 window_attr_return->width = rc.right;
2178 window_attr_return->height = rc.bottom;
2179 window_attr_return->depth = WINDOW_DEPTH;
2180 window_attr_return->root = (int)hwnd;
2181
2182 return 0;
2183 }
2184
2185 /*-
2186 * XGrabKeyboard
2187 * not currently used
2188 */
XGrabKeyboard(Display * display,Window grab_window,Bool owner_events,int pointer_mode,int keyboard_mode,Time time)2189 int XGrabKeyboard(Display *display, Window grab_window,
2190 Bool owner_events, int pointer_mode,
2191 int keyboard_mode, Time time)
2192 {
2193 return 0;
2194 }
2195
2196 /*-
2197 * XGrabPointer
2198 * not currently used
2199 */
XGrabPointer(Display * display,Window grab_window,Bool owner_events,unsigned int event_mask,int pointer_mode,int keyboard_mode,Window confine_to,Cursor cursor,Time time)2200 int XGrabPointer(Display *display, Window grab_window, Bool owner_events,
2201 unsigned int event_mask, int pointer_mode,
2202 int keyboard_mode, Window confine_to, Cursor cursor,
2203 Time time)
2204 {
2205 return 0;
2206 }
2207
2208 /*-
2209 * XGrabServer
2210 * not currently used
2211 */
XGrabServer(Display * display)2212 void XGrabServer(Display *display)
2213 {
2214 }
2215
2216 /*-
2217 * XInstallColormap
2218 * not currently used
2219 */
XInstallColormap(Display * display,Colormap colormap)2220 void XInstallColormap(Display *display, Colormap colormap)
2221 {
2222 }
2223
2224 /*-
2225 * XListHosts
2226 * not currently used, returns NULL
2227 */
XListHosts(Display * display,int * nhosts_return,Bool * state_return)2228 XHostAddress *XListHosts(Display *display, int *nhosts_return,
2229 Bool *state_return)
2230 {
2231 return NULL;
2232 }
2233
2234 /*-
2235 * XLoadQueryFont
2236 * not currently used
2237 */
XLoadQueryFont(Display * display,char * name)2238 XFontStruct *XLoadQueryFont(Display *display, char *name)
2239 {
2240 static XFontStruct fontStruct = { 0 };
2241 return &fontStruct;
2242 }
2243
2244 /*-
2245 * XLookupString
2246 * not currently used
2247 */
XLookupString(XKeyEvent * event_struct,char * buffer_return,int bytes_buffer,KeySym * keysym_return,XComposeStatus * status_in_out)2248 int XLookupString(XKeyEvent *event_struct, char *buffer_return,
2249 int bytes_buffer, KeySym *keysym_return,
2250 XComposeStatus *status_in_out)
2251 {
2252 return 0;
2253 }
2254
2255 /*-
2256 * XMapWindow
2257 * not currently used
2258 */
XMapWindow(Display * display,Window w)2259 void XMapWindow(Display *display, Window w)
2260 {
2261 }
2262
2263 /*-
2264 * XNextEvent
2265 * not currently used
2266 */
XNextEvent(Display * display,XEvent * event_return)2267 void XNextEvent(Display *display, XEvent *event_return)
2268 {
2269 }
2270
2271 /*-
2272 * XOpenDisplay
2273 * not currently used
2274 */
XOpenDisplay(char * display_name)2275 Display *XOpenDisplay(char *display_name)
2276 {
2277 return NULL;
2278 }
2279
2280 /*-
2281 * XParseColor
2282 * not currently used
2283 */
XParseColor(Display * display,Colormap colormap,char * spec,XColor * exact_def_return)2284 Status XParseColor(Display *display, Colormap colormap,
2285 char *spec, XColor *exact_def_return)
2286 {
2287 return 0;
2288 }
2289
2290 /*-
2291 * XPending
2292 * not currently used, return 0
2293 */
XPending(Display * display)2294 int XPending(Display *display)
2295 {
2296 return 0;
2297 }
2298
2299 /*-
2300 * XPutBackEvent
2301 * not currently used
2302 */
XPutBackEvent(Display * display,XEvent * event)2303 void XPutBackEvent(Display *display, XEvent *event)
2304 {
2305 }
2306
2307 /*-
2308 * XPutImage
2309 * Draw an image in screen
2310 */
XPutImage(Display * display,Drawable d,GC gc,XImage * image,int src_x,int src_y,int dest_x,int dest_y,unsigned int width,unsigned int height)2311 void XPutImage(Display *display, Drawable d, GC gc, XImage *image, int src_x,
2312 int src_y, int dest_x, int dest_y, unsigned int width,
2313 unsigned int height)
2314 {
2315 HDC hBitmapDC;
2316 HBITMAP hOldBitmap;
2317 HBITMAP hBitmap;
2318 HPALETTE hPalette;
2319 RGBQUAD rgbQuad = { 0, 0, 0, 0 };
2320 HDC dc;
2321
2322 if ((dc = GCGetDC(d, gc)) == NULL)
2323 return;
2324
2325 /* set the color table for the bitmap */
2326 rgbQuad.rgbRed = cred;
2327 rgbQuad.rgbGreen = cgreen;
2328 rgbQuad.rgbBlue = cblue;
2329
2330 if (image->format == XYBitmap)
2331 {
2332 if (image->depth != 1)
2333 return;
2334
2335 if ((hBitmapDC = CreateCompatibleDC(dc)) == NULL)
2336 return;
2337
2338 LCreateBitmap(image, &hBitmap, &hPalette);
2339 DeleteObject(hPalette); /* we don't need the palette */
2340 if (hBitmap == NULL)
2341 {
2342 DeleteObject(hBitmap);
2343 DeleteDC(hBitmapDC);
2344 return;
2345 }
2346
2347 if ((hOldBitmap = (HBITMAP)SelectObject(hBitmapDC, hBitmap)) == NULL)
2348 {
2349 DeleteObject(hBitmap);
2350 DeleteDC(hBitmapDC);
2351 return;
2352 }
2353
2354 /* set the correct color table */
2355 SetDIBColorTable(hBitmapDC, 0, 1, &rgbQuad);
2356
2357 BitBlt(dc, dest_x, dest_y, width, height, hBitmapDC,
2358 src_x, src_y, SRCCOPY);
2359
2360 SelectObject(hBitmapDC, hOldBitmap);
2361 DeleteObject(hBitmap);
2362 DeleteDC(hBitmapDC);
2363 }
2364 }
2365
2366 /*-
2367 * XPutPixel
2368 * Set a pixels color value on an image
2369 *
2370 * NOTE: I'm not sure what this function returns. The header files
2371 * under cygwin says it should return int, but some references out
2372 * on the web indicate void. I've used int, and it returns 0 if
2373 * it fails, otherwise 1
2374 */
XPutPixel(XImage * ximage,int x,int y,unsigned long pixel)2375 int XPutPixel(XImage *ximage, int x, int y, unsigned long pixel)
2376 {
2377 int pos = 0;
2378 unsigned long val = 0;
2379
2380 /* check ximage points to an image */
2381 if (ximage == NULL)
2382 {
2383 return 0;
2384 }
2385
2386 /* check x & y are within range */
2387 if ((x < 0 || x > ximage->width - 1) ||
2388 (y < 0 || y > ximage->height - 1))
2389 {
2390 return 0;
2391 }
2392
2393 /* only support images of bit depth 1 or > 8 */
2394 if (ximage->depth == 1)
2395 {
2396 int byte_pos = 0;
2397 int oldval = 0;
2398 int i = 0;
2399
2400 pos = (ximage->bytes_per_line * y) + (x / 8);
2401 byte_pos = x % 8;
2402 oldval = ximage->data[pos];
2403 for (i=0; i<8; i++)
2404 {
2405 val <<= 1;
2406 val = ((val & 0xFE) + ((byte_pos != i) ? oldval >> i : pixel)) & 0x01;
2407 }
2408 }
2409 else
2410 {
2411 pos = (ximage->width * y) + x;
2412 val = pixel;
2413 }
2414
2415 ximage->data[pos] = val;
2416
2417 return 1;
2418 }
2419
2420 /*-
2421 * XQueryColor
2422 * not currently used
2423 */
XQueryColor(Display * display,Colormap colormap,XColor * def_in_out)2424 void XQueryColor(Display *display, Colormap colormap, XColor *def_in_out)
2425 {
2426 }
2427
2428 /*-
2429 * XQueryFont
2430 * not currently used
2431 */
XQueryFont(Display * display,XID font_ID)2432 XFontStruct *XQueryFont(Display* display, XID font_ID)
2433 {
2434 static XFontStruct dummy;
2435 return &dummy;
2436 }
2437
2438 /*-
2439 * XQueryPointer
2440 * not currently used
2441 */
XQueryPointer(Display * display,Window w,Window * root_return,Window * child_return,int * root_x_return,int * root_y_return,int * win_x_return,int * win_y_return,unsigned int * mask_return)2442 Bool XQueryPointer(Display *display, Window w, Window *root_return,
2443 Window *child_return, int *root_x_return, int *root_y_return,
2444 int *win_x_return, int *win_y_return,
2445 unsigned int *mask_return)
2446 {
2447 return FALSE;
2448 }
2449
2450 /*-
2451 * XQueryTree
2452 * not currently used
2453 */
XQueryTree(Display * display,Window w,Window * root_return,Window * parent_return,Window ** children_return,unsigned int * nchildren_return)2454 Status XQueryTree(Display *display, Window w, Window *root_return,
2455 Window *parent_return, Window **children_return,
2456 unsigned int *nchildren_return)
2457 {
2458 return 0;
2459 }
2460
2461 /*-
2462 * XRaiseWindow
2463 * not currently used
2464 */
XRaiseWindow(Display * display,Window w)2465 void XRaiseWindow(Display *display, Window w)
2466 {
2467 }
2468
2469 /*-
2470 * XReadBitmapFile
2471 * not currently used
2472 */
XReadBitmapFile(Display * display,Drawable d,char * filename,unsigned int * width_return,unsigned int * height_return,Pixmap * bitmap_return,int * x_hot_return,int * y_hot_return)2473 int XReadBitmapFile(Display *display, Drawable d, char *filename,
2474 unsigned int *width_return, unsigned int *height_return,
2475 Pixmap *bitmap_return, int *x_hot_return, int *y_hot_return)
2476 {
2477 char *data;
2478 unsigned int height;
2479 int rv;
2480 unsigned int width;
2481
2482 /* TODO: implement me */
2483 return BitmapOpenFailed;
2484
2485 /* read the file into data structure */
2486
2487 /* create the bitmap */
2488 if ((*bitmap_return = XCreateBitmapFromData(display, d, data, width, height)) != None)
2489 {
2490 *width_return = width;
2491 *height_return = height;
2492 /* TODO:: hot spot */
2493 *x_hot_return = -1;
2494 *y_hot_return = -1;
2495 rv = BitmapSuccess;
2496 }
2497 else
2498 rv = BitmapFileInvalid;
2499
2500 return rv;
2501 }
2502
2503 /*-
2504 * XRemoveHosts
2505 * not currently used
2506 */
XRemoveHosts(Display * display,XHostAddress * hosts,int num_hosts)2507 void XRemoveHosts(Display *display, XHostAddress *hosts, int num_hosts)
2508 {
2509 }
2510
2511 /*-
2512 * XResourceManagerString
2513 * not currently used, return NULL
2514 */
XResourceManagerString(Display * display)2515 char *XResourceManagerString(Display *display)
2516 {
2517 return NULL;
2518 }
2519
2520 /*-
2521 * XrmDestroyDatabase
2522 * not currently used
2523 */
XrmDestroyDatabase(XrmDatabase database)2524 void XrmDestroyDatabase(XrmDatabase database)
2525 {
2526 }
2527
2528 /*-
2529 * XrmGetFileDatabase
2530 * not currently used, return NULL
2531 */
XrmGetFileDatabase(char * filename)2532 XrmDatabase XrmGetFileDatabase(char *filename)
2533 {
2534 return NULL;
2535 }
2536
2537 /*-
2538 * XrmGetResource
2539 * not currently used, return True
2540 */
XrmGetResource(XrmDatabase database,char * str_name,char * str_class,char ** str_type_return,XrmValue * value_return)2541 Bool XrmGetResource(XrmDatabase database, char *str_name,
2542 char *str_class, char **str_type_return,
2543 XrmValue *value_return)
2544 {
2545 return True;
2546 }
2547
2548 /*-
2549 * XrmGetFileDatabase
2550 * not currently used, return NULL
2551 */
XrmGetStringDatabase(char * data)2552 XrmDatabase XrmGetStringDatabase(char *data)
2553 {
2554 return NULL;
2555 }
2556
2557 /*-
2558 * XrmInitialize
2559 * not currently used
2560 */
XrmInitialize(void)2561 void XrmInitialize(void)
2562 {
2563 }
2564
2565 /*-
2566 * XrmMergeDatabases
2567 * not currently used
2568 */
XrmMergeDatabases(XrmDatabase source_db,XrmDatabase * target_db)2569 void XrmMergeDatabases(XrmDatabase source_db, XrmDatabase *target_db)
2570 {
2571 }
2572
2573 /*-
2574 * XrmParseCommand
2575 * not currently used
2576 */
XrmParseCommand(XrmDatabase * database,XrmOptionDescList table,int table_count,char * name,int * argc_in_out,char ** argv_in_out)2577 void XrmParseCommand(XrmDatabase *database, XrmOptionDescList table,
2578 int table_count, char *name, int *argc_in_out,
2579 char **argv_in_out)
2580 {
2581 }
2582
2583 /*-
2584 * XSetBackground
2585 * sets the background color of pens, shapes, etc
2586 */
XSetBackground(Display * display,GC gc,unsigned long background)2587 void XSetBackground(Display *display, GC gc, unsigned long background)
2588 {
2589 if (gc >= 0 && gc < numGCInfo && gcInfo[gc].isActive == TRUE)
2590 {
2591 gcInfo[gc].needsReset = TRUE;
2592
2593 /* check if drawable is a bitmap, and adjust the 1 and 0 colors
2594 (white and black) to their proper win32 values */
2595 if (gcInfo[gc].depth == 1)
2596 {
2597 if (background == 0 || background == 1)
2598 background = 256 + background;
2599 }
2600
2601 /* check that the background is in range */
2602 if (background > (NUMCOLORS+1))
2603 gcInfo[gc].color.background = NUMCOLORS-1;
2604 else
2605 gcInfo[gc].color.background = background;
2606 }
2607 }
2608
2609 /*-
2610 * XSetFillRule
2611 * sets the fill rule
2612 */
XSetFillRule(Display * display,GC gc,int fill_rule)2613 void XSetFillRule(Display *display, GC gc, int fill_rule)
2614 {
2615 if (gc >= 0 && gc < numGCInfo && gcInfo[gc].isActive == TRUE)
2616 {
2617 gcInfo[gc].needsReset = TRUE;
2618 gcInfo[gc].fillRule.hasFillRule = TRUE;
2619 gcInfo[gc].fillRule.value = fill_rule;
2620 }
2621 }
2622
2623 /*-
2624 * XSetFillStyle
2625 * sets the fill style
2626 */
XSetFillStyle(Display * display,GC gc,int fill_style)2627 void XSetFillStyle(Display *display, GC gc, int fill_style)
2628 {
2629 if (gc >= 0 && gc < numGCInfo && gcInfo[gc].isActive == TRUE)
2630 {
2631 gcInfo[gc].needsReset = TRUE;
2632 gcInfo[gc].fillStyle.hasFillStyle = TRUE;
2633 gcInfo[gc].fillStyle.value = fill_style;
2634 }
2635 }
2636
2637 /*-
2638 * XSetFont
2639 * sets the font to be used for text
2640 */
XSetFont(Display * display,GC gc,Font font)2641 void XSetFont(Display *display, GC gc, Font font)
2642 {
2643 if (gc >= 0 && gc < numGCInfo && gcInfo[gc].isActive == TRUE)
2644 {
2645 gcInfo[gc].needsReset = TRUE;
2646 gcInfo[gc].font.hasFont = TRUE;
2647 gcInfo[gc].font.value = font;
2648 }
2649 }
2650
2651 /*-
2652 * XSetForeground
2653 * sets the color of the current color, foreground pen and
2654 * brush
2655 */
XSetForeground(Display * display,GC gc,unsigned long foreground)2656 void XSetForeground(Display *display, GC gc, unsigned long foreground)
2657 {
2658 if (gc >= 0 && gc < numGCInfo && gcInfo[gc].isActive == TRUE)
2659 {
2660 gcInfo[gc].needsReset = TRUE;
2661
2662 /* check if drawable is a bitmap, and adjust the 1 and 0 colors
2663 (white and black) to their proper win32 values */
2664 if (gcInfo[gc].depth == 1)
2665 {
2666 if (foreground == 0 || foreground == 1)
2667 foreground = 256 + foreground;
2668 }
2669
2670 /* check that the foreground is in range */
2671 if (foreground > (NUMCOLORS+1))
2672 gcInfo[gc].color.foreground = NUMCOLORS-1;
2673 else
2674 gcInfo[gc].color.foreground = foreground;
2675 }
2676 }
2677
2678 /*-
2679 * XSetFunction
2680 * sets the logical operation applied between source pixel
2681 * and destination pixel
2682 * Not fully implemented yet.
2683 */
2684
XSetFunction(Display * display,GC gc,int function)2685 void XSetFunction(Display *display, GC gc, int function)
2686 {
2687 if (gc >= 0 && gc < numGCInfo && gcInfo[gc].isActive == TRUE)
2688 {
2689 gcInfo[gc].needsReset = TRUE;
2690 gcInfo[gc].function.hasFunction = TRUE;
2691 gcInfo[gc].function.value = function;
2692 }
2693 }
2694
2695 /*-
2696 * XSetGraphicsExposures
2697 * Not implemented yet.
2698 */
2699
XSetGraphicsExposures(Display * display,GC gc,Bool graphics_exposures)2700 int XSetGraphicsExposures(Display *display, GC gc, Bool graphics_exposures)
2701 {
2702 return 0;
2703 }
2704
2705 /*-
2706 * XSetLineAttributes
2707 * creates a new pen that has the attributes given
2708 */
XSetLineAttributes(Display * display,GC gc,unsigned int line_width,int line_style,int cap_style,int join_style)2709 void XSetLineAttributes(Display *display, GC gc,
2710 unsigned int line_width, int line_style,
2711 int cap_style, int join_style)
2712 {
2713 if (gc >= 0 && gc < numGCInfo && gcInfo[gc].isActive == TRUE)
2714 {
2715 gcInfo[gc].needsReset = TRUE;
2716 gcInfo[gc].lineAttributes.hasLineAttributes = TRUE;
2717 gcInfo[gc].lineAttributes.width = line_width;
2718 gcInfo[gc].lineAttributes.lineStyle = line_style;
2719 gcInfo[gc].lineAttributes.capStyle = cap_style;
2720 gcInfo[gc].lineAttributes.joinStyle = join_style;
2721 }
2722 }
2723
2724 /*-
2725 * XSetScreenSaver
2726 * not currently used
2727 */
XSetScreenSaver(Display * display,int timeout,int interval,int prefer_blanking,int allow_exposures)2728 void XSetScreenSaver(Display *display, int timeout, int interval,
2729 int prefer_blanking, int allow_exposures)
2730 {
2731 }
2732
2733 /*-
2734 * XSetStipple
2735 * Set the stipple for filled objects
2736 */
XSetStipple(Display * display,GC gc,Pixmap stipple)2737 void XSetStipple(Display *display, GC gc, Pixmap stipple)
2738 {
2739 if (gc >= 0 && gc < numGCInfo && gcInfo[gc].isActive == TRUE)
2740 {
2741 gcInfo[gc].needsReset = TRUE;
2742 gcInfo[gc].stipple.hasStipple = TRUE;
2743 gcInfo[gc].stipple.graphic = stipple;
2744 }
2745 }
2746
2747 /*-
2748 * XSetTSOrigin
2749 * Set the tile or stipple origin
2750 */
XSetTSOrigin(Display * display,GC gc,int ts_x_origin,int ts_y_origin)2751 void XSetTSOrigin(Display *display, GC gc, int ts_x_origin, int ts_y_origin)
2752 {
2753 if (gc >= 0 && gc < numGCInfo && gcInfo[gc].isActive == TRUE)
2754 {
2755 gcInfo[gc].needsReset = TRUE;
2756 gcInfo[gc].tsorigin.hasOrigin = TRUE;
2757 gcInfo[gc].tsorigin.x = ts_x_origin;
2758 gcInfo[gc].tsorigin.y = ts_y_origin;
2759 }
2760 }
2761
2762 /*-
2763 * XSetWindowColormap
2764 * not currently used
2765 */
XSetWindowColormap(Display * display,Window w,Colormap colormap)2766 void XSetWindowColormap(Display *display, Window w, Colormap colormap)
2767 {
2768 }
2769
2770 /*-
2771 * XSetWMName
2772 * not currently used
2773 */
XSetWMName(Display * display,Window w,XTextProperty * text_prop)2774 void XSetWMName(Display *display, Window w, XTextProperty *text_prop)
2775 {
2776 }
2777
2778 /*-
2779 * XStoreColors
2780 * not currently used
2781 */
XStoreColors(Display * display,Colormap colormap,XColor color[],int ncolors)2782 void XStoreColors(Display *display, Colormap colormap, XColor color[],
2783 int ncolors)
2784 {
2785 }
2786
2787 /*-
2788 * XStringListToTextProperty
2789 * not currently used
2790 */
XStringListToTextProperty(char ** list,int count,XTextProperty * text_prop_return)2791 Status XStringListToTextProperty(char **list, int count,
2792 XTextProperty *text_prop_return)
2793 {
2794 return 0;
2795 }
2796
2797 /*-
2798 * XSync
2799 * not currently used
2800 */
XSync(Display * display,Bool discard)2801 void XSync(Display *display, Bool discard)
2802 {
2803 }
2804
2805 /*-
2806 * XTextWidth
2807 * not currently used, returns 0
2808 */
XTextWidth(XFontStruct * font_struct,char * string,int count)2809 int XTextWidth(XFontStruct *font_struct, char *string, int count)
2810 {
2811 return 0;
2812 }
2813
2814 /*-
2815 * XTranslateCoordinates
2816 * Simple implementation ignores source and destination and just
2817 * reports position of global hdc relative to the screen.
2818 */
XTranslateCoordinates(Display * display,Window src_w,Window dest_w,int src_x,int src_y,int * dest_x_return,int * dest_y_return,Window * child_return)2819 Bool XTranslateCoordinates(Display* display, Window src_w, Window dest_w,
2820 int src_x, int src_y,
2821 int* dest_x_return, int* dest_y_return,
2822 Window* child_return)
2823 {
2824 POINT p;
2825 /* use global hdc */
2826 if (GetDCOrgEx(hdc, &p)) {
2827 *dest_x_return = p.x + src_x;
2828 *dest_y_return = p.y + src_y;
2829
2830 } else {
2831 *dest_x_return = src_x;
2832 *dest_y_return = src_y;
2833 }
2834 *child_return = None;
2835 return 1;
2836 }
2837
2838 /*-
2839 * XUngrabKeyboard
2840 * not currently used
2841 */
XUngrabKeyboard(Display * display,Time time)2842 void XUngrabKeyboard(Display *display, Time time)
2843 {
2844 }
2845
2846 /*-
2847 * XUngrabPointer
2848 * not currently used
2849 */
XUngrabPointer(Display * display,Time time)2850 void XUngrabPointer(Display *display, Time time)
2851 {
2852 }
2853
2854 /*-
2855 * XUngrabServer
2856 * not currently used
2857 */
XUngrabServer(Display * display)2858 void XUngrabServer(Display *display)
2859 {
2860 }
2861
2862 /*-
2863 * XUnmapWindow
2864 * not currently used
2865 */
XUnmapWindow(Display * display,Window w)2866 void XUnmapWindow(Display *display, Window w)
2867 {
2868 }
2869
glXSwapBuffers(Display * display,Window w)2870 void glXSwapBuffers(Display *display, Window w)
2871 {
2872 SwapBuffers(hdc);
2873 }
2874
2875
2876
2877 #endif /* WIN32 */
2878
2879 /* -------------------------------------------------------------------- */
2880