1
/* $Xorg: PsWindow.c,v 1.4 2001/02/09 02:04:36 xorgcvs Exp $ */
4
Copyright 1996, 1998 The Open Group
6
Permission to use, copy, modify, distribute, and sell this software and its
7
documentation for any purpose is hereby granted without fee, provided that
8
the above copyright notice appear in all copies and that both that
9
copyright notice and this permission notice appear in supporting
12
The above copyright notice and this permission notice shall be included in
13
all copies or substantial portions of the Software.
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
Except as contained in this notice, the name of The Open Group shall not be
23
used in advertising or otherwise to promote the sale, use or other dealings
24
in this Software without prior written authorization from The Open Group.
28
* (c) Copyright 1996 Hewlett-Packard Company
29
* (c) Copyright 1996 International Business Machines Corp.
30
* (c) Copyright 1996 Sun Microsystems, Inc.
31
* (c) Copyright 1996 Novell, Inc.
32
* (c) Copyright 1996 Digital Equipment Corp.
33
* (c) Copyright 1996 Fujitsu Limited
34
* (c) Copyright 1996 Hitachi, Ltd.
36
* Permission is hereby granted, free of charge, to any person obtaining
37
* a copy of this software and associated documentation files (the
38
* "Software"), to deal in the Software without restriction, including
39
* without limitation the rights to use, copy, modify, merge, publish,
40
* distribute, sublicense, and/or sell copies of the Software, and to
41
* permit persons to whom the Software is furnished to do so, subject
42
* to the following conditions:
44
* The above copyright notice and this permission notice shall be included
45
* in all copies or substantial portions of the Software.
47
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
48
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
49
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
50
* THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
51
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
52
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
55
* Except as contained in this notice, the names of the copyright holders
56
* shall not be used in advertising or otherwise to promote the sale, use
57
* or other dealings in this Software without prior written authorization
58
* from said copyright holders.
61
/*******************************************************************
63
** *********************************************************
67
** * Contents: Window code for PS driver.
69
** * Created By: Roger Helmendach (Liberty Systems)
71
** * Copyright: Copyright 1996 The Open Group, Inc.
73
** *********************************************************
75
********************************************************************/
77
#ifdef HAVE_DIX_CONFIG_H
78
#include <dix-config.h>
86
#include "regionstr.h"
87
#include "windowstr.h"
92
extern WindowPtr *WindowTable;
95
* The following list of strings defines the properties which will be
96
* placed on the screen's root window if the property was defined in
97
* the start-up configuration resource database.
99
static char *propStrings[] = {
101
DT_PRINT_JOB_TRAILER,
102
DT_PRINT_JOB_COMMAND,
103
DT_PRINT_JOB_EXEC_COMMAND,
104
DT_PRINT_JOB_EXEC_OPTIONS,
105
DT_PRINT_PAGE_HEADER,
106
DT_PRINT_PAGE_TRAILER,
107
DT_PRINT_PAGE_COMMAND,
113
* PsCreateWindow - watch for the creation of the root window.
114
* When it's created, register the screen with the print extension,
115
* and put the default command/header properties on it.
120
PsCreateWindow(WindowPtr pWin)
122
PsWindowPrivPtr pPriv;
125
Bool status = Success;
126
ScreenPtr pScreen = pWin->drawable.pScreen;
127
PsScreenPrivPtr pScreenPriv = (PsScreenPrivPtr)
128
pScreen->devPrivates[PsScreenPrivateIndex].ptr;
129
PsWindowPrivPtr pWinPriv = (PsWindowPrivPtr)
130
pWin->devPrivates[PsWindowPrivateIndex].ptr;
133
* Initialize this window's private struct.
135
pWinPriv->jobFileName = (char *)NULL;
136
pWinPriv->pJobFile = (FILE *)NULL;
137
pWinPriv->pageFileName = (char *)NULL;
138
pWinPriv->pPageFile = (FILE *)NULL;
140
if(pWin->parent == (WindowPtr)NULL) /* root window? */
142
Atom propName; /* type = XA_STRING */
145
XrmDatabase rmdb = pScreenPriv->resDB;
148
* Put the defaults spec'd in the config files in properties on this
149
* screen's root window.
151
for(i = 0; propStrings[i] != (char *)NULL; i++)
153
if((propVal = _DtPrintGetPrinterResource(pWin, rmdb,
157
propName = MakeAtom(propStrings[i], strlen(propStrings[i]),
159
ChangeWindowProperty(pWin, propName, XA_STRING, 8,
160
PropModeReplace, strlen(propVal),
161
(pointer)propVal, FALSE);
170
pPriv = (PsWindowPrivPtr)pWin->devPrivates[PsWindowPrivateIndex].ptr;
171
pPriv->validContext = 0;
178
Bool PsMapWindow(WindowPtr pWindow)
195
PsUnmapWindow(WindowPtr pWindow)
204
DDXPointRec ptOldOrg,
211
PsChangeWindowAttributes(
239
pointer newValues [COUNT_BITS];
241
BITS32 gcmask, index, mask;
243
DDXPointRec oldCorner;
248
register BoxPtr pbox;
249
register ScreenPtr pScreen = pWin->drawable.pScreen;
250
register xRectangle *prect;
256
* We don't want to paint a window that has no place to put the
259
if( PsGetContextFromWindow(pWin)==(XpContextPtr)NULL ) return;
261
if( what==PW_BACKGROUND )
263
switch(pWin->backgroundState)
267
(*pWin->parent->drawable.pScreen->PaintWindowBackground)
268
(pWin->parent, pRegion, what);
270
case BackgroundPixel:
271
newValues[FOREGROUND] = (pointer)pWin->background.pixel;
272
newValues[FILLSTYLE] = (pointer)FillSolid;
273
gcmask |= GCForeground | GCFillStyle;
275
case BackgroundPixmap:
276
newValues[TILE] = (pointer)pWin->background.pixmap;
277
newValues[FILLSTYLE] = (pointer)FillTiled;
278
gcmask |= GCTile | GCFillStyle | GCTileStipXOrigin | GCTileStipYOrigin;
284
if( pWin->borderIsPixel )
286
newValues[FOREGROUND] = (pointer)pWin->border.pixel;
287
newValues[FILLSTYLE] = (pointer)FillSolid;
288
gcmask |= GCForeground | GCFillStyle;
292
newValues[TILE] = (pointer)pWin->border.pixmap;
293
newValues[FILLSTYLE] = (pointer)FillTiled;
294
gcmask |= GCTile | GCFillStyle | GCTileStipXOrigin | GCTileStipYOrigin;
298
prect = (xRectangle *)ALLOCATE_LOCAL(REGION_NUM_RECTS(pRegion) *
302
newValues[FUNCTION] = (pointer)GXcopy;
303
gcmask |= GCFunction | GCClipMask;
306
pRoot = WindowTable[i];
309
if (what == PW_BORDER)
311
while( pBgWin->backgroundState==ParentRelative ) pBgWin = pBgWin->parent;
314
pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen);
317
DEALLOCATE_LOCAL(prect);
321
* mash the clip list so we can paint the border by
322
* mangling the window in place, pretending it
323
* spans the entire screen
325
if( what==PW_BORDER )
327
prgnWin = pWin->clipList;
328
oldCorner.x = pWin->drawable.x;
329
oldCorner.y = pWin->drawable.y;
330
pWin->drawable.x = pWin->drawable.y = 0;
333
box.x2 = pScreen->width;
334
box.y2 = pScreen->height;
335
REGION_INIT(pScreen, &pWin->clipList, &box, 1);
336
pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
337
newValues[ABSX] = (pointer)(long)pBgWin->drawable.x;
338
newValues[ABSY] = (pointer)(long)pBgWin->drawable.y;
342
newValues[ABSX] = (pointer)0;
343
newValues[ABSY] = (pointer)0;
347
* XXX Backing store is turned off for the PS driver
349
if( pWin->backStorage )
350
(*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeVisBack);
358
index = lowbit (mask);
363
if( (pointer)(long)pGC->alu!=newValues[FUNCTION] )
366
gcval[i++] = newValues[FUNCTION];
369
case GCTileStipXOrigin:
370
if( (pointer)(long)pGC->patOrg.x!=newValues[ABSX] )
373
gcval[i++] = newValues[ABSX];
376
case GCTileStipYOrigin:
377
if( (pointer)(long)pGC->patOrg.y!=newValues[ABSY] )
380
gcval[i++] = newValues[ABSY];
384
if( (pointer)pGC->clientClipType!=(pointer)CT_NONE )
387
gcval[i++] = (pointer)CT_NONE;
390
case GCSubwindowMode:
391
if( (pointer)pGC->subWindowMode!=newValues[SUBWINDOW] )
394
gcval[i++] = newValues[SUBWINDOW];
398
if( pGC->tileIsPixel || (pointer)pGC->tile.pixmap!=newValues[TILE] )
401
gcval[i++] = newValues[TILE];
405
if( (pointer)pGC->fillStyle!=newValues[FILLSTYLE] )
408
gcval[i++] = newValues[FILLSTYLE];
412
if( (pointer)pGC->fgPixel!=newValues[FOREGROUND] )
415
gcval[i++] = newValues[FOREGROUND];
421
if( gcmask ) DoChangeGC(pGC, gcmask, (XID *)gcval, 1);
423
if( pWin->drawable.serialNumber!=pGC->serialNumber )
424
ValidateGC((DrawablePtr)pWin, pGC);
426
numRects = REGION_NUM_RECTS(pRegion);
427
pbox = REGION_RECTS(pRegion);
428
for( i=numRects ; --i >= 0 ; pbox++,prect++ )
430
prect->x = pbox->x1 - pWin->drawable.x;
431
prect->y = pbox->y1 - pWin->drawable.y;
432
prect->width = pbox->x2 - pbox->x1;
433
prect->height = pbox->y2 - pbox->y1;
436
(*pGC->ops->PolyFillRect)((DrawablePtr)pWin, pGC, numRects, prect);
437
DEALLOCATE_LOCAL(prect);
440
* XXX Backing store is turned off for the PS driver
442
if( pWin->backStorage )
443
(*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeNothing);
446
if( what==PW_BORDER )
448
REGION_UNINIT(pScreen, &pWin->clipList);
449
pWin->clipList = prgnWin;
450
pWin->drawable.x = oldCorner.x;
451
pWin->drawable.y = oldCorner.y;
452
pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
459
PsDestroyWindow(WindowPtr pWin)