2 * Copyright (c) 2002-2005 Alban G. Hertroys
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 * DAShapedPixmap functions
40 void setGCs(DAShapedPixmap
*dasp
);
41 DAShapedPixmap
*_daMakeShapedPixmap(daShapeSource source
, char **data
);
43 extern struct DAContext
*_daContext
;
45 /* Create a new shaped pixmap with width & height of dockapp window */
49 DAShapedPixmap
*dasp
= malloc(sizeof(DAShapedPixmap
));
54 memset(dasp
, 0, sizeof(DAShapedPixmap
));
55 dasp
->pixmap
= DAMakePixmap();
56 dasp
->shape
= DAMakeShape();
57 dasp
->geometry
.width
= _daContext
->width
;
58 dasp
->geometry
.height
= _daContext
->height
;
67 /* Create a new shaped pixmap from XPM-data */
69 DAMakeShapedPixmapFromData(char **data
)
71 return _daMakeShapedPixmap(daShapeSourceData
, data
);
75 /* Create a new shaped pixmap from XPM-data */
77 DAMakeShapedPixmapFromFile(char *filename
)
79 return _daMakeShapedPixmap(daShapeSourceFile
, (char **)filename
);
83 /* Free memory reserved for a shaped pixmap */
85 DAFreeShapedPixmap(DAShapedPixmap
*dasp
)
89 XFreePixmap(DADisplay
, dasp
->pixmap
);
90 XFreePixmap(DADisplay
, dasp
->shape
);
91 XFreeGC(DADisplay
, dasp
->shapeGC
);
96 /* Copy shape-mask and pixmap-data from an area in one shaped pixmap
97 * into another shaped pixmap */
99 DASPCopyArea(DAShapedPixmap
*src
, DAShapedPixmap
*dst
, int x1
, int y1
, int w
, int h
, int x2
, int y2
)
101 assert(src
!= NULL
&& dst
!= NULL
);
103 XCopyPlane(DADisplay
, src
->shape
, dst
->shape
, src
->shapeGC
, x1
, y1
, w
, h
, x2
, y2
, 1);
104 XCopyArea(DADisplay
, src
->pixmap
, dst
->pixmap
, src
->drawGC
, x1
, y1
, w
, h
, x2
, y2
);
108 /* Clear a shaped pixmap */
110 DASPClear(DAShapedPixmap
*dasp
)
114 assert(dasp
!= NULL
);
117 XChangeGC(DADisplay
, dasp
->shapeGC
, GCForeground
, &gcv
);
120 XFillRectangle(DADisplay
, dasp
->pixmap
,
121 DAClearGC
, 0, 0, dasp
->geometry
.width
, dasp
->geometry
.height
);
122 XFillRectangle(DADisplay
, dasp
->shape
,
123 dasp
->shapeGC
, 0, 0, dasp
->geometry
.width
, dasp
->geometry
.height
);
126 XChangeGC(DADisplay
, dasp
->shapeGC
, GCForeground
, &gcv
);
130 /* Show the pixmap in the dockapp-window */
132 DASPSetPixmap(DAShapedPixmap
*dasp
)
134 DASPSetPixmapForWindow(DAWindow
, dasp
);
138 DASPSetPixmapForWindow(Window window
, DAShapedPixmap
*dasp
)
140 assert(dasp
!= NULL
);
142 DASetShapeForWindow(window
, dasp
->shape
);
143 DASetPixmapForWindow(window
, dasp
->pixmap
);
148 setGCs(DAShapedPixmap
*dasp
)
153 dasp
->clearGC
= DAClearGC
;
155 /* create GC for bit-plane operations in shapes */
156 gcv
.graphics_exposures
= False
;
161 dasp
->shapeGC
= XCreateGC(
164 GCGraphicsExposures
|GCForeground
|GCBackground
|GCPlaneMask
,
170 /* Create a new shaped pixmap using specified method */
172 _daMakeShapedPixmap(daShapeSource source
, char **data
)
175 DAShapedPixmap
*dasp
= malloc(sizeof(DAShapedPixmap
));
180 memset(dasp
, 0, sizeof(DAShapedPixmap
));
182 if (source
== daShapeSourceData
)
183 success
= DAMakePixmapFromData(data
, &dasp
->pixmap
, &dasp
->shape
,
184 &dasp
->geometry
.width
, &dasp
->geometry
.height
);
186 success
= DAMakePixmapFromFile((char *)data
, &dasp
->pixmap
, &dasp
->shape
,
187 &dasp
->geometry
.width
, &dasp
->geometry
.height
);