Track screens' installed colormaps as screen privates.
Several DDXes allow each screen to have at most one (or in some cases, exactly one) installed colormap. These all use the same pattern: Declare a global-lifetime array of MAXSCREENS ColormapPtrs, and index it by screen number. This patch converts most of those to use screen privates instead. Signed-off-by: Jamey Sharp <jamey@minilop.net> Acked-by: Tiago Vignatti <tiago.vignatti@nokia.com>
This commit is contained in:
parent
22c4300ee2
commit
da02178919
16
fb/fbcmap.c
16
fb/fbcmap.c
|
@ -36,16 +36,18 @@
|
||||||
#error "You should be compiling fbcmap_mi.c instead of fbcmap.c!"
|
#error "You should be compiling fbcmap_mi.c instead of fbcmap.c!"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static int cmapScrPrivateKeyIndex;
|
||||||
|
static DevPrivateKey cmapScrPrivateKey = &cmapScrPrivateKeyIndex;
|
||||||
|
|
||||||
|
#define GetInstalledColormap(s) ((ColormapPtr) dixLookupPrivate(&(s)->devPrivates, cmapScrPrivateKey))
|
||||||
ColormapPtr FbInstalledMaps[MAXSCREENS];
|
#define SetInstalledColormap(s,c) (dixSetPrivate(&(s)->devPrivates, cmapScrPrivateKey, c))
|
||||||
|
|
||||||
int
|
int
|
||||||
fbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps)
|
fbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps)
|
||||||
{
|
{
|
||||||
/* By the time we are processing requests, we can guarantee that there
|
/* By the time we are processing requests, we can guarantee that there
|
||||||
* is always a colormap installed */
|
* is always a colormap installed */
|
||||||
*pmaps = FbInstalledMaps[pScreen->myNum]->mid;
|
*pmaps = GetInstalledColormap(pScreen)->mid;
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,8 +55,7 @@ fbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps)
|
||||||
void
|
void
|
||||||
fbInstallColormap(ColormapPtr pmap)
|
fbInstallColormap(ColormapPtr pmap)
|
||||||
{
|
{
|
||||||
int index = pmap->pScreen->myNum;
|
ColormapPtr oldpmap = GetInstalledColormap(pmap->pScreen);
|
||||||
ColormapPtr oldpmap = FbInstalledMaps[index];
|
|
||||||
|
|
||||||
if(pmap != oldpmap)
|
if(pmap != oldpmap)
|
||||||
{
|
{
|
||||||
|
@ -63,7 +64,7 @@ fbInstallColormap(ColormapPtr pmap)
|
||||||
if(oldpmap != (ColormapPtr)None)
|
if(oldpmap != (ColormapPtr)None)
|
||||||
WalkTree(pmap->pScreen, TellLostMap, (char *)&oldpmap->mid);
|
WalkTree(pmap->pScreen, TellLostMap, (char *)&oldpmap->mid);
|
||||||
/* Install pmap */
|
/* Install pmap */
|
||||||
FbInstalledMaps[index] = pmap;
|
SetInstalledColormap(pmap->pScreen, pmap);
|
||||||
WalkTree(pmap->pScreen, TellGainedMap, (char *)&pmap->mid);
|
WalkTree(pmap->pScreen, TellGainedMap, (char *)&pmap->mid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,8 +72,7 @@ fbInstallColormap(ColormapPtr pmap)
|
||||||
void
|
void
|
||||||
fbUninstallColormap(ColormapPtr pmap)
|
fbUninstallColormap(ColormapPtr pmap)
|
||||||
{
|
{
|
||||||
int index = pmap->pScreen->myNum;
|
ColormapPtr curpmap = GetInstalledColormap(pmap->pScreen);
|
||||||
ColormapPtr curpmap = FbInstalledMaps[index];
|
|
||||||
|
|
||||||
if(pmap == curpmap)
|
if(pmap == curpmap)
|
||||||
{
|
{
|
||||||
|
|
|
@ -427,14 +427,18 @@ ddxProcessArgument(int argc, char *argv[], int i)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ColormapPtr InstalledMaps[MAXSCREENS];
|
static int cmapScrPrivateKeyIndex;
|
||||||
|
static DevPrivateKey cmapScrPrivateKey = &cmapScrPrivateKeyIndex;
|
||||||
|
|
||||||
|
#define GetInstalledColormap(s) ((ColormapPtr) dixLookupPrivate(&(s)->devPrivates, cmapScrPrivateKey))
|
||||||
|
#define SetInstalledColormap(s,c) (dixSetPrivate(&(s)->devPrivates, cmapScrPrivateKey, c))
|
||||||
|
|
||||||
static int
|
static int
|
||||||
vfbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps)
|
vfbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps)
|
||||||
{
|
{
|
||||||
/* By the time we are processing requests, we can guarantee that there
|
/* By the time we are processing requests, we can guarantee that there
|
||||||
* is always a colormap installed */
|
* is always a colormap installed */
|
||||||
*pmaps = InstalledMaps[pScreen->myNum]->mid;
|
*pmaps = GetInstalledColormap(pScreen)->mid;
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,8 +446,7 @@ vfbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps)
|
||||||
static void
|
static void
|
||||||
vfbInstallColormap(ColormapPtr pmap)
|
vfbInstallColormap(ColormapPtr pmap)
|
||||||
{
|
{
|
||||||
int index = pmap->pScreen->myNum;
|
ColormapPtr oldpmap = GetInstalledColormap(pmap->pScreen);
|
||||||
ColormapPtr oldpmap = InstalledMaps[index];
|
|
||||||
|
|
||||||
if (pmap != oldpmap)
|
if (pmap != oldpmap)
|
||||||
{
|
{
|
||||||
|
@ -459,7 +462,7 @@ vfbInstallColormap(ColormapPtr pmap)
|
||||||
if(oldpmap != (ColormapPtr)None)
|
if(oldpmap != (ColormapPtr)None)
|
||||||
WalkTree(pmap->pScreen, TellLostMap, (char *)&oldpmap->mid);
|
WalkTree(pmap->pScreen, TellLostMap, (char *)&oldpmap->mid);
|
||||||
/* Install pmap */
|
/* Install pmap */
|
||||||
InstalledMaps[index] = pmap;
|
SetInstalledColormap(pmap->pScreen, pmap);
|
||||||
WalkTree(pmap->pScreen, TellGainedMap, (char *)&pmap->mid);
|
WalkTree(pmap->pScreen, TellGainedMap, (char *)&pmap->mid);
|
||||||
|
|
||||||
entries = pmap->pVisual->ColormapEntries;
|
entries = pmap->pVisual->ColormapEntries;
|
||||||
|
@ -500,7 +503,7 @@ vfbInstallColormap(ColormapPtr pmap)
|
||||||
static void
|
static void
|
||||||
vfbUninstallColormap(ColormapPtr pmap)
|
vfbUninstallColormap(ColormapPtr pmap)
|
||||||
{
|
{
|
||||||
ColormapPtr curpmap = InstalledMaps[pmap->pScreen->myNum];
|
ColormapPtr curpmap = GetInstalledColormap(pmap->pScreen);
|
||||||
|
|
||||||
if(pmap == curpmap)
|
if(pmap == curpmap)
|
||||||
{
|
{
|
||||||
|
@ -521,7 +524,7 @@ vfbStoreColors(ColormapPtr pmap, int ndef, xColorItem *pdefs)
|
||||||
XWDColor *pXWDCmap;
|
XWDColor *pXWDCmap;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (pmap != InstalledMaps[pmap->pScreen->myNum])
|
if (pmap != GetInstalledColormap(pmap->pScreen))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -830,10 +833,10 @@ vfbCloseScreen(int index, ScreenPtr pScreen)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX probably lots of stuff to clean. For now,
|
* XXX probably lots of stuff to clean. For now,
|
||||||
* clear InstalledMaps[] so that server reset works correctly.
|
* clear installed colormaps so that server reset works correctly.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < MAXSCREENS; i++)
|
for (i = 0; i < screenInfo.numScreens; i++)
|
||||||
InstalledMaps[i] = NULL;
|
SetInstalledColormap(screenInfo.screens[i], NULL);
|
||||||
|
|
||||||
return pScreen->CloseScreen(index, pScreen);
|
return pScreen->CloseScreen(index, pScreen);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,11 @@ is" without express or implied warranty.
|
||||||
#include "XNWindow.h"
|
#include "XNWindow.h"
|
||||||
#include "Args.h"
|
#include "Args.h"
|
||||||
|
|
||||||
static ColormapPtr InstalledMaps[MAXSCREENS];
|
static int cmapScrPrivateKeyIndex;
|
||||||
|
static DevPrivateKey cmapScrPrivateKey = &cmapScrPrivateKeyIndex;
|
||||||
|
|
||||||
|
#define GetInstalledColormap(s) ((ColormapPtr) dixLookupPrivate(&(s)->devPrivates, cmapScrPrivateKey))
|
||||||
|
#define SetInstalledColormap(s,c) (dixSetPrivate(&(s)->devPrivates, cmapScrPrivateKey, c))
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
xnestCreateColormap(ColormapPtr pCmap)
|
xnestCreateColormap(ColormapPtr pCmap)
|
||||||
|
@ -332,11 +336,7 @@ xnestDirectUninstallColormaps(ScreenPtr pScreen)
|
||||||
void
|
void
|
||||||
xnestInstallColormap(ColormapPtr pCmap)
|
xnestInstallColormap(ColormapPtr pCmap)
|
||||||
{
|
{
|
||||||
int index;
|
ColormapPtr pOldCmap = GetInstalledColormap(pCmap->pScreen);
|
||||||
ColormapPtr pOldCmap;
|
|
||||||
|
|
||||||
index = pCmap->pScreen->myNum;
|
|
||||||
pOldCmap = InstalledMaps[index];
|
|
||||||
|
|
||||||
if(pCmap != pOldCmap)
|
if(pCmap != pOldCmap)
|
||||||
{
|
{
|
||||||
|
@ -346,7 +346,7 @@ xnestInstallColormap(ColormapPtr pCmap)
|
||||||
if(pOldCmap != (ColormapPtr)None)
|
if(pOldCmap != (ColormapPtr)None)
|
||||||
WalkTree(pCmap->pScreen, TellLostMap, (pointer)&pOldCmap->mid);
|
WalkTree(pCmap->pScreen, TellLostMap, (pointer)&pOldCmap->mid);
|
||||||
|
|
||||||
InstalledMaps[index] = pCmap;
|
SetInstalledColormap(pCmap->pScreen, pCmap);
|
||||||
WalkTree(pCmap->pScreen, TellGainedMap, (pointer)&pCmap->mid);
|
WalkTree(pCmap->pScreen, TellGainedMap, (pointer)&pCmap->mid);
|
||||||
|
|
||||||
xnestSetInstalledColormapWindows(pCmap->pScreen);
|
xnestSetInstalledColormapWindows(pCmap->pScreen);
|
||||||
|
@ -357,11 +357,7 @@ xnestInstallColormap(ColormapPtr pCmap)
|
||||||
void
|
void
|
||||||
xnestUninstallColormap(ColormapPtr pCmap)
|
xnestUninstallColormap(ColormapPtr pCmap)
|
||||||
{
|
{
|
||||||
int index;
|
ColormapPtr pCurCmap = GetInstalledColormap(pCmap->pScreen);
|
||||||
ColormapPtr pCurCmap;
|
|
||||||
|
|
||||||
index = pCmap->pScreen->myNum;
|
|
||||||
pCurCmap = InstalledMaps[index];
|
|
||||||
|
|
||||||
if(pCmap == pCurCmap)
|
if(pCmap == pCurCmap)
|
||||||
{
|
{
|
||||||
|
@ -382,7 +378,7 @@ int
|
||||||
xnestListInstalledColormaps(ScreenPtr pScreen, Colormap *pCmapIDs)
|
xnestListInstalledColormaps(ScreenPtr pScreen, Colormap *pCmapIDs)
|
||||||
{
|
{
|
||||||
if (xnestInstalledDefaultColormap) {
|
if (xnestInstalledDefaultColormap) {
|
||||||
*pCmapIDs = InstalledMaps[pScreen->myNum]->mid;
|
*pCmapIDs = GetInstalledColormap(pScreen)->mid;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue
Block a user