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: Window 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>
85 #include "regionstr.h"
86 #include "windowstr.h"
92 * The following list of strings defines the properties which will be
93 * placed on the screen's root window if the property was defined in
94 * the start-up configuration resource database.
97 static char *propStrings
[] = {
100 DT_PRINT_JOB_COMMAND
,
101 DT_PRINT_JOB_EXEC_COMMAND
,
102 DT_PRINT_JOB_EXEC_OPTIONS
,
103 DT_PRINT_PAGE_HEADER
,
104 DT_PRINT_PAGE_TRAILER
,
105 DT_PRINT_PAGE_COMMAND
,
111 * PsCreateWindow - watch for the creation of the root window.
112 * When it's created, register the screen with the print extension,
113 * and put the default command/header properties on it.
118 PsCreateWindow(WindowPtr pWin
)
120 PsWindowPrivPtr pPriv
;
123 Bool status
= Success
;
124 ScreenPtr pScreen
= pWin
->drawable
.pScreen
;
125 PsScreenPrivPtr pScreenPriv
= (PsScreenPrivPtr
)
126 pScreen
->devPrivates
[PsScreenPrivateIndex
].ptr
;
127 PsWindowPrivPtr pWinPriv
= (PsWindowPrivPtr
)
128 pWin
->devPrivates
[PsWindowPrivateIndex
].ptr
;
131 * Initialize this window's private struct.
133 pWinPriv
->jobFileName
= (char *)NULL
;
134 pWinPriv
->pJobFile
= (FILE *)NULL
;
135 pWinPriv
->pageFileName
= (char *)NULL
;
136 pWinPriv
->pPageFile
= (FILE *)NULL
;
138 if(pWin
->parent
== (WindowPtr
)NULL
) /* root window? */
140 Atom propName
; /* type = XA_STRING */
143 XrmDatabase rmdb
= pScreenPriv
->resDB
;
146 * Put the defaults spec'd in the config files in properties on this
147 * screen's root window.
149 for(i
= 0; propStrings
[i
] != (char *)NULL
; i
++)
151 if((propVal
= _DtPrintGetPrinterResource(pWin
, rmdb
,
155 propName
= MakeAtom(propStrings
[i
], strlen(propStrings
[i
]),
157 ChangeWindowProperty(pWin
, propName
, XA_STRING
, 8,
158 PropModeReplace
, strlen(propVal
),
159 (pointer
)propVal
, FALSE
);
168 pPriv
= (PsWindowPrivPtr
)pWin
->devPrivates
[PsWindowPrivateIndex
].ptr
;
169 pPriv
->validContext
= 0;
176 Bool
PsMapWindow(WindowPtr pWindow
)
193 PsUnmapWindow(WindowPtr pWindow
)
202 DDXPointRec ptOldOrg
,
209 PsChangeWindowAttributes(
236 pointer newValues
[COUNT_BITS
];
238 BITS32 gcmask
, index
, mask
;
240 DDXPointRec oldCorner
;
245 register BoxPtr pbox
;
246 register ScreenPtr pScreen
= pWin
->drawable
.pScreen
;
247 register xRectangle
*prect
;
253 * We don't want to paint a window that has no place to put the
256 if( PsGetContextFromWindow(pWin
)==(XpContextPtr
)NULL
) return;
258 if( what
==PW_BACKGROUND
)
260 switch(pWin
->backgroundState
)
264 (*pWin
->parent
->drawable
.pScreen
->PaintWindowBackground
)
265 (pWin
->parent
, pRegion
, what
);
267 case BackgroundPixel
:
268 newValues
[FOREGROUND
] = (pointer
)pWin
->background
.pixel
;
269 newValues
[FILLSTYLE
] = (pointer
)FillSolid
;
270 gcmask
|= GCForeground
| GCFillStyle
;
272 case BackgroundPixmap
:
273 newValues
[TILE
] = (pointer
)pWin
->background
.pixmap
;
274 newValues
[FILLSTYLE
] = (pointer
)FillTiled
;
275 gcmask
|= GCTile
| GCFillStyle
| GCTileStipXOrigin
| GCTileStipYOrigin
;
281 if( pWin
->borderIsPixel
)
283 newValues
[FOREGROUND
] = (pointer
)pWin
->border
.pixel
;
284 newValues
[FILLSTYLE
] = (pointer
)FillSolid
;
285 gcmask
|= GCForeground
| GCFillStyle
;
289 newValues
[TILE
] = (pointer
)pWin
->border
.pixmap
;
290 newValues
[FILLSTYLE
] = (pointer
)FillTiled
;
291 gcmask
|= GCTile
| GCFillStyle
| GCTileStipXOrigin
| GCTileStipYOrigin
;
295 prect
= (xRectangle
*)ALLOCATE_LOCAL(REGION_NUM_RECTS(pRegion
) *
299 newValues
[FUNCTION
] = (pointer
)GXcopy
;
300 gcmask
|= GCFunction
| GCClipMask
;
303 pRoot
= WindowTable
[i
];
306 if (what
== PW_BORDER
)
308 while( pBgWin
->backgroundState
==ParentRelative
) pBgWin
= pBgWin
->parent
;
311 pGC
= GetScratchGC(pWin
->drawable
.depth
, pWin
->drawable
.pScreen
);
314 DEALLOCATE_LOCAL(prect
);
318 * mash the clip list so we can paint the border by
319 * mangling the window in place, pretending it
320 * spans the entire screen
322 if( what
==PW_BORDER
)
324 prgnWin
= pWin
->clipList
;
325 oldCorner
.x
= pWin
->drawable
.x
;
326 oldCorner
.y
= pWin
->drawable
.y
;
327 pWin
->drawable
.x
= pWin
->drawable
.y
= 0;
330 box
.x2
= pScreen
->width
;
331 box
.y2
= pScreen
->height
;
332 REGION_INIT(pScreen
, &pWin
->clipList
, &box
, 1);
333 pWin
->drawable
.serialNumber
= NEXT_SERIAL_NUMBER
;
334 newValues
[ABSX
] = (pointer
)(long)pBgWin
->drawable
.x
;
335 newValues
[ABSY
] = (pointer
)(long)pBgWin
->drawable
.y
;
339 newValues
[ABSX
] = (pointer
)0;
340 newValues
[ABSY
] = (pointer
)0;
344 * XXX Backing store is turned off for the PS driver
346 if( pWin->backStorage )
347 (*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeVisBack);
355 index
= lowbit (mask
);
360 if( (pointer
)(long)pGC
->alu
!=newValues
[FUNCTION
] )
363 gcval
[i
++] = newValues
[FUNCTION
];
366 case GCTileStipXOrigin
:
367 if( (pointer
)(long)pGC
->patOrg
.x
!=newValues
[ABSX
] )
370 gcval
[i
++] = newValues
[ABSX
];
373 case GCTileStipYOrigin
:
374 if( (pointer
)(long)pGC
->patOrg
.y
!=newValues
[ABSY
] )
377 gcval
[i
++] = newValues
[ABSY
];
381 if( (pointer
)pGC
->clientClipType
!=(pointer
)CT_NONE
)
384 gcval
[i
++] = (pointer
)CT_NONE
;
387 case GCSubwindowMode
:
388 if( (pointer
)pGC
->subWindowMode
!=newValues
[SUBWINDOW
] )
391 gcval
[i
++] = newValues
[SUBWINDOW
];
395 if( pGC
->tileIsPixel
|| (pointer
)pGC
->tile
.pixmap
!=newValues
[TILE
] )
398 gcval
[i
++] = newValues
[TILE
];
402 if( (pointer
)pGC
->fillStyle
!=newValues
[FILLSTYLE
] )
405 gcval
[i
++] = newValues
[FILLSTYLE
];
409 if( (pointer
)pGC
->fgPixel
!=newValues
[FOREGROUND
] )
412 gcval
[i
++] = newValues
[FOREGROUND
];
418 if( gcmask
) DoChangeGC(pGC
, gcmask
, (XID
*)gcval
, 1);
420 if( pWin
->drawable
.serialNumber
!=pGC
->serialNumber
)
421 ValidateGC((DrawablePtr
)pWin
, pGC
);
423 numRects
= REGION_NUM_RECTS(pRegion
);
424 pbox
= REGION_RECTS(pRegion
);
425 for( i
=numRects
; --i
>= 0 ; pbox
++,prect
++ )
427 prect
->x
= pbox
->x1
- pWin
->drawable
.x
;
428 prect
->y
= pbox
->y1
- pWin
->drawable
.y
;
429 prect
->width
= pbox
->x2
- pbox
->x1
;
430 prect
->height
= pbox
->y2
- pbox
->y1
;
433 (*pGC
->ops
->PolyFillRect
)((DrawablePtr
)pWin
, pGC
, numRects
, prect
);
434 DEALLOCATE_LOCAL(prect
);
437 * XXX Backing store is turned off for the PS driver
439 if( pWin->backStorage )
440 (*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeNothing);
443 if( what
==PW_BORDER
)
445 REGION_UNINIT(pScreen
, &pWin
->clipList
);
446 pWin
->clipList
= prgnWin
;
447 pWin
->drawable
.x
= oldCorner
.x
;
448 pWin
->drawable
.y
= oldCorner
.y
;
449 pWin
->drawable
.serialNumber
= NEXT_SERIAL_NUMBER
;
456 PsDestroyWindow(WindowPtr pWin
)