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

« back to all changes in this revision

Viewing changes to Xext/shm.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:
120
120
 
121
121
static Bool ShmDestroyPixmap (PixmapPtr pPixmap);
122
122
 
123
 
static DISPATCH_PROC(ProcShmAttach);
124
 
static DISPATCH_PROC(ProcShmCreatePixmap);
125
 
static DISPATCH_PROC(ProcShmDetach);
126
 
static DISPATCH_PROC(ProcShmDispatch);
127
 
static DISPATCH_PROC(ProcShmGetImage);
128
 
static DISPATCH_PROC(ProcShmPutImage);
129
 
static DISPATCH_PROC(ProcShmQueryVersion);
130
 
static DISPATCH_PROC(SProcShmAttach);
131
 
static DISPATCH_PROC(SProcShmCreatePixmap);
132
 
static DISPATCH_PROC(SProcShmDetach);
133
 
static DISPATCH_PROC(SProcShmDispatch);
134
 
static DISPATCH_PROC(SProcShmGetImage);
135
 
static DISPATCH_PROC(SProcShmPutImage);
136
 
static DISPATCH_PROC(SProcShmQueryVersion);
137
123
 
138
124
static unsigned char ShmReqCode;
139
125
int ShmCompletionCode;
254
240
    return TRUE;
255
241
}
256
242
 
257
 
void
258
 
ShmExtensionInit(INITARGS)
259
 
{
260
 
    ExtensionEntry *extEntry;
261
 
    int i;
262
 
 
263
 
#ifdef MUST_CHECK_FOR_SHM_SYSCALL
264
 
    if (!CheckForShmSyscall())
265
 
    {
266
 
        ErrorF("MIT-SHM extension disabled due to lack of kernel support\n");
267
 
        return;
268
 
    }
269
 
#endif
270
 
 
271
 
    if (!ShmRegisterPrivates())
272
 
        return;
273
 
 
274
 
    sharedPixmaps = xFalse;
275
 
    {
276
 
      sharedPixmaps = xTrue;
277
 
      for (i = 0; i < screenInfo.numScreens; i++)
278
 
      {
279
 
        ShmScrPrivateRec *screen_priv = ShmInitScreenPriv(screenInfo.screens[i]);
280
 
        if (!screen_priv->shmFuncs)
281
 
            screen_priv->shmFuncs = &miFuncs;
282
 
        if (!screen_priv->shmFuncs->CreatePixmap)
283
 
            sharedPixmaps = xFalse;
284
 
      }
285
 
      if (sharedPixmaps)
286
 
        for (i = 0; i < screenInfo.numScreens; i++)
287
 
        {
288
 
            ShmScrPrivateRec *screen_priv = ShmGetScreenPriv(screenInfo.screens[i]);
289
 
            screen_priv->destroyPixmap = screenInfo.screens[i]->DestroyPixmap;
290
 
            screenInfo.screens[i]->DestroyPixmap = ShmDestroyPixmap;
291
 
        }
292
 
    }
293
 
    ShmSegType = CreateNewResourceType(ShmDetachSegment, "ShmSeg");
294
 
    if (ShmSegType &&
295
 
        (extEntry = AddExtension(SHMNAME, ShmNumberEvents, ShmNumberErrors,
296
 
                                 ProcShmDispatch, SProcShmDispatch,
297
 
                                 ShmResetProc, StandardMinorOpcode)))
298
 
    {
299
 
        ShmReqCode = (unsigned char)extEntry->base;
300
 
        ShmCompletionCode = extEntry->eventBase;
301
 
        BadShmSegCode = extEntry->errorBase;
302
 
        SetResourceTypeErrorValue(ShmSegType, BadShmSegCode);
303
 
        EventSwapVector[ShmCompletionCode] = (EventSwapPtr) SShmCompletionEvent;
304
 
    }
305
 
}
306
 
 
307
243
/*ARGSUSED*/
308
244
static void
309
245
ShmResetProc(ExtensionEntry *extEntry)
581
517
    }
582
518
}
583
519
 
 
520
static int
 
521
ProcShmPutImage(ClientPtr client)
 
522
{
 
523
    GCPtr pGC;
 
524
    DrawablePtr pDraw;
 
525
    long length;
 
526
    ShmDescPtr shmdesc;
 
527
    REQUEST(xShmPutImageReq);
 
528
 
 
529
    REQUEST_SIZE_MATCH(xShmPutImageReq);
 
530
    VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
 
531
    VERIFY_SHMPTR(stuff->shmseg, stuff->offset, FALSE, shmdesc, client);
 
532
    if ((stuff->sendEvent != xTrue) && (stuff->sendEvent != xFalse))
 
533
        return BadValue;
 
534
    if (stuff->format == XYBitmap)
 
535
    {
 
536
        if (stuff->depth != 1)
 
537
            return BadMatch;
 
538
        length = PixmapBytePad(stuff->totalWidth, 1);
 
539
    }
 
540
    else if (stuff->format == XYPixmap)
 
541
    {
 
542
        if (pDraw->depth != stuff->depth)
 
543
            return BadMatch;
 
544
        length = PixmapBytePad(stuff->totalWidth, 1);
 
545
        length *= stuff->depth;
 
546
    }
 
547
    else if (stuff->format == ZPixmap)
 
548
    {
 
549
        if (pDraw->depth != stuff->depth)
 
550
            return BadMatch;
 
551
        length = PixmapBytePad(stuff->totalWidth, stuff->depth);
 
552
    }
 
553
    else
 
554
    {
 
555
        client->errorValue = stuff->format;
 
556
        return BadValue;
 
557
    }
 
558
 
 
559
    /*
 
560
     * There's a potential integer overflow in this check:
 
561
     * VERIFY_SHMSIZE(shmdesc, stuff->offset, length * stuff->totalHeight,
 
562
     *                client);
 
563
     * the version below ought to avoid it
 
564
     */
 
565
    if (stuff->totalHeight != 0 &&
 
566
        length > (shmdesc->size - stuff->offset)/stuff->totalHeight) {
 
567
        client->errorValue = stuff->totalWidth;
 
568
        return BadValue;
 
569
    }
 
570
    if (stuff->srcX > stuff->totalWidth)
 
571
    {
 
572
        client->errorValue = stuff->srcX;
 
573
        return BadValue;
 
574
    }
 
575
    if (stuff->srcY > stuff->totalHeight)
 
576
    {
 
577
        client->errorValue = stuff->srcY;
 
578
        return BadValue;
 
579
    }
 
580
    if ((stuff->srcX + stuff->srcWidth) > stuff->totalWidth)
 
581
    {
 
582
        client->errorValue = stuff->srcWidth;
 
583
        return BadValue;
 
584
    }
 
585
    if ((stuff->srcY + stuff->srcHeight) > stuff->totalHeight)
 
586
    {
 
587
        client->errorValue = stuff->srcHeight;
 
588
        return BadValue;
 
589
    }
 
590
 
 
591
    if ((((stuff->format == ZPixmap) && (stuff->srcX == 0)) ||
 
592
         ((stuff->format != ZPixmap) &&
 
593
          (stuff->srcX < screenInfo.bitmapScanlinePad) &&
 
594
          ((stuff->format == XYBitmap) ||
 
595
           ((stuff->srcY == 0) &&
 
596
            (stuff->srcHeight == stuff->totalHeight))))) &&
 
597
        ((stuff->srcX + stuff->srcWidth) == stuff->totalWidth))
 
598
        (*pGC->ops->PutImage) (pDraw, pGC, stuff->depth,
 
599
                               stuff->dstX, stuff->dstY,
 
600
                               stuff->totalWidth, stuff->srcHeight,
 
601
                               stuff->srcX, stuff->format,
 
602
                               shmdesc->addr + stuff->offset +
 
603
                               (stuff->srcY * length));
 
604
    else
 
605
        doShmPutImage(pDraw, pGC, stuff->depth, stuff->format,
 
606
                      stuff->totalWidth, stuff->totalHeight,
 
607
                      stuff->srcX, stuff->srcY,
 
608
                      stuff->srcWidth, stuff->srcHeight,
 
609
                      stuff->dstX, stuff->dstY,
 
610
                      shmdesc->addr + stuff->offset);
 
611
 
 
612
    if (stuff->sendEvent)
 
613
    {
 
614
        xShmCompletionEvent ev;
 
615
 
 
616
        ev.type = ShmCompletionCode;
 
617
        ev.drawable = stuff->drawable;
 
618
        ev.minorEvent = X_ShmPutImage;
 
619
        ev.majorEvent = ShmReqCode;
 
620
        ev.shmseg = stuff->shmseg;
 
621
        ev.offset = stuff->offset;
 
622
        WriteEventsToClient(client, 1, (xEvent *) &ev);
 
623
    }
 
624
 
 
625
    return Success;
 
626
}
 
627
 
 
628
static int
 
629
ProcShmGetImage(ClientPtr client)
 
630
{
 
631
    DrawablePtr         pDraw;
 
632
    long                lenPer = 0, length;
 
633
    Mask                plane = 0;
 
634
    xShmGetImageReply   xgi;
 
635
    ShmDescPtr          shmdesc;
 
636
    int                 n, rc;
 
637
 
 
638
    REQUEST(xShmGetImageReq);
 
639
 
 
640
    REQUEST_SIZE_MATCH(xShmGetImageReq);
 
641
    if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap))
 
642
    {
 
643
        client->errorValue = stuff->format;
 
644
        return BadValue;
 
645
    }
 
646
    rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
 
647
                           DixReadAccess);
 
648
    if (rc != Success)
 
649
        return rc;
 
650
    VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client);
 
651
    if (pDraw->type == DRAWABLE_WINDOW)
 
652
    {
 
653
      if( /* check for being viewable */
 
654
         !((WindowPtr) pDraw)->realized ||
 
655
          /* check for being on screen */
 
656
         pDraw->x + stuff->x < 0 ||
 
657
         pDraw->x + stuff->x + (int)stuff->width > pDraw->pScreen->width ||
 
658
         pDraw->y + stuff->y < 0 ||
 
659
         pDraw->y + stuff->y + (int)stuff->height > pDraw->pScreen->height ||
 
660
          /* check for being inside of border */
 
661
         stuff->x < - wBorderWidth((WindowPtr)pDraw) ||
 
662
         stuff->x + (int)stuff->width >
 
663
                wBorderWidth((WindowPtr)pDraw) + (int)pDraw->width ||
 
664
         stuff->y < -wBorderWidth((WindowPtr)pDraw) ||
 
665
         stuff->y + (int)stuff->height >
 
666
                wBorderWidth((WindowPtr)pDraw) + (int)pDraw->height
 
667
        )
 
668
            return BadMatch;
 
669
        xgi.visual = wVisual(((WindowPtr)pDraw));
 
670
    }
 
671
    else
 
672
    {
 
673
        if (stuff->x < 0 ||
 
674
            stuff->x+(int)stuff->width > pDraw->width ||
 
675
            stuff->y < 0 ||
 
676
            stuff->y+(int)stuff->height > pDraw->height
 
677
            )
 
678
            return BadMatch;
 
679
        xgi.visual = None;
 
680
    }
 
681
    xgi.type = X_Reply;
 
682
    xgi.length = 0;
 
683
    xgi.sequenceNumber = client->sequence;
 
684
    xgi.depth = pDraw->depth;
 
685
    if(stuff->format == ZPixmap)
 
686
    {
 
687
        length = PixmapBytePad(stuff->width, pDraw->depth) * stuff->height;
 
688
    }
 
689
    else
 
690
    {
 
691
        lenPer = PixmapBytePad(stuff->width, 1) * stuff->height;
 
692
        plane = ((Mask)1) << (pDraw->depth - 1);
 
693
        /* only planes asked for */
 
694
        length = lenPer * Ones(stuff->planeMask & (plane | (plane - 1)));
 
695
    }
 
696
 
 
697
    VERIFY_SHMSIZE(shmdesc, stuff->offset, length, client);
 
698
    xgi.size = length;
 
699
 
 
700
    if (length == 0)
 
701
    {
 
702
        /* nothing to do */
 
703
    }
 
704
    else if (stuff->format == ZPixmap)
 
705
    {
 
706
        (*pDraw->pScreen->GetImage)(pDraw, stuff->x, stuff->y,
 
707
                                    stuff->width, stuff->height,
 
708
                                    stuff->format, stuff->planeMask,
 
709
                                    shmdesc->addr + stuff->offset);
 
710
    }
 
711
    else
 
712
    {
 
713
 
 
714
        length = stuff->offset;
 
715
        for (; plane; plane >>= 1)
 
716
        {
 
717
            if (stuff->planeMask & plane)
 
718
            {
 
719
                (*pDraw->pScreen->GetImage)(pDraw,
 
720
                                            stuff->x, stuff->y,
 
721
                                            stuff->width, stuff->height,
 
722
                                            stuff->format, plane,
 
723
                                            shmdesc->addr + length);
 
724
                length += lenPer;
 
725
            }
 
726
        }
 
727
    }
 
728
 
 
729
    if (client->swapped) {
 
730
        swaps(&xgi.sequenceNumber, n);
 
731
        swapl(&xgi.length, n);
 
732
        swapl(&xgi.visual, n);
 
733
        swapl(&xgi.size, n);
 
734
    }
 
735
    WriteToClient(client, sizeof(xShmGetImageReply), (char *)&xgi);
 
736
 
 
737
    return Success;
 
738
}
 
739
 
584
740
#ifdef PANORAMIX
585
741
static int 
586
742
ProcPanoramiXShmPutImage(ClientPtr client)
858
1014
 
859
1015
    return result;
860
1016
}
861
 
 
862
1017
#endif
863
1018
 
864
 
static int
865
 
ProcShmPutImage(ClientPtr client)
866
 
{
867
 
    GCPtr pGC;
868
 
    DrawablePtr pDraw;
869
 
    long length;
870
 
    ShmDescPtr shmdesc;
871
 
    REQUEST(xShmPutImageReq);
872
 
 
873
 
    REQUEST_SIZE_MATCH(xShmPutImageReq);
874
 
    VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess);
875
 
    VERIFY_SHMPTR(stuff->shmseg, stuff->offset, FALSE, shmdesc, client);
876
 
    if ((stuff->sendEvent != xTrue) && (stuff->sendEvent != xFalse))
877
 
        return BadValue;
878
 
    if (stuff->format == XYBitmap)
879
 
    {
880
 
        if (stuff->depth != 1)
881
 
            return BadMatch;
882
 
        length = PixmapBytePad(stuff->totalWidth, 1);
883
 
    }
884
 
    else if (stuff->format == XYPixmap)
885
 
    {
886
 
        if (pDraw->depth != stuff->depth)
887
 
            return BadMatch;
888
 
        length = PixmapBytePad(stuff->totalWidth, 1);
889
 
        length *= stuff->depth;
890
 
    }
891
 
    else if (stuff->format == ZPixmap)
892
 
    {
893
 
        if (pDraw->depth != stuff->depth)
894
 
            return BadMatch;
895
 
        length = PixmapBytePad(stuff->totalWidth, stuff->depth);
896
 
    }
897
 
    else
898
 
    {
899
 
        client->errorValue = stuff->format;
900
 
        return BadValue;
901
 
    }
902
 
 
903
 
    /* 
904
 
     * There's a potential integer overflow in this check:
905
 
     * VERIFY_SHMSIZE(shmdesc, stuff->offset, length * stuff->totalHeight,
906
 
     *                client);
907
 
     * the version below ought to avoid it
908
 
     */
909
 
    if (stuff->totalHeight != 0 && 
910
 
        length > (shmdesc->size - stuff->offset)/stuff->totalHeight) {
911
 
        client->errorValue = stuff->totalWidth;
912
 
        return BadValue;
913
 
    }
914
 
    if (stuff->srcX > stuff->totalWidth)
915
 
    {
916
 
        client->errorValue = stuff->srcX;
917
 
        return BadValue;
918
 
    }
919
 
    if (stuff->srcY > stuff->totalHeight)
920
 
    {
921
 
        client->errorValue = stuff->srcY;
922
 
        return BadValue;
923
 
    }
924
 
    if ((stuff->srcX + stuff->srcWidth) > stuff->totalWidth)
925
 
    {
926
 
        client->errorValue = stuff->srcWidth;
927
 
        return BadValue;
928
 
    }
929
 
    if ((stuff->srcY + stuff->srcHeight) > stuff->totalHeight)
930
 
    {
931
 
        client->errorValue = stuff->srcHeight;
932
 
        return BadValue;
933
 
    }
934
 
 
935
 
    if ((((stuff->format == ZPixmap) && (stuff->srcX == 0)) ||
936
 
         ((stuff->format != ZPixmap) &&
937
 
          (stuff->srcX < screenInfo.bitmapScanlinePad) &&
938
 
          ((stuff->format == XYBitmap) ||
939
 
           ((stuff->srcY == 0) &&
940
 
            (stuff->srcHeight == stuff->totalHeight))))) &&
941
 
        ((stuff->srcX + stuff->srcWidth) == stuff->totalWidth))
942
 
        (*pGC->ops->PutImage) (pDraw, pGC, stuff->depth,
943
 
                               stuff->dstX, stuff->dstY,
944
 
                               stuff->totalWidth, stuff->srcHeight, 
945
 
                               stuff->srcX, stuff->format, 
946
 
                               shmdesc->addr + stuff->offset +
947
 
                               (stuff->srcY * length));
948
 
    else
949
 
        doShmPutImage(pDraw, pGC, stuff->depth, stuff->format,
950
 
                      stuff->totalWidth, stuff->totalHeight,
951
 
                      stuff->srcX, stuff->srcY,
952
 
                      stuff->srcWidth, stuff->srcHeight,
953
 
                      stuff->dstX, stuff->dstY,
954
 
                      shmdesc->addr + stuff->offset);
955
 
 
956
 
    if (stuff->sendEvent)
957
 
    {
958
 
        xShmCompletionEvent ev;
959
 
 
960
 
        ev.type = ShmCompletionCode;
961
 
        ev.drawable = stuff->drawable;
962
 
        ev.minorEvent = X_ShmPutImage;
963
 
        ev.majorEvent = ShmReqCode;
964
 
        ev.shmseg = stuff->shmseg;
965
 
        ev.offset = stuff->offset;
966
 
        WriteEventsToClient(client, 1, (xEvent *) &ev);
967
 
    }
968
 
 
969
 
    return Success;
970
 
}
971
 
 
972
 
 
973
 
 
974
 
static int
975
 
ProcShmGetImage(ClientPtr client)
976
 
{
977
 
    DrawablePtr         pDraw;
978
 
    long                lenPer = 0, length;
979
 
    Mask                plane = 0;
980
 
    xShmGetImageReply   xgi;
981
 
    ShmDescPtr          shmdesc;
982
 
    int                 n, rc;
983
 
 
984
 
    REQUEST(xShmGetImageReq);
985
 
 
986
 
    REQUEST_SIZE_MATCH(xShmGetImageReq);
987
 
    if ((stuff->format != XYPixmap) && (stuff->format != ZPixmap))
988
 
    {
989
 
        client->errorValue = stuff->format;
990
 
        return BadValue;
991
 
    }
992
 
    rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0,
993
 
                           DixReadAccess);
994
 
    if (rc != Success)
995
 
        return rc;
996
 
    VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client);
997
 
    if (pDraw->type == DRAWABLE_WINDOW)
998
 
    {
999
 
      if( /* check for being viewable */
1000
 
         !((WindowPtr) pDraw)->realized ||
1001
 
          /* check for being on screen */
1002
 
         pDraw->x + stuff->x < 0 ||
1003
 
         pDraw->x + stuff->x + (int)stuff->width > pDraw->pScreen->width ||
1004
 
         pDraw->y + stuff->y < 0 ||
1005
 
         pDraw->y + stuff->y + (int)stuff->height > pDraw->pScreen->height ||
1006
 
          /* check for being inside of border */
1007
 
         stuff->x < - wBorderWidth((WindowPtr)pDraw) ||
1008
 
         stuff->x + (int)stuff->width >
1009
 
                wBorderWidth((WindowPtr)pDraw) + (int)pDraw->width ||
1010
 
         stuff->y < -wBorderWidth((WindowPtr)pDraw) ||
1011
 
         stuff->y + (int)stuff->height >
1012
 
                wBorderWidth((WindowPtr)pDraw) + (int)pDraw->height
1013
 
        )
1014
 
            return BadMatch;
1015
 
        xgi.visual = wVisual(((WindowPtr)pDraw));
1016
 
    }
1017
 
    else
1018
 
    {
1019
 
        if (stuff->x < 0 ||
1020
 
            stuff->x+(int)stuff->width > pDraw->width ||
1021
 
            stuff->y < 0 ||
1022
 
            stuff->y+(int)stuff->height > pDraw->height
1023
 
            )
1024
 
            return BadMatch;
1025
 
        xgi.visual = None;
1026
 
    }
1027
 
    xgi.type = X_Reply;
1028
 
    xgi.length = 0;
1029
 
    xgi.sequenceNumber = client->sequence;
1030
 
    xgi.depth = pDraw->depth;
1031
 
    if(stuff->format == ZPixmap)
1032
 
    {
1033
 
        length = PixmapBytePad(stuff->width, pDraw->depth) * stuff->height;
1034
 
    }
1035
 
    else 
1036
 
    {
1037
 
        lenPer = PixmapBytePad(stuff->width, 1) * stuff->height;
1038
 
        plane = ((Mask)1) << (pDraw->depth - 1);
1039
 
        /* only planes asked for */
1040
 
        length = lenPer * Ones(stuff->planeMask & (plane | (plane - 1)));
1041
 
    }
1042
 
 
1043
 
    VERIFY_SHMSIZE(shmdesc, stuff->offset, length, client);
1044
 
    xgi.size = length;
1045
 
 
1046
 
    if (length == 0)
1047
 
    {
1048
 
        /* nothing to do */
1049
 
    }
1050
 
    else if (stuff->format == ZPixmap)
1051
 
    {
1052
 
        (*pDraw->pScreen->GetImage)(pDraw, stuff->x, stuff->y,
1053
 
                                    stuff->width, stuff->height,
1054
 
                                    stuff->format, stuff->planeMask,
1055
 
                                    shmdesc->addr + stuff->offset);
1056
 
    }
1057
 
    else
1058
 
    {
1059
 
 
1060
 
        length = stuff->offset;
1061
 
        for (; plane; plane >>= 1)
1062
 
        {
1063
 
            if (stuff->planeMask & plane)
1064
 
            {
1065
 
                (*pDraw->pScreen->GetImage)(pDraw,
1066
 
                                            stuff->x, stuff->y,
1067
 
                                            stuff->width, stuff->height,
1068
 
                                            stuff->format, plane,
1069
 
                                            shmdesc->addr + length);
1070
 
                length += lenPer;
1071
 
            }
1072
 
        }
1073
 
    }
1074
 
    
1075
 
    if (client->swapped) {
1076
 
        swaps(&xgi.sequenceNumber, n);
1077
 
        swapl(&xgi.length, n);
1078
 
        swapl(&xgi.visual, n);
1079
 
        swapl(&xgi.size, n);
1080
 
    }
1081
 
    WriteToClient(client, sizeof(xShmGetImageReply), (char *)&xgi);
1082
 
 
1083
 
    return Success;
1084
 
}
1085
 
 
1086
1019
static PixmapPtr
1087
1020
fbShmCreatePixmap (ScreenPtr pScreen,
1088
1021
                   int width, int height, int depth, char *addr)
1342
1275
        return BadRequest;
1343
1276
    }
1344
1277
}
 
1278
 
 
1279
void
 
1280
ShmExtensionInit(INITARGS)
 
1281
{
 
1282
    ExtensionEntry *extEntry;
 
1283
    int i;
 
1284
 
 
1285
#ifdef MUST_CHECK_FOR_SHM_SYSCALL
 
1286
    if (!CheckForShmSyscall())
 
1287
    {
 
1288
        ErrorF("MIT-SHM extension disabled due to lack of kernel support\n");
 
1289
        return;
 
1290
    }
 
1291
#endif
 
1292
 
 
1293
    if (!ShmRegisterPrivates())
 
1294
        return;
 
1295
 
 
1296
    sharedPixmaps = xFalse;
 
1297
    {
 
1298
      sharedPixmaps = xTrue;
 
1299
      for (i = 0; i < screenInfo.numScreens; i++)
 
1300
      {
 
1301
        ShmScrPrivateRec *screen_priv = ShmInitScreenPriv(screenInfo.screens[i]);
 
1302
        if (!screen_priv->shmFuncs)
 
1303
            screen_priv->shmFuncs = &miFuncs;
 
1304
        if (!screen_priv->shmFuncs->CreatePixmap)
 
1305
            sharedPixmaps = xFalse;
 
1306
      }
 
1307
      if (sharedPixmaps)
 
1308
        for (i = 0; i < screenInfo.numScreens; i++)
 
1309
        {
 
1310
            ShmScrPrivateRec *screen_priv = ShmGetScreenPriv(screenInfo.screens[i]);
 
1311
            screen_priv->destroyPixmap = screenInfo.screens[i]->DestroyPixmap;
 
1312
            screenInfo.screens[i]->DestroyPixmap = ShmDestroyPixmap;
 
1313
        }
 
1314
    }
 
1315
    ShmSegType = CreateNewResourceType(ShmDetachSegment, "ShmSeg");
 
1316
    if (ShmSegType &&
 
1317
        (extEntry = AddExtension(SHMNAME, ShmNumberEvents, ShmNumberErrors,
 
1318
                                 ProcShmDispatch, SProcShmDispatch,
 
1319
                                 ShmResetProc, StandardMinorOpcode)))
 
1320
    {
 
1321
        ShmReqCode = (unsigned char)extEntry->base;
 
1322
        ShmCompletionCode = extEntry->eventBase;
 
1323
        BadShmSegCode = extEntry->errorBase;
 
1324
        SetResourceTypeErrorValue(ShmSegType, BadShmSegCode);
 
1325
        EventSwapVector[ShmCompletionCode] = (EventSwapPtr) SShmCompletionEvent;
 
1326
    }
 
1327
}