~ubuntu-branches/ubuntu/intrepid/xserver-xgl/intrepid

« back to all changes in this revision

Viewing changes to hw/dmx/dmxscrinit.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthew Garrett
  • Date: 2006-02-13 14:21:43 UTC
  • Revision ID: james.westby@ubuntu.com-20060213142143-mad6z9xzem7hzxz9
Tags: upstream-7.0.0
ImportĀ upstreamĀ versionĀ 7.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $XFree86$ */
 
2
/*
 
3
 * Copyright 2001-2004 Red Hat Inc., Durham, North Carolina.
 
4
 *
 
5
 * All Rights Reserved.
 
6
 *
 
7
 * Permission is hereby granted, free of charge, to any person obtaining
 
8
 * a copy of this software and associated documentation files (the
 
9
 * "Software"), to deal in the Software without restriction, including
 
10
 * without limitation on the rights to use, copy, modify, merge,
 
11
 * publish, distribute, sublicense, and/or sell copies of the Software,
 
12
 * and to permit persons to whom the Software is furnished to do so,
 
13
 * subject to the following conditions:
 
14
 *
 
15
 * The above copyright notice and this permission notice (including the
 
16
 * next paragraph) shall be included in all copies or substantial
 
17
 * portions of the Software.
 
18
 *
 
19
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 
20
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
21
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 
22
 * NON-INFRINGEMENT.  IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
 
23
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 
24
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
25
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 
26
 * SOFTWARE.
 
27
 */
 
28
 
 
29
/*
 
30
 * Authors:
 
31
 *   Kevin E. Martin <kem@redhat.com>
 
32
 *   David H. Dawes <dawes@xfree86.org>
 
33
 *
 
34
 */
 
35
 
 
36
/** \file
 
37
 * This file provides support for screen initialization. */
 
38
 
 
39
#ifdef HAVE_DMX_CONFIG_H
 
40
#include <dmx-config.h>
 
41
#endif
 
42
 
 
43
#include "dmx.h"
 
44
#include "dmxsync.h"
 
45
#include "dmxshadow.h"
 
46
#include "dmxscrinit.h"
 
47
#include "dmxcursor.h"
 
48
#include "dmxgc.h"
 
49
#include "dmxgcops.h"
 
50
#include "dmxwindow.h"
 
51
#include "dmxpixmap.h"
 
52
#include "dmxfont.h"
 
53
#include "dmxcmap.h"
 
54
#include "dmxprop.h"
 
55
#include "dmxdpms.h"
 
56
 
 
57
#ifdef RENDER
 
58
#include "dmxpict.h"
 
59
#endif
 
60
 
 
61
#include "fb.h"
 
62
#include "mipointer.h"
 
63
#include "micmap.h"
 
64
 
 
65
extern Bool dmxCloseScreen(int idx, ScreenPtr pScreen);
 
66
static Bool dmxSaveScreen(ScreenPtr pScreen, int what);
 
67
 
 
68
static unsigned long dmxGeneration;
 
69
static unsigned long *dmxCursorGeneration;
 
70
 
 
71
int dmxGCPrivateIndex;          /**< Private index for GCs       */
 
72
int dmxWinPrivateIndex;         /**< Private index for Windows   */
 
73
#ifdef PIXPRIV
 
74
int dmxPixPrivateIndex;         /**< Private index for Pixmaps   */
 
75
#endif
 
76
int dmxFontPrivateIndex;        /**< Private index for Fonts     */
 
77
int dmxScreenPrivateIndex;      /**< Private index for Screens   */
 
78
int dmxColormapPrivateIndex;    /**< Private index for Colormaps */
 
79
#ifdef RENDER
 
80
int dmxPictPrivateIndex;        /**< Private index for Picts     */
 
81
int dmxGlyphSetPrivateIndex;    /**< Private index for GlyphSets */
 
82
#endif
 
83
 
 
84
/** Initialize the parts of screen \a idx that require access to the
 
85
 *  back-end server. */
 
86
void dmxBEScreenInit(int idx, ScreenPtr pScreen)
 
87
{
 
88
    DMXScreenInfo        *dmxScreen = &dmxScreens[idx];
 
89
    XSetWindowAttributes  attribs;
 
90
    XGCValues             gcvals;
 
91
    unsigned long         mask;
 
92
    int                   i, j;
 
93
 
 
94
    /* FIXME: The dmxScreenInit() code currently assumes that it will
 
95
     * not be called if the Xdmx server is started with this screen
 
96
     * detached -- i.e., it assumes that dmxScreen->beDisplay is always
 
97
     * valid.  This is not necessarily a valid assumption when full
 
98
     * addition/removal of screens is implemented, but when this code is
 
99
     * broken out for screen reattachment, then we will reevaluate this
 
100
     * assumption.
 
101
     */
 
102
 
 
103
    pScreen->mmWidth = DisplayWidthMM(dmxScreen->beDisplay, 
 
104
                                      DefaultScreen(dmxScreen->beDisplay));
 
105
    pScreen->mmHeight = DisplayHeightMM(dmxScreen->beDisplay, 
 
106
                                        DefaultScreen(dmxScreen->beDisplay));
 
107
 
 
108
    pScreen->whitePixel = dmxScreen->beWhitePixel;
 
109
    pScreen->blackPixel = dmxScreen->beBlackPixel;
 
110
 
 
111
    /* Handle screen savers and DPMS on the backend */
 
112
    dmxDPMSInit(dmxScreen);
 
113
 
 
114
    /* Create root window for screen */
 
115
    mask = CWBackPixel | CWEventMask | CWColormap | CWOverrideRedirect;
 
116
    attribs.background_pixel = dmxScreen->beBlackPixel;
 
117
    attribs.event_mask = (KeyPressMask
 
118
                          | KeyReleaseMask
 
119
                          | ButtonPressMask
 
120
                          | ButtonReleaseMask
 
121
                          | EnterWindowMask
 
122
                          | LeaveWindowMask
 
123
                          | PointerMotionMask
 
124
                          | KeymapStateMask
 
125
                          | FocusChangeMask);
 
126
    attribs.colormap = dmxScreen->beDefColormaps[dmxScreen->beDefVisualIndex];
 
127
    attribs.override_redirect = True;
 
128
    
 
129
    dmxScreen->scrnWin =
 
130
        XCreateWindow(dmxScreen->beDisplay, 
 
131
                      DefaultRootWindow(dmxScreen->beDisplay),
 
132
                      dmxScreen->scrnX,
 
133
                      dmxScreen->scrnY,
 
134
                      dmxScreen->scrnWidth,
 
135
                      dmxScreen->scrnHeight,
 
136
                      0,
 
137
                      pScreen->rootDepth,
 
138
                      InputOutput,
 
139
                      dmxScreen->beVisuals[dmxScreen->beDefVisualIndex].visual,
 
140
                      mask,
 
141
                      &attribs);
 
142
    dmxPropertyWindow(dmxScreen);
 
143
 
 
144
    /*
 
145
     * This turns off the cursor by defining a cursor with no visible
 
146
     * components.
 
147
     */
 
148
    {
 
149
        char noCursorData[] = {0, 0, 0, 0,
 
150
                               0, 0, 0, 0};
 
151
        Pixmap pixmap;
 
152
        XColor color, tmp;
 
153
 
 
154
        pixmap = XCreateBitmapFromData(dmxScreen->beDisplay, dmxScreen->scrnWin,
 
155
                                       noCursorData, 8, 8);
 
156
        XAllocNamedColor(dmxScreen->beDisplay, dmxScreen->beDefColormaps[0],
 
157
                         "black", &color, &tmp);
 
158
        dmxScreen->noCursor = XCreatePixmapCursor(dmxScreen->beDisplay,
 
159
                                                  pixmap, pixmap,
 
160
                                                  &color, &color, 0, 0);
 
161
        XDefineCursor(dmxScreen->beDisplay, dmxScreen->scrnWin,
 
162
                      dmxScreen->noCursor);
 
163
 
 
164
        XFreePixmap(dmxScreen->beDisplay, pixmap);
 
165
    }
 
166
 
 
167
    XMapWindow(dmxScreen->beDisplay, dmxScreen->scrnWin);
 
168
 
 
169
    if (dmxShadowFB) {
 
170
        mask = (GCFunction
 
171
                | GCPlaneMask
 
172
                | GCClipMask);
 
173
        gcvals.function = GXcopy;
 
174
        gcvals.plane_mask = AllPlanes;
 
175
        gcvals.clip_mask = None;
 
176
 
 
177
        dmxScreen->shadowGC = XCreateGC(dmxScreen->beDisplay,
 
178
                                        dmxScreen->scrnWin,
 
179
                                        mask, &gcvals);
 
180
 
 
181
        dmxScreen->shadowFBImage =
 
182
            XCreateImage(dmxScreen->beDisplay,
 
183
                         dmxScreen->beVisuals[dmxScreen->beDefVisualIndex].visual,
 
184
                         dmxScreen->beDepth,
 
185
                         ZPixmap,
 
186
                         0,
 
187
                         (char *)dmxScreen->shadow,
 
188
                         dmxScreen->scrnWidth, dmxScreen->scrnHeight,
 
189
                         dmxScreen->beBPP,
 
190
                         PixmapBytePad(dmxScreen->scrnWidth,
 
191
                                       dmxScreen->beBPP));
 
192
    } else {
 
193
        /* Create default drawables (used during GC creation) */
 
194
        for (i = 0; i < dmxScreen->beNumPixmapFormats; i++) 
 
195
            for (j = 0; j < dmxScreen->beNumDepths; j++)
 
196
                if ((dmxScreen->bePixmapFormats[i].depth == 1) ||
 
197
                    (dmxScreen->bePixmapFormats[i].depth ==
 
198
                     dmxScreen->beDepths[j])) {
 
199
                    dmxScreen->scrnDefDrawables[i] = (Drawable)
 
200
                        XCreatePixmap(dmxScreen->beDisplay, dmxScreen->scrnWin,
 
201
                                      1, 1, dmxScreen->bePixmapFormats[i].depth);
 
202
                    break;
 
203
                }
 
204
    }
 
205
}
 
206
 
 
207
/** Initialize screen number \a idx. */
 
208
Bool dmxScreenInit(int idx, ScreenPtr pScreen, int argc, char *argv[])
 
209
{
 
210
    DMXScreenInfo        *dmxScreen = &dmxScreens[idx];
 
211
    int                   i, j;
 
212
 
 
213
    if (dmxGeneration != serverGeneration) {
 
214
#ifdef RENDER
 
215
        /* Allocate picture private index */
 
216
        dmxPictPrivateIndex = AllocatePicturePrivateIndex();
 
217
        if (dmxPictPrivateIndex == -1)
 
218
            return FALSE;
 
219
 
 
220
        /* Allocate glyph set private index */
 
221
        dmxGlyphSetPrivateIndex = AllocateGlyphSetPrivateIndex();
 
222
        if (dmxGlyphSetPrivateIndex == -1)
 
223
            return FALSE;
 
224
#endif
 
225
 
 
226
        /* Allocate GC private index */
 
227
        dmxGCPrivateIndex = AllocateGCPrivateIndex();
 
228
        if (dmxGCPrivateIndex == -1)
 
229
            return FALSE;
 
230
 
 
231
        /* Allocate window private index */
 
232
        dmxWinPrivateIndex = AllocateWindowPrivateIndex();
 
233
        if (dmxWinPrivateIndex == -1)
 
234
            return FALSE;
 
235
 
 
236
#ifdef PIXPRIV
 
237
        /* Allocate pixmap private index */
 
238
        dmxPixPrivateIndex = AllocatePixmapPrivateIndex();
 
239
        if (dmxPixPrivateIndex == -1)
 
240
            return FALSE;
 
241
#else
 
242
#error Must define PIXPRIV to compile DMX X server
 
243
#endif
 
244
 
 
245
        /* Allocate font private index */
 
246
        dmxFontPrivateIndex = AllocateFontPrivateIndex();
 
247
        if (dmxFontPrivateIndex == -1)
 
248
            return FALSE;
 
249
 
 
250
        /* Allocate screen private index */
 
251
        dmxScreenPrivateIndex = AllocateScreenPrivateIndex();
 
252
        if (dmxScreenPrivateIndex == -1)
 
253
            return FALSE;
 
254
 
 
255
        dmxGeneration = serverGeneration;
 
256
    }
 
257
 
 
258
    if (dmxShadowFB) {
 
259
        dmxScreen->shadow = shadowAlloc(dmxScreen->scrnWidth,
 
260
                                        dmxScreen->scrnHeight,
 
261
                                        dmxScreen->beBPP);
 
262
    } else {
 
263
        if (!dmxInitGC(pScreen)) return FALSE;
 
264
        if (!dmxInitWindow(pScreen)) return FALSE;
 
265
        if (!dmxInitPixmap(pScreen)) return FALSE;
 
266
    }
 
267
 
 
268
    /*
 
269
     * Initalise the visual types.  miSetVisualTypesAndMasks() requires
 
270
     * that all of the types for each depth be collected together.  It's
 
271
     * intended for slightly different usage to what we would like here.
 
272
     * Maybe a miAddVisualTypeAndMask() function will be added to make
 
273
     * things easier here.
 
274
     */
 
275
    for (i = 0; i < dmxScreen->beNumDepths; i++) {
 
276
        int    depth;
 
277
        int    visuals        = 0;
 
278
        int    bitsPerRgb     = 0;
 
279
        int    preferredClass = -1;
 
280
        Pixel  redMask        = 0;
 
281
        Pixel  greenMask      = 0;
 
282
        Pixel  blueMask       = 0;
 
283
 
 
284
        depth = dmxScreen->beDepths[i];
 
285
        for (j = 0; j < dmxScreen->beNumVisuals; j++) {
 
286
            XVisualInfo *vi;
 
287
 
 
288
            vi = &dmxScreen->beVisuals[j];
 
289
            if (vi->depth == depth) {
 
290
                /* Assume the masks are all the same. */
 
291
                visuals |= (1 << vi->class);
 
292
                bitsPerRgb = vi->bits_per_rgb;
 
293
                redMask = vi->red_mask;
 
294
                greenMask = vi->green_mask;
 
295
                blueMask = vi->blue_mask;
 
296
                if (j == dmxScreen->beDefVisualIndex) {
 
297
                    preferredClass = vi->class;
 
298
                }
 
299
            }
 
300
        }
 
301
        miSetVisualTypesAndMasks(depth, visuals, bitsPerRgb, preferredClass,
 
302
                                 redMask, greenMask, blueMask);
 
303
    }
 
304
 
 
305
    fbScreenInit(pScreen,
 
306
                 dmxShadowFB ? dmxScreen->shadow : NULL,
 
307
                 dmxScreen->scrnWidth,
 
308
                 dmxScreen->scrnHeight,
 
309
                 dmxScreen->beXDPI,
 
310
                 dmxScreen->beXDPI,
 
311
                 dmxScreen->scrnWidth,
 
312
                 dmxScreen->beBPP);
 
313
#ifdef RENDER
 
314
    (void)dmxPictureInit(pScreen, 0, 0);
 
315
#endif
 
316
 
 
317
    if (dmxShadowFB && !shadowInit(pScreen, dmxShadowUpdateProc, NULL))
 
318
        return FALSE;
 
319
 
 
320
    miInitializeBackingStore(pScreen);
 
321
 
 
322
    if (dmxShadowFB) {
 
323
        miDCInitialize(pScreen, &dmxPointerCursorFuncs);
 
324
    } else {
 
325
        MAXSCREENSALLOC(dmxCursorGeneration);
 
326
        if (dmxCursorGeneration[idx] != serverGeneration) {
 
327
            if (!(miPointerInitialize(pScreen,
 
328
                                      &dmxPointerSpriteFuncs,
 
329
                                      &dmxPointerCursorFuncs,
 
330
                                      FALSE)))
 
331
                return FALSE;
 
332
 
 
333
            dmxCursorGeneration[idx] = serverGeneration;
 
334
        }
 
335
    }
 
336
 
 
337
    DMX_WRAP(CloseScreen, dmxCloseScreen, dmxScreen, pScreen);
 
338
    DMX_WRAP(SaveScreen, dmxSaveScreen, dmxScreen, pScreen);
 
339
 
 
340
    dmxBEScreenInit(idx, pScreen);
 
341
 
 
342
    if (!dmxShadowFB) {
 
343
        /* Wrap GC functions */
 
344
        DMX_WRAP(CreateGC, dmxCreateGC, dmxScreen, pScreen);
 
345
 
 
346
        /* Wrap Window functions */
 
347
        DMX_WRAP(CreateWindow, dmxCreateWindow, dmxScreen, pScreen);
 
348
        DMX_WRAP(DestroyWindow, dmxDestroyWindow, dmxScreen, pScreen);
 
349
        DMX_WRAP(PositionWindow, dmxPositionWindow, dmxScreen, pScreen);
 
350
        DMX_WRAP(ChangeWindowAttributes, dmxChangeWindowAttributes, dmxScreen,
 
351
                 pScreen);
 
352
        DMX_WRAP(RealizeWindow, dmxRealizeWindow, dmxScreen, pScreen);
 
353
        DMX_WRAP(UnrealizeWindow, dmxUnrealizeWindow, dmxScreen, pScreen);
 
354
        DMX_WRAP(RestackWindow, dmxRestackWindow, dmxScreen, pScreen);
 
355
        DMX_WRAP(WindowExposures, dmxWindowExposures, dmxScreen, pScreen);
 
356
        DMX_WRAP(PaintWindowBackground, dmxPaintWindowBackground, dmxScreen,
 
357
                 pScreen);
 
358
        DMX_WRAP(PaintWindowBorder, dmxPaintWindowBorder, dmxScreen, pScreen);
 
359
        DMX_WRAP(CopyWindow, dmxCopyWindow, dmxScreen, pScreen);
 
360
 
 
361
        DMX_WRAP(ResizeWindow, dmxResizeWindow, dmxScreen, pScreen);
 
362
        DMX_WRAP(ReparentWindow, dmxReparentWindow, dmxScreen, pScreen);
 
363
 
 
364
        DMX_WRAP(ChangeBorderWidth, dmxChangeBorderWidth, dmxScreen, pScreen);
 
365
 
 
366
        /* Wrap Image functions */
 
367
        DMX_WRAP(GetImage, dmxGetImage, dmxScreen, pScreen);
 
368
        DMX_WRAP(GetSpans, dmxGetSpans, dmxScreen, pScreen);
 
369
 
 
370
        /* Wrap Pixmap functions */
 
371
        DMX_WRAP(CreatePixmap, dmxCreatePixmap, dmxScreen, pScreen);
 
372
        DMX_WRAP(DestroyPixmap, dmxDestroyPixmap, dmxScreen, pScreen);
 
373
        DMX_WRAP(BitmapToRegion, dmxBitmapToRegion, dmxScreen, pScreen);
 
374
 
 
375
        /* Wrap Font functions */
 
376
        DMX_WRAP(RealizeFont, dmxRealizeFont, dmxScreen, pScreen);
 
377
        DMX_WRAP(UnrealizeFont, dmxUnrealizeFont, dmxScreen, pScreen);
 
378
 
 
379
        /* Wrap Colormap functions */
 
380
        DMX_WRAP(CreateColormap, dmxCreateColormap, dmxScreen, pScreen);
 
381
        DMX_WRAP(DestroyColormap, dmxDestroyColormap, dmxScreen, pScreen);
 
382
        DMX_WRAP(InstallColormap, dmxInstallColormap, dmxScreen, pScreen);
 
383
        DMX_WRAP(StoreColors, dmxStoreColors, dmxScreen, pScreen);
 
384
 
 
385
#ifdef SHAPE
 
386
        /* Wrap Shape functions */
 
387
        DMX_WRAP(SetShape, dmxSetShape, dmxScreen, pScreen);
 
388
#endif
 
389
    }
 
390
 
 
391
    if (!dmxCreateDefColormap(pScreen))
 
392
        return FALSE;
 
393
 
 
394
    return TRUE;
 
395
}
 
396
 
 
397
/** Close the \a pScreen resources on the back-end server. */
 
398
void dmxBECloseScreen(ScreenPtr pScreen)
 
399
{
 
400
    DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
 
401
    int            i;
 
402
 
 
403
    /* Restore the back-end screen-saver and DPMS state. */
 
404
    dmxDPMSTerm(dmxScreen);
 
405
 
 
406
    /* Free the screen resources */
 
407
 
 
408
    XFreeCursor(dmxScreen->beDisplay, dmxScreen->noCursor);
 
409
    dmxScreen->noCursor = (Cursor)0;
 
410
 
 
411
    XUnmapWindow(dmxScreen->beDisplay, dmxScreen->scrnWin);
 
412
    XDestroyWindow(dmxScreen->beDisplay, dmxScreen->scrnWin);
 
413
    dmxScreen->scrnWin = (Window)0;
 
414
 
 
415
    if (dmxShadowFB) {
 
416
        /* Free the shadow GC and image assocated with the back-end server */
 
417
        XFreeGC(dmxScreen->beDisplay, dmxScreen->shadowGC);
 
418
        dmxScreen->shadowGC = NULL;
 
419
        XFree(dmxScreen->shadowFBImage);
 
420
        dmxScreen->shadowFBImage = NULL;
 
421
    } else {
 
422
        /* Free the default drawables */
 
423
        for (i = 0; i < dmxScreen->beNumPixmapFormats; i++) {
 
424
            XFreePixmap(dmxScreen->beDisplay, dmxScreen->scrnDefDrawables[i]);
 
425
            dmxScreen->scrnDefDrawables[i] = (Drawable)0;
 
426
        }
 
427
    }
 
428
 
 
429
    /* Free resources allocated during initialization (in dmxinit.c) */
 
430
    for (i = 0; i < dmxScreen->beNumDefColormaps; i++)
 
431
        XFreeColormap(dmxScreen->beDisplay, dmxScreen->beDefColormaps[i]);
 
432
    xfree(dmxScreen->beDefColormaps);
 
433
    dmxScreen->beDefColormaps = NULL;
 
434
 
 
435
#if 0
 
436
    /* Do not free visuals, depths and pixmap formats here.  Free them
 
437
     * in dmxCloseScreen() instead -- see comment below. */
 
438
    XFree(dmxScreen->beVisuals);
 
439
    dmxScreen->beVisuals = NULL;
 
440
 
 
441
    XFree(dmxScreen->beDepths);
 
442
    dmxScreen->beDepths = NULL;
 
443
 
 
444
    XFree(dmxScreen->bePixmapFormats);
 
445
    dmxScreen->bePixmapFormats = NULL;
 
446
#endif
 
447
 
 
448
#ifdef GLXEXT
 
449
    if (dmxScreen->glxVisuals) {
 
450
        XFree(dmxScreen->glxVisuals);
 
451
        dmxScreen->glxVisuals = NULL;
 
452
        dmxScreen->numGlxVisuals = 0;
 
453
    }
 
454
#endif
 
455
 
 
456
    /* Close display */
 
457
    XCloseDisplay(dmxScreen->beDisplay);
 
458
    dmxScreen->beDisplay = NULL;
 
459
}
 
460
 
 
461
/** Close screen number \a idx. */
 
462
Bool dmxCloseScreen(int idx, ScreenPtr pScreen)
 
463
{
 
464
    DMXScreenInfo *dmxScreen = &dmxScreens[idx];
 
465
 
 
466
    /* Reset the proc vectors */
 
467
    if (idx == 0) {
 
468
#ifdef RENDER
 
469
        dmxResetRender();
 
470
#endif
 
471
        dmxResetFonts();
 
472
    }
 
473
 
 
474
    if (dmxShadowFB) {
 
475
        /* Free the shadow framebuffer */
 
476
        xfree(dmxScreen->shadow);
 
477
    } else {
 
478
 
 
479
#ifdef SHAPE
 
480
        /* Unwrap Shape functions */
 
481
        DMX_UNWRAP(SetShape, dmxScreen, pScreen);
 
482
#endif
 
483
 
 
484
        /* Unwrap the pScreen functions */
 
485
        DMX_UNWRAP(CreateGC, dmxScreen, pScreen);
 
486
 
 
487
        DMX_UNWRAP(CreateWindow, dmxScreen, pScreen);
 
488
        DMX_UNWRAP(DestroyWindow, dmxScreen, pScreen);
 
489
        DMX_UNWRAP(PositionWindow, dmxScreen, pScreen);
 
490
        DMX_UNWRAP(ChangeWindowAttributes, dmxScreen, pScreen);
 
491
        DMX_UNWRAP(RealizeWindow, dmxScreen, pScreen);
 
492
        DMX_UNWRAP(UnrealizeWindow, dmxScreen, pScreen);
 
493
        DMX_UNWRAP(RestackWindow, dmxScreen, pScreen);
 
494
        DMX_UNWRAP(WindowExposures, dmxScreen, pScreen);
 
495
        DMX_UNWRAP(PaintWindowBackground, dmxScreen, pScreen);
 
496
        DMX_UNWRAP(PaintWindowBorder, dmxScreen, pScreen);
 
497
        DMX_UNWRAP(CopyWindow, dmxScreen, pScreen);
 
498
 
 
499
        DMX_UNWRAP(ResizeWindow, dmxScreen, pScreen);
 
500
        DMX_UNWRAP(ReparentWindow, dmxScreen, pScreen);
 
501
 
 
502
        DMX_UNWRAP(ChangeBorderWidth, dmxScreen, pScreen);
 
503
 
 
504
        DMX_UNWRAP(GetImage, dmxScreen, pScreen);
 
505
        DMX_UNWRAP(GetSpans, dmxScreen, pScreen);
 
506
 
 
507
        DMX_UNWRAP(CreatePixmap, dmxScreen, pScreen);
 
508
        DMX_UNWRAP(DestroyPixmap, dmxScreen, pScreen);
 
509
        DMX_UNWRAP(BitmapToRegion, dmxScreen, pScreen);
 
510
 
 
511
        DMX_UNWRAP(RealizeFont, dmxScreen, pScreen);
 
512
        DMX_UNWRAP(UnrealizeFont, dmxScreen, pScreen);
 
513
 
 
514
        DMX_UNWRAP(CreateColormap, dmxScreen, pScreen);
 
515
        DMX_UNWRAP(DestroyColormap, dmxScreen, pScreen);
 
516
        DMX_UNWRAP(InstallColormap, dmxScreen, pScreen);
 
517
        DMX_UNWRAP(StoreColors, dmxScreen, pScreen);
 
518
    }
 
519
 
 
520
    DMX_UNWRAP(SaveScreen, dmxScreen, pScreen);
 
521
 
 
522
    if (dmxScreen->beDisplay) {
 
523
        dmxBECloseScreen(pScreen);
 
524
 
 
525
#if 1
 
526
        /* Free visuals, depths and pixmap formats here so that they
 
527
         * won't be freed when a screen is detached, thereby allowing
 
528
         * the screen to be reattached to be compared to the one
 
529
         * previously removed.
 
530
         */
 
531
        XFree(dmxScreen->beVisuals);
 
532
        dmxScreen->beVisuals = NULL;
 
533
 
 
534
        XFree(dmxScreen->beDepths);
 
535
        dmxScreen->beDepths = NULL;
 
536
 
 
537
        XFree(dmxScreen->bePixmapFormats);
 
538
        dmxScreen->bePixmapFormats = NULL;
 
539
#endif
 
540
    }
 
541
 
 
542
    DMX_UNWRAP(CloseScreen, dmxScreen, pScreen);
 
543
    return pScreen->CloseScreen(idx, pScreen);
 
544
}
 
545
 
 
546
static Bool dmxSaveScreen(ScreenPtr pScreen, int what)
 
547
{
 
548
    DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
 
549
 
 
550
    if (dmxScreen->beDisplay) {
 
551
        switch (what) {
 
552
        case SCREEN_SAVER_OFF:
 
553
        case SCREEN_SAVER_FORCER:
 
554
            XResetScreenSaver(dmxScreen->beDisplay);
 
555
            dmxSync(dmxScreen, FALSE);
 
556
            break;
 
557
        case SCREEN_SAVER_ON:
 
558
        case SCREEN_SAVER_CYCLE:
 
559
            XActivateScreenSaver(dmxScreen->beDisplay);
 
560
            dmxSync(dmxScreen, FALSE);
 
561
            break;
 
562
        }
 
563
    }
 
564
 
 
565
    return TRUE;
 
566
}