Exemplo n.º 1
0
/*
 * xprAddPseudoramiXScreens
 *  Add a single virtual screen encompassing all the physical screens
 *  with PseudoramiX.
 */
static void
xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height, ScreenPtr pScreen)
{
    CGDisplayCount i, displayCount;
    CGDirectDisplayID *displayList = NULL;
    CGRect unionRect = CGRectNull, frame;

    // Find all the CoreGraphics displays
    CGGetActiveDisplayList(0, NULL, &displayCount);
    DEBUG_LOG("displayCount: %d\n", (int)displayCount);

    if(!displayCount) {
        ErrorF("CoreGraphics has reported no connected displays.  Creating a stub 800x600 display.\n");
        *x = *y = 0;
        *width = 800;
        *height = 600;
        PseudoramiXAddScreen(*x, *y, *width, *height);
        return;
    }

    displayList = malloc(displayCount * sizeof(CGDirectDisplayID));
    if(!displayList)
        FatalError("Unable to allocate memory for list of displays.\n");
    CGGetActiveDisplayList(displayCount, displayList, &displayCount);
    QuartzCopyDisplayIDs(pScreen, displayCount, displayList);

    /* Get the union of all screens */
    for (i = 0; i < displayCount; i++) {
        CGDirectDisplayID dpy = displayList[i];
        frame = displayScreenBounds(dpy);
        unionRect = CGRectUnion(unionRect, frame);
    }

    /* Use unionRect as the screen size for the X server. */
    *x = unionRect.origin.x;
    *y = unionRect.origin.y;
    *width = unionRect.size.width;
    *height = unionRect.size.height;

    DEBUG_LOG("  screen union origin: (%d,%d) size: (%d,%d).\n",
              *x, *y, *width, *height);

    /* Tell PseudoramiX about the real screens. */
    for (i = 0; i < displayCount; i++)
    {
        CGDirectDisplayID dpy = displayList[i];

        frame = displayScreenBounds(dpy);
        frame.origin.x -= unionRect.origin.x;
        frame.origin.y -= unionRect.origin.y;

        DEBUG_LOG("    placed at X11 coordinate (%d,%d).\n",
                  (int)frame.origin.x, (int)frame.origin.y);

        PseudoramiXAddScreen(frame.origin.x, frame.origin.y,
                             frame.size.width, frame.size.height);
    }

    free(displayList);
}
Exemplo n.º 2
0
/*
 * xprAddPseudoramiXScreens
 *  Add a single virtual screen encompassing all the physical screens
 *  with PseudoramiX.
 */
static void
xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height)
{
    CGDisplayCount i, displayCount;
    CGDirectDisplayID *displayList = NULL;
    CGRect unionRect = CGRectNull, frame;

    // Find all the CoreGraphics displays
    CGGetActiveDisplayList(0, NULL, &displayCount);
    displayList = xalloc(displayCount * sizeof(CGDirectDisplayID));
    CGGetActiveDisplayList(displayCount, displayList, &displayCount);

    /* Get the union of all screens */
    for (i = 0; i < displayCount; i++)
    {
        CGDirectDisplayID dpy = displayList[i];
        frame = displayScreenBounds(dpy);
        unionRect = CGRectUnion(unionRect, frame);
    }

    /* Use unionRect as the screen size for the X server. */
    *x = unionRect.origin.x;
    *y = unionRect.origin.y;
    *width = unionRect.size.width;
    *height = unionRect.size.height;

    /* Tell PseudoramiX about the real screens. */
    for (i = 0; i < displayCount; i++)
    {
        CGDirectDisplayID dpy = displayList[i];

        frame = displayScreenBounds(dpy);

        ErrorF("PseudoramiX screen %d added: %dx%d @ (%d,%d).\n", i,
               (int)frame.size.width, (int)frame.size.height,
               (int)frame.origin.x, (int)frame.origin.y);

        frame.origin.x -= unionRect.origin.x;
        frame.origin.y -= unionRect.origin.y;

        ErrorF("PseudoramiX screen %d placed at X11 coordinate (%d,%d).\n",
               i, (int)frame.origin.x, (int)frame.origin.y);

        PseudoramiXAddScreen(frame.origin.x, frame.origin.y,
                             frame.size.width, frame.size.height);
    }

    xfree(displayList);
}
/*
 * xprAddScreen
 *  Init the framebuffer and record pixmap parameters for the screen.
 */
static Bool
xprAddScreen(int index, ScreenPtr pScreen)
{
    DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
    int depth = darwinDesiredDepth;

    DEBUG_LOG("index=%d depth=%d\n", index, depth);
    
    if(depth == -1) {
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
        depth = CGDisplaySamplesPerPixel(kCGDirectMainDisplay) * CGDisplayBitsPerSample(kCGDirectMainDisplay);
#else
        CGDisplayModeRef modeRef;
        CFStringRef encStrRef;
        
        modeRef = CGDisplayCopyDisplayMode(kCGDirectMainDisplay);
        if(!modeRef)
            goto have_depth;

        encStrRef = CGDisplayModeCopyPixelEncoding(modeRef);
        CFRelease(modeRef);
        if(!encStrRef)
            goto have_depth;
        
        if(CFStringCompare(encStrRef, CFSTR(IO32BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
            depth = 24;
        } else if(CFStringCompare(encStrRef, CFSTR(IO16BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
            depth = 15;
        } else if(CFStringCompare(encStrRef, CFSTR(IO8BitIndexedPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
            depth = 8;
        }

        CFRelease(encStrRef);
#endif
    }
    
have_depth:
    switch(depth) {
        case 8: // pseudo-working
            dfb->visuals = PseudoColorMask;
            dfb->preferredCVC = PseudoColor;
            dfb->depth = 8;
            dfb->bitsPerRGB = 8;
            dfb->bitsPerPixel = 8;
            dfb->redMask = 0;
            dfb->greenMask = 0;
            dfb->blueMask = 0;
            break;
        case 15:
            dfb->visuals = TrueColorMask; //LARGE_VISUALS;
            dfb->preferredCVC = TrueColor;
            dfb->depth = 15;
            dfb->bitsPerRGB = 5;
            dfb->bitsPerPixel = 16;
            dfb->redMask   = RM_ARGB(0,5,5,5);
            dfb->greenMask = GM_ARGB(0,5,5,5);
            dfb->blueMask  = BM_ARGB(0,5,5,5);
            break;
//        case 24:
        default:
            if(depth != 24)
                ErrorF("Unsupported color depth requested.  Defaulting to 24bit. (depth=%d darwinDesiredDepth=%d)\n", depth, darwinDesiredDepth);
            dfb->visuals = TrueColorMask; //LARGE_VISUALS;
            dfb->preferredCVC = TrueColor;
            dfb->depth = 24;
            dfb->bitsPerRGB = 8;
            dfb->bitsPerPixel = 32;
            dfb->redMask   = RM_ARGB(0,8,8,8);
            dfb->greenMask = GM_ARGB(0,8,8,8);
            dfb->blueMask  = BM_ARGB(0,8,8,8);
            break;
    }

    if (noPseudoramiXExtension)
    {
        CGDirectDisplayID dpy;
        CGRect frame;

        ErrorF("Warning: noPseudoramiXExtension!\n");
        
        dpy = displayAtIndex(index);
        QuartzCopyDisplayIDs(pScreen, 1, &dpy);

        frame = displayScreenBounds(dpy);

        dfb->x = frame.origin.x;
        dfb->y = frame.origin.y;
        dfb->width =  frame.size.width;
        dfb->height = frame.size.height;
    }
    else
    {
        xprAddPseudoramiXScreens(&dfb->x, &dfb->y, &dfb->width, &dfb->height, pScreen);
    }

    /* Passing zero width (pitch) makes miCreateScreenResources set the
       screen pixmap to the framebuffer pointer, i.e. NULL. The generic
       rootless code takes care of making this work. */
    dfb->pitch = 0;
    dfb->framebuffer = NULL;

    DRIScreenInit(pScreen);

    return TRUE;
}
Exemplo n.º 4
0
/*
 * xprAddScreen
 *  Init the framebuffer and record pixmap parameters for the screen.
 */
static Bool
xprAddScreen(int index, ScreenPtr pScreen)
{
    DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);
    int depth = darwinDesiredDepth;

    DEBUG_LOG("index=%d depth=%d\n", index, depth);

    if(depth == -1) {
        depth = CGDisplaySamplesPerPixel(kCGDirectMainDisplay) * CGDisplayBitsPerSample(kCGDirectMainDisplay);
    }

    switch(depth) {
    case 8: // pseudo-working
        dfb->visuals = PseudoColorMask;
        dfb->preferredCVC = PseudoColor;
        dfb->depth = 8;
        dfb->bitsPerRGB = 8;
        dfb->bitsPerPixel = 8;
        dfb->redMask = 0;
        dfb->greenMask = 0;
        dfb->blueMask = 0;
        break;
    case 15:
        dfb->visuals = TrueColorMask; //LARGE_VISUALS;
        dfb->preferredCVC = TrueColor;
        dfb->depth = 15;
        dfb->bitsPerRGB = 5;
        dfb->bitsPerPixel = 16;
        dfb->redMask   = RM_ARGB(0,5,5,5);
        dfb->greenMask = GM_ARGB(0,5,5,5);
        dfb->blueMask  = BM_ARGB(0,5,5,5);
        break;
//        case 24:
    default:
        if(depth != 24)
            ErrorF("Unsupported color depth requested.  Defaulting to 24bit. (depth=%d darwinDesiredDepth=%d CGDisplaySamplesPerPixel=%d CGDisplayBitsPerSample=%d)\n",  darwinDesiredDepth, depth, (int)CGDisplaySamplesPerPixel(kCGDirectMainDisplay), (int)CGDisplayBitsPerSample(kCGDirectMainDisplay));
        dfb->visuals = TrueColorMask; //LARGE_VISUALS;
        dfb->preferredCVC = TrueColor;
        dfb->depth = 24;
        dfb->bitsPerRGB = 8;
        dfb->bitsPerPixel = 32;
        dfb->redMask   = RM_ARGB(0,8,8,8);
        dfb->greenMask = GM_ARGB(0,8,8,8);
        dfb->blueMask  = BM_ARGB(0,8,8,8);
        break;
    }

    if (noPseudoramiXExtension)
    {
        CGDirectDisplayID dpy;
        CGRect frame;

        ErrorF("Warning: noPseudoramiXExtension!\n");

        dpy = displayAtIndex(index);
        QuartzCopyDisplayIDs(pScreen, 1, &dpy);

        frame = displayScreenBounds(dpy);

        dfb->x = frame.origin.x;
        dfb->y = frame.origin.y;
        dfb->width =  frame.size.width;
        dfb->height = frame.size.height;
    }
    else
    {
        xprAddPseudoramiXScreens(&dfb->x, &dfb->y, &dfb->width, &dfb->height, pScreen);
    }

    /* Passing zero width (pitch) makes miCreateScreenResources set the
       screen pixmap to the framebuffer pointer, i.e. NULL. The generic
       rootless code takes care of making this work. */
    dfb->pitch = 0;
    dfb->framebuffer = NULL;

    DRIScreenInit(pScreen);

    return TRUE;
}
Exemplo n.º 5
0
/*
 * xprAddScreen
 *  Init the framebuffer and record pixmap parameters for the screen.
 */
static Bool
xprAddScreen(int index, ScreenPtr pScreen)
{
    DarwinFramebufferPtr dfb = SCREEN_PRIV(pScreen);

    /* If no specific depth chosen, look for the depth of the main display.
       Else if 16bpp specified, use that. Else use 32bpp. */

    dfb->colorType = TrueColor;
    dfb->bitsPerComponent = 8;
    dfb->bitsPerPixel = 32;
    dfb->colorBitsPerPixel = 24;

    if (darwinDesiredDepth == -1)
    {
        dfb->bitsPerComponent = CGDisplayBitsPerSample(kCGDirectMainDisplay);
        dfb->bitsPerPixel = CGDisplayBitsPerPixel(kCGDirectMainDisplay);
        dfb->colorBitsPerPixel =
                CGDisplaySamplesPerPixel(kCGDirectMainDisplay) *
                dfb->bitsPerComponent;
    }
    else if (darwinDesiredDepth == 15)
    {
        dfb->bitsPerComponent = 5;
        dfb->bitsPerPixel = 16;
        dfb->colorBitsPerPixel = 15;
    }
    else if (darwinDesiredDepth == 8)
    {
        dfb->colorType = PseudoColor;
        dfb->bitsPerComponent = 8;
        dfb->bitsPerPixel = 8;
        dfb->colorBitsPerPixel = 8;
    }

    if (noPseudoramiXExtension)
    {
        CGDirectDisplayID dpy;
        CGRect frame;

        dpy = displayAtIndex(index);

        frame = displayScreenBounds(dpy);

        dfb->x = frame.origin.x;
        dfb->y = frame.origin.y;
        dfb->width =  frame.size.width;
        dfb->height = frame.size.height;
    }
    else
    {
        xprAddPseudoramiXScreens(&dfb->x, &dfb->y, &dfb->width, &dfb->height);
    }

    /* Passing zero width (pitch) makes miCreateScreenResources set the
       screen pixmap to the framebuffer pointer, i.e. NULL. The generic
       rootless code takes care of making this work. */
    dfb->pitch = 0;
    dfb->framebuffer = NULL;

    DRIScreenInit(pScreen);

    return TRUE;
}