compinit.c revision ed6184df
105b261ecSmrg/*
29ace9065Smrg * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
305b261ecSmrg *
46747b715Smrg * Permission is hereby granted, free of charge, to any person obtaining a
56747b715Smrg * copy of this software and associated documentation files (the "Software"),
66747b715Smrg * to deal in the Software without restriction, including without limitation
76747b715Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
86747b715Smrg * and/or sell copies of the Software, and to permit persons to whom the
96747b715Smrg * Software is furnished to do so, subject to the following conditions:
1005b261ecSmrg *
116747b715Smrg * The above copyright notice and this permission notice (including the next
126747b715Smrg * paragraph) shall be included in all copies or substantial portions of the
136747b715Smrg * Software.
146747b715Smrg *
156747b715Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
166747b715Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
176747b715Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
186747b715Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
196747b715Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
206747b715Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
216747b715Smrg * DEALINGS IN THE SOFTWARE.
2205b261ecSmrg *
2305b261ecSmrg * Copyright © 2003 Keith Packard
2405b261ecSmrg *
2505b261ecSmrg * Permission to use, copy, modify, distribute, and sell this software and its
2605b261ecSmrg * documentation for any purpose is hereby granted without fee, provided that
2705b261ecSmrg * the above copyright notice appear in all copies and that both that
2805b261ecSmrg * copyright notice and this permission notice appear in supporting
2905b261ecSmrg * documentation, and that the name of Keith Packard not be used in
3005b261ecSmrg * advertising or publicity pertaining to distribution of the software without
3105b261ecSmrg * specific, written prior permission.  Keith Packard makes no
3205b261ecSmrg * representations about the suitability of this software for any purpose.  It
3305b261ecSmrg * is provided "as is" without express or implied warranty.
3405b261ecSmrg *
3505b261ecSmrg * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
3605b261ecSmrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
3705b261ecSmrg * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
3805b261ecSmrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
3905b261ecSmrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
4005b261ecSmrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
4105b261ecSmrg * PERFORMANCE OF THIS SOFTWARE.
4205b261ecSmrg */
4305b261ecSmrg
4405b261ecSmrg#ifdef HAVE_DIX_CONFIG_H
4505b261ecSmrg#include <dix-config.h>
4605b261ecSmrg#endif
4705b261ecSmrg
4805b261ecSmrg#include "compint.h"
496747b715Smrg#include "compositeext.h"
5005b261ecSmrg
516747b715SmrgDevPrivateKeyRec CompScreenPrivateKeyRec;
526747b715SmrgDevPrivateKeyRec CompWindowPrivateKeyRec;
536747b715SmrgDevPrivateKeyRec CompSubwindowsPrivateKeyRec;
5405b261ecSmrg
5505b261ecSmrgstatic Bool
5635c4bbdfSmrgcompCloseScreen(ScreenPtr pScreen)
5705b261ecSmrg{
5835c4bbdfSmrg    CompScreenPtr cs = GetCompScreen(pScreen);
5935c4bbdfSmrg    Bool ret;
6005b261ecSmrg
616747b715Smrg    free(cs->alternateVisuals);
6205b261ecSmrg
6305b261ecSmrg    pScreen->CloseScreen = cs->CloseScreen;
6405b261ecSmrg    pScreen->InstallColormap = cs->InstallColormap;
654642e01fSmrg    pScreen->ChangeWindowAttributes = cs->ChangeWindowAttributes;
6605b261ecSmrg    pScreen->ReparentWindow = cs->ReparentWindow;
676747b715Smrg    pScreen->ConfigNotify = cs->ConfigNotify;
6805b261ecSmrg    pScreen->MoveWindow = cs->MoveWindow;
6905b261ecSmrg    pScreen->ResizeWindow = cs->ResizeWindow;
7005b261ecSmrg    pScreen->ChangeBorderWidth = cs->ChangeBorderWidth;
7135c4bbdfSmrg
7205b261ecSmrg    pScreen->ClipNotify = cs->ClipNotify;
7305b261ecSmrg    pScreen->UnrealizeWindow = cs->UnrealizeWindow;
7405b261ecSmrg    pScreen->RealizeWindow = cs->RealizeWindow;
7505b261ecSmrg    pScreen->DestroyWindow = cs->DestroyWindow;
7605b261ecSmrg    pScreen->CreateWindow = cs->CreateWindow;
7705b261ecSmrg    pScreen->CopyWindow = cs->CopyWindow;
7805b261ecSmrg    pScreen->PositionWindow = cs->PositionWindow;
799ace9065Smrg    pScreen->SourceValidate = cs->SourceValidate;
809ace9065Smrg
816747b715Smrg    free(cs);
824642e01fSmrg    dixSetPrivate(&pScreen->devPrivates, CompScreenPrivateKey, NULL);
8335c4bbdfSmrg    ret = (*pScreen->CloseScreen) (pScreen);
8405b261ecSmrg
8505b261ecSmrg    return ret;
8605b261ecSmrg}
8705b261ecSmrg
8805b261ecSmrgstatic void
8935c4bbdfSmrgcompInstallColormap(ColormapPtr pColormap)
9005b261ecSmrg{
9135c4bbdfSmrg    VisualPtr pVisual = pColormap->pVisual;
9235c4bbdfSmrg    ScreenPtr pScreen = pColormap->pScreen;
9335c4bbdfSmrg    CompScreenPtr cs = GetCompScreen(pScreen);
9435c4bbdfSmrg    int a;
9505b261ecSmrg
9605b261ecSmrg    for (a = 0; a < cs->numAlternateVisuals; a++)
9735c4bbdfSmrg        if (pVisual->vid == cs->alternateVisuals[a])
9835c4bbdfSmrg            return;
9905b261ecSmrg    pScreen->InstallColormap = cs->InstallColormap;
10005b261ecSmrg    (*pScreen->InstallColormap) (pColormap);
10105b261ecSmrg    cs->InstallColormap = pScreen->InstallColormap;
10205b261ecSmrg    pScreen->InstallColormap = compInstallColormap;
10305b261ecSmrg}
10405b261ecSmrg
10535c4bbdfSmrgstatic void
10635c4bbdfSmrgcompCheckBackingStore(WindowPtr pWin)
10735c4bbdfSmrg{
108ed6184dfSmrg    if (pWin->backingStore != NotUseful) {
10935c4bbdfSmrg        compRedirectWindow(serverClient, pWin, CompositeRedirectAutomatic);
11035c4bbdfSmrg    }
111ed6184dfSmrg    else {
11235c4bbdfSmrg        compUnredirectWindow(serverClient, pWin,
11335c4bbdfSmrg                             CompositeRedirectAutomatic);
11435c4bbdfSmrg    }
11535c4bbdfSmrg}
11635c4bbdfSmrg
1174642e01fSmrg/* Fake backing store via automatic redirection */
1184642e01fSmrgstatic Bool
1194642e01fSmrgcompChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
1204642e01fSmrg{
1214642e01fSmrg    ScreenPtr pScreen = pWin->drawable.pScreen;
12235c4bbdfSmrg    CompScreenPtr cs = GetCompScreen(pScreen);
1234642e01fSmrg    Bool ret;
1244642e01fSmrg
1254642e01fSmrg    pScreen->ChangeWindowAttributes = cs->ChangeWindowAttributes;
1264642e01fSmrg    ret = pScreen->ChangeWindowAttributes(pWin, mask);
1274642e01fSmrg
1284642e01fSmrg    if (ret && (mask & CWBackingStore) &&
12935c4bbdfSmrg        pScreen->backingStoreSupport != NotUseful)
13035c4bbdfSmrg        compCheckBackingStore(pWin);
1314642e01fSmrg
1324642e01fSmrg    pScreen->ChangeWindowAttributes = compChangeWindowAttributes;
1334642e01fSmrg
1344642e01fSmrg    return ret;
1354642e01fSmrg}
1364642e01fSmrg
13735c4bbdfSmrgstatic void
13835c4bbdfSmrgcompSourceValidate(DrawablePtr pDrawable,
13935c4bbdfSmrg                   int x, int y,
14035c4bbdfSmrg                   int width, int height, unsigned int subWindowMode)
14105b261ecSmrg{
1429ace9065Smrg    ScreenPtr pScreen = pDrawable->pScreen;
14335c4bbdfSmrg    CompScreenPtr cs = GetCompScreen(pScreen);
14405b261ecSmrg
1459ace9065Smrg    pScreen->SourceValidate = cs->SourceValidate;
1469ace9065Smrg    if (pDrawable->type == DRAWABLE_WINDOW && subWindowMode == IncludeInferiors)
14735c4bbdfSmrg        compPaintChildrenToWindow((WindowPtr) pDrawable);
148ed6184dfSmrg    (*pScreen->SourceValidate) (pDrawable, x, y, width, height,
149ed6184dfSmrg                                subWindowMode);
1509ace9065Smrg    cs->SourceValidate = pScreen->SourceValidate;
1519ace9065Smrg    pScreen->SourceValidate = compSourceValidate;
15205b261ecSmrg}
15305b261ecSmrg
15405b261ecSmrg/*
15505b261ecSmrg * Add alternate visuals -- always expose an ARGB32 and RGB24 visual
15605b261ecSmrg */
15705b261ecSmrg
15805b261ecSmrgstatic DepthPtr
15935c4bbdfSmrgcompFindVisuallessDepth(ScreenPtr pScreen, int d)
16005b261ecSmrg{
16135c4bbdfSmrg    int i;
16235c4bbdfSmrg
16335c4bbdfSmrg    for (i = 0; i < pScreen->numDepths; i++) {
16435c4bbdfSmrg        DepthPtr depth = &pScreen->allowedDepths[i];
16535c4bbdfSmrg
16635c4bbdfSmrg        if (depth->depth == d) {
16735c4bbdfSmrg            /*
16835c4bbdfSmrg             * Make sure it doesn't have visuals already
16935c4bbdfSmrg             */
17035c4bbdfSmrg            if (depth->numVids)
17135c4bbdfSmrg                return 0;
17235c4bbdfSmrg            /*
17335c4bbdfSmrg             * looks fine
17435c4bbdfSmrg             */
17535c4bbdfSmrg            return depth;
17635c4bbdfSmrg        }
17705b261ecSmrg    }
17805b261ecSmrg    /*
17935c4bbdfSmrg     * If there isn't one, then it's gonna be hard to have
18005b261ecSmrg     * an associated visual
18105b261ecSmrg     */
18205b261ecSmrg    return 0;
18305b261ecSmrg}
18405b261ecSmrg
18505b261ecSmrg/*
18605b261ecSmrg * Add a list of visual IDs to the list of visuals to implicitly redirect.
18705b261ecSmrg */
18805b261ecSmrgstatic Bool
18935c4bbdfSmrgcompRegisterAlternateVisuals(CompScreenPtr cs, VisualID * vids, int nVisuals)
19005b261ecSmrg{
19105b261ecSmrg    VisualID *p;
19205b261ecSmrg
19335c4bbdfSmrg    p = reallocarray(cs->alternateVisuals,
19435c4bbdfSmrg                     cs->numAlternateVisuals + nVisuals, sizeof(VisualID));
19535c4bbdfSmrg    if (p == NULL)
19635c4bbdfSmrg        return FALSE;
19705b261ecSmrg
19805b261ecSmrg    memcpy(&p[cs->numAlternateVisuals], vids, sizeof(VisualID) * nVisuals);
19905b261ecSmrg
20005b261ecSmrg    cs->alternateVisuals = p;
20105b261ecSmrg    cs->numAlternateVisuals += nVisuals;
20205b261ecSmrg
20305b261ecSmrg    return TRUE;
20405b261ecSmrg}
20505b261ecSmrg
20635c4bbdfSmrgBool
20735c4bbdfSmrgCompositeRegisterAlternateVisuals(ScreenPtr pScreen, VisualID * vids,
20835c4bbdfSmrg                                  int nVisuals)
20905b261ecSmrg{
21035c4bbdfSmrg    CompScreenPtr cs = GetCompScreen(pScreen);
21135c4bbdfSmrg
21205b261ecSmrg    return compRegisterAlternateVisuals(cs, vids, nVisuals);
21305b261ecSmrg}
21405b261ecSmrg
21535c4bbdfSmrgBool
21635c4bbdfSmrgCompositeRegisterImplicitRedirectionException(ScreenPtr pScreen,
21735c4bbdfSmrg                                              VisualID parentVisual,
21835c4bbdfSmrg                                              VisualID winVisual)
21935c4bbdfSmrg{
22035c4bbdfSmrg    CompScreenPtr cs = GetCompScreen(pScreen);
22135c4bbdfSmrg    CompImplicitRedirectException *p;
22235c4bbdfSmrg
22335c4bbdfSmrg    p = reallocarray(cs->implicitRedirectExceptions,
22435c4bbdfSmrg                     cs->numImplicitRedirectExceptions + 1, sizeof(p[0]));
22535c4bbdfSmrg    if (p == NULL)
22635c4bbdfSmrg        return FALSE;
22735c4bbdfSmrg
22835c4bbdfSmrg    p[cs->numImplicitRedirectExceptions].parentVisual = parentVisual;
22935c4bbdfSmrg    p[cs->numImplicitRedirectExceptions].winVisual = winVisual;
23035c4bbdfSmrg
23135c4bbdfSmrg    cs->implicitRedirectExceptions = p;
23235c4bbdfSmrg    cs->numImplicitRedirectExceptions++;
23335c4bbdfSmrg
23435c4bbdfSmrg    return TRUE;
23535c4bbdfSmrg}
23635c4bbdfSmrg
23705b261ecSmrgtypedef struct _alternateVisual {
23835c4bbdfSmrg    int depth;
23935c4bbdfSmrg    CARD32 format;
24005b261ecSmrg} CompAlternateVisual;
24105b261ecSmrg
24235c4bbdfSmrgstatic CompAlternateVisual altVisuals[] = {
24305b261ecSmrg#if COMP_INCLUDE_RGB24_VISUAL
24435c4bbdfSmrg    {24, PICT_r8g8b8},
24505b261ecSmrg#endif
24635c4bbdfSmrg    {32, PICT_a8r8g8b8},
24705b261ecSmrg};
24805b261ecSmrg
24905b261ecSmrgstatic Bool
25005b261ecSmrgcompAddAlternateVisual(ScreenPtr pScreen, CompScreenPtr cs,
25135c4bbdfSmrg                       CompAlternateVisual * alt)
25205b261ecSmrg{
25335c4bbdfSmrg    VisualPtr visual;
25435c4bbdfSmrg    DepthPtr depth;
25535c4bbdfSmrg    PictFormatPtr pPictFormat;
25635c4bbdfSmrg    unsigned long alphaMask;
25705b261ecSmrg
25805b261ecSmrg    /*
25905b261ecSmrg     * The ARGB32 visual is always available.  Other alternate depth visuals
26005b261ecSmrg     * are only provided if their depth is less than the root window depth.
26105b261ecSmrg     * There's no deep reason for this.
26205b261ecSmrg     */
26305b261ecSmrg    if (alt->depth >= pScreen->rootDepth && alt->depth != 32)
26435c4bbdfSmrg        return FALSE;
26505b261ecSmrg
26635c4bbdfSmrg    depth = compFindVisuallessDepth(pScreen, alt->depth);
26705b261ecSmrg    if (!depth)
26835c4bbdfSmrg        /* alt->depth doesn't exist or already has alternate visuals. */
26935c4bbdfSmrg        return TRUE;
27005b261ecSmrg
27135c4bbdfSmrg    pPictFormat = PictureMatchFormat(pScreen, alt->depth, alt->format);
27205b261ecSmrg    if (!pPictFormat)
27335c4bbdfSmrg        return FALSE;
27405b261ecSmrg
2756747b715Smrg    if (ResizeVisualArray(pScreen, 1, depth) == FALSE) {
2766747b715Smrg        return FALSE;
27705b261ecSmrg    }
27805b261ecSmrg
27935c4bbdfSmrg    visual = pScreen->visuals + (pScreen->numVisuals - 1);      /* the new one */
28005b261ecSmrg
28105b261ecSmrg    /* Initialize the visual */
28205b261ecSmrg    visual->bitsPerRGBValue = 8;
28305b261ecSmrg    if (PICT_FORMAT_TYPE(alt->format) == PICT_TYPE_COLOR) {
28435c4bbdfSmrg        visual->class = PseudoColor;
28535c4bbdfSmrg        visual->nplanes = PICT_FORMAT_BPP(alt->format);
28635c4bbdfSmrg        visual->ColormapEntries = 1 << visual->nplanes;
28735c4bbdfSmrg    }
28835c4bbdfSmrg    else {
28935c4bbdfSmrg        DirectFormatRec *direct = &pPictFormat->direct;
29035c4bbdfSmrg
29135c4bbdfSmrg        visual->class = TrueColor;
29235c4bbdfSmrg        visual->redMask = ((unsigned long) direct->redMask) << direct->red;
29335c4bbdfSmrg        visual->greenMask =
29435c4bbdfSmrg            ((unsigned long) direct->greenMask) << direct->green;
29535c4bbdfSmrg        visual->blueMask = ((unsigned long) direct->blueMask) << direct->blue;
29635c4bbdfSmrg        alphaMask = ((unsigned long) direct->alphaMask) << direct->alpha;
29735c4bbdfSmrg        visual->offsetRed = direct->red;
29835c4bbdfSmrg        visual->offsetGreen = direct->green;
29935c4bbdfSmrg        visual->offsetBlue = direct->blue;
30035c4bbdfSmrg        /*
30135c4bbdfSmrg         * Include A bits in this (unlike GLX which includes only RGB)
30235c4bbdfSmrg         * This lets DIX compute suitable masks for colormap allocations
30335c4bbdfSmrg         */
30435c4bbdfSmrg        visual->nplanes = Ones(visual->redMask |
30535c4bbdfSmrg                               visual->greenMask |
30635c4bbdfSmrg                               visual->blueMask | alphaMask);
30735c4bbdfSmrg        /* find widest component */
30835c4bbdfSmrg        visual->ColormapEntries = (1 << max(Ones(visual->redMask),
30935c4bbdfSmrg                                            max(Ones(visual->greenMask),
31035c4bbdfSmrg                                                Ones(visual->blueMask))));
31105b261ecSmrg    }
31205b261ecSmrg
31305b261ecSmrg    /* remember the visual ID to detect auto-update windows */
31405b261ecSmrg    compRegisterAlternateVisuals(cs, &visual->vid, 1);
31505b261ecSmrg
31605b261ecSmrg    return TRUE;
31705b261ecSmrg}
31805b261ecSmrg
31905b261ecSmrgstatic Bool
32035c4bbdfSmrgcompAddAlternateVisuals(ScreenPtr pScreen, CompScreenPtr cs)
32105b261ecSmrg{
32205b261ecSmrg    int alt, ret = 0;
32305b261ecSmrg
3241b5d61b8Smrg    for (alt = 0; alt < ARRAY_SIZE(altVisuals); alt++)
32535c4bbdfSmrg        ret |= compAddAlternateVisual(pScreen, cs, altVisuals + alt);
32605b261ecSmrg
32735c4bbdfSmrg    return ! !ret;
32805b261ecSmrg}
32905b261ecSmrg
33005b261ecSmrgBool
33135c4bbdfSmrgcompScreenInit(ScreenPtr pScreen)
33205b261ecSmrg{
33335c4bbdfSmrg    CompScreenPtr cs;
33405b261ecSmrg
3356747b715Smrg    if (!dixRegisterPrivateKey(&CompScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
33635c4bbdfSmrg        return FALSE;
3376747b715Smrg    if (!dixRegisterPrivateKey(&CompWindowPrivateKeyRec, PRIVATE_WINDOW, 0))
33835c4bbdfSmrg        return FALSE;
3396747b715Smrg    if (!dixRegisterPrivateKey(&CompSubwindowsPrivateKeyRec, PRIVATE_WINDOW, 0))
34035c4bbdfSmrg        return FALSE;
3416747b715Smrg
34235c4bbdfSmrg    if (GetCompScreen(pScreen))
34335c4bbdfSmrg        return TRUE;
34435c4bbdfSmrg    cs = (CompScreenPtr) malloc(sizeof(CompScreenRec));
34505b261ecSmrg    if (!cs)
34635c4bbdfSmrg        return FALSE;
34705b261ecSmrg
3484642e01fSmrg    cs->overlayWid = FakeClientID(0);
34905b261ecSmrg    cs->pOverlayWin = NULL;
35005b261ecSmrg    cs->pOverlayClients = NULL;
35105b261ecSmrg
3521b5d61b8Smrg    cs->pendingScreenUpdate = FALSE;
3531b5d61b8Smrg
35405b261ecSmrg    cs->numAlternateVisuals = 0;
35505b261ecSmrg    cs->alternateVisuals = NULL;
35635c4bbdfSmrg    cs->numImplicitRedirectExceptions = 0;
35735c4bbdfSmrg    cs->implicitRedirectExceptions = NULL;
35805b261ecSmrg
35935c4bbdfSmrg    if (!compAddAlternateVisuals(pScreen, cs)) {
36035c4bbdfSmrg        free(cs);
36135c4bbdfSmrg        return FALSE;
36205b261ecSmrg    }
36305b261ecSmrg
36435c4bbdfSmrg    if (!disableBackingStore)
36535c4bbdfSmrg        pScreen->backingStoreSupport = WhenMapped;
36635c4bbdfSmrg
36705b261ecSmrg    cs->PositionWindow = pScreen->PositionWindow;
36805b261ecSmrg    pScreen->PositionWindow = compPositionWindow;
36905b261ecSmrg
37005b261ecSmrg    cs->CopyWindow = pScreen->CopyWindow;
37105b261ecSmrg    pScreen->CopyWindow = compCopyWindow;
37205b261ecSmrg
37305b261ecSmrg    cs->CreateWindow = pScreen->CreateWindow;
37405b261ecSmrg    pScreen->CreateWindow = compCreateWindow;
37505b261ecSmrg
37605b261ecSmrg    cs->DestroyWindow = pScreen->DestroyWindow;
37705b261ecSmrg    pScreen->DestroyWindow = compDestroyWindow;
37805b261ecSmrg
37905b261ecSmrg    cs->RealizeWindow = pScreen->RealizeWindow;
38005b261ecSmrg    pScreen->RealizeWindow = compRealizeWindow;
38105b261ecSmrg
38205b261ecSmrg    cs->UnrealizeWindow = pScreen->UnrealizeWindow;
38305b261ecSmrg    pScreen->UnrealizeWindow = compUnrealizeWindow;
38405b261ecSmrg
38505b261ecSmrg    cs->ClipNotify = pScreen->ClipNotify;
38605b261ecSmrg    pScreen->ClipNotify = compClipNotify;
38705b261ecSmrg
3886747b715Smrg    cs->ConfigNotify = pScreen->ConfigNotify;
3896747b715Smrg    pScreen->ConfigNotify = compConfigNotify;
3906747b715Smrg
39105b261ecSmrg    cs->MoveWindow = pScreen->MoveWindow;
39205b261ecSmrg    pScreen->MoveWindow = compMoveWindow;
39305b261ecSmrg
39405b261ecSmrg    cs->ResizeWindow = pScreen->ResizeWindow;
39505b261ecSmrg    pScreen->ResizeWindow = compResizeWindow;
39605b261ecSmrg
39705b261ecSmrg    cs->ChangeBorderWidth = pScreen->ChangeBorderWidth;
39805b261ecSmrg    pScreen->ChangeBorderWidth = compChangeBorderWidth;
39905b261ecSmrg
40005b261ecSmrg    cs->ReparentWindow = pScreen->ReparentWindow;
40105b261ecSmrg    pScreen->ReparentWindow = compReparentWindow;
40205b261ecSmrg
40305b261ecSmrg    cs->InstallColormap = pScreen->InstallColormap;
40405b261ecSmrg    pScreen->InstallColormap = compInstallColormap;
40505b261ecSmrg
4064642e01fSmrg    cs->ChangeWindowAttributes = pScreen->ChangeWindowAttributes;
4074642e01fSmrg    pScreen->ChangeWindowAttributes = compChangeWindowAttributes;
4084642e01fSmrg
40905b261ecSmrg    cs->CloseScreen = pScreen->CloseScreen;
41005b261ecSmrg    pScreen->CloseScreen = compCloseScreen;
41105b261ecSmrg
4129ace9065Smrg    cs->SourceValidate = pScreen->SourceValidate;
4139ace9065Smrg    pScreen->SourceValidate = compSourceValidate;
4149ace9065Smrg
4154642e01fSmrg    dixSetPrivate(&pScreen->devPrivates, CompScreenPrivateKey, cs);
41605b261ecSmrg
41705b261ecSmrg    RegisterRealChildHeadProc(CompositeRealChildHead);
41805b261ecSmrg
41905b261ecSmrg    return TRUE;
42005b261ecSmrg}
421