[beryl-commits] compiz mirror: Changes to 'master' (adcb5424960810ec189a7aa58111b5a8469f5663)

compiz at server.beryl-project.org compiz at server.beryl-project.org
Mon Jun 11 18:48:20 CEST 2007


New commits:
commit adcb5424960810ec189a7aa58111b5a8469f5663
Author: Dennis Kasprzyk <onestone at beryl-project.org>
Date:   Mon Jun 11 18:47:42 2007 +0200

    Use cs->invert directly.

commit 5df7a14a79393c0ab9b0c5b9661689c87b413156
Author: Dennis Kasprzyk <onestone at beryl-project.org>
Date:   Mon Jun 11 18:47:18 2007 +0200

    Don't zoom in inside cube mode.

commit 5a1b25101f8f8333705be47a0f4da7dff5907fb0
Author: Dennis Kasprzyk <onestone at beryl-project.org>
Date:   Mon Jun 11 18:46:56 2007 +0200

    Added zoom out for mouse rotation.

commit 03c94324a154f9d4e74c869c104f9d5b82abc9d3
Author: Dennis Kasprzyk <onestone at beryl-project.org>
Date:   Mon Jun 11 18:46:38 2007 +0200

    Added zoom out for viewport change rotation.

commit f48fbc8d45f5c80e65c787d9ee7f465753f6e73b
Author: Dennis Kasprzyk <onestone at beryl-project.org>
Date:   Mon Jun 11 18:46:10 2007 +0200

    Added metadata for rotate zoom option.

commit ea94dec5e31072481560e60284c8c06ac5eaffa3
Author: Dennis Kasprzyk <onestone at beryl-project.org>
Date:   Mon Jun 11 18:45:26 2007 +0200

    Added basic zoom out support to rotate.

commit 8d1a7611d0931aeaafe105bcf7f23375d0236c12
Author: Dennis Kasprzyk <onestone at beryl-project.org>
Date:   Mon Jun 11 18:43:48 2007 +0200

    Allow that cube caps get painted multiple times.

commit ad7075408e1cfd8891eff36cc12ea53ee1a0a9e4
Author: Dennis Kasprzyk <onestone at beryl-project.org>
Date:   Mon Jun 11 18:43:09 2007 +0200

    Fixed float rounding errors during option setting


 metadata/rotate.xml.in |    8 +++
 plugins/cube.c         |    2 +-
 plugins/rotate.c       |  143 ++++++++++++++++++++++++++++++------------------
 src/option.c           |    8 ++-
 4 files changed, 105 insertions(+), 56 deletions(-)


Modified: compiz/metadata/rotate.xml.in
===================================================================
--- compiz/metadata/rotate.xml.in
+++ compiz/metadata/rotate.xml.in
@@ -261,6 +261,14 @@
 		<max>50.0</max>
 		<precision>0.1</precision>
 	    </option>
+		<option name="zoom" type="float">
+		<_short>Zoom</_short>
+		<_long>Rotation Zoom</_long>
+		<default>0.0</default>
+		<min>0.0</min>
+		<max>2.0</max>
+		<precision>0.1</precision>
+	    </option>
 
 	</screen>
     </plugin>

Modified: compiz/plugins/cube.c
===================================================================
--- compiz/plugins/cube.c
+++ compiz/plugins/cube.c
@@ -1105,7 +1105,7 @@ cubePaintTransformedOutput (CompScreen		    *s,
 	}
     }
 
-    if (!clear && cs->grabIndex == 0 && hsize > 2 &&
+    if (cs->grabIndex == 0 && hsize > 2 &&
 	(cs->invert != 1 || sa.vRotate != 0.0f || sa.yTranslate != 0.0f))
     {
 	(*cs->paintTopBottom) (s, &sa, transform, outputPtr, hsize);

Modified: compiz/plugins/rotate.c
===================================================================
--- compiz/plugins/rotate.c
+++ compiz/plugins/rotate.c
@@ -94,13 +94,13 @@ typedef struct _RotateDisplay {
 #define ROTATE_SCREEN_OPTION_SNAP_TOP		 3
 #define ROTATE_SCREEN_OPTION_SPEED		 4
 #define ROTATE_SCREEN_OPTION_TIMESTEP		 5
-#define ROTATE_SCREEN_OPTION_NUM		 6
+#define ROTATE_SCREEN_OPTION_ZOOM		 6
+#define ROTATE_SCREEN_OPTION_NUM		 7
 
 typedef struct _RotateScreen {
     PreparePaintScreenProc	 preparePaintScreen;
     DonePaintScreenProc		 donePaintScreen;
     PaintOutputProc		 paintOutput;
-    SetScreenOptionForPluginProc setScreenOptionForPlugin;
     WindowGrabNotifyProc	 windowGrabNotify;
     WindowUngrabNotifyProc	 windowUngrabNotify;
 
@@ -122,8 +122,6 @@ typedef struct _RotateScreen {
     Bool    moving;
     GLfloat moveTo;
 
-    int invert;
-
     Window moveWindow;
     int    moveWindowX;
 
@@ -134,6 +132,9 @@ typedef struct _RotateScreen {
     Bool	      slow;
     unsigned int      grabMask;
     CompWindow	      *grabWindow;
+
+    GLfloat zoomTranslate;
+    GLfloat zoomVelocity;
 } RotateScreen;
 
 #define GET_ROTATE_DISPLAY(d)				       \
@@ -260,6 +261,9 @@ rotatePreparePaintScreen (CompScreen *s,
 			  int	     msSinceLastPaint)
 {
     ROTATE_SCREEN (s);
+    CUBE_SCREEN (s);
+
+    float oldXrot = rs->xrot + rs->baseXrot;
 
     if (rs->grabIndex || rs->moving)
     {
@@ -289,7 +293,7 @@ rotatePreparePaintScreen (CompScreen *s,
 		rs->xrot += 360.0f / s->hsize;
 	    }
 
-	    if (rs->invert == -1)
+	    if (cs->invert == -1)
 	    {
 		if (rs->yrot > 45.0f)
 		{
@@ -404,6 +408,72 @@ rotatePreparePaintScreen (CompScreen *s,
 	}
     }
 
+    if (rs->moving && cs->invert == 1)
+    {
+	if (fabs(rs->xrot + rs->baseXrot + rs->moveTo) <=
+	    (360.0 / (s->hsize * 2.0)))
+	    rs->zoomTranslate = rs->opt[ROTATE_SCREEN_OPTION_ZOOM].value.f *
+		fabs(rs->xrot + rs->baseXrot + rs->moveTo) /
+		(360.0 / (s->hsize * 2.0));
+	else if (fabs(rs->xrot + rs->baseXrot) <= (360.0 / (s->hsize * 2.0)))
+	    rs->zoomTranslate = rs->opt[ROTATE_SCREEN_OPTION_ZOOM].value.f *
+		fabs(rs->xrot + rs->baseXrot) /
+		(360.0 / (s->hsize * 2.0));
+	else
+	{
+	    rs->zoomTranslate += fabs (rs->xrot + rs->baseXrot - oldXrot) /
+		(360.0 / (s->hsize * 2.0)) *
+		rs->opt[ROTATE_SCREEN_OPTION_ZOOM].value.f;
+	    rs->zoomTranslate = MIN (rs->zoomTranslate,
+		rs->opt[ROTATE_SCREEN_OPTION_ZOOM].value.f);
+	}
+    }
+    else if ((rs->zoomTranslate != 0.0f || rs->grabbed) && cs->invert == 1)
+    {
+	int steps, stepsCount;
+	float amount, chunk;
+	
+	amount = msSinceLastPaint * 0.05f *
+		 rs->opt[ROTATE_SCREEN_OPTION_SPEED].value.f;
+	steps = stepsCount = amount / (0.5f *
+		rs->opt[ROTATE_SCREEN_OPTION_TIMESTEP].value.f);
+	if (!steps)
+		steps = stepsCount = 1;
+	chunk = amount / (float)steps;
+
+	while (steps--)
+	{
+	    float dt, adjust, tamount;
+
+	    if (rs->grabbed)
+		dt = rs->opt[ROTATE_SCREEN_OPTION_ZOOM].value.f -
+		     rs->zoomTranslate;
+	    else
+		dt = 0.0f - rs->zoomTranslate;
+
+	    adjust = dt * 0.15f;
+	    tamount = fabs(dt) * 1.5f;
+	    if (tamount < 0.2f)
+		tamount = 0.2f;
+	    else if (tamount > 2.0f)
+		tamount = 2.0f;
+
+	    rs->zoomVelocity = (tamount * rs->zoomVelocity + adjust) /
+			       (tamount + 1.0f);
+
+	    if (fabs(dt) < 0.1f && fabs(rs->zoomVelocity) < 0.0005f)
+	    {
+		if (rs->grabbed)
+		    rs->zoomTranslate =
+			rs->opt[ROTATE_SCREEN_OPTION_ZOOM].value.f;
+		else
+		    rs->zoomTranslate = 0.0f;
+		break;
+	    }
+	    rs->zoomTranslate += rs->zoomVelocity * chunk;
+	}
+    }
+
     UNWRAP (rs, s, preparePaintScreen);
     (*s->preparePaintScreen) (s, msSinceLastPaint);
     WRAP (rs, s, preparePaintScreen, rotatePreparePaintScreen);
@@ -420,6 +490,10 @@ rotateDonePaintScreen (CompScreen *s)
 	    damageScreen (s);
     }
 
+    if (rs->zoomTranslate > 0.0f &&
+	rs->zoomTranslate < rs->opt[ROTATE_SCREEN_OPTION_ZOOM].value.f)
+	damageScreen (s);
+
     UNWRAP (rs, s, donePaintScreen);
     (*s->donePaintScreen) (s);
     WRAP (rs, s, donePaintScreen, rotateDonePaintScreen);
@@ -450,17 +524,19 @@ rotatePaintOutput (CompScreen		   *s,
 		   unsigned int		   mask)
 {
     Bool status;
+    ScreenPaintAttrib sA = *sAttrib;
 
     ROTATE_SCREEN (s);
 
-    if (rs->grabIndex || rs->moving)
+    if (rs->grabIndex || rs->moving || rs->zoomTranslate != 0.0f)
     {
+	sA.zCamera -= rs->zoomTranslate;
 	mask &= ~PAINT_SCREEN_REGION_MASK;
 	mask |= PAINT_SCREEN_TRANSFORMED_MASK;
     }
 
     UNWRAP (rs, s, paintOutput);
-    status = (*s->paintOutput) (s, sAttrib, transform, region, output, mask);
+    status = (*s->paintOutput) (s, &sA, transform, region, output, mask);
     WRAP (rs, s, paintOutput, rotatePaintOutput);
 
     return status;
@@ -1322,6 +1398,7 @@ rotateHandleEvent (CompDisplay *d,
 	if (s)
 	{
 	    ROTATE_SCREEN (s);
+	    CUBE_SCREEN (s);
 
 	    if (rs->grabIndex)
 	    {
@@ -1346,7 +1423,7 @@ rotateHandleEvent (CompDisplay *d,
 			pointerDy = -pointerDy;
 
 		    rs->xVelocity += pointerDx * rs->pointerSensitivity *
-			rs->invert;
+			cs->invert;
 		    rs->yVelocity += pointerDy * rs->pointerSensitivity;
 
 		    damageScreen (s);
@@ -1516,46 +1593,6 @@ rotateWindowUngrabNotify (CompWindow *w)
     WRAP (rs, w->screen, windowUngrabNotify, rotateWindowUngrabNotify);
 }
 
-static void
-rotateUpdateCubeOptions (CompScreen *s)
-{
-    CompPlugin *p;
-
-    ROTATE_SCREEN (s);
-
-    p = findActivePlugin ("cube");
-    if (p && p->vTable->getScreenOptions)
-    {
-	CompOption *options, *option;
-	int	   nOptions;
-
-	options = (*p->vTable->getScreenOptions) (p, s, &nOptions);
-	option = compFindOption (options, nOptions, "in", 0);
-	if (option)
-	    rs->invert = option->value.b ? -1 : 1;
-    }
-}
-
-static Bool
-rotateSetScreenOptionForPlugin (CompScreen      *s,
-				char	        *plugin,
-				char	        *name,
-				CompOptionValue *value)
-{
-    Bool status;
-
-    ROTATE_SCREEN (s);
-
-    UNWRAP (rs, s, setScreenOptionForPlugin);
-    status = (*s->setScreenOptionForPlugin) (s, plugin, name, value);
-    WRAP (rs, s, setScreenOptionForPlugin, rotateSetScreenOptionForPlugin);
-
-    if (status && strcmp (plugin, "cube") == 0 && strcmp (name, "in") == 0)
-	rotateUpdateCubeOptions (s);
-
-    return status;
-}
-
 static CompOption *
 rotateGetDisplayOptions (CompPlugin  *plugin,
 			 CompDisplay *display,
@@ -1701,7 +1738,8 @@ static const CompMetadataOptionInfo rotateScreenOptionInfo[] = {
     { "acceleration", "float", "<min>1.0</min>", 0, 0 },
     { "snap_top", "bool", 0, 0, 0 },
     { "speed", "float", "<min>0.1</min>", 0, 0 },
-    { "timestep", "float", "<min>0.1</min>", 0, 0 }
+    { "timestep", "float", "<min>0.1</min>", 0, 0 },
+    { "zoom", "float", 0, 0, 0 }
 };
 
 static Bool
@@ -1757,10 +1795,12 @@ rotateInitScreen (CompPlugin *p,
 
     rs->rotateHandle = 0;
 
+    rs->zoomTranslate = 0.0;
+    rs->zoomVelocity  = 0.0;
+
     WRAP (rs, s, preparePaintScreen, rotatePreparePaintScreen);
     WRAP (rs, s, donePaintScreen, rotateDonePaintScreen);
     WRAP (rs, s, paintOutput, rotatePaintOutput);
-    WRAP (rs, s, setScreenOptionForPlugin, rotateSetScreenOptionForPlugin);
     WRAP (rs, s, windowGrabNotify, rotateWindowGrabNotify);
     WRAP (rs, s, windowUngrabNotify, rotateWindowUngrabNotify);
 
@@ -1768,8 +1808,6 @@ rotateInitScreen (CompPlugin *p,
 
     s->privates[rd->screenPrivateIndex].ptr = rs;
 
-    rotateUpdateCubeOptions (s);
-
     return TRUE;
 }
 
@@ -1785,7 +1823,6 @@ rotateFiniScreen (CompPlugin *p,
     UNWRAP (rs, s, preparePaintScreen);
     UNWRAP (rs, s, donePaintScreen);
     UNWRAP (rs, s, paintOutput);
-    UNWRAP (rs, s, setScreenOptionForPlugin);
     UNWRAP (rs, s, windowGrabNotify);
     UNWRAP (rs, s, windowUngrabNotify);
 

Modified: compiz/src/option.c
===================================================================
--- compiz/src/option.c
+++ compiz/src/option.c
@@ -155,13 +155,17 @@ compSetFloatOption (CompOption	    *option,
 		    CompOptionValue *value)
 {
     float v, p;
+    
+    /* Workaround for float rounding errors */
+    static float equalRange = 1e-5;
+
     int sign = (value->f < 0 ? -1 : 1);
 
     p = 1.0f / option->rest.f.precision;
     v = ((int) (value->f * p + sign * 0.5f)) / p;
 
-    if (v < option->rest.f.min ||
-	v > option->rest.f.max ||
+    if (v < option->rest.f.min - equalRange ||
+	v > option->rest.f.max + equalRange ||
 	v == option->value.f)
 	return FALSE;
 



More information about the commits mailing list