Beispiel #1
0
static Bool
winStoreColorsShadowDDNL(ColormapPtr pColormap, int ndef, xColorItem * pdefs)
{
    ScreenPtr pScreen = pColormap->pScreen;

    winScreenPriv(pScreen);
    winCmapPriv(pColormap);
    ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
    HRESULT ddrval = DD_OK;

    /* Put the X colormap entries into the Windows logical palette */
    ddrval = IDirectDrawPalette_SetEntries(pCmapPriv->lpDDPalette,
                                           0,
                                           pdefs[0].pixel,
                                           ndef,
                                           pCmapPriv->peColors
                                           + pdefs[0].pixel);
    if (FAILED(ddrval)) {
        ErrorF("winStoreColorsShadowDDNL - SetEntries () failed: %08x\n",
               (unsigned int) ddrval);
        return FALSE;
    }

    /* Don't install the DirectDraw palette if the colormap is not installed */
    if (pColormap != curpmap) {
        return TRUE;
    }

    if (!winInstallColormapShadowDDNL(pColormap)) {
        ErrorF("winStoreColorsShadowDDNL - Failed installing colormap\n");
        return FALSE;
    }

    return TRUE;
}
Beispiel #2
0
static Bool
winInstallColormapShadowGDI (ColormapPtr pColormap)
{
  ScreenPtr		pScreen = pColormap->pScreen;
  winScreenPriv(pScreen);
  winScreenInfo		*pScreenInfo = pScreenPriv->pScreenInfo;
  winCmapPriv(pColormap);

  /*
   * Tell Windows to install the new colormap
   */
  if (SelectPalette (pScreenPriv->hdcScreen,
		     pCmapPriv->hPalette,
		     FALSE) == NULL)
    {
      ErrorF ("winInstallColormapShadowGDI - SelectPalette () failed\n");
      return FALSE;
    }
      
  /* Realize the palette */
  if (GDI_ERROR == RealizePalette (pScreenPriv->hdcScreen))
    {
      ErrorF ("winInstallColormapShadowGDI - RealizePalette () failed\n");
      return FALSE;
    }

  /* Set the DIB color table */
  if (SetDIBColorTable (pScreenPriv->hdcShadow,
			0,
			WIN_NUM_PALETTE_ENTRIES,
			pCmapPriv->rgbColors) == 0)
    {
      ErrorF ("winInstallColormapShadowGDI - SetDIBColorTable () failed\n");
      return FALSE;
    }

  /* Redraw the whole window, to take account for the new colors */
  BitBlt (pScreenPriv->hdcScreen,
	  0, 0,
	  pScreenInfo->dwWidth, pScreenInfo->dwHeight,
	  pScreenPriv->hdcShadow,
	  0, 0,
	  SRCCOPY);

  /* Save a pointer to the newly installed colormap */
  pScreenPriv->pcmapInstalled = pColormap;

#ifdef XWIN_MULTIWINDOW
  /* Redraw all windows */
  if (pScreenInfo->fMultiWindow)
    EnumThreadWindows (g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0);
#endif

  return TRUE;
}
Beispiel #3
0
static Bool
winStoreColorsShadowGDI (ColormapPtr pColormap,
			 int ndef,
			 xColorItem *pdefs)
{
  ScreenPtr		pScreen = pColormap->pScreen;
  winScreenPriv(pScreen);
  winCmapPriv(pColormap);
  ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
  
  /* Put the X colormap entries into the Windows logical palette */
  if (SetPaletteEntries (pCmapPriv->hPalette,
			 pdefs[0].pixel,
			 ndef,
			 pCmapPriv->peColors + pdefs[0].pixel) == 0)
    {
      ErrorF ("winStoreColorsShadowGDI - SetPaletteEntries () failed\n");
      return FALSE;
    }

  /* Don't install the Windows palette if the colormap is not installed */
  if (pColormap != curpmap)
    {
      return TRUE;
    }

  /* Try to install the newly modified colormap */
  if (!winInstallColormapShadowGDI (pColormap))
    {
      ErrorF ("winInstallColormapShadowGDI - winInstallColormapShadowGDI "
	      "failed\n");
      return FALSE;
    }

#if 0
  /* Tell Windows that the palette has changed */
  RealizePalette (pScreenPriv->hdcScreen);
  
  /* Set the DIB color table */
  if (SetDIBColorTable (pScreenPriv->hdcShadow,
			pdefs[0].pixel,
			ndef,
			pCmapPriv->rgbColors + pdefs[0].pixel) == 0)
    {
      ErrorF ("winInstallColormapShadowGDI - SetDIBColorTable () failed\n");
      return FALSE;
    }

  /* Save a pointer to the newly installed colormap */
  pScreenPriv->pcmapInstalled = pColormap;
#endif

  return TRUE;
}
Beispiel #4
0
Bool
qtCreateColormapShadow (ColormapPtr pColormap)
{
#if 0	/* ### NOT YET */
	LPLOGPALETTE		lpPaletteNew = NULL;
	DWORD			dwEntriesMax;
	VisualPtr		pVisual;
	HPALETTE		hpalNew = NULL;
	winCmapPriv(pColormap);

	/* Get a pointer to the visual that the colormap belongs to */
	pVisual = pColormap->pVisual;

	/* Get the maximum number of palette entries for this visual */
	dwEntriesMax = pVisual->ColormapEntries;

	/* Allocate a Windows logical color palette with max entries */
	lpPaletteNew = malloc (sizeof (LOGPALETTE)
			       + (dwEntriesMax - 1) * sizeof (PALETTEENTRY));
	if (lpPaletteNew == NULL)
	{
		ErrorF ("qtCreateColormapShadow - Couldn't allocate palette "
			"with %d entries\n",
			dwEntriesMax);
		return FALSE;
	}

	/* Zero out the colormap */
	ZeroMemory (lpPaletteNew, sizeof (LOGPALETTE)
		    + (dwEntriesMax - 1) * sizeof (PALETTEENTRY));
  
	/* Set the logical palette structure */
	lpPaletteNew->palVersion = 0x0300;
	lpPaletteNew->palNumEntries = dwEntriesMax;

	/* Tell Windows to create the palette */
	hpalNew = CreatePalette (lpPaletteNew);
	if (hpalNew == NULL)
	{
		ErrorF ("qtCreateColormapShadow - CreatePalette () failed\n");
		free (lpPaletteNew);
		return FALSE;
	}

	/* Save the Windows logical palette handle in the X colormaps' privates */
	pCmapPriv->hPalette = hpalNew;

	/* Free the palette initialization memory */
	free (lpPaletteNew);

#endif
	return TRUE;
}
Beispiel #5
0
static Bool
winDestroyColormapShadowDD (ColormapPtr pColormap)
{
  winScreenPriv(pColormap->pScreen);
  winCmapPriv(pColormap);
  HRESULT		ddrval = DD_OK;

  /*
   * Is colormap to be destroyed the default?
   *
   * Non-default colormaps should have had winUninstallColormap
   * called on them before we get here.  The default colormap
   * will not have had winUninstallColormap called on it.  Thus,
   * we need to handle the default colormap in a special way.
   */
  if (pColormap->flags & IsDefault)
    {
#if CYGDEBUG
      winDebug ("winDestroyColormapShadowDD - Destroying default "
	      "colormap\n");
#endif
      
      /*
       * FIXME: Walk the list of all screens, popping the default
       * palette out of each screen device context.
       */
      
      /* Pop the palette out of the primary surface */
      ddrval = IDirectDrawSurface2_SetPalette (pScreenPriv->pddsPrimary,
					       NULL);
      if (FAILED (ddrval))
	{
	  ErrorF ("winDestroyColormapShadowDD - Failed freeing the "
		  "default colormap DirectDraw palette.\n");
	  return FALSE;
	}

      /* Clear our private installed colormap pointer */
      pScreenPriv->pcmapInstalled = NULL;
    }
  
  /* Release the palette */
  IDirectDrawPalette_Release (pCmapPriv->lpDDPalette);
 
  /* Invalidate the colormap privates */
  pCmapPriv->lpDDPalette = NULL;

  return TRUE;
}
Beispiel #6
0
static Bool
winDestroyColormapShadowGDI (ColormapPtr pColormap)
{
  winScreenPriv(pColormap->pScreen);
  winCmapPriv(pColormap);

  /*
   * Is colormap to be destroyed the default?
   *
   * Non-default colormaps should have had winUninstallColormap
   * called on them before we get here.  The default colormap
   * will not have had winUninstallColormap called on it.  Thus,
   * we need to handle the default colormap in a special way.
   */
  if (pColormap->flags & IsDefault)
    {
#if CYGDEBUG
      winDebug ("winDestroyColormapShadowGDI - Destroying default "
	      "colormap\n");
#endif
      
      /*
       * FIXME: Walk the list of all screens, popping the default
       * palette out of each screen device context.
       */
      
      /* Pop the palette out of the device context */
      SelectPalette (pScreenPriv->hdcScreen,
		     GetStockObject (DEFAULT_PALETTE),
		     FALSE);

      /* Clear our private installed colormap pointer */
      pScreenPriv->pcmapInstalled = NULL;
    }
  
  /* Try to delete the logical palette */
  if (DeleteObject (pCmapPriv->hPalette) == 0)
    {
      ErrorF ("winDestroyColormap - DeleteObject () failed\n");
      return FALSE;
    }
  
  /* Invalidate the colormap privates */
  pCmapPriv->hPalette = NULL;

  return TRUE;
}
Beispiel #7
0
static Bool
winCreateColormapShadowDDNL(ColormapPtr pColormap)
{
    HRESULT ddrval = DD_OK;
    ScreenPtr pScreen = pColormap->pScreen;

    winScreenPriv(pScreen);
    winCmapPriv(pColormap);

    /* Create a DirectDraw palette */
    ddrval = IDirectDraw4_CreatePalette(pScreenPriv->pdd4,
                                        DDPCAPS_8BIT | DDPCAPS_ALLOW256,
                                        pCmapPriv->peColors,
                                        &pCmapPriv->lpDDPalette, NULL);
    if (FAILED(ddrval)) {
        ErrorF("winCreateColormapShadowDDNL - CreatePalette failed\n");
        return FALSE;
    }

    return TRUE;
}
Beispiel #8
0
Bool
qtStoreColorsShadow (ColormapPtr pColormap,
			 int ndef,
			 xColorItem *pdefs)
{
#if 0	/* ### NOT YET */
	ScreenPtr		pScreen = pColormap->pScreen;
	winScreenPriv(pScreen);
	winCmapPriv(pColormap);
	ColormapPtr curpmap = pScreenPriv->pcmapInstalled;
  
	/* Put the X colormap entries into the Windows logical palette */
	if (SetPaletteEntries (pCmapPriv->hPalette,
			       pdefs[0].pixel,
			       ndef,
			       pCmapPriv->peColors + pdefs[0].pixel) == 0)
	{
		ErrorF ("qtStoreColorsShadow - SetPaletteEntries () failed\n");
		return FALSE;
	}

	/* Don't install the Windows palette if the colormap is not installed */
	if (pColormap != curpmap)
	{
		return TRUE;
	}

	/* Try to install the newly modified colormap */
	if (!winInstallColormapShadow (pColormap))
	{
		ErrorF ("qtInstallColormapShadow - winInstallColormapShadow "
			"failed\n");
		return FALSE;
	}
#endif

	return TRUE;
}
Beispiel #9
0
static Bool
winInstallColormapShadowDD (ColormapPtr pColormap)
{
  ScreenPtr		pScreen = pColormap->pScreen;
  winScreenPriv(pScreen);
  winCmapPriv(pColormap);
  HRESULT		ddrval = DD_OK;

  /* Install the DirectDraw palette on the primary surface */
  ddrval = IDirectDrawSurface2_SetPalette (pScreenPriv->pddsPrimary,
					   pCmapPriv->lpDDPalette);
  if (FAILED (ddrval))
    {
      ErrorF ("winInstallColormapShadowDD - Failed installing the "
	      "DirectDraw palette.\n");
      return FALSE;
    }

  /* Save a pointer to the newly installed colormap */
  pScreenPriv->pcmapInstalled = pColormap;

  return TRUE;
}