Example #1
0
Bool
winScreenInit (int index,
	       ScreenPtr pScreen,
	       int argc, char **argv)
{
  winScreenInfoPtr      pScreenInfo = &g_ScreenInfo[index];
  winPrivScreenPtr	pScreenPriv;
  HDC			hdc;

#if CYGDEBUG || YES
  winDebug ("winScreenInit - dwWidth: %ld dwHeight: %ld\n",
	  pScreenInfo->dwWidth, pScreenInfo->dwHeight);
#endif

  /* Allocate privates for this screen */
  if (!winAllocatePrivates (pScreen))
    {
      ErrorF ("winScreenInit - Couldn't allocate screen privates\n");
      return FALSE;
    }

  /* Get a pointer to the privates structure that was allocated */
  pScreenPriv = winGetScreenPriv (pScreen);

  /* Save a pointer to this screen in the screen info structure */
  pScreenInfo->pScreen = pScreen;

  /* Save a pointer to the screen info in the screen privates structure */
  /* This allows us to get back to the screen info from a screen pointer */
  pScreenPriv->pScreenInfo = pScreenInfo;

  /*
   * Determine which engine to use.
   *
   * NOTE: This is done once per screen because each screen possibly has
   * a preferred engine specified on the command line.
   */
  if (!winSetEngine (pScreen))
    {
      ErrorF ("winScreenInit - winSetEngine () failed\n");
      return FALSE;
    }

  /* Adjust the video mode for our engine type */
  if (!(*pScreenPriv->pwinAdjustVideoMode) (pScreen))
    {
      ErrorF ("winScreenInit - winAdjustVideoMode () failed\n");
      return FALSE;
    }

  /* Check for supported display depth */
  if (!(WIN_SUPPORTED_BPPS & (1 << (pScreenInfo->dwBPP - 1))))
    {
      ErrorF ("winScreenInit - Unsupported display depth: %d\n" \
	      "Change your Windows display depth to 15, 16, 24, or 32 bits "
	      "per pixel.\n",
	      (int) pScreenInfo->dwBPP);
      ErrorF ("winScreenInit - Supported depths: %08x\n",
	      WIN_SUPPORTED_BPPS);
#if WIN_CHECK_DEPTH
      return FALSE;
#endif
    }

  /*
   * Check that all monitors have the same display depth if we are using
   * multiple monitors
   */
  if (pScreenInfo->fMultipleMonitors 
      && !GetSystemMetrics (SM_SAMEDISPLAYFORMAT))
    {
      ErrorF ("winScreenInit - Monitors do not all have same pixel format / "
	      "display depth.\n"
	      "Using primary display only.\n");
      pScreenInfo->fMultipleMonitors = FALSE;
    }

  /* Create display window */
  if (!(*pScreenPriv->pwinCreateBoundingWindow) (pScreen))
    {
      ErrorF ("winScreenInit - pwinCreateBoundingWindow () "
	      "failed\n");
      return FALSE;
    }

  /* Get a device context */
  hdc = GetDC (pScreenPriv->hwndScreen);

  /* Store the initial height, width, and depth of the display */
  /* Are we using multiple monitors? */
  if (pScreenInfo->fMultipleMonitors)
    {
      pScreenPriv->dwLastWindowsWidth = GetSystemMetrics (SM_CXVIRTUALSCREEN);
      pScreenPriv->dwLastWindowsHeight = GetSystemMetrics (SM_CYVIRTUALSCREEN);

      /* 
       * In this case, some of the defaults set in
       * winInitializeScreenDefaults() are not correct ...
       */
      if (!pScreenInfo->fUserGaveHeightAndWidth)
	{
	  pScreenInfo->dwWidth = GetSystemMetrics (SM_CXVIRTUALSCREEN);
	  pScreenInfo->dwHeight = GetSystemMetrics (SM_CYVIRTUALSCREEN);
	  pScreenInfo->dwWidth_mm = (pScreenInfo->dwWidth /
				     WIN_DEFAULT_DPI) * 25.4;
	  pScreenInfo->dwHeight_mm = (pScreenInfo->dwHeight /
				      WIN_DEFAULT_DPI) * 25.4;
	}
    }
  else
    {
      pScreenPriv->dwLastWindowsWidth = GetSystemMetrics (SM_CXSCREEN);
      pScreenPriv->dwLastWindowsHeight = GetSystemMetrics (SM_CYSCREEN);
    }

  /* Save the original bits per pixel */
  pScreenPriv->dwLastWindowsBitsPixel = GetDeviceCaps (hdc, BITSPIXEL);

  /* Release the device context */
  ReleaseDC (pScreenPriv->hwndScreen, hdc);
    
  /* Clear the visuals list */
  miClearVisualTypes ();
  
  /* Set the padded screen width */
  pScreenInfo->dwPaddedWidth = PixmapBytePad (pScreenInfo->dwWidth,
					      pScreenInfo->dwBPP);

  /* Call the engine dependent screen initialization procedure */
  if (!((*pScreenPriv->pwinFinishScreenInit) (index, pScreen, argc, argv)))
    {
      ErrorF ("winScreenInit - winFinishScreenInit () failed\n");
      return FALSE;
    }

  if (!g_fSoftwareCursor)
    winInitCursor(pScreen);
  else
    winErrorFVerb(2, "winScreenInit - Using software cursor\n");  

  /*
     Note the screen origin in a normalized coordinate space where (0,0) is at the top left
     of the native virtual desktop area
  */
  pScreen->x = pScreenInfo->dwInitialX - GetSystemMetrics(SM_XVIRTUALSCREEN);
  pScreen->y = pScreenInfo->dwInitialY - GetSystemMetrics(SM_YVIRTUALSCREEN);

  ErrorF("Screen %d added at virtual desktop coordinate (%d,%d).\n",
         index, pScreen->x, pScreen->y);

#if CYGDEBUG || YES
  winDebug ("winScreenInit - returning\n");
#endif

  return TRUE;
}
Example #2
0
Bool
winScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
{
    winScreenInfoPtr pScreenInfo = &g_ScreenInfo[index];
    winPrivScreenPtr pScreenPriv;
    HDC hdc;
    DWORD dwInitialBPP;

#if CYGDEBUG || YES
    winDebug("winScreenInit - dwWidth: %ld dwHeight: %ld\n",
             pScreenInfo->dwWidth, pScreenInfo->dwHeight);
#endif

    /* Allocate privates for this screen */
    if (!winAllocatePrivates(pScreen)) {
        ErrorF("winScreenInit - Couldn't allocate screen privates\n");
        return FALSE;
    }

    /* Get a pointer to the privates structure that was allocated */
    pScreenPriv = winGetScreenPriv(pScreen);

    /* Save a pointer to this screen in the screen info structure */
    pScreenInfo->pScreen = pScreen;

    /* Save a pointer to the screen info in the screen privates structure */
    /* This allows us to get back to the screen info from a screen pointer */
    pScreenPriv->pScreenInfo = pScreenInfo;

    /*
     * Determine which engine to use.
     *
     * NOTE: This is done once per screen because each screen possibly has
     * a preferred engine specified on the command line.
     */
    if (!winSetEngine(pScreen)) {
        ErrorF("winScreenInit - winSetEngine () failed\n");
        return FALSE;
    }

    /* Horribly misnamed function: Allow engine to adjust BPP for screen */
    dwInitialBPP = pScreenInfo->dwBPP;

    if (!(*pScreenPriv->pwinAdjustVideoMode) (pScreen)) {
        ErrorF("winScreenInit - winAdjustVideoMode () failed\n");
        return FALSE;
    }

    if (dwInitialBPP == WIN_DEFAULT_BPP) {
        /* No -depth parameter was passed, let the user know the depth being used */
        ErrorF
            ("winScreenInit - Using Windows display depth of %d bits per pixel\n",
             (int) pScreenInfo->dwBPP);
    }
    else if (dwInitialBPP != pScreenInfo->dwBPP) {
        /* Warn user if engine forced a depth different to -depth parameter */
        ErrorF
            ("winScreenInit - Command line depth of %d bpp overidden by engine, using %d bpp\n",
             (int) dwInitialBPP, (int) pScreenInfo->dwBPP);
    }
    else {
        ErrorF("winScreenInit - Using command line depth of %d bpp\n",
               (int) pScreenInfo->dwBPP);
    }

    /* Check for supported display depth */
    if (!(WIN_SUPPORTED_BPPS & (1 << (pScreenInfo->dwBPP - 1)))) {
        ErrorF("winScreenInit - Unsupported display depth: %d\n"
               "Change your Windows display depth to 15, 16, 24, or 32 bits "
               "per pixel.\n", (int) pScreenInfo->dwBPP);
        ErrorF("winScreenInit - Supported depths: %08x\n", WIN_SUPPORTED_BPPS);
#if WIN_CHECK_DEPTH
        return FALSE;
#endif
    }

    /*
     * Check that all monitors have the same display depth if we are using
     * multiple monitors
     */
    if (pScreenInfo->fMultipleMonitors
        && !GetSystemMetrics(SM_SAMEDISPLAYFORMAT)) {
        ErrorF("winScreenInit - Monitors do not all have same pixel format / "
               "display depth.\n");
        if (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI) {
            ErrorF
                ("winScreenInit - Performance may suffer off primary display.\n");
        }
        else {
            ErrorF("winScreenInit - Using primary display only.\n");
            pScreenInfo->fMultipleMonitors = FALSE;
        }
    }

    /* Create display window */
    if (!(*pScreenPriv->pwinCreateBoundingWindow) (pScreen)) {
        ErrorF("winScreenInit - pwinCreateBoundingWindow () " "failed\n");
        return FALSE;
    }

    /* Get a device context */
    hdc = GetDC(pScreenPriv->hwndScreen);

    /* Are we using multiple monitors? */
    if (pScreenInfo->fMultipleMonitors) {
        /* 
         * In this case, some of the defaults set in
         * winInitializeScreenDefaults() are not correct ...
         */
        if (!pScreenInfo->fUserGaveHeightAndWidth) {
            pScreenInfo->dwWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
            pScreenInfo->dwHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
        }
    }

    /* Release the device context */
    ReleaseDC(pScreenPriv->hwndScreen, hdc);

    /* Clear the visuals list */
    miClearVisualTypes();

    /* Call the engine dependent screen initialization procedure */
    if (!((*pScreenPriv->pwinFinishScreenInit) (index, pScreen, argc, argv))) {
        ErrorF("winScreenInit - winFinishScreenInit () failed\n");

        /* call the engine dependent screen close procedure to clean up from a failure */
        pScreenPriv->pwinCloseScreen(index, pScreen);

        return FALSE;
    }

    if (!g_fSoftwareCursor)
        winInitCursor(pScreen);
    else
        winErrorFVerb(2, "winScreenInit - Using software cursor\n");

    /*
       Note the screen origin in a normalized coordinate space where (0,0) is at the top left
       of the native virtual desktop area
     */
    pScreen->x = pScreenInfo->dwInitialX - GetSystemMetrics(SM_XVIRTUALSCREEN);
    pScreen->y = pScreenInfo->dwInitialY - GetSystemMetrics(SM_YVIRTUALSCREEN);

    ErrorF("Screen %d added at virtual desktop coordinate (%d,%d).\n",
           index, pScreen->x, pScreen->y);

#if CYGDEBUG || YES
    winDebug("winScreenInit - returning\n");
#endif

    return TRUE;
}