[compiz] Privates example? (fwd)

Tuukka Hastrup Tuukka.Hastrup at iki.fi
Thu Oct 12 15:07:39 PDT 2006


Resending this as the message size limit for the list is 100 KB,
and uncompressed, the attached plugin code is 150 KB.

---------- Forwarded message ----------
Date: Thu, 12 Oct 2006 23:47:25 +0300 (EEST)
From: Tuukka Hastrup <Tuukka.Hastrup at iki.fi>
To: Mike Dransfield <mike at blueroot.co.uk>
Cc: compiz at lists.freedesktop.org
Subject: Re: [compiz] Privates example?

On Thu, 12 Oct 2006, Mike Dransfield wrote:
> I have looked around but I cannot find an example of how to use the
> privates system.
>
> Could someone give me a quick example of the usage as I would like to
> finalize
> the animation porting.

I looked at the second version you sent to the list on October 4. To make
the plugin compile without the patches to Compiz core, I moved the new
fields from the public CompScreen and CompWindow to the private AnimScreen
and AnimWindow respectively. Similarily, I moved their initialization to
the functions where those structures are allocated in the plugin.

I tried to keep the changes to minimum and have a patch attached plus the
resulting animation.c. Based on short testing it runs at least. I happened
to see some odd-looking code at the second branch of animGetScreenOptions
though: it's using an essentially uninitialized AnimScreen and losing the
pointer to it on return.

Anyway, hope this serves as an example in the vein of what you had in
mind.

-- 
-- Trying to catch me? Just follow up my Electric Fingerprints
-- To help you: Tuukka.Hastrup at iki.fi
                http://www.iki.fi/Tuukka.Hastrup/
-------------- next part --------------
diff -ur animation-for-compiz.orig/animation.c animation-for-compiz.privates/animation.c
--- animation-for-compiz.orig/animation.c	2006-10-04 15:49:27.000000000 +0300
+++ animation-for-compiz.privates/animation.c	2006-10-12 22:41:12.000000000 +0300
@@ -489,6 +489,9 @@
     unsigned int focusWMask;
     unsigned int shadeWMask;
     unsigned int unshadeWMask;
+
+    // for temporarily disabling effects like blur
+    Bool disablePostprocessFX;
 } AnimScreen;
 
 typedef struct _AnimWindow
@@ -516,6 +519,12 @@
 
     int unmapCnt;
     int destroyCnt;
+
+    // for temporarily disabling effects like blur per window
+    Bool disablePostprocessFX;
+
+    int texCoordSize;
+    int indexCount;
 } AnimWindow;
 
 #define GET_ANIM_DISPLAY(d)                                       \
@@ -2971,10 +2980,10 @@
         aw->animOverrideProgressDir = 0;
 
         if (as->ppDisabling == PostprocessDisablingWindow)
-            w->disablePostprocessFX = FALSE;
+            aw->disablePostprocessFX = FALSE;
         if (!(as->animInProgress) &&
             as->ppDisabling == PostprocessDisablingScreen)
-            w->screen->disablePostprocessFX = FALSE;
+            as->disablePostprocessFX = FALSE;
         if (aw->model)
         {
             if (aw->model->magicLampWaves)
@@ -3013,9 +3022,9 @@
         Point topLeft, bottomRight;
 
         if (as->ppDisabling == PostprocessDisablingScreen)
-            s->disablePostprocessFX = TRUE;
+            as->disablePostprocessFX = TRUE;
         else
-            s->disablePostprocessFX = FALSE;
+            as->disablePostprocessFX = FALSE;
 
         region.rects = &region.extents;
         region.numRects = region.size = 1;
@@ -3028,9 +3037,9 @@
             if (aw->animRemainingTime > 0)
             {
                 if (as->ppDisabling == PostprocessDisablingWindow)
-                    w->disablePostprocessFX = TRUE;
+                    aw->disablePostprocessFX = TRUE;
                 else
-                    w->disablePostprocessFX = FALSE;
+                    aw->disablePostprocessFX = FALSE;
 
                 if (aw->model)
                 {
@@ -3180,13 +3189,13 @@
         if (w->vCount == 0)
         {
             // reset
-            w->indexCount = 0;
-            w->texCoordSize = 4;
+            aw->indexCount = 0;
+            aw->texCoordSize = 4;
         }
-        vSize = 2 + w->texUnits * w->texCoordSize;
+        vSize = 2 + w->texUnits * aw->texCoordSize;
 
         nVertices = w->vCount;
-        nIndices = w->indexCount;
+        nIndices = aw->indexCount;
 
         v = w->vertices + (nVertices * vSize);
         i = w->indices + nIndices;
@@ -3523,7 +3532,7 @@
             }
         }
         w->vCount = nVertices;
-        w->indexCount = nIndices;
+        aw->indexCount = nIndices;
     }
     else
     {
@@ -3542,7 +3551,7 @@
     {
         int texUnit = w->texUnits;
         int currentTexUnit = 0;
-        int stride = 2 + texUnit * w->texCoordSize;
+        int stride = 2 + texUnit * aw->texCoordSize;
         GLfloat *vertices = w->vertices + (stride - 2);
 
         stride *= sizeof (GLfloat);
@@ -3559,11 +3568,11 @@
                 glEnableClientState (GL_TEXTURE_COORD_ARRAY);
                 currentTexUnit = texUnit;
             }
-            vertices -= w->texCoordSize;
-            glTexCoordPointer (w->texCoordSize, GL_FLOAT, stride, vertices);
+            vertices -= aw->texCoordSize;
+            glTexCoordPointer (aw->texCoordSize, GL_FLOAT, stride, vertices);
         }
 
-        glDrawElements (GL_QUADS, w->indexCount, GL_UNSIGNED_SHORT,
+        glDrawElements (GL_QUADS, aw->indexCount, GL_UNSIGNED_SHORT,
                         w->indices);
 
         // disable all texture coordinate arrays except 0
@@ -3601,7 +3610,7 @@
 
     if (aw->animRemainingTime > 0)
     {
-        w->indexCount = 0;
+        aw->indexCount = 0;
 
         WindowPaintAttrib wAttrib = *attrib;
 
@@ -4480,6 +4489,8 @@
     WRAP (as, s, windowUngrabNotify, animWindowUngrabNotify);
     WRAP (as, s, setWindowScale, animSetWindowScale);
 
+    as->disablePostprocessFX = FALSE;
+
     s->privates[ad->screenPrivateIndex].ptr = as;
 
     return TRUE;
@@ -4535,7 +4546,6 @@
     aw->curAnimEffect = AnimEffectNone;
     aw->curWindowEvent = WindowEventNone;
     aw->animOverrideProgressDir = 0;
-    w->indexCount = 0;
 
     aw->unmapCnt = 0;
     aw->destroyCnt = 0;
@@ -4553,6 +4563,10 @@
         aw->nowShaded = FALSE;
     }
 
+    aw->disablePostprocessFX = FALSE;
+    aw->texCoordSize = 2;       // default: only S and T (no R or Q coordinate)
+    aw->indexCount = 0;
+
     w->privates[as->windowPrivateIndex].ptr = aw;
 
     return TRUE;
Vain hakemistossa animation-for-compiz.privates/: animation.c~
Vain hakemistossa animation-for-compiz.privates/: animation.o
-------------- next part --------------
A non-text attachment was scrubbed...
Name: animation.c.gz
Type: application/octet-stream
Size: 21423 bytes
Desc: Plugin code
Url : http://lists.freedesktop.org/archives/compiz/attachments/20061013/46fc2a6d/animation.c-0001.obj


More information about the compiz mailing list