6 WMPixmap
*WMRetainPixmap(WMPixmap
* pixmap
)
14 void WMReleasePixmap(WMPixmap
* pixmap
)
16 wassertr(pixmap
!= NULL
);
20 if (pixmap
->refCount
< 1) {
22 XFreePixmap(pixmap
->screen
->display
, pixmap
->pixmap
);
24 XFreePixmap(pixmap
->screen
->display
, pixmap
->mask
);
29 WMPixmap
*WMCreatePixmap(WMScreen
* scrPtr
, int width
, int height
, int depth
, Bool masked
)
33 pixPtr
= wmalloc(sizeof(WMPixmap
));
34 pixPtr
->screen
= scrPtr
;
35 pixPtr
->width
= width
;
36 pixPtr
->height
= height
;
37 pixPtr
->depth
= depth
;
40 pixPtr
->pixmap
= XCreatePixmap(scrPtr
->display
, W_DRAWABLE(scrPtr
), width
, height
, depth
);
42 pixPtr
->mask
= XCreatePixmap(scrPtr
->display
, W_DRAWABLE(scrPtr
), width
, height
, 1);
50 WMPixmap
*WMCreatePixmapFromXPixmaps(WMScreen
* scrPtr
, Pixmap pixmap
, Pixmap mask
,
51 int width
, int height
, int depth
)
55 pixPtr
= wmalloc(sizeof(WMPixmap
));
56 pixPtr
->screen
= scrPtr
;
57 pixPtr
->pixmap
= pixmap
;
59 pixPtr
->width
= width
;
60 pixPtr
->height
= height
;
61 pixPtr
->depth
= depth
;
67 WMPixmap
*WMCreatePixmapFromFile(WMScreen
* scrPtr
, char *fileName
)
72 image
= RLoadImage(scrPtr
->rcontext
, fileName
, 0);
76 pixPtr
= WMCreatePixmapFromRImage(scrPtr
, image
, 127);
83 WMPixmap
*WMCreatePixmapFromRImage(WMScreen
* scrPtr
, RImage
* image
, int threshold
)
88 if (!RConvertImageMask(scrPtr
->rcontext
, image
, &pixmap
, &mask
, threshold
)) {
92 pixPtr
= wmalloc(sizeof(WMPixmap
));
93 pixPtr
->screen
= scrPtr
;
94 pixPtr
->pixmap
= pixmap
;
96 pixPtr
->width
= image
->width
;
97 pixPtr
->height
= image
->height
;
98 pixPtr
->depth
= scrPtr
->depth
;
104 WMPixmap
*WMCreateBlendedPixmapFromRImage(WMScreen
* scrPtr
, RImage
* image
, RColor
* color
)
109 copy
= RCloneImage(image
);
113 RCombineImageWithColor(copy
, color
);
114 pixPtr
= WMCreatePixmapFromRImage(scrPtr
, copy
, 0);
120 WMPixmap
*WMCreateBlendedPixmapFromFile(WMScreen
* scrPtr
, char *fileName
, RColor
* color
)
125 image
= RLoadImage(scrPtr
->rcontext
, fileName
, 0);
129 RCombineImageWithColor(image
, color
);
131 pixPtr
= WMCreatePixmapFromRImage(scrPtr
, image
, 0);
133 RReleaseImage(image
);
138 WMPixmap
*WMCreatePixmapFromXPMData(WMScreen
* scrPtr
, char **data
)
143 image
= RGetImageFromXPMData(scrPtr
->rcontext
, data
);
147 pixPtr
= WMCreatePixmapFromRImage(scrPtr
, image
, 127);
149 RReleaseImage(image
);
154 Pixmap
WMGetPixmapXID(WMPixmap
* pixmap
)
156 wassertrv(pixmap
!= NULL
, None
);
158 return pixmap
->pixmap
;
161 Pixmap
WMGetPixmapMaskXID(WMPixmap
* pixmap
)
163 wassertrv(pixmap
!= NULL
, None
);
168 WMSize
WMGetPixmapSize(WMPixmap
* pixmap
)
170 WMSize size
= { 0, 0 };
172 wassertrv(pixmap
!= NULL
, size
);
174 size
.width
= pixmap
->width
;
175 size
.height
= pixmap
->height
;
180 WMPixmap
*WMGetSystemPixmap(WMScreen
* scr
, int image
)
184 return WMRetainPixmap(scr
->buttonArrow
);
186 case WSIHighlightedReturnArrow
:
187 return WMRetainPixmap(scr
->pushedButtonArrow
);
189 case WSIScrollerDimple
:
190 return WMRetainPixmap(scr
->scrollerDimple
);
193 return WMRetainPixmap(scr
->leftArrow
);
195 case WSIHighlightedArrowLeft
:
196 return WMRetainPixmap(scr
->hiLeftArrow
);
199 return WMRetainPixmap(scr
->rightArrow
);
201 case WSIHighlightedArrowRight
:
202 return WMRetainPixmap(scr
->hiRightArrow
);
205 return WMRetainPixmap(scr
->upArrow
);
207 case WSIHighlightedArrowUp
:
208 return WMRetainPixmap(scr
->hiUpArrow
);
211 return WMRetainPixmap(scr
->downArrow
);
213 case WSIHighlightedArrowDown
:
214 return WMRetainPixmap(scr
->hiDownArrow
);
217 return WMRetainPixmap(scr
->checkMark
);
224 void WMDrawPixmap(WMPixmap
* pixmap
, Drawable d
, int x
, int y
)
226 WMScreen
*scr
= pixmap
->screen
;
228 XSetClipMask(scr
->display
, scr
->clipGC
, pixmap
->mask
);
229 XSetClipOrigin(scr
->display
, scr
->clipGC
, x
, y
);
231 XCopyArea(scr
->display
, pixmap
->pixmap
, d
, scr
->clipGC
, 0, 0, pixmap
->width
, pixmap
->height
, x
, y
);