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