summaryrefslogtreecommitdiff
path: root/composite
diff options
context:
space:
mode:
authorAaron Plattner <aplattner@nvidia.com>2006-08-08 18:07:22 -0700
committerAaron Plattner <aplattner@nvidia.com>2006-08-08 18:41:30 -0700
commit462bb61b0fe968fae1b99cf98ec6f7de09105dcd (patch)
tree29a7ada8be1cf9ad96850909440088d7f029b5bd /composite
parent12dbd8a02f797ad57a1be683a02a1fcb1ca35438 (diff)
Add CompositeRegisterAlternateVisuals.
This provides drivers the ability to add their own alternate visuals and then register them with Composite for implicit redirection.
Diffstat (limited to 'composite')
-rw-r--r--composite/compinit.c46
-rw-r--r--composite/compint.h13
-rw-r--r--composite/compwindow.c2
3 files changed, 49 insertions, 12 deletions
diff --git a/composite/compinit.c b/composite/compinit.c
index 5a1361216..1d5cc7b04 100644
--- a/composite/compinit.c
+++ b/composite/compinit.c
@@ -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);
diff --git a/composite/compint.h b/composite/compint.h
index 9395512b4..3958b3b31 100644
--- a/composite/compint.h
+++ b/composite/compint.h
@@ -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;
@@ -225,6 +220,10 @@ CompositeExtensionInit (void);
*/
Bool
+CompositeRegisterAlternateVisuals (ScreenPtr pScreen,
+ VisualID *vids, int nVisuals);
+
+Bool
compScreenInit (ScreenPtr pScreen);
/*
diff --git a/composite/compwindow.c b/composite/compwindow.c
index 87055b70c..2c86cdd95 100644
--- a/composite/compwindow.c
+++ b/composite/compwindow.c
@@ -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;