X11 driver changes.
[wine] / graphics / x11drv / oembitmap.c
1 /*
2  * X11DRV OEM bitmap objects
3  *
4  * Copyright 1994, 1995 Alexandre Julliard
5  *
6  */
7
8 #include "config.h"
9
10 #ifndef X_DISPLAY_MISSING
11
12 #include "ts_xlib.h"
13 #include "ts_xutil.h"
14
15 #ifdef HAVE_LIBXXPM
16 #include "ts_xpm.h"
17 #else /* defined(HAVE_LIBXXPM) */
18 typedef unsigned long Pixel;
19 #endif /* defined(HAVE_LIBXXPM) */
20
21 #include <stdlib.h>
22 #include <string.h>
23
24 #include "bitmap.h"
25 #include "callback.h"
26 #include "color.h"
27 #include "cursoricon.h"
28 #include "debug.h"
29 #include "gdi.h"
30 #include "heap.h"
31 #include "local.h"
32 #include "monitor.h"
33 #include "tweak.h"
34 #include "x11drv.h"
35
36   /* Include OEM pixmaps */
37 #include "bitmaps/obm_cdrom"
38 #include "bitmaps/obm_harddisk"
39 #include "bitmaps/obm_drive"
40 #include "bitmaps/obm_folder2"
41 #include "bitmaps/obm_folder"
42 #include "bitmaps/obm_lfarrowi"
43 #include "bitmaps/obm_rgarrowi"
44 #include "bitmaps/obm_dnarrowi"
45 #include "bitmaps/obm_uparrowi"
46 #include "bitmaps/obm_combo"
47 #include "bitmaps/obm_mnarrow"
48 #include "bitmaps/obm_lfarrowd"
49 #include "bitmaps/obm_rgarrowd"
50 #include "bitmaps/obm_dnarrowd"
51 #include "bitmaps/obm_uparrowd"
52 #include "bitmaps/obm_restored"
53 #include "bitmaps/obm_restore"
54 #include "bitmaps/obm_lfarrow"
55 #include "bitmaps/obm_rgarrow"
56 #include "bitmaps/obm_dnarrow"
57 #include "bitmaps/obm_uparrow"
58 #include "bitmaps/obm_old_restore"
59 #include "bitmaps/obm_old_zoom"
60 #include "bitmaps/obm_old_reduce"
61 #include "bitmaps/obm_btncorners"
62 #include "bitmaps/obm_checkboxes"
63 #include "bitmaps/obm_check"
64 #include "bitmaps/obm_btsize"
65 #include "bitmaps/obm_old_lfarrow"
66 #include "bitmaps/obm_old_rgarrow"
67 #include "bitmaps/obm_old_dnarrow"
68 #include "bitmaps/obm_old_uparrow"
69 #include "bitmaps/obm_size"
70 #include "bitmaps/obm_old_close"
71 #include "bitmaps/obm_trtype"
72 #include "bitmaps/obm_radiocheck"
73
74 #include "bitmaps/obm_zoomd"
75 #include "bitmaps/obm_reduced"
76 #include "bitmaps/obm_zoom"
77 #include "bitmaps/obm_reduce"
78 #include "bitmaps/obm_close"
79 #include "bitmaps/obm_zoomd_95"
80 #include "bitmaps/obm_reduced_95"
81 #include "bitmaps/obm_zoom_95"
82 #include "bitmaps/obm_reduce_95"
83 #include "bitmaps/obm_close_95"
84 #include "bitmaps/obm_closed_95"
85 #include "bitmaps/obm_restore_95"
86 #include "bitmaps/obm_restored_95"
87
88
89 #define OBM_FIRST  OBM_RADIOCHECK  /* First OEM bitmap */
90 #define OBM_LAST   OBM_OLD_CLOSE   /* Last OEM bitmap */
91
92 static struct
93 {
94     char** data;   /* Pointer to bitmap data */
95     BOOL32 color;  /* Is it a color bitmap?  */
96 } OBM_Pixmaps_Data[OBM_LAST-OBM_FIRST+1] = {
97     { obm_radiocheck, FALSE },  /* OBM_RADIOCHECK */
98     { obm_trtype, TRUE },       /* OBM_TRTYPE */    
99     { obm_cdrom, TRUE },        /* OBM_CDROM    */
100     { obm_harddisk, TRUE },     /* OBM_HARDDISK */
101     { obm_drive, TRUE },        /* OBM_DRIVE    */
102     { obm_folder2, TRUE },      /* OBM_FOLDER2  */
103     { obm_folder, TRUE },       /* OBM_FOLDER   */
104     { obm_lfarrowi, TRUE },     /* OBM_LFARROWI */
105     { obm_rgarrowi, TRUE },     /* OBM_RGARROWI */
106     { obm_dnarrowi, TRUE },     /* OBM_DNARROWI */
107     { obm_uparrowi, TRUE },     /* OBM_UPARROWI */
108     { obm_combo, FALSE },       /* OBM_COMBO */
109     { obm_mnarrow, FALSE },     /* OBM_MNARROW */
110     { obm_lfarrowd, TRUE },     /* OBM_LFARROWD */
111     { obm_rgarrowd, TRUE },     /* OBM_RGARROWD */
112     { obm_dnarrowd, TRUE },     /* OBM_DNARROWD */
113     { obm_uparrowd, TRUE },     /* OBM_UPARROWD */
114     { obm_restored, TRUE },     /* OBM_RESTORED */
115     { obm_zoomd, TRUE },        /* OBM_ZOOMD */
116     { obm_reduced, TRUE },      /* OBM_REDUCED */
117     { obm_restore, TRUE },      /* OBM_RESTORE */
118     { obm_zoom, TRUE },         /* OBM_ZOOM */
119     { obm_reduce, TRUE },       /* OBM_REDUCE */
120     { obm_lfarrow, TRUE },      /* OBM_LFARROW */
121     { obm_rgarrow, TRUE },      /* OBM_RGARROW */
122     { obm_dnarrow, TRUE },      /* OBM_DNARROW */
123     { obm_uparrow, TRUE },      /* OBM_UPARROW */
124     { obm_close, TRUE },        /* OBM_CLOSE */
125     { obm_old_restore, FALSE }, /* OBM_OLD_RESTORE */
126     { obm_old_zoom, FALSE },    /* OBM_OLD_ZOOM */
127     { obm_old_reduce, FALSE },  /* OBM_OLD_REDUCE */
128     { obm_btncorners, FALSE },  /* OBM_BTNCORNERS */
129     { obm_checkboxes, FALSE },  /* OBM_CHECKBOXES */
130     { obm_check, FALSE },       /* OBM_CHECK */
131     { obm_btsize, FALSE },      /* OBM_BTSIZE */
132     { obm_old_lfarrow, FALSE }, /* OBM_OLD_LFARROW */
133     { obm_old_rgarrow, FALSE }, /* OBM_OLD_RGARROW */
134     { obm_old_dnarrow, FALSE }, /* OBM_OLD_DNARROW */
135     { obm_old_uparrow, FALSE }, /* OBM_OLD_UPARROW */
136     { obm_size, FALSE },        /* OBM_SIZE */
137     { obm_old_close, FALSE },   /* OBM_OLD_CLOSE */
138 };
139
140
141   /* Include OEM icons */
142 #include "bitmaps/oic_sample"
143 #include "bitmaps/oic_hand"
144 #include "bitmaps/oic_ques"
145 #include "bitmaps/oic_bang"
146 #include "bitmaps/oic_note"
147 #include "bitmaps/oic_portrait"
148 #include "bitmaps/oic_landscape"
149 #include "bitmaps/oic_wineicon"
150 #include "bitmaps/oic_hand_95"
151 #include "bitmaps/oic_ques_95"
152 #include "bitmaps/oic_bang_95"
153 #include "bitmaps/oic_note_95"
154
155 #define OIC_FIRST  OIC_SAMPLE      /* First OEM icon */
156 #define OIC_LAST   OIC_WINEICON   /* Last OEM icon */
157
158 static char **OBM_Icons_Data[OIC_LAST-OIC_FIRST+1] =
159 {
160     oic_sample,    /* OIC_SAMPLE */
161     oic_hand,      /* OIC_HAND */
162     oic_ques,      /* OIC_QUES */
163     oic_bang,      /* OIC_BANG */
164     oic_note,      /* OIC_NOTE */
165     oic_portrait,  /* OIC_PORTRAIT */
166     oic_landscape, /* OIC_LANDSCAPE */
167     oic_wineicon   /* OIC_WINEICON */
168 };
169
170
171   /* Include OEM cursors */
172 #include "bitmaps/ocr_normal"
173 #include "bitmaps/ocr_ibeam"
174 #include "bitmaps/ocr_wait"
175 #include "bitmaps/ocr_cross"
176 #include "bitmaps/ocr_up"
177 #include "bitmaps/ocr_size"
178 #include "bitmaps/ocr_icon"
179 #include "bitmaps/ocr_sizenwse"
180 #include "bitmaps/ocr_sizenesw"
181 #include "bitmaps/ocr_sizewe"
182 #include "bitmaps/ocr_sizens"
183 #include "bitmaps/ocr_bummer"
184 #include "bitmaps/ocr_dragobject"
185 /*#include "bitmaps/ocr_sizeall"*/
186 /*#include "bitmaps/ocr_icocur"*/
187 #include "bitmaps/ocr_no"
188 #include "bitmaps/ocr_appstarting"
189 #include "bitmaps/ocr_help"
190
191 /* Cursor are not all contiguous (go figure...) */
192 #define OCR_FIRST0 OCR_BUMMER
193 #define OCR_LAST0  OCR_DRAGOBJECT
194 #define OCR_BASE0       0
195
196 #define OCR_FIRST1 OCR_NORMAL
197 #define OCR_LAST1  OCR_UP
198 #define OCR_BASE1       (OCR_BASE0 + OCR_LAST0 - OCR_FIRST0 + 1)
199
200 #define OCR_FIRST2 OCR_SIZE
201 #define OCR_LAST2  OCR_SIZENS 
202 #define OCR_BASE2       (OCR_BASE1 + OCR_LAST1 - OCR_FIRST1 + 1)
203
204 #define OCR_FIRST3 OCR_NO
205 #define OCR_LAST3  OCR_NO
206 #define OCR_BASE3       (OCR_BASE2 + OCR_LAST2 - OCR_FIRST2 + 1)
207
208 #define OCR_FIRST4 OCR_APPSTARTING
209 #define OCR_LAST4  OCR_APPSTARTING
210 #define OCR_BASE4       (OCR_BASE3 + OCR_LAST3 - OCR_FIRST3 + 1)
211
212 #define OCR_FIRST5 OCR_HELP
213 #define OCR_LAST5  OCR_HELP
214 #define OCR_BASE5       (OCR_BASE4 + OCR_LAST4 - OCR_FIRST4 + 1)
215
216 #define NB_CURSORS (OCR_BASE5 + OCR_LAST5 - OCR_FIRST5 + 1)
217 static char **OBM_Cursors_Data[NB_CURSORS] = 
218 {
219     ocr_bummer,      /* OCR_BUMMER */
220     ocr_dragobject,  /* OCR_DRAGOBJECT */ 
221     ocr_normal,      /* OCR_NORMAL */
222     ocr_ibeam,       /* OCR_IBEAM */
223     ocr_wait,        /* OCR_WAIT */
224     ocr_cross,       /* OCR_CROSS */
225     ocr_up,          /* OCR_UP */
226     ocr_size,        /* OCR_SIZE */
227     ocr_icon,        /* OCR_ICON */
228     ocr_sizenwse,    /* OCR_SIZENWSE */
229     ocr_sizenesw,    /* OCR_SIZENESW */
230     ocr_sizewe,      /* OCR_SIZEWE */
231     ocr_sizens,      /* OCR_SIZENS */
232 #if 0
233     ocr_sizeall,     /* OCR_SIZEALL */
234     ocr_icocur       /* OCR_ICOCUR */
235 #endif
236     ocr_no,          /* OCR_NO */
237     ocr_appstarting, /* OCR_APPSTARTING */
238     ocr_help         /* OCR_HELP */
239 };
240
241 static HGLOBAL16 OBM_Cursors[NB_CURSORS];
242
243
244   /* All the colors used in the xpm files must be included in this   */
245   /* list, to make sure that the loaded bitmaps only use colors from */
246   /* the Windows colormap. Note: the PALETTEINDEX() are not really   */
247   /* palette indexes, but system colors that will be converted to    */
248   /* indexes later on.                                               */
249
250 #ifdef HAVE_LIBXXPM
251 static XpmColorSymbol
252 #else /* defined(HAVE_LIBXXPM) */
253 static struct
254 {
255     char  *name;
256     char  *value;
257     Pixel  pixel;
258
259 #endif /* defined(HAVE_LIBXXPM) */
260 OBM_Colors[] =
261 {
262     { "black",            NULL, (Pixel)RGB(0,0,0) },
263     { "white",            NULL, (Pixel)RGB(255,255,255) },
264     { "red",              NULL, (Pixel)RGB(255,0,0) },
265     { "green",            NULL, (Pixel)RGB(0,255,0) },
266     { "blue",             NULL, (Pixel)RGB(0,0,255) },
267     { "yellow",           NULL, (Pixel)RGB(255,255,0) },
268     { "cyan",             NULL, (Pixel)RGB(0,255,255) },    
269     { "dkyellow",         NULL, (Pixel)RGB(128,128,0) },
270     { "purple",           NULL, (Pixel)RGB(128,0,128) },
271     { "ltgray",           NULL, (Pixel)RGB(192,192,192) },
272     { "dkgray",           NULL, (Pixel)RGB(128,128,128) },
273     { "foldercol",        NULL, (Pixel)RGB(0,191,191) },
274     { "button_face",      NULL, (Pixel)PALETTEINDEX(COLOR_BTNFACE) },
275     { "button_shadow",    NULL, (Pixel)PALETTEINDEX(COLOR_BTNSHADOW) },
276     { "button_highlight", NULL, (Pixel)PALETTEINDEX(COLOR_BTNHIGHLIGHT) },
277     { "button_edge",      NULL, (Pixel)PALETTEINDEX(COLOR_BTNHIGHLIGHT) },
278     { "button_text",      NULL, (Pixel)PALETTEINDEX(COLOR_BTNTEXT) },
279     { "window_frame",     NULL, (Pixel)PALETTEINDEX(COLOR_WINDOWFRAME) }
280 };
281
282 #define NB_COLOR_SYMBOLS (sizeof(OBM_Colors)/sizeof(OBM_Colors[0]))
283
284   /* These are the symbolic colors for monochrome bitmaps   */
285   /* This is needed to make sure that black is always 0 and */
286   /* white always 1, as required by Windows.                */
287
288 #ifdef HAVE_LIBXXPM
289 static XpmColorSymbol OBM_BlackAndWhite[2] =
290 {
291     { "black", NULL, 0 },
292     { "white", NULL, 0xffffffff }
293 };
294 #endif /* defined(HAVE_LIBXXPM) */
295
296
297 /* This structure holds the arguments for OBM_CreateBitmaps() */
298 typedef struct
299 {
300     char     **data;      /* In: bitmap data */
301     BOOL32     color;     /* In: color or monochrome */
302     BOOL32     need_mask; /* In: do we need a mask? */
303     HBITMAP16  bitmap;    /* Out: resulting bitmap */
304     HBITMAP16  mask;      /* Out: resulting mask (if needed) */
305     POINT32    hotspot;   /* Out: bitmap hotspot */
306 } OBM_BITMAP_DESCR;
307
308
309 /***********************************************************************
310  *           OBM_InitColorSymbols
311  */
312 static BOOL32 OBM_InitColorSymbols()
313 {
314     static BOOL32 initialized = FALSE;
315     int i;
316
317     if (initialized) return TRUE;  /* Already initialised */
318     initialized = TRUE;
319
320     for (i = 0; i < NB_COLOR_SYMBOLS; i++)
321     {
322         if (OBM_Colors[i].pixel & 0xff000000)  /* PALETTEINDEX */
323             OBM_Colors[i].pixel = COLOR_ToPhysical( NULL,
324                                     GetSysColor32(OBM_Colors[i].pixel & 0xff));
325         else  /* RGB*/
326             OBM_Colors[i].pixel = COLOR_ToPhysical( NULL, OBM_Colors[i].pixel);
327     }
328     return TRUE;
329 }
330
331
332 /***********************************************************************
333  *           OBM_MakeBitmap
334  *
335  * Allocate a GDI bitmap.
336  */
337 #ifdef HAVE_LIBXXPM
338 static HBITMAP16 OBM_MakeBitmap( WORD width, WORD height,
339                                  WORD bpp, Pixmap pixmap )
340 {
341     HBITMAP16 hbitmap;
342     BITMAPOBJ * bmpObjPtr;
343     X11DRV_PHYSBITMAP *pbitmap;
344
345     if (!pixmap) return 0;
346
347     hbitmap = GDI_AllocObject( sizeof(BITMAPOBJ), BITMAP_MAGIC );
348     if (!hbitmap) return 0;
349
350     bmpObjPtr = (BITMAPOBJ *) GDI_HEAP_LOCK( hbitmap );
351     bmpObjPtr->size.cx = width;
352     bmpObjPtr->size.cy = height;
353     bmpObjPtr->bitmap.bmType       = 0;
354     bmpObjPtr->bitmap.bmWidth      = width;
355     bmpObjPtr->bitmap.bmHeight     = height;
356     bmpObjPtr->bitmap.bmWidthBytes = BITMAP_GetWidthBytes( width, bpp );
357     bmpObjPtr->bitmap.bmPlanes     = 1;
358     bmpObjPtr->bitmap.bmBitsPixel  = bpp;
359     bmpObjPtr->bitmap.bmBits       = NULL;
360     bmpObjPtr->dib                 = NULL;
361
362     pbitmap = X11DRV_AllocBitmap(bmpObjPtr);
363
364     pbitmap->pixmap  = pixmap;
365
366     GDI_HEAP_UNLOCK( hbitmap );
367     return hbitmap;
368 }
369 #endif /* defined(HAVE_LIBXXPM) */
370
371 /***********************************************************************
372  *           OBM_CreateBitmaps
373  *
374  * Create the 2 bitmaps from XPM data.
375  *
376  * The Xlib critical section must be entered before calling this function.
377  */
378 static BOOL32 OBM_CreateBitmaps( OBM_BITMAP_DESCR *descr )
379 {
380 #ifdef HAVE_LIBXXPM
381     Pixmap pixmap, pixmask;
382     XpmAttributes *attrs;
383     int err;
384
385     attrs = (XpmAttributes *)HEAP_xalloc( GetProcessHeap(), 0,
386                                           XpmAttributesSize() );
387     attrs->valuemask    = XpmColormap | XpmDepth | XpmColorSymbols |XpmHotspot;
388     attrs->colormap     = X11DRV_COLOR_GetColormap();
389     attrs->depth        = descr->color ? MONITOR_GetDepth(&MONITOR_PrimaryMonitor) : 1;
390     attrs->colorsymbols = (attrs->depth > 1) ? OBM_Colors : OBM_BlackAndWhite;
391     attrs->numsymbols   = (attrs->depth > 1) ? NB_COLOR_SYMBOLS : 2;
392         
393     err = XpmCreatePixmapFromData( display, X11DRV_GetXRootWindow(), descr->data,
394                                    &pixmap, &pixmask, attrs );
395
396     if (err != XpmSuccess)
397     {
398         HeapFree( GetProcessHeap(), 0, attrs );
399         return FALSE;
400     }
401     descr->hotspot.x = attrs->x_hotspot;
402     descr->hotspot.y = attrs->y_hotspot;
403     descr->bitmap = OBM_MakeBitmap( attrs->width, attrs->height,
404                                     attrs->depth, pixmap );
405     if (descr->need_mask)
406         descr->mask = OBM_MakeBitmap( attrs->width, attrs->height,
407                                       1, pixmask );
408     HeapFree( GetProcessHeap(), 0, attrs );
409     if (!descr->bitmap)
410     {
411         if (pixmap) XFreePixmap( display, pixmap );
412         if (pixmask) XFreePixmap( display, pixmask );
413         if (descr->bitmap) GDI_FreeObject( descr->bitmap );
414         if (descr->need_mask && descr->mask) GDI_FreeObject( descr->mask );
415         return FALSE;
416     }
417     else return TRUE;
418 #else /* defined(HAVE_LIBXXPM) */
419     FIXME(x11drv,
420         "Xpm support not in the binary, "
421         "please install Xpm and recompile\n"
422     );
423     return FALSE;
424 #endif /* defined(HAVE_LIBXXPM) */
425 }
426
427
428 /***********************************************************************
429  *           OBM_LoadBitmap
430  */
431 static HBITMAP16 OBM_LoadBitmap( WORD id )
432 {
433     OBM_BITMAP_DESCR descr;
434
435     if ((id < OBM_FIRST) || (id > OBM_LAST)) return 0;
436     id -= OBM_FIRST;
437
438     if (!OBM_InitColorSymbols()) return 0;
439
440     descr.data      = OBM_Pixmaps_Data[id].data;
441     descr.color     = OBM_Pixmaps_Data[id].color;
442     descr.need_mask = FALSE;
443
444     EnterCriticalSection( &X11DRV_CritSection );
445     if (!CALL_LARGE_STACK( OBM_CreateBitmaps, &descr ))
446     {
447         LeaveCriticalSection( &X11DRV_CritSection );
448         WARN(bitmap, "Error creating OEM bitmap %d\n", OBM_FIRST+id );
449         return 0;
450     }
451     LeaveCriticalSection( &X11DRV_CritSection );
452     return descr.bitmap;
453 }
454
455
456 /***********************************************************************
457  *           OBM_LoadCursorIcon
458  */
459 static HGLOBAL16 OBM_LoadCursorIcon( WORD id, BOOL32 fCursor )
460 {
461     OBM_BITMAP_DESCR descr;
462     HGLOBAL16 handle;
463     CURSORICONINFO *pInfo;
464     BITMAPOBJ *bmpXor, *bmpAnd;
465     int sizeXor, sizeAnd;
466
467     if (fCursor)
468     {
469         if ((id >= OCR_FIRST1) && (id <= OCR_LAST1))
470              id = OCR_BASE1 + id - OCR_FIRST1;
471         else if ((id >= OCR_FIRST2) && (id <= OCR_LAST2))
472                   id = OCR_BASE2 + id - OCR_FIRST2;
473              else if ((id >= OCR_FIRST0) && (id <= OCR_LAST0))
474                        id = OCR_BASE0 + id - OCR_FIRST0;
475                   else if ((id >= OCR_FIRST3) && (id <= OCR_LAST3))
476                             id = OCR_BASE3 + id - OCR_FIRST3;
477                        else if ((id >= OCR_FIRST4) && (id <= OCR_LAST4))
478                                  id = OCR_BASE4 + id - OCR_FIRST4;
479                             else if ((id >= OCR_FIRST5) && (id <= OCR_LAST5))
480                                       id = OCR_BASE5 + id - OCR_FIRST5;
481         else return 0;
482         if (OBM_Cursors[id]) return OBM_Cursors[id];
483     }
484     else
485     {
486         if ((id < OIC_FIRST) || (id > OIC_LAST)) return 0;
487         id -= OIC_FIRST;
488     }
489
490     if (!OBM_InitColorSymbols()) return 0;
491     
492     descr.data      = fCursor ? OBM_Cursors_Data[id] : OBM_Icons_Data[id];
493     descr.color     = !fCursor;
494     descr.need_mask = TRUE;
495
496     EnterCriticalSection( &X11DRV_CritSection );
497     if (!CALL_LARGE_STACK( OBM_CreateBitmaps, &descr ))
498     {
499         LeaveCriticalSection( &X11DRV_CritSection );
500         WARN(cursor, "Error creating OEM cursor/icon %d\n", id );
501         return 0;
502     }
503     LeaveCriticalSection( &X11DRV_CritSection );
504
505     bmpXor = (BITMAPOBJ *) GDI_GetObjPtr( descr.bitmap, BITMAP_MAGIC );
506     bmpAnd = (BITMAPOBJ *) GDI_GetObjPtr( descr.mask, BITMAP_MAGIC );
507     sizeXor = bmpXor->bitmap.bmHeight * bmpXor->bitmap.bmWidthBytes;
508     sizeAnd = bmpXor->bitmap.bmHeight * 
509                         BITMAP_GetWidthBytes( bmpXor->bitmap.bmWidth, 1 );
510
511     if (!(handle = GlobalAlloc16( GMEM_MOVEABLE,
512                                   sizeof(CURSORICONINFO) + sizeXor + sizeAnd)))
513     {
514         DeleteObject32( descr.bitmap );
515         DeleteObject32( descr.mask );
516         return 0;
517     }
518
519     pInfo = (CURSORICONINFO *)GlobalLock16( handle );
520     pInfo->ptHotSpot.x   = descr.hotspot.x;
521     pInfo->ptHotSpot.y   = descr.hotspot.y;
522     pInfo->nWidth        = bmpXor->bitmap.bmWidth;
523     pInfo->nHeight       = bmpXor->bitmap.bmHeight;
524     pInfo->nWidthBytes   = bmpXor->bitmap.bmWidthBytes;
525     pInfo->bPlanes       = bmpXor->bitmap.bmPlanes;
526     pInfo->bBitsPerPixel = bmpXor->bitmap.bmBitsPixel;
527
528     if (descr.mask)
529     {
530         X11DRV_PHYSBITMAP *pbitmapAnd = bmpAnd->DDBitmap->physBitmap;
531           /* Invert the mask */
532
533         TSXSetFunction( display, BITMAP_monoGC, GXinvert );
534         TSXFillRectangle( display, pbitmapAnd->pixmap, BITMAP_monoGC, 0, 0,
535                         bmpAnd->bitmap.bmWidth, bmpAnd->bitmap.bmHeight );
536         TSXSetFunction( display, BITMAP_monoGC, GXcopy );
537
538           /* Set the masked pixels to black */
539
540         if (bmpXor->bitmap.bmBitsPixel != 1)
541         {
542             X11DRV_PHYSBITMAP *pbitmapXor = bmpXor->DDBitmap->physBitmap;
543             TSXSetForeground( display, BITMAP_colorGC,
544                             COLOR_ToPhysical( NULL, RGB(0,0,0) ));
545             TSXSetBackground( display, BITMAP_colorGC, 0 );
546             TSXSetFunction( display, BITMAP_colorGC, GXor );
547             TSXCopyPlane(display, pbitmapAnd->pixmap, pbitmapXor->pixmap, BITMAP_colorGC,
548                        0, 0, bmpXor->bitmap.bmWidth, bmpXor->bitmap.bmHeight,
549                        0, 0, 1 );
550             TSXSetFunction( display, BITMAP_colorGC, GXcopy );
551         }
552     }
553
554     if (descr.mask) GetBitmapBits32( descr.mask, sizeAnd, (char *)(pInfo + 1));
555     else memset( (char *)(pInfo + 1), 0xff, sizeAnd );
556     GetBitmapBits32( descr.bitmap, sizeXor, (char *)(pInfo + 1) + sizeAnd );
557
558     DeleteObject32( descr.bitmap );
559     DeleteObject32( descr.mask );
560
561     if (fCursor) OBM_Cursors[id] = handle;
562     return handle;
563 }
564
565 /***********************************************************************
566  *           X11DRV_LoadOEMResource
567  *
568  */
569 HANDLE32 X11DRV_LoadOEMResource(WORD resid, WORD type)
570 {
571     switch(type) {
572     case OEM_BITMAP:
573         return OBM_LoadBitmap(resid);
574
575     case OEM_CURSOR:
576         return OBM_LoadCursorIcon(resid, TRUE);
577
578     case OEM_ICON:
579         return OBM_LoadCursorIcon(resid, FALSE);
580
581     default:
582         ERR(x11drv, "Unknown type\n");
583     }
584     return 0;
585 }
586
587
588 /***********************************************************************
589  *           X11DRV_OBM_Init
590  *
591  * Initializes the OBM_Pixmaps_Data and OBM_Icons_Data struct
592  */
593 BOOL32 X11DRV_OBM_Init(void)
594 {
595     if (TWEAK_WineLook == WIN31_LOOK) {
596         OBM_Pixmaps_Data[OBM_ZOOMD - OBM_FIRST].data = obm_zoomd;
597         OBM_Pixmaps_Data[OBM_REDUCED - OBM_FIRST].data = obm_reduced;
598         OBM_Pixmaps_Data[OBM_ZOOM - OBM_FIRST].data = obm_zoom;
599         OBM_Pixmaps_Data[OBM_REDUCE - OBM_FIRST].data = obm_reduce;
600         OBM_Pixmaps_Data[OBM_CLOSE - OBM_FIRST].data = obm_close;
601         OBM_Pixmaps_Data[OBM_RESTORE - OBM_FIRST].data = obm_restore;
602         OBM_Pixmaps_Data[OBM_RESTORED - OBM_FIRST].data = obm_restored;
603
604         OBM_Icons_Data[OIC_HAND - OIC_FIRST] = oic_hand;
605         OBM_Icons_Data[OIC_QUES - OIC_FIRST] = oic_ques;
606         OBM_Icons_Data[OIC_BANG - OIC_FIRST] = oic_bang;
607         OBM_Icons_Data[OIC_NOTE - OIC_FIRST] = oic_note;
608     }
609     else {
610         OBM_Pixmaps_Data[OBM_ZOOMD - OBM_FIRST].data = obm_zoomd_95;
611         OBM_Pixmaps_Data[OBM_REDUCED - OBM_FIRST].data = obm_reduced_95;
612         OBM_Pixmaps_Data[OBM_ZOOM - OBM_FIRST].data = obm_zoom_95;
613         OBM_Pixmaps_Data[OBM_REDUCE - OBM_FIRST].data = obm_reduce_95;
614         OBM_Pixmaps_Data[OBM_CLOSE - OBM_FIRST].data = obm_close_95;
615         OBM_Pixmaps_Data[OBM_RESTORE - OBM_FIRST].data = obm_restore_95;
616         OBM_Pixmaps_Data[OBM_RESTORED - OBM_FIRST].data = obm_restored_95;
617
618         OBM_Icons_Data[OIC_HAND - OIC_FIRST] = oic_hand_95;
619         OBM_Icons_Data[OIC_QUES - OIC_FIRST] = oic_ques_95;
620         OBM_Icons_Data[OIC_BANG - OIC_FIRST] = oic_bang_95;
621         OBM_Icons_Data[OIC_NOTE - OIC_FIRST] = oic_note_95;
622     }
623
624     return 1;
625 }
626
627 #endif /* !defined(X_DISPLAY_MISSING) */