small update to display if xinerama is supported in the configure summary. nicer...
[wmaker-crm.git] / WINGs / wpixmap.c
blobcecfc82c98340dc50acc852146b15c4416ff59a6
2 #include "WINGsP.h"
4 #include <wraster.h>
7 WMPixmap*
8 WMRetainPixmap(WMPixmap *pixmap)
10 if (pixmap)
11 pixmap->refCount++;
13 return pixmap;
17 void
18 WMReleasePixmap(WMPixmap *pixmap)
20 wassertr(pixmap!=NULL);
22 pixmap->refCount--;
24 if (pixmap->refCount<1) {
25 if (pixmap->pixmap)
26 XFreePixmap(pixmap->screen->display, pixmap->pixmap);
27 if (pixmap->mask)
28 XFreePixmap(pixmap->screen->display, pixmap->mask);
29 wfree(pixmap);
34 WMPixmap*
35 WMCreatePixmap(WMScreen *scrPtr, int width, int height, int depth, Bool masked)
37 WMPixmap *pixPtr;
39 pixPtr = wmalloc(sizeof(WMPixmap));
40 pixPtr->screen = scrPtr;
41 pixPtr->width = width;
42 pixPtr->height = height;
43 pixPtr->depth = depth;
44 pixPtr->refCount = 1;
46 pixPtr->pixmap = XCreatePixmap(scrPtr->display, W_DRAWABLE(scrPtr),
47 width, height, depth);
48 if (masked) {
49 pixPtr->mask = XCreatePixmap(scrPtr->display, W_DRAWABLE(scrPtr),
50 width, height, 1);
51 } else {
52 pixPtr->mask = None;
55 return pixPtr;
59 WMPixmap*
60 WMCreatePixmapFromXPixmaps(WMScreen *scrPtr, Pixmap pixmap, Pixmap mask,
61 int width, int height, int depth)
63 WMPixmap *pixPtr;
65 pixPtr = wmalloc(sizeof(WMPixmap));
66 pixPtr->screen = scrPtr;
67 pixPtr->pixmap = pixmap;
68 pixPtr->mask = mask;
69 pixPtr->width = width;
70 pixPtr->height = height;
71 pixPtr->depth = depth;
72 pixPtr->refCount = 1;
74 return pixPtr;
78 WMPixmap*
79 WMCreatePixmapFromFile(WMScreen *scrPtr, char *fileName)
81 WMPixmap *pixPtr;
82 RImage *image;
84 image = RLoadImage(scrPtr->rcontext, fileName, 0);
85 if (!image)
86 return NULL;
88 pixPtr = WMCreatePixmapFromRImage(scrPtr, image, 127);
90 RReleaseImage(image);
92 return pixPtr;
96 WMPixmap*
97 WMCreatePixmapFromRImage(WMScreen *scrPtr, RImage *image, int threshold)
99 WMPixmap *pixPtr;
100 Pixmap pixmap, mask;
102 if (!RConvertImageMask(scrPtr->rcontext, image, &pixmap, &mask,
103 threshold)) {
104 return NULL;
107 pixPtr = wmalloc(sizeof(WMPixmap));
108 pixPtr->screen = scrPtr;
109 pixPtr->pixmap = pixmap;
110 pixPtr->mask = mask;
111 pixPtr->width = image->width;
112 pixPtr->height = image->height;
113 pixPtr->depth = scrPtr->depth;
114 pixPtr->refCount = 1;
116 return pixPtr;
120 WMPixmap*
121 WMCreateBlendedPixmapFromRImage(WMScreen *scrPtr, RImage *image, RColor *color)
123 WMPixmap *pixPtr;
124 RImage *copy;
126 copy = RCloneImage(image);
127 if (!copy)
128 return NULL;
130 RCombineImageWithColor(copy, color);
131 pixPtr = WMCreatePixmapFromRImage(scrPtr, copy, 0);
132 RReleaseImage(copy);
134 return pixPtr;
138 WMPixmap*
139 WMCreateBlendedPixmapFromFile(WMScreen *scrPtr, char *fileName, RColor *color)
141 WMPixmap *pixPtr;
142 RImage *image;
145 image = RLoadImage(scrPtr->rcontext, fileName, 0);
146 if (!image)
147 return NULL;
149 RCombineImageWithColor(image, color);
151 pixPtr = WMCreatePixmapFromRImage(scrPtr, image, 0);
153 RReleaseImage(image);
155 return pixPtr;
159 WMPixmap*
160 WMCreatePixmapFromXPMData(WMScreen *scrPtr, char **data)
162 WMPixmap *pixPtr;
163 RImage *image;
165 image = RGetImageFromXPMData(scrPtr->rcontext, data);
166 if (!image)
167 return NULL;
169 pixPtr = WMCreatePixmapFromRImage(scrPtr, image, 127);
171 RReleaseImage(image);
173 return pixPtr;
177 Pixmap
178 WMGetPixmapXID(WMPixmap *pixmap)
180 wassertrv(pixmap != NULL, None);
182 return pixmap->pixmap;
186 Pixmap
187 WMGetPixmapMaskXID(WMPixmap *pixmap)
189 wassertrv(pixmap != NULL, None);
191 return pixmap->mask;
195 WMSize
196 WMGetPixmapSize(WMPixmap *pixmap)
198 WMSize size = {0,0};
200 wassertrv(pixmap != NULL, size);
202 size.width = pixmap->width;
203 size.height = pixmap->height;
205 return size;
209 WMPixmap*
210 WMGetSystemPixmap(WMScreen *scr, int image)
212 switch (image) {
213 case WSIReturnArrow:
214 return WMRetainPixmap(scr->buttonArrow);
216 case WSIHighlightedReturnArrow:
217 return WMRetainPixmap(scr->pushedButtonArrow);
219 case WSIScrollerDimple:
220 return WMRetainPixmap(scr->scrollerDimple);
222 case WSIArrowLeft:
223 return WMRetainPixmap(scr->leftArrow);
225 case WSIHighlightedArrowLeft:
226 return WMRetainPixmap(scr->hiLeftArrow);
228 case WSIArrowRight:
229 return WMRetainPixmap(scr->rightArrow);
231 case WSIHighlightedArrowRight:
232 return WMRetainPixmap(scr->hiRightArrow);
234 case WSIArrowUp:
235 return WMRetainPixmap(scr->upArrow);
237 case WSIHighlightedArrowUp:
238 return WMRetainPixmap(scr->hiUpArrow);
240 case WSIArrowDown:
241 return WMRetainPixmap(scr->downArrow);
243 case WSIHighlightedArrowDown:
244 return WMRetainPixmap(scr->hiDownArrow);
246 case WSICheckMark:
247 return WMRetainPixmap(scr->checkMark);
249 default:
250 return NULL;
256 void
257 WMDrawPixmap(WMPixmap *pixmap, Drawable d, int x, int y)
259 WMScreen *scr = pixmap->screen;
261 XSetClipMask(scr->display, scr->clipGC, pixmap->mask);
262 XSetClipOrigin(scr->display, scr->clipGC, x, y);
264 XCopyArea(scr->display, pixmap->pixmap, d, scr->clipGC, 0, 0,
265 pixmap->width, pixmap->height, x, y);