Bug #14692: Allow drivers to have a say in Xinerama visual consolidation.

Create a new exported global variable, XineramaVisualsEqualPtr.  Use this
pointer to decide whether two visuals are equal during visual consolidation.
This pointer can be wrapped, which allows drivers and extensions to control
which visuals are consolidated.  A wrapper can reject the visuals without
calling down, but must call down and return that result if it deems the visuals
equal.  This ensures that all layers agree that the visuals are equal.

Pass the screen of the other visual into the VisualsEqual callchain.

Don't free PanoramiXVisuals since we need it for PanoramiXTranslateVisualID.

Don't skip the first visual on the other screen in PanoramiXMaybeAddVisual.

Skip the loop in PanoramiXTranslateVisualID if screen is 0.
This commit is contained in:
Aaron Plattner 2008-05-04 13:45:27 -07:00
parent 86678e7cc2
commit c50b5d9789
2 changed files with 31 additions and 12 deletions

View File

@ -87,6 +87,9 @@ _X_EXPORT unsigned long XRT_PIXMAP;
_X_EXPORT unsigned long XRT_GC;
_X_EXPORT unsigned long XRT_COLORMAP;
static Bool VisualsEqual(VisualPtr, ScreenPtr, VisualPtr);
_X_EXPORT XineramaVisualsEqualProcPtr XineramaVisualsEqualPtr = &VisualsEqual;
/*
* Function prototypes
*/
@ -668,10 +671,10 @@ Bool PanoramiXCreateConnectionBlock(void)
connSetupPrefix.length = length >> 2;
xfree(PanoramiXVisuals);
for (i = 0; i < PanoramiXNumDepths; i++)
xfree(PanoramiXDepths[i].vids);
xfree(PanoramiXDepths);
PanoramiXDepths = NULL;
/*
* OK, change some dimensions so it looks as if it were one big screen
@ -709,7 +712,7 @@ Bool PanoramiXCreateConnectionBlock(void)
* do their own back-mapping.
*/
static Bool
VisualsEqual(VisualPtr a, VisualPtr b)
VisualsEqual(VisualPtr a, ScreenPtr pScreenB, VisualPtr b)
{
return ((a->class == b->class) &&
(a->ColormapEntries == b->ColormapEntries) &&
@ -759,7 +762,6 @@ static void
PanoramiXMaybeAddVisual(VisualPtr pVisual)
{
ScreenPtr pScreen;
VisualPtr candidate = NULL;
int j, k;
Bool found = FALSE;
@ -767,10 +769,10 @@ PanoramiXMaybeAddVisual(VisualPtr pVisual)
pScreen = screenInfo.screens[j];
found = FALSE;
candidate = pScreen->visuals;
for (k = 0; k < pScreen->numVisuals; k++) {
candidate++;
if (VisualsEqual(pVisual, candidate)
VisualPtr candidate = &pScreen->visuals[k];
if ((*XineramaVisualsEqualPtr)(pVisual, pScreen, candidate)
#ifdef GLXPROXY
&& glxMatchVisual(screenInfo.screens[0], pVisual, pScreen)
#endif
@ -844,8 +846,13 @@ PanoramiXConsolidate(void)
_X_EXPORT VisualID
PanoramiXTranslateVisualID(int screen, VisualID orig)
{
ScreenPtr pOtherScreen = screenInfo.screens[screen];
VisualPtr pVisual = NULL;
int i, j;
int i;
/* if screen is 0, orig is already the correct visual ID */
if (screen == 0)
return orig;
for (i = 0; i < PanoramiXNumVisuals; i++) {
if (orig == PanoramiXVisuals[i].vid) {
@ -858,11 +865,13 @@ PanoramiXTranslateVisualID(int screen, VisualID orig)
return 0;
/* found the original, now translate it relative to the backend screen */
for (i = 0; i < PanoramiXNumScreens; i++)
for (j = 0; j < screenInfo.screens[i]->numVisuals; j++)
if (VisualsEqual(pVisual, &screenInfo.screens[i]->visuals[j]))
return screenInfo.screens[i]->visuals[j].vid;
for (i = 0; i < pOtherScreen->numVisuals; i++) {
VisualPtr pOtherVisual = &pOtherScreen->visuals[i];
if ((*XineramaVisualsEqualPtr)(pVisual, pOtherScreen, pOtherVisual))
return pOtherVisual->vid;
}
return 0;
}

View File

@ -30,6 +30,16 @@ extern unsigned long XRT_PIXMAP;
extern unsigned long XRT_GC;
extern unsigned long XRT_COLORMAP;
/*
* Drivers are allowed to wrap this function. Each wrapper can decide that the
* two visuals are unequal, but if they are deemed equal, the wrapper must call
* down and return FALSE if the wrapped function does. This ensures that all
* layers agree that the visuals are equal. The first visual is always from
* screen 0.
*/
typedef Bool (*XineramaVisualsEqualProcPtr)(VisualPtr, ScreenPtr, VisualPtr);
extern XineramaVisualsEqualProcPtr XineramaVisualsEqualPtr;
extern void XineramaGetImageData(
DrawablePtr *pDrawables,
int left,