All pastes #435567 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-04-12 00:13 UTC
rendered paste body
diff --git a/plugins/cube.c b/plugins/cube.c
index 57ebbcc..f7c2e12 100644
--- a/plugins/cube.c
+++ b/plugins/cube.c
@@ -52,6 +52,13 @@
 
 #define CUBE_IN_DEFAULT FALSE
 
+typedef enum _RotationMode
+{
+    NoRotation = 0,
+    RotationChange,
+    RotationManual
+} RotationMode;
+
 static char *cubeImages[] = {
     "freedesktop"
 };
@@ -108,6 +115,8 @@ typedef struct _CubeDisplay {
     int		    screenPrivateIndex;
 
     CompOption opt[CUBE_DISPLAY_OPTION_NUM];
+    
+    HandleCompizEventProc handleCompizEvent;
 } CubeDisplay;
 
 #define CUBE_SCREEN_OPTION_COLOR	      0
@@ -174,11 +183,15 @@ typedef struct _CubeScreen {
     Bool cleared[64];
 
     Bool fullscreenOutput;
+    RotationMode rotationMode;
 
     float outputXScale;
     float outputYScale;
     float outputXOffset;
     float outputYOffset;
+    
+    Bool disableCaps;
+    Bool paintAllViewports;
 
 #ifdef USE_LIBRSVG
     cairo_t	    *cr;
@@ -1619,6 +1632,85 @@ cubeApplyScreenTransform (CompScreen		  *s,
     matrixTranslate (transform, -cs->outputXOffset, cs->outputYOffset, 0.0f);
 }
 
+static void cubeHandleCompizEvent(CompDisplay * d, char *pluginName,
+				 char *eventName, CompOption * option, int nOption)
+{
+    CUBE_DISPLAY(d);
+
+    UNWRAP (cd, d, handleCompizEvent);
+    (*d->handleCompizEvent) (d, pluginName, eventName, option, nOption);
+    WRAP (cd, d, handleCompizEvent, cubeHandleCompizEvent);
+	
+    if (strcmp(pluginName, "3d") == 0)
+    {
+	if (strcmp(eventName, "disableCapsEvent") == 0)
+	{
+	    Window xid = getIntOptionNamed(option, nOption, "root", 0);
+	    CompScreen *s = findScreenAtDisplay(d, xid);
+
+	    if (s)
+	    {
+		CUBE_SCREEN(s);
+		cs->disableCaps = getBoolOptionNamed(option, nOption, "disableCaps", FALSE);
+	    }
+	}
+	
+	else if (strcmp(eventName, "paintAllViewportsEvent") == 0)
+	{
+	    Window xid = getIntOptionNamed(option, nOption, "root", 0);
+	    CompScreen *s = findScreenAtDisplay(d, xid);
+
+	    if (s)
+	    {
+		CUBE_SCREEN(s);
+		cs->paintAllViewports = getBoolOptionNamed(option, nOption, "paintAllViewports", FALSE);
+	    }
+	}
+    }
+    if (strcmp(pluginName, "rotate") == 0)
+    {
+	if (strcmp(eventName, "rotateEvent") == 0)
+	{
+	    Window xid = getIntOptionNamed(option, nOption, "root", 0);
+	    CompScreen *s = findScreenAtDisplay(d, xid);
+
+	    if (s)
+	    {
+		CUBE_SCREEN(s);
+		Bool rotate = getBoolOptionNamed(option, nOption, "rotating", FALSE);
+		Bool manual = getBoolOptionNamed(option, nOption, "manual", FALSE);
+
+		if (rotate && manual)
+		    cs->rotationMode = RotationManual;
+		else if (rotate)
+		    cs->rotationMode = RotationChange;
+		else
+		    cs->rotationMode = NoRotation;
+		damageScreen(s);
+	    }
+	}
+    }
+}
+
+static void
+cubeFoldEvent(CompScreen *s, Bool unfolded)
+{
+    CompOption o[2];
+    
+    o[0].type = CompOptionTypeInt;
+    o[0].name = "root";
+    o[0].value.i = s->root;
+
+    o[1].type = CompOptionTypeBool;
+    o[1].name = "unfolded";
+    o[1].value.b = unfolded;
+
+    (*s->display->handleCompizEvent) (s->display, 
+                                      "cube", 
+                                      "unfoldEvent", 
+                                      o, 2);
+}
+
 static Bool
 cubeUnfold (CompDisplay     *d,
 	    CompAction      *action,
@@ -1647,6 +1739,7 @@ cubeUnfold (CompDisplay     *d,
 
 	if (cs->grabIndex)
 	{
+	    cubeFoldEvent (s, TRUE);
 	    cs->unfolded = TRUE;
 	    damageScreen (s);
 	}
@@ -1682,6 +1775,7 @@ cubeFold (CompDisplay     *d,
 
 	if (cs->grabIndex)
 	{
+	    cubeFoldEvent (s, FALSE);
 	    cs->unfolded = FALSE;
 	    damageScreen (s);
 	}
@@ -1905,6 +1999,8 @@ cubeInitDisplay (CompPlugin  *p,
     cubeDisplayInitOptions (cd, d->display);
 
     d->privates[displayPrivateIndex].ptr = cd;
+    
+    WRAP (cd, d, handleCompizEvent, cubeHandleCompizEvent);
 
     return TRUE;
 }
@@ -1919,6 +2015,8 @@ cubeFiniDisplay (CompPlugin  *p,
 #endif
 
     CUBE_DISPLAY (d);
+    
+    UNWRAP (cd, d, handleCompizEvent);
 
     freeScreenPrivateIndex (d, cd->screenPrivateIndex);
 
@@ -1977,6 +2075,10 @@ cubeInitScreen (CompPlugin *p,
     cs->unfoldVelocity = 0.0f;
 
     cs->fullscreenOutput = TRUE;
+    
+    cs->disableCaps = FALSE;
+    cs->paintAllViewports = FALSE;
+    cs->rotationMode = NoRotation;
 
     memset (cs->cleared, 0, sizeof (cs->cleared));
 
diff --git a/plugins/rotate.c b/plugins/rotate.c
index c19030b..25eb9ab 100644
--- a/plugins/rotate.c
+++ b/plugins/rotate.c
@@ -400,6 +400,30 @@ rotateReleaseMoveWindow (CompScreen *s)
     rs->moveWindow = None;
 }
 
+static void rotateEvent(CompScreen *s, 
+			Bool       rotating, 
+			Bool       manual)
+{
+    CompOption o[3];
+
+    o[0].type = CompOptionTypeInt;
+    o[0].name = "root";
+    o[0].value.i = s->root;
+
+    o[1].type = CompOptionTypeBool;
+    o[1].name = "rotating";
+    o[1].value.b = rotating;
+
+    o[2].type = CompOptionTypeBool;
+    o[2].name = "manual";
+    o[2].value.b = manual;
+
+    (*s->display->handleCompizEvent)(s->display, 
+				     "rotate", 
+				     "rotateEvent", 
+				     o, 3);
+}
+
 static void
 rotatePreparePaintScreen (CompScreen *s,
 			  int	     msSinceLastPaint)
@@ -484,6 +508,8 @@ rotatePreparePaintScreen (CompScreen *s,
 			tx = (s->hsize * xrot / 360.0f) - 0.5f;
 		    else
 			tx = (s->hsize * xrot / 360.0f) + 0.5f;
+		    
+		    rotateEvent (s, FALSE, FALSE);
 
 		    moveScreenViewport (s, tx, 0, TRUE);
 
@@ -637,6 +663,10 @@ rotateInitiate (CompDisplay     *d,
 
 	rs->moving = FALSE;
 	rs->slow   = FALSE;
+	
+	/* notify other plugins that rotation starts - if action is
+	   non-NULL, we are called from the 'Initiate rotate' binding */
+	rotateEvent (s, TRUE, (action != NULL));
 
 	if (!rs->grabIndex)
 	{