~ubuntu-branches/ubuntu/precise/xorg-server/precise-updates

« back to all changes in this revision

Viewing changes to dix/window.c

Tags: 2:1.10.1-2
* Build xserver-xorg-core-udeb on hurd-i386.  Thanks, Samuel Thibault!
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
137
137
 *    ChangeWindowDeviceCursor
138
138
 ******/
139
139
 
 
140
Bool bgNoneRoot = FALSE;
 
141
 
140
142
static unsigned char _back_lsb[4] = {0x88, 0x22, 0x44, 0x11};
141
143
static unsigned char _back_msb[4] = {0x11, 0x44, 0x22, 0x88};
142
144
 
296
298
#ifdef ROOTLESS
297
299
    pWin->rootlessUnhittable = FALSE;
298
300
#endif
 
301
 
 
302
#ifdef COMPOSITE
 
303
    pWin->damagedDescendants = FALSE;
 
304
#endif
299
305
}
300
306
 
301
307
static void
463
469
    if (party_like_its_1989) {
464
470
        MakeRootTile(pWin);
465
471
        backFlag |= CWBackPixmap;
 
472
    } else if (pScreen->canDoBGNoneRoot && bgNoneRoot) {
 
473
        pWin->backgroundState = XaceBackgroundNoneState(pWin);
 
474
        pWin->background.pixel = pScreen->whitePixel;
 
475
        backFlag |= CWBackPixmap;
466
476
    } else {
467
477
        if (whiteRoot)
468
478
            pWin->background.pixel = pScreen->whitePixel;
950
960
    return Success;
951
961
}
952
962
 
 
963
static void
 
964
SetRootWindowBackground(WindowPtr pWin, ScreenPtr pScreen, Mask *index2)
 
965
{
 
966
    /* following the protocol: "Changing the background of a root window to
 
967
     * None or ParentRelative restores the default background pixmap" */
 
968
    if (bgNoneRoot) {
 
969
        pWin->backgroundState = XaceBackgroundNoneState(pWin);
 
970
        pWin->background.pixel = pScreen->whitePixel;
 
971
    }
 
972
    else if (party_like_its_1989)
 
973
        MakeRootTile(pWin);
 
974
    else {
 
975
        if (whiteRoot)
 
976
            pWin->background.pixel = pScreen->whitePixel;
 
977
        else
 
978
            pWin->background.pixel = pScreen->blackPixel;
 
979
        *index2 = CWBackPixel;
 
980
    }
 
981
}
 
982
 
953
983
/*****
954
984
 *  ChangeWindowAttributes
955
985
 *   
999
1029
                if (pWin->backgroundState == BackgroundPixmap)
1000
1030
                    (*pScreen->DestroyPixmap)(pWin->background.pixmap);
1001
1031
                if (!pWin->parent)
1002
 
                    MakeRootTile(pWin);
 
1032
                    SetRootWindowBackground(pWin, pScreen, &index2);
1003
1033
                else {
1004
1034
                    pWin->backgroundState = XaceBackgroundNoneState(pWin);
1005
1035
                    pWin->background.pixel = pScreen->whitePixel;
1016
1046
                if (pWin->backgroundState == BackgroundPixmap)
1017
1047
                    (*pScreen->DestroyPixmap)(pWin->background.pixmap);
1018
1048
                if (!pWin->parent)
1019
 
                    MakeRootTile(pWin);
 
1049
                    SetRootWindowBackground(pWin, pScreen, &index2);
1020
1050
                else
1021
1051
                    pWin->backgroundState = ParentRelative;
1022
1052
                borderRelative = TRUE;
3087
3117
}
3088
3118
 
3089
3119
#define RANDOM_WIDTH 32
3090
 
 
3091
 
#ifndef NOLOGOHACK
3092
 
static void DrawLogo(
3093
 
    WindowPtr pWin
3094
 
);
3095
 
#endif
3096
 
 
3097
3120
int
3098
3121
dixSaveScreens(ClientPtr client, int on, int mode)
3099
3122
{
3155
3178
                 * for the root window, so miPaintWindow works
3156
3179
                 */
3157
3180
                screenIsSaved = SCREEN_SAVER_OFF;
3158
 
#ifndef NOLOGOHACK
3159
 
                if (logoScreenSaver)
3160
 
                    (*pWin->drawable.pScreen->ClearToBackground)(pWin, 0, 0, 0, 0, FALSE);
3161
 
#endif
3162
3181
                (*pWin->drawable.pScreen->MoveWindow)(pWin,
3163
3182
                           (short)(-(rand() % RANDOM_WIDTH)),
3164
3183
                           (short)(-(rand() % RANDOM_WIDTH)),
3165
3184
                           pWin->nextSib, VTMove);
3166
 
#ifndef NOLOGOHACK
3167
 
                if (logoScreenSaver)
3168
 
                    DrawLogo(pWin);
3169
 
#endif
3170
3185
                screenIsSaved = SCREEN_SAVER_ON;
3171
3186
            }
3172
3187
            /*
3324
3339
        (*pWin->drawable.pScreen->ChangeWindowAttributes)(pWin, CWBackPixmap);
3325
3340
    }
3326
3341
    MapWindow(pWin, serverClient);
3327
 
#ifndef NOLOGOHACK
3328
 
    if (kind == SCREEN_IS_TILED && logoScreenSaver)
3329
 
        DrawLogo(pWin);
3330
 
#endif
3331
3342
    return TRUE;
3332
3343
}
3333
3344
 
3673
3684
    }
3674
3685
    return FALSE;
3675
3686
}
3676
 
 
3677
 
#ifndef NOLOGOHACK
3678
 
static void
3679
 
DrawLogo(WindowPtr pWin)
3680
 
{
3681
 
    DrawablePtr pDraw;
3682
 
    ScreenPtr pScreen;
3683
 
    int x, y;
3684
 
    unsigned int width, height, size;
3685
 
    GC *pGC;
3686
 
    int rc, thin, gap, d31;
3687
 
    DDXPointRec poly[4];
3688
 
    ChangeGCVal fore[2], back[2];
3689
 
    xrgb rgb[2];
3690
 
    BITS32 fmask, bmask;
3691
 
    ColormapPtr cmap;
3692
 
 
3693
 
    pDraw = (DrawablePtr)pWin;
3694
 
    pScreen = pDraw->pScreen;
3695
 
    x = -pWin->origin.x;
3696
 
    y = -pWin->origin.y;
3697
 
    width = pScreen->width;
3698
 
    height = pScreen->height;
3699
 
    pGC = GetScratchGC(pScreen->rootDepth, pScreen);
3700
 
    if (!pGC)
3701
 
        return;
3702
 
 
3703
 
    if ((rand() % 100) <= 17) /* make the probability for white fairly low */
3704
 
        fore[0].val = pScreen->whitePixel;
3705
 
    else
3706
 
        fore[0].val = pScreen->blackPixel;
3707
 
    if (pWin->backgroundState == BackgroundPixel) {
3708
 
        rc = dixLookupResourceByType((pointer *)&cmap, wColormap(pWin),
3709
 
                                     RT_COLORMAP, serverClient, DixReadAccess);
3710
 
        if (rc == Success) {
3711
 
            Pixel querypixels[2];
3712
 
 
3713
 
            querypixels[0] = fore[0].val;
3714
 
            querypixels[1] = pWin->background.pixel;
3715
 
            QueryColors(cmap, 2, querypixels, rgb, serverClient);
3716
 
            if ((rgb[0].red == rgb[1].red) &&
3717
 
                (rgb[0].green == rgb[1].green) &&
3718
 
                (rgb[0].blue == rgb[1].blue)) {
3719
 
                if (fore[0].val == pScreen->blackPixel)
3720
 
                    fore[0].val = pScreen->whitePixel;
3721
 
                else
3722
 
                    fore[0].val = pScreen->blackPixel;
3723
 
            }
3724
 
        }
3725
 
    }
3726
 
    fore[1].val = FillSolid;
3727
 
    fmask = GCForeground|GCFillStyle;
3728
 
    if (pWin->backgroundState == BackgroundPixel) {
3729
 
        back[0].val = pWin->background.pixel;
3730
 
        back[1].val = FillSolid;
3731
 
        bmask = GCForeground|GCFillStyle;
3732
 
    } else {
3733
 
        back[0].val = 0;
3734
 
        back[1].val = 0;
3735
 
        ChangeGC(NullClient, pGC, GCTileStipXOrigin|GCTileStipYOrigin, back);
3736
 
        back[0].val = FillTiled;
3737
 
        back[1].ptr = pWin->background.pixmap;
3738
 
        bmask = GCFillStyle|GCTile;
3739
 
    }
3740
 
 
3741
 
    /* should be the same as the reference function XmuDrawLogo() */
3742
 
 
3743
 
    size = width;
3744
 
    if (height < width)
3745
 
         size = height;
3746
 
    size = RANDOM_WIDTH + rand() % (size - RANDOM_WIDTH);
3747
 
    size &= ~1;
3748
 
    x += rand() % (width - size);
3749
 
    y += rand() % (height - size);
3750
 
 
3751
 
/*
3752
 
 * Draw what will be the thin strokes.
3753
 
 *
3754
 
 *           -----
3755
 
 *          /    /
3756
 
 *         /    /
3757
 
 *        /    /
3758
 
 *       /    /
3759
 
 *      /____/
3760
 
 *           d
3761
 
 *
3762
 
 * Point d is 9/44 (~1/5) of the way across.
3763
 
 */
3764
 
 
3765
 
    thin = (size / 11);
3766
 
    if (thin < 1) thin = 1;
3767
 
    gap = (thin+3) / 4;
3768
 
    d31 = thin + thin + gap;
3769
 
    poly[0].x = x + size;              poly[0].y = y;
3770
 
    poly[1].x = x + size-d31;          poly[1].y = y;
3771
 
    poly[2].x = x + 0;                 poly[2].y = y + size;
3772
 
    poly[3].x = x + d31;               poly[3].y = y + size;
3773
 
    ChangeGC(NullClient, pGC, fmask, fore);
3774
 
    ValidateGC(pDraw, pGC);
3775
 
    (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
3776
 
 
3777
 
/*
3778
 
 * Erase area not needed for lower thin stroke.
3779
 
 *
3780
 
 *           ------
3781
 
 *          /     /
3782
 
 *         /  __ /
3783
 
 *        /  /  /
3784
 
 *       /  /  /
3785
 
 *      /__/__/
3786
 
 */
3787
 
 
3788
 
    poly[0].x = x + d31/2;                       poly[0].y = y + size;
3789
 
    poly[1].x = x + size / 2;                    poly[1].y = y + size/2;
3790
 
    poly[2].x = x + (size/2)+(d31-(d31/2));      poly[2].y = y + size/2;
3791
 
    poly[3].x = x + d31;                         poly[3].y = y + size;
3792
 
    ChangeGC(NullClient, pGC, bmask, back);
3793
 
    ValidateGC(pDraw, pGC);
3794
 
    (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
3795
 
 
3796
 
/*
3797
 
 * Erase area not needed for upper thin stroke.
3798
 
 *
3799
 
 *           ------
3800
 
 *          /  /  /
3801
 
 *         /--/  /
3802
 
 *        /     /
3803
 
 *       /     /
3804
 
 *      /_____/
3805
 
 */
3806
 
 
3807
 
    poly[0].x = x + size - d31/2;                poly[0].y = y;
3808
 
    poly[1].x = x + size / 2;                    poly[1].y = y + size/2;
3809
 
    poly[2].x = x + (size/2)-(d31-(d31/2));      poly[2].y = y + size/2;
3810
 
    poly[3].x = x + size - d31;                  poly[3].y = y;
3811
 
    ValidateGC(pDraw, pGC);
3812
 
    (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
3813
 
 
3814
 
/*
3815
 
 * Draw thick stroke.
3816
 
 * Point b is 1/4 of the way across.
3817
 
 *
3818
 
 *      b
3819
 
 * -----
3820
 
 * \    \
3821
 
 *  \    \
3822
 
 *   \    \
3823
 
 *    \    \
3824
 
 *     \____\
3825
 
 */
3826
 
 
3827
 
    poly[0].x = x;                     poly[0].y = y;
3828
 
    poly[1].x = x + size/4;            poly[1].y = y;
3829
 
    poly[2].x = x + size;              poly[2].y = y + size;
3830
 
    poly[3].x = x + size - size/4;     poly[3].y = y + size;
3831
 
    ChangeGC(NullClient, pGC, fmask, fore);
3832
 
    ValidateGC(pDraw, pGC);
3833
 
    (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
3834
 
 
3835
 
/*
3836
 
 * Erase to create gap.
3837
 
 *
3838
 
 *          /
3839
 
 *         /
3840
 
 *        /
3841
 
 *       /
3842
 
 *      /
3843
 
 */
3844
 
 
3845
 
    poly[0].x = x + size- thin;       poly[0].y = y;
3846
 
    poly[1].x = x + size-( thin+gap);  poly[1].y = y;
3847
 
    poly[2].x = x + thin;             poly[2].y = y + size;
3848
 
    poly[3].x = x + thin + gap;       poly[3].y = y + size;
3849
 
    ChangeGC(NullClient, pGC, bmask, back);
3850
 
    ValidateGC(pDraw, pGC);
3851
 
    (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
3852
 
 
3853
 
    FreeScratchGC(pGC);
3854
 
}
3855
 
 
3856
 
#endif