Commit 462bb61b authored by Aaron Plattner's avatar Aaron Plattner
Browse files

Add CompositeRegisterAlternateVisuals.

This provides drivers the ability to add their own alternate visuals and then
register them with Composite for implicit redirection.
parent 12dbd8a0
......@@ -60,6 +60,8 @@ compCloseScreen (int index, ScreenPtr pScreen)
CompScreenPtr cs = GetCompScreen (pScreen);
Bool ret;
xfree (cs->alternateVisuals);
pScreen->CloseScreen = cs->CloseScreen;
pScreen->BlockHandler = cs->BlockHandler;
pScreen->InstallColormap = cs->InstallColormap;
......@@ -100,7 +102,7 @@ compInstallColormap (ColormapPtr pColormap)
CompScreenPtr cs = GetCompScreen (pScreen);
int a;
for (a = 0; a < NUM_COMP_ALTERNATE_VISUALS; a++)
for (a = 0; a < cs->numAlternateVisuals; a++)
if (pVisual->vid == cs->alternateVisuals[a])
return;
pScreen->InstallColormap = cs->InstallColormap;
......@@ -170,6 +172,41 @@ compFindVisuallessDepth (ScreenPtr pScreen, int d)
return 0;
}
/*
* Add a list of visual IDs to the list of visuals to implicitly redirect.
*/
static Bool
compRegisterAlternateVisuals (CompScreenPtr cs, VisualID *vids, int nVisuals)
{
VisualID *p;
p = xrealloc(cs->alternateVisuals,
sizeof(VisualID) * (cs->numAlternateVisuals + nVisuals));
if(p == NULL)
return FALSE;
memcpy(&p[cs->numAlternateVisuals], vids, sizeof(VisualID) * nVisuals);
cs->alternateVisuals = p;
cs->numAlternateVisuals += nVisuals;
return TRUE;
}
_X_EXPORT
Bool CompositeRegisterAlternateVisuals (ScreenPtr pScreen, VisualID *vids,
int nVisuals)
{
CompScreenPtr cs = GetCompScreen (pScreen);
return compRegisterAlternateVisuals(cs, vids, nVisuals);
}
#if COMP_INCLUDE_RGB24_VISUAL
#define NUM_COMP_ALTERNATE_VISUALS 2
#else
#define NUM_COMP_ALTERNATE_VISUALS 1
#endif
typedef struct _alternateVisual {
int depth;
CARD32 format;
......@@ -197,8 +234,6 @@ compAddAlternateVisuals (ScreenPtr pScreen, CompScreenPtr cs)
int numAlternate = 0;
int alt;
memset (cs->alternateVisuals, '\0', sizeof (cs->alternateVisuals));
for (alt = 0; alt < NUM_COMP_ALTERNATE_VISUALS; alt++)
{
DepthPtr depth;
......@@ -321,7 +356,7 @@ compAddAlternateVisuals (ScreenPtr pScreen, CompScreenPtr cs)
/*
* remember the visual ID to detect auto-update windows
*/
cs->alternateVisuals[alt] = visual->vid;
compRegisterAlternateVisuals(cs, &visual->vid, 1);
/*
* Fix up the depth
......@@ -367,6 +402,9 @@ compScreenInit (ScreenPtr pScreen)
cs->pOverlayWin = NULL;
cs->pOverlayClients = NULL;
cs->numAlternateVisuals = 0;
cs->alternateVisuals = NULL;
if (!compAddAlternateVisuals (pScreen, cs))
{
xfree (cs);
......
......@@ -109,12 +109,6 @@ typedef struct _CompSubwindows {
#define COMP_INCLUDE_RGB24_VISUAL 0
#endif
#if COMP_INCLUDE_RGB24_VISUAL
#define NUM_COMP_ALTERNATE_VISUALS 2
#else
#define NUM_COMP_ALTERNATE_VISUALS 1
#endif
typedef struct _CompOverlayClientRec *CompOverlayClientPtr;
typedef struct _CompOverlayClientRec {
......@@ -154,7 +148,8 @@ typedef struct _CompScreen {
ScreenBlockHandlerProcPtr BlockHandler;
CloseScreenProcPtr CloseScreen;
Bool damaged;
XID alternateVisuals[NUM_COMP_ALTERNATE_VISUALS];
int numAlternateVisuals;
VisualID *alternateVisuals;
WindowPtr pOverlayWin;
CompOverlayClientPtr pOverlayClients;
......@@ -224,6 +219,10 @@ CompositeExtensionInit (void);
* compinit.c
*/
Bool
CompositeRegisterAlternateVisuals (ScreenPtr pScreen,
VisualID *vids, int nVisuals);
Bool
compScreenInit (ScreenPtr pScreen);
......
......@@ -301,7 +301,7 @@ compIsAlternateVisual (ScreenPtr pScreen,
CompScreenPtr cs = GetCompScreen (pScreen);
int i;
for (i = 0; i < NUM_COMP_ALTERNATE_VISUALS; i++)
for (i = 0; i < cs->numAlternateVisuals; i++)
if (cs->alternateVisuals[i] == visual)
return TRUE;
return FALSE;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment