1
/* $Xorg: PclWindow.c,v 1.3 2000/08/17 19:48:08 cpqbld Exp $ */
2
/*******************************************************************
4
** *********************************************************
9
** * Window code for Pcl driver.
13
** *********************************************************
15
********************************************************************/
17
(c) Copyright 1996 Hewlett-Packard Company
18
(c) Copyright 1996 International Business Machines Corp.
19
(c) Copyright 1996 Sun Microsystems, Inc.
20
(c) Copyright 1996 Novell, Inc.
21
(c) Copyright 1996 Digital Equipment Corp.
22
(c) Copyright 1996 Fujitsu Limited
23
(c) Copyright 1996 Hitachi, Ltd.
25
Permission is hereby granted, free of charge, to any person obtaining a copy
26
of this software and associated documentation files (the "Software"), to deal
27
in the Software without restriction, including without limitation the rights
28
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
29
copies of the Software, and to permit persons to whom the Software is
30
furnished to do so, subject to the following conditions:
32
The above copyright notice and this permission notice shall be included in
33
all copies or substantial portions of the Software.
35
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
38
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
39
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
40
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42
Except as contained in this notice, the names of the copyright holders shall
43
not be used in advertising or otherwise to promote the sale, use or other
44
dealings in this Software without prior written authorization from said
47
/* $XFree86: xc/programs/Xserver/Xprint/pcl/PclWindow.c,v 1.10tsi Exp $ */
50
#ifdef HAVE_DIX_CONFIG_H
51
#include <dix-config.h>
56
#include <sys/types.h>
60
#include "regionstr.h"
61
#include "windowstr.h"
68
* The following list of strings defines the properties which will be
69
* placed on the screen's root window if the property was defined in
70
* the start-up configuration resource database.
72
static /* const */ char *propStrings[] = {
75
DT_PRINT_JOB_COMMAND, /* old-obsolete */
76
DT_PRINT_JOB_EXEC_COMMAND,
77
DT_PRINT_JOB_EXEC_OPTIONS,
79
DT_PRINT_PAGE_TRAILER,
80
DT_PRINT_PAGE_COMMAND,
86
* PclCreateWindow - watch for the creation of the root window.
87
* When it's created, register the screen with the print extension,
88
* and put the default command/header properties on it.
94
register WindowPtr pWin)
96
PclWindowPrivPtr pPriv;
99
Bool status = Success;
100
ScreenPtr pScreen = pWin->drawable.pScreen;
101
PclScreenPrivPtr pScreenPriv = (PclScreenPrivPtr)
102
pScreen->devPrivates[PclScreenPrivateIndex].ptr;
103
PclWindowPrivPtr pWinPriv = (PclWindowPrivPtr)
104
pWin->devPrivates[PclWindowPrivateIndex].ptr;
107
* Initialize this window's private struct.
109
pWinPriv->jobFileName = (char *)NULL;
110
pWinPriv->pJobFile = (FILE *)NULL;
111
pWinPriv->pageFileName = (char *)NULL;
112
pWinPriv->pPageFile = (FILE *)NULL;
114
if(pWin->parent == (WindowPtr)NULL) /* root window? */
116
Atom propName; /* type = XA_STRING */
119
XrmDatabase rmdb = pScreenPriv->resDB;
122
* Put the defaults spec'd in the config files in properties on this
123
* screen's root window.
125
for(i = 0; propStrings[i] != (char *)NULL; i++)
127
if((propVal = _DtPrintGetPrinterResource(pWin, rmdb,
131
propName = MakeAtom(propStrings[i], strlen(propStrings[i]),
133
ChangeWindowProperty(pWin, propName, XA_STRING, 8,
134
PropModeReplace, strlen(propVal),
135
(pointer)propVal, FALSE);
145
* Invalidate the window's private print context.
147
pPriv = (PclWindowPrivPtr)pWin->devPrivates[PclWindowPrivateIndex].ptr;
148
pPriv->validContext = 0;
164
register WindowPtr pWin,
183
DDXPointRec ptOldOrg,
190
PclChangeWindowAttributes(
191
register WindowPtr pWin,
192
register unsigned long mask)
194
if( pWin->backingStore != NotUseful )
196
pWin->backingStore = NotUseful;
197
mask |= CWBackingStore;
205
* This function is largely ripped from miPaintWindow, but modified so
206
* that the background is not painted to the root window, and so that
207
* the backing store is not referenced.
227
pointer newValues [COUNT_BITS];
229
BITS32 gcmask, index, mask;
231
DDXPointRec oldCorner;
236
register BoxPtr pbox;
237
register ScreenPtr pScreen = pWin->drawable.pScreen;
238
register xRectangle *prect;
244
* We don't want to paint a window that has no place to put the
247
if( PclGetContextFromWindow( pWin ) == (XpContextPtr)NULL )
250
if (what == PW_BACKGROUND)
252
switch (pWin->backgroundState) {
256
(*pWin->parent->drawable.pScreen->PaintWindowBackground)
257
(pWin->parent, pRegion, what);
259
case BackgroundPixel:
260
newValues[FOREGROUND] = (pointer)pWin->background.pixel;
261
newValues[FILLSTYLE] = (pointer)FillSolid;
262
gcmask |= GCForeground | GCFillStyle;
264
case BackgroundPixmap:
265
newValues[TILE] = (pointer)pWin->background.pixmap;
266
newValues[FILLSTYLE] = (pointer)FillTiled;
267
gcmask |= GCTile | GCFillStyle | GCTileStipXOrigin |
274
if (pWin->borderIsPixel)
276
newValues[FOREGROUND] = (pointer)pWin->border.pixel;
277
newValues[FILLSTYLE] = (pointer)FillSolid;
278
gcmask |= GCForeground | GCFillStyle;
282
newValues[TILE] = (pointer)pWin->border.pixmap;
283
newValues[FILLSTYLE] = (pointer)FillTiled;
284
gcmask |= GCTile | GCFillStyle | GCTileStipXOrigin
289
prect = (xRectangle *)ALLOCATE_LOCAL(REGION_NUM_RECTS(pRegion) *
294
newValues[FUNCTION] = (pointer)GXcopy;
295
gcmask |= GCFunction | GCClipMask;
300
if (what == PW_BORDER)
302
while (pBgWin->backgroundState == ParentRelative)
303
pBgWin = pBgWin->parent;
306
pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen);
309
DEALLOCATE_LOCAL(prect);
313
* mash the clip list so we can paint the border by
314
* mangling the window in place, pretending it
315
* spans the entire screen
317
if (what == PW_BORDER)
319
prgnWin = pWin->clipList;
320
oldCorner.x = pWin->drawable.x;
321
oldCorner.y = pWin->drawable.y;
322
pWin->drawable.x = pWin->drawable.y = 0;
325
box.x2 = pScreen->width;
326
box.y2 = pScreen->height;
327
REGION_INIT(pScreen, &pWin->clipList, &box, 1);
328
pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
329
newValues[ABSX] = (pointer)(long)pBgWin->drawable.x;
330
newValues[ABSY] = (pointer)(long)pBgWin->drawable.y;
334
newValues[ABSX] = (pointer)0;
335
newValues[ABSY] = (pointer)0;
339
* XXX Backing store is turned off for the PCL driver
341
if (pWin->backStorage)
342
(*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC,
350
index = lowbit (mask);
354
if ((pointer)(long) pGC->alu != newValues[FUNCTION]) {
356
gcval[i++] = newValues[FUNCTION];
359
case GCTileStipXOrigin:
360
if ((pointer)(long) pGC->patOrg.x != newValues[ABSX]) {
362
gcval[i++] = newValues[ABSX];
365
case GCTileStipYOrigin:
366
if ((pointer)(long) pGC->patOrg.y != newValues[ABSY]) {
368
gcval[i++] = newValues[ABSY];
372
if ((pointer)(long) pGC->clientClipType != (pointer)CT_NONE) {
374
gcval[i++] = (pointer)CT_NONE;
377
case GCSubwindowMode:
378
if ((pointer)(long) pGC->subWindowMode != newValues[SUBWINDOW]) {
380
gcval[i++] = newValues[SUBWINDOW];
384
if (pGC->tileIsPixel ||
385
(pointer) pGC->tile.pixmap != newValues[TILE])
388
gcval[i++] = newValues[TILE];
392
if ((pointer)(long) pGC->fillStyle != newValues[FILLSTYLE]) {
394
gcval[i++] = newValues[FILLSTYLE];
398
if ((pointer) pGC->fgPixel != newValues[FOREGROUND]) {
400
gcval[i++] = newValues[FOREGROUND];
407
DoChangeGC(pGC, gcmask, (XID *)gcval, 1);
409
if (pWin->drawable.serialNumber != pGC->serialNumber)
410
ValidateGC((DrawablePtr)pWin, pGC);
412
numRects = REGION_NUM_RECTS(pRegion);
413
pbox = REGION_RECTS(pRegion);
414
for (i= numRects; --i >= 0; pbox++, prect++)
416
prect->x = pbox->x1 - pWin->drawable.x;
417
prect->y = pbox->y1 - pWin->drawable.y;
418
prect->width = pbox->x2 - pbox->x1;
419
prect->height = pbox->y2 - pbox->y1;
422
(*pGC->ops->PolyFillRect)((DrawablePtr)pWin, pGC, numRects, prect);
423
DEALLOCATE_LOCAL(prect);
426
* XXX Backing store is turned off for the PCL driver
428
if (pWin->backStorage)
429
(*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC,
433
if (what == PW_BORDER)
435
REGION_UNINIT(pScreen, &pWin->clipList);
436
pWin->clipList = prgnWin;
437
pWin->drawable.x = oldCorner.x;
438
pWin->drawable.y = oldCorner.y;
439
pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;