3 Copyright 1993 by Davor Matic
5 Permission to use, copy, modify, distribute, and sell this software
6 and its documentation for any purpose is hereby granted without fee,
7 provided that the above copyright notice appear in all copies and that
8 both that copyright notice and this permission notice appear in
9 supporting documentation. Davor Matic makes no representations about
10 the suitability of this software for any purpose. It is provided "as
11 is" without express or implied warranty.
15 #ifdef HAVE_XNEST_CONFIG_H
16 #include <xnest-config.h>
20 #include <X11/Xproto.h>
21 #include "regionstr.h"
22 #include <X11/fonts/fontstruct.h>
24 #include "scrnintstr.h"
25 #include "windowstr.h"
26 #include "pixmapstr.h"
41 xnestFillSpans(DrawablePtr pDrawable
, GCPtr pGC
, int nSpans
, xPoint
* pPoints
,
42 int *pWidths
, int fSorted
)
44 ErrorF("xnest warning: function xnestFillSpans not implemented\n");
48 xnestSetSpans(DrawablePtr pDrawable
, GCPtr pGC
, char *pSrc
,
49 xPoint
* pPoints
, int *pWidths
, int nSpans
, int fSorted
)
51 ErrorF("xnest warning: function xnestSetSpans not implemented\n");
55 xnestGetSpans(DrawablePtr pDrawable
, int maxWidth
, DDXPointPtr pPoints
,
56 int *pWidths
, int nSpans
, char *pBuffer
)
58 ErrorF("xnest warning: function xnestGetSpans not implemented\n");
62 xnestQueryBestSize(int class, unsigned short *pWidth
, unsigned short *pHeight
,
65 unsigned int width
, height
;
70 XQueryBestSize(xnestDisplay
, class,
71 xnestDefaultWindows
[pScreen
->myNum
],
72 width
, height
, &width
, &height
);
79 xnestPutImage(DrawablePtr pDrawable
, GCPtr pGC
, int depth
, int x
, int y
,
80 int w
, int h
, int leftPad
, int format
, char *pImage
)
84 ximage
= XCreateImage(xnestDisplay
, xnestDefaultVisual(pDrawable
->pScreen
),
85 depth
, format
, leftPad
, (char *) pImage
,
86 w
, h
, BitmapPad(xnestDisplay
),
88 PixmapBytePad(w
, depth
) : BitmapBytePad(w
+ leftPad
));
91 XPutImage(xnestDisplay
, xnestDrawable(pDrawable
), xnestGC(pGC
),
92 ximage
, 0, 0, x
, y
, w
, h
);
98 xnestIgnoreErrorHandler (Display
*display
,
101 return False
; /* return value is ignored */
105 xnestGetImage(DrawablePtr pDrawable
, int x
, int y
, int w
, int h
,
106 unsigned int format
, unsigned long planeMask
, char *pImage
)
110 int (*old_handler
)(Display
*, XErrorEvent
*);
112 /* we may get BadMatch error when xnest window is minimized */
113 XSync(xnestDisplay
, False
);
114 old_handler
= XSetErrorHandler (xnestIgnoreErrorHandler
);
116 ximage
= XGetImage(xnestDisplay
, xnestDrawable(pDrawable
),
117 x
, y
, w
, h
, planeMask
, format
);
118 XSetErrorHandler(old_handler
);
121 length
= ximage
->bytes_per_line
* ximage
->height
;
123 memmove(pImage
, ximage
->data
, length
);
125 XDestroyImage(ximage
);
130 xnestBitBlitPredicate(Display
* display
, XEvent
* event
, char *args
)
132 return event
->type
== GraphicsExpose
|| event
->type
== NoExpose
;
136 xnestBitBlitHelper(GCPtr pGC
)
138 if (!pGC
->graphicsExposures
)
142 RegionPtr pReg
, pTmpReg
;
144 Bool pending
, overlap
;
146 pReg
= RegionCreate(NULL
, 1);
147 pTmpReg
= RegionCreate(NULL
, 1);
148 if (!pReg
|| !pTmpReg
)
153 XIfEvent(xnestDisplay
, &event
, xnestBitBlitPredicate
, NULL
);
155 switch (event
.type
) {
161 Box
.x1
= event
.xgraphicsexpose
.x
;
162 Box
.y1
= event
.xgraphicsexpose
.y
;
163 Box
.x2
= event
.xgraphicsexpose
.x
+ event
.xgraphicsexpose
.width
;
164 Box
.y2
= event
.xgraphicsexpose
.y
+ event
.xgraphicsexpose
.height
;
165 RegionReset(pTmpReg
, &Box
);
166 RegionAppend(pReg
, pTmpReg
);
167 pending
= event
.xgraphicsexpose
.count
;
172 RegionDestroy(pTmpReg
);
173 RegionValidate(pReg
, &overlap
);
179 xnestCopyArea(DrawablePtr pSrcDrawable
, DrawablePtr pDstDrawable
,
180 GCPtr pGC
, int srcx
, int srcy
, int width
, int height
,
183 XCopyArea(xnestDisplay
,
184 xnestDrawable(pSrcDrawable
), xnestDrawable(pDstDrawable
),
185 xnestGC(pGC
), srcx
, srcy
, width
, height
, dstx
, dsty
);
187 return xnestBitBlitHelper(pGC
);
191 xnestCopyPlane(DrawablePtr pSrcDrawable
, DrawablePtr pDstDrawable
,
192 GCPtr pGC
, int srcx
, int srcy
, int width
, int height
,
193 int dstx
, int dsty
, unsigned long plane
)
195 XCopyPlane(xnestDisplay
,
196 xnestDrawable(pSrcDrawable
), xnestDrawable(pDstDrawable
),
197 xnestGC(pGC
), srcx
, srcy
, width
, height
, dstx
, dsty
, plane
);
199 return xnestBitBlitHelper(pGC
);
203 xnestPolyPoint(DrawablePtr pDrawable
, GCPtr pGC
, int mode
, int nPoints
,
206 XDrawPoints(xnestDisplay
, xnestDrawable(pDrawable
), xnestGC(pGC
),
207 (XPoint
*) pPoints
, nPoints
, mode
);
211 xnestPolylines(DrawablePtr pDrawable
, GCPtr pGC
, int mode
, int nPoints
,
214 XDrawLines(xnestDisplay
, xnestDrawable(pDrawable
), xnestGC(pGC
),
215 (XPoint
*) pPoints
, nPoints
, mode
);
219 xnestPolySegment(DrawablePtr pDrawable
, GCPtr pGC
, int nSegments
,
220 xSegment
* pSegments
)
222 XDrawSegments(xnestDisplay
, xnestDrawable(pDrawable
), xnestGC(pGC
),
223 (XSegment
*) pSegments
, nSegments
);
227 xnestPolyRectangle(DrawablePtr pDrawable
, GCPtr pGC
, int nRectangles
,
228 xRectangle
*pRectangles
)
230 XDrawRectangles(xnestDisplay
, xnestDrawable(pDrawable
), xnestGC(pGC
),
231 (XRectangle
*) pRectangles
, nRectangles
);
235 xnestPolyArc(DrawablePtr pDrawable
, GCPtr pGC
, int nArcs
, xArc
* pArcs
)
237 XDrawArcs(xnestDisplay
, xnestDrawable(pDrawable
), xnestGC(pGC
),
238 (XArc
*) pArcs
, nArcs
);
242 xnestFillPolygon(DrawablePtr pDrawable
, GCPtr pGC
, int shape
, int mode
,
243 int nPoints
, DDXPointPtr pPoints
)
245 XFillPolygon(xnestDisplay
, xnestDrawable(pDrawable
), xnestGC(pGC
),
246 (XPoint
*) pPoints
, nPoints
, shape
, mode
);
250 xnestPolyFillRect(DrawablePtr pDrawable
, GCPtr pGC
, int nRectangles
,
251 xRectangle
*pRectangles
)
253 XFillRectangles(xnestDisplay
, xnestDrawable(pDrawable
), xnestGC(pGC
),
254 (XRectangle
*) pRectangles
, nRectangles
);
258 xnestPolyFillArc(DrawablePtr pDrawable
, GCPtr pGC
, int nArcs
, xArc
* pArcs
)
260 XFillArcs(xnestDisplay
, xnestDrawable(pDrawable
), xnestGC(pGC
),
261 (XArc
*) pArcs
, nArcs
);
265 xnestPolyText8(DrawablePtr pDrawable
, GCPtr pGC
, int x
, int y
, int count
,
270 XDrawString(xnestDisplay
, xnestDrawable(pDrawable
), xnestGC(pGC
),
271 x
, y
, string
, count
);
273 width
= XTextWidth(xnestFontStruct(pGC
->font
), string
, count
);
279 xnestPolyText16(DrawablePtr pDrawable
, GCPtr pGC
, int x
, int y
, int count
,
280 unsigned short *string
)
284 XDrawString16(xnestDisplay
, xnestDrawable(pDrawable
), xnestGC(pGC
),
285 x
, y
, (XChar2b
*) string
, count
);
287 width
= XTextWidth16(xnestFontStruct(pGC
->font
), (XChar2b
*) string
, count
);
293 xnestImageText8(DrawablePtr pDrawable
, GCPtr pGC
, int x
, int y
, int count
,
296 XDrawImageString(xnestDisplay
, xnestDrawable(pDrawable
), xnestGC(pGC
),
297 x
, y
, string
, count
);
301 xnestImageText16(DrawablePtr pDrawable
, GCPtr pGC
, int x
, int y
, int count
,
302 unsigned short *string
)
304 XDrawImageString16(xnestDisplay
, xnestDrawable(pDrawable
), xnestGC(pGC
),
305 x
, y
, (XChar2b
*) string
, count
);
309 xnestImageGlyphBlt(DrawablePtr pDrawable
, GCPtr pGC
, int x
, int y
,
310 unsigned int nGlyphs
, CharInfoPtr
* pCharInfo
,
313 ErrorF("xnest warning: function xnestImageGlyphBlt not implemented\n");
317 xnestPolyGlyphBlt(DrawablePtr pDrawable
, GCPtr pGC
, int x
, int y
,
318 unsigned int nGlyphs
, CharInfoPtr
* pCharInfo
,
321 ErrorF("xnest warning: function xnestPolyGlyphBlt not implemented\n");
325 xnestPushPixels(GCPtr pGC
, PixmapPtr pBitmap
, DrawablePtr pDst
,
326 int width
, int height
, int x
, int y
)
328 /* only works for solid bitmaps */
329 if (pGC
->fillStyle
== FillSolid
) {
330 XSetStipple(xnestDisplay
, xnestGC(pGC
), xnestPixmap(pBitmap
));
331 XSetTSOrigin(xnestDisplay
, xnestGC(pGC
), x
, y
);
332 XSetFillStyle(xnestDisplay
, xnestGC(pGC
), FillStippled
);
333 XFillRectangle(xnestDisplay
, xnestDrawable(pDst
),
334 xnestGC(pGC
), x
, y
, width
, height
);
335 XSetFillStyle(xnestDisplay
, xnestGC(pGC
), FillSolid
);
338 ErrorF("xnest warning: function xnestPushPixels not implemented\n");