3 Copyright 1996, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
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 OPEN GROUP 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.
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
27 * (c) Copyright 1996 Hewlett-Packard Company
28 * (c) Copyright 1996 International Business Machines Corp.
29 * (c) Copyright 1996 Sun Microsystems, Inc.
30 * (c) Copyright 1996 Novell, Inc.
31 * (c) Copyright 1996 Digital Equipment Corp.
32 * (c) Copyright 1996 Fujitsu Limited
33 * (c) Copyright 1996 Hitachi, Ltd.
35 * Permission is hereby granted, free of charge, to any person obtaining
36 * a copy of this software and associated documentation files (the
37 * "Software"), to deal in the Software without restriction, including
38 * without limitation the rights to use, copy, modify, merge, publish,
39 * distribute, sublicense, and/or sell copies of the Software, and to
40 * permit persons to whom the Software is furnished to do so, subject
41 * to the following conditions:
43 * The above copyright notice and this permission notice shall be included
44 * in all copies or substantial portions of the Software.
46 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
47 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
48 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
49 * THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
50 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
51 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
54 * Except as contained in this notice, the names of the copyright holders
55 * shall not be used in advertising or otherwise to promote the sale, use
56 * or other dealings in this Software without prior written authorization
57 * from said copyright holders.
60 /*******************************************************************
62 ** *********************************************************
66 ** * Contents: Miscellaneous code for Ps driver.
68 ** * Created By: Roger Helmendach (Liberty Systems)
70 ** * Copyright: Copyright 1996 The Open Group, Inc.
72 ** *********************************************************
74 ********************************************************************/
76 #ifdef HAVE_DIX_CONFIG_H
77 #include <dix-config.h>
80 #include <X11/Xos.h> /* for SIGCLD on pre-POSIX systems */
87 #include "windowstr.h"
88 #include "propertyst.h"
99 unsigned width
, highBit
;
111 /* Return the nearest power of two >= what they gave us */
112 highBit
= 0x80000000;
113 /* Find the highest 1 bit in the given width */
114 while(!(highBit
& width
))
116 /* If greater than that then return the next power of two */
117 if((highBit
- 1) & width
)
120 /* height is a don't-care */
126 * PsGetMediumDimensions is installed in the GetMediumDimensions field
127 * of each Ps-initialized context.
130 PsGetMediumDimensions(XpContextPtr pCon
, CARD16
*width
, CARD16
*height
)
132 XpGetMediumDimensions(pCon
, width
, height
);
137 * PsGetReproducibleArea is installed in the GetReproducibleArea field
138 * of each Ps-initialized context.
141 PsGetReproducibleArea(XpContextPtr pCon
, xRectangle
*pRect
)
143 XpGetReproductionArea(pCon
, pRect
);
148 * PsSetImageResolution is installed in the SetImageResolution field
149 * of each Ps-initialized context.
152 PsSetImageResolution(XpContextPtr pCon
, int imageRes
, Bool
*status
)
154 pCon
->imageRes
= imageRes
;
160 * GetPropString searches the window heirarchy from pWin up looking for
161 * a property by the name of propName. If found, returns the property's
162 * value. If not, it returns NULL.
171 PropertyPtr pProp = (PropertyPtr)NULL;
174 atom = MakeAtom(propName, strlen(propName), FALSE);
175 if(atom != BAD_RESOURCE)
182 * The atom has been defined, but it might only exist as a
183 * property on an unrelated window.
186 for(pPropWin = pWin; pPropWin != (WindowPtr)NULL;
187 pPropWin = pPropWin->parent)
189 for(pProp = (PropertyPtr)(wUserProps(pPropWin));
190 pProp != (PropertyPtr)NULL;
193 if (pProp->propertyName == atom)
196 if(pProp != (PropertyPtr)NULL)
199 if(pProp == (PropertyPtr)NULL)
202 n = (pProp->format/8) * pProp->size; *//* size (bytes) of prop */
204 retVal = (char *)xalloc(n + 1);
205 (void)memcpy((void *)retVal, (void *)pProp->data, n);
219 static void SigchldHndlr (int dummy)
222 struct sigaction act;
223 sigfillset(&act.sa_mask);
225 act.sa_handler = SigchldHndlr;
231 * Is this really necessary?
234 sigaction(SIGCHLD, &act, (struct sigaction *)NULL);
239 * SystemCmd provides a wrapper for the 'system' library call. The call
240 * appears to be sensitive to the handling of SIGCHLD, so this wrapper
241 * sets the status to SIG_DFL, and then resets the established handler
242 * after system returns.
246 SystemCmd(char *cmdStr)
249 struct sigaction newAct, oldAct;
250 sigfillset(&newAct.sa_mask);
252 newAct.sa_handler = SIG_DFL;
253 sigfillset(&oldAct.sa_mask);
255 oldAct.sa_handler = SigchldHndlr;
259 * get the old handler, and set the action to IGN
262 sigaction(SIGCHLD, &newAct, &oldAct);
264 status = system (cmdStr);
266 sigaction(SIGCHLD, &oldAct, (struct sigaction *)NULL);
292 switch(pGC
->capStyle
) {
293 case CapButt
: cap
= PsCButt
; break;
294 case CapRound
: cap
= PsCRound
; break;
295 case CapProjecting
: cap
= PsCSquare
; break;
296 default: cap
= PsCButt
; break; }
297 switch(pGC
->joinStyle
) {
298 case JoinMiter
: join
= PsJMiter
; break;
299 case JoinRound
: join
= PsJRound
; break;
300 case JoinBevel
: join
= PsJBevel
; break;
301 default: join
= PsJBevel
; break; }
302 if( pGC
->lineStyle
==LineSolid
) { nDsh
= dshOff
= 0; dsh
= (int *)0; }
305 nDsh
= pGC
->numInDashList
;
306 dshOff
= pGC
->dashOffset
;
307 if( !nDsh
) dsh
= (int *)0;
310 dsh
= (int *)xalloc(sizeof(int)*nDsh
);
311 for( i
=0 ; i
<nDsh
; i
++ ) dsh
[i
] = (int)pGC
->dash
[i
]&0xFF;
315 if( pGC
->lineStyle
!=LineDoubleDash
)
316 PsOut_LineAttrs(psOut
, (int)pGC
->lineWidth
,
317 cap
, join
, nDsh
, dsh
, dshOff
, -1);
319 PsOut_LineAttrs(psOut
, (int)pGC
->lineWidth
,
320 cap
, join
, nDsh
, dsh
, dshOff
,
321 PsGetPixelColor(cMap
, pGC
->bgPixel
));
322 if( nDsh
&& dsh
) xfree(dsh
);