summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Plattner <aplattner@nvidia.com>2008-05-04 13:45:27 -0700
committerAaron Plattner <aplattner@nvidia.com>2008-05-12 14:49:53 -0700
commitc50b5d978981b13cdb22a9ad41c1b64f90cebe51 (patch)
tree2335e197fc8431365e3a341830e38016db044cd7
parent86678e7cc2b021851ff508433fa160170f500c51 (diff)
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.
-rw-r--r--Xext/panoramiX.c33
-rw-r--r--Xext/panoramiXsrv.h10
2 files changed, 31 insertions, 12 deletions
diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index f92414764..eb7068925 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -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;
}
diff --git a/Xext/panoramiXsrv.h b/Xext/panoramiXsrv.h
index 6d556e963..d5c3d9827 100644
--- a/Xext/panoramiXsrv.h
+++ b/Xext/panoramiXsrv.h
@@ -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,