summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcornelius <cornelius@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2007-02-15 08:47:45 +0000
committercornelius <cornelius@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2007-02-15 08:47:45 +0000
commit6acebd48859d34b408f3c4c82c322c69f50f70a7 (patch)
treeb0d54bc00b935bb2dcb4c7b90ac4e146aec07963
parent067c0e4fbb2ddeba0d98f2428ebbf0206524d9b9 (diff)
downloadmarex-dev-6acebd48859d34b408f3c4c82c322c69f50f70a7.tar.gz
marex-dev-6acebd48859d34b408f3c4c82c322c69f50f70a7.tar.bz2
wall: Added zoom animation (use NxN virtual size for best results) (doesn't use aspect ratio setting yet). Some case corrections for setting descriptions.
git-svn-id: file:///beryl/trunk@4071 d7aaf104-2d23-0410-ae22-9d23157bf5a3
-rw-r--r--beryl-plugins/src/wall.c214
1 files changed, 163 insertions, 51 deletions
diff --git a/beryl-plugins/src/wall.c b/beryl-plugins/src/wall.c
index 2c25cf4..ae5e137 100644
--- a/beryl-plugins/src/wall.c
+++ b/beryl-plugins/src/wall.c
@@ -41,6 +41,7 @@ Known Bugs:
*/
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <math.h>
#include <sys/time.h>
@@ -84,8 +85,6 @@ Known Bugs:
#define WALL_DOWN_WHEEL_DEFAULT Button5
#define WALL_WHEEL_MODIFIERS_DEFAULT 0
-#define WALL_DISPLAY_OPTION_SIMPLE_ANIMATION_DEFAULT TRUE
-
#define WALL_MIPMAPS_DEFAULT FALSE
#define WALL_ASPECT_DEFAULT 1.0f
#define WALL_MINISCREEN_DEFAULT FALSE
@@ -102,7 +101,7 @@ static int displayPrivateIndex;
#define WALL_DISPLAY_OPTION_EXPO 0
#define WALL_DISPLAY_OPTION_ROTATE 1
#define WALL_DISPLAY_OPTION_STICKY 2
-#define WALL_DISPLAY_OPTION_SIMPLE_ANIMATION 3
+#define WALL_DISPLAY_OPTION_EXPO_ANIMATION 3
#define WALL_DISPLAY_OPTION_LEFT 4
#define WALL_DISPLAY_OPTION_RIGHT 5
#define WALL_DISPLAY_OPTION_UP 6
@@ -138,12 +137,31 @@ enum DnDState
DnDStart
};
+typedef enum
+{
+ ExpoAnimationZoom = 0,
+ ExpoAnimationFadeZoom,
+ ExpoAnimationVortex,
+ ExpoAnimationNum
+} ExpoAnimation;
+
+#define WALL_EXPO_ANIMATION_DEFAULT ExpoAnimationZoom
+
+static char *expoAnimationName[] = {
+ N_("Zoom"),
+ N_("Fade + Zoom"),
+ N_("Vortex")
+};
+
typedef struct _WallDisplay
{
int screenPrivateIndex;
HandleEventProc handleEvent;
CompOption opt[WALL_DISPLAY_OPTION_NUM];
+
+ ExpoAnimation expoAnimationType;
+
} WallDisplay;
typedef struct _WallScreen
@@ -216,6 +234,12 @@ typedef struct _WallWindow
int origy;
} WallWindow;
+typedef struct _xyz_tuple
+{
+ float x, y, z;
+} Point3d;
+
+
/* Helpers */
#define GET_WALL_DISPLAY(d) \
((WallDisplay *) (d)->privates[displayPrivateIndex].ptr)
@@ -242,6 +266,10 @@ typedef struct _WallWindow
xid = getIntOptionNamed(option, nOption, "root", 0); \
s = findScreenAtDisplay(d, xid)
+#define sigmoid(x) (1.0f/(1.0f+exp(-5.5f*2*((x)-0.5))))
+#define sigmoidProgress(x) ((sigmoid(x) - sigmoid(0)) / \
+ (sigmoid(1) - sigmoid(0)))
+
static Bool wallCheckDestination(CompScreen * s, int destX, int destY)
{
if (s->x - destX < 0)
@@ -1275,6 +1303,43 @@ static void wallPaintTransformedScreen(CompScreen * s,
int origVX = s->x;
int origVY = s->y;
+ const float gapy = 0.01f; // amount of gap between viewports
+ const float gapx = 0.01f * s->height / s->width;
+
+ // Zoom animation stuff
+
+ Point3d vpCamPos = {0, 0, 0}; // camera position for the selected viewport
+ Point3d expoCamPos = {0, 0, 0}; // camera position during expo mode
+
+ vpCamPos.x = s->hsize * ((s->x + 0.5) / s->hsize - 0.5) + gapx * (s->x);
+ vpCamPos.y = -s->vsize * ((s->y + 0.5) / s->vsize - 0.5) - gapy * (s->y);
+ vpCamPos.z = 0;
+
+ float biasz = 0;
+ if (wd->opt[WALL_DISPLAY_OPTION_ROTATE].value.b)
+ biasz = MAX(s->hsize, s->vsize) * 0.15;
+
+ expoCamPos.x = gapx * (s->hsize - 1) * 0.5;
+ expoCamPos.y = -gapy * (s->vsize - 1) * 0.5;
+ expoCamPos.z = -DEFAULT_Z_CAMERA +
+ DEFAULT_Z_CAMERA * (MAX(s->hsize +
+ (s->hsize - 1) * gapx /
+ (s->width / s->outputDev[output].width),
+ s->vsize +
+ (s->vsize - 1) * gapy /
+ (s->height / s->outputDev[output].height))
+ + biasz);
+
+ float progress = sigmoidProgress(ws->expoCam);
+
+ // interpolate between vpCamPos and expoCamPos
+ float camx = vpCamPos.x * (1 - progress) + expoCamPos.x * progress;
+ float camy = vpCamPos.y * (1 - progress) + expoCamPos.y * progress;
+ float camz = vpCamPos.z * (1 - progress) + expoCamPos.z * progress;
+
+ // End of Zoom animation stuff
+
+
moveScreenViewport(s, s->x, s->y, FALSE);
WALL_DISPLAY(s->display);
@@ -1283,8 +1348,12 @@ static void wallPaintTransformedScreen(CompScreen * s,
float rotation = 0.0;
if (wd->opt[WALL_DISPLAY_OPTION_ROTATE].value.b)
- rotation = 10.0 * ws->expoCam;
-
+ {
+ if (wd->expoAnimationType == ExpoAnimationZoom)
+ rotation = 10.0 * sigmoidProgress(ws->expoCam);
+ else
+ rotation = 10.0 * ws->expoCam;
+ }
// ALL TRANSFORMATION ARE EXECUTED FROM BOTTOM TO TOP
@@ -1296,8 +1365,10 @@ static void wallPaintTransformedScreen(CompScreen * s,
matrixTranslate(&sTransform, 0.0f, 0.0f, -DEFAULT_Z_CAMERA);
// zoom out
- if (wd->opt[WALL_DISPLAY_OPTION_SIMPLE_ANIMATION].value.b)
+ if (wd->expoAnimationType == ExpoAnimationFadeZoom)
matrixTranslate(&sTransform, 0.0f, 0.0f, 1.0f - 1.2 * ws->expoCam);
+ else if (wd->expoAnimationType == ExpoAnimationZoom)
+ matrixTranslate(&sTransform, -camx, -camy, -camz);
else
matrixTranslate(&sTransform, 0.0f, 0.0f, -1.4f + 1.2 * ws->expoCam);
@@ -1311,17 +1382,19 @@ static void wallPaintTransformedScreen(CompScreen * s,
// rotate
matrixRotate(&sTransform, rotation, 0.0f, 1.0f, 0.0f);
-
- // scale that all viewports fit the screen
- float aspect = wd->opt[WALL_DISPLAY_OPTION_ASPECT].value.f;
- float scale = (1.0 / MAX(s->hsize, s->vsize)) * ws->expoCam;
- float scaleX =
- (aspect * scale) +
- ((1.0 - aspect) * ((1.0 / s->hsize) * ws->expoCam));
- float scaleY =
- (aspect * scale) +
- ((1.0 - aspect) * ((1.0 / s->vsize) * ws->expoCam));
- matrixScale(&sTransform, scaleX, scaleY, 1.0);
+ if (wd->expoAnimationType != ExpoAnimationZoom)
+ {
+ // scale that all viewports fit the screen
+ float aspect = wd->opt[WALL_DISPLAY_OPTION_ASPECT].value.f;
+ float scale = (1.0 / MAX(s->hsize, s->vsize)) * ws->expoCam;
+ float scaleX =
+ (aspect * scale) +
+ ((1.0 - aspect) * ((1.0 / s->hsize) * ws->expoCam));
+ float scaleY =
+ (aspect * scale) +
+ ((1.0 - aspect) * ((1.0 / s->vsize) * ws->expoCam));
+ matrixScale(&sTransform, scaleX, scaleY, 1.0);
+ }
// translate wall to center
matrixTranslate(&sTransform, -(s->width / s->outputDev[output].width) * s->hsize *
@@ -1346,7 +1419,7 @@ static void wallPaintTransformedScreen(CompScreen * s,
CompTransform sTransform2 = sTransform;
for (i = 0; i < s->hsize; i++)
{
- if (!wd->opt[WALL_DISPLAY_OPTION_SIMPLE_ANIMATION].value.b)
+ if (wd->expoAnimationType == ExpoAnimationVortex)
matrixRotate(&sTransform2, 360 * ws->expoCam, 0.0f, 1.0f,
2.0f * ws->expoCam);
@@ -1383,7 +1456,7 @@ static void wallPaintTransformedScreen(CompScreen * s,
// not sure this will work with different resolutions
- matrixTranslate(&sTransform2,(s->width / s->outputDev[output].width + 0.01),
+ matrixTranslate(&sTransform2,(s->width / s->outputDev[output].width + gapx),
0.0f, 0.0);
moveScreenViewport(s, -1, 0, FALSE);
@@ -1391,7 +1464,7 @@ static void wallPaintTransformedScreen(CompScreen * s,
// not sure this will work with different resolutions
matrixTranslate(&sTransform, 0,
- (-s->height / s->outputDev[output].height - 0.01f),
+ (-s->height / s->outputDev[output].height - gapy),
0.0f);
moveScreenViewport(s, 0, -1, FALSE);
@@ -1472,6 +1545,7 @@ wallDrawWindow(CompWindow * w,
Region region, unsigned int mask)
{
WALL_SCREEN(w->screen);
+ WALL_DISPLAY(w->screen->display);
Bool status;
FragmentAttrib pA = *attrib;
@@ -1481,21 +1555,35 @@ wallDrawWindow(CompWindow * w,
if (ws->expoActive)
{
- pA.opacity = attrib->opacity * ws->expoCam;
+ if (wd->expoAnimationType == ExpoAnimationZoom)
+ pA.opacity = attrib->opacity;
+ else
+ pA.opacity = attrib->opacity * ws->expoCam;
+
if (w == ws->stickyWindow)
pA.opacity = 0;
if (w->wmType & CompWindowTypeDockMask)
- pA.opacity = 0;
-
- pA.brightness = OPAQUE * .75;
+ {
+ if (wd->expoAnimationType == ExpoAnimationZoom &&
+ ((w->screen->x == ws->origVX &&
+ w->screen->y == ws->origVY) ||
+ (w->screen->x == ws->rorigx &&
+ w->screen->y == ws->rorigy &&
+ ws->origVY < 0 &&
+ ws->origVX < 0)))
+ pA.opacity = OPAQUE * (1 - sigmoidProgress(ws->expoCam));
+ else
+ pA.opacity = 0;
+ }
+ pA.brightness = BRIGHT * .75;
if (w->screen->x == ws->origVX && w->screen->y == ws->origVY)
{
- pA.brightness = OPAQUE;
+ pA.brightness = BRIGHT;
}
if (w->screen->x == ws->rorigx && w->screen->y == ws->rorigy &&
ws->origVY < 0 && ws->origVX < 0)
{
- pA.brightness = OPAQUE;
+ pA.brightness = BRIGHT;
}
/*
* FIXME: Bugged with windows intersecting more than one border
@@ -1509,8 +1597,13 @@ wallDrawWindow(CompWindow * w,
else
{
if (!(w == ws->stickyWindow))
- pA.brightness =
- attrib->brightness * (1.0 - (0.99 * ws->expoCam));
+ {
+ if (wd->expoAnimationType == ExpoAnimationZoom)
+ pA.brightness = attrib->brightness * 0.01;
+ else
+ pA.brightness =
+ attrib->brightness * (1.0 - (0.99 * ws->expoCam));
+ }
}
}
@@ -1683,7 +1776,7 @@ static void wallDisplayInitOptions(WallDisplay * wd)
o->group = N_("Misc. Settings");
o->subGroup = N_("");
o->displayHints = "";
- o->shortDesc = N_("Rotate wall");
+ o->shortDesc = N_("Rotate Wall");
o->longDesc = N_("Rotate wall in expo mode");
o->type = CompOptionTypeBool;
o->value.b = WALL_ROTATE_DEFAULT;
@@ -1694,7 +1787,7 @@ static void wallDisplayInitOptions(WallDisplay * wd)
o->group = N_("Misc. Settings");
o->subGroup = N_("");
o->displayHints = "";
- o->shortDesc = N_("Wall sliding duration");
+ o->shortDesc = N_("Wall Sliding Duration");
o->longDesc = N_("Duration (in seconds) for wall sliding viewport "
"switching animation");
o->type = CompOptionTypeFloat;
@@ -1703,16 +1796,18 @@ static void wallDisplayInitOptions(WallDisplay * wd)
o->rest.f.min = WALL_SLIDE_DURATION_MIN;
o->rest.f.precision = WALL_SLIDE_DURATION_PRECISION;
- o = &wd->opt[WALL_DISPLAY_OPTION_SIMPLE_ANIMATION];
- o->advanced = False;
- o->name = "simple";
+ o = &wd->opt[WALL_DISPLAY_OPTION_EXPO_ANIMATION];
+ o->name = "expo_animation";
o->group = N_("Misc. Settings");
o->subGroup = N_("");
+ o->advanced = False;
+ o->shortDesc = N_("Expo Animation");
+ o->longDesc = N_("Animation used when switching to expo mode.");
o->displayHints = "";
- o->shortDesc = N_("Simple expo animation.");
- o->longDesc = N_("Simple animation when switching to expo mode.");
- o->type = CompOptionTypeBool;
- o->value.b = WALL_DISPLAY_OPTION_SIMPLE_ANIMATION_DEFAULT;
+ o->type = CompOptionTypeString;
+ o->value.s = strdup(expoAnimationName[WALL_EXPO_ANIMATION_DEFAULT]);
+ o->rest.s.string = expoAnimationName;
+ o->rest.s.nString = ExpoAnimationNum;
o = &wd->opt[WALL_DISPLAY_OPTION_STICKY];
o->advanced = False;
@@ -1736,7 +1831,7 @@ static void wallDisplayInitOptions(WallDisplay * wd)
o = &wd->opt [WALL_DISPLAY_OPTION_##UPPER]; \
o->advanced = False; \
o->name = #LOWERCASE; \
- o->group = N_("Viewport switching"); \
+ o->group = N_("Viewport Switching"); \
o->subGroup = N_(""); \
o->displayHints = ""; \
o->shortDesc = N_("Move "#LOWERCASE); \
@@ -1778,10 +1873,10 @@ static void wallDisplayInitOptions(WallDisplay * wd)
o = &wd->opt [WALL_DISPLAY_OPTION_WINDOW_##UPPER]; \
o->advanced = False; \
o->name = "wall_window_"#LOWERCASE; \
- o->group = N_("Viewport switching"); \
+ o->group = N_("Viewport Switching"); \
o->subGroup = N_(""); \
o->displayHints = ""; \
- o->shortDesc = N_("Move with window "#LOWERCASE); \
+ o->shortDesc = N_("Move With Window "#LOWERCASE); \
o->longDesc = N_("Move with window along the wall "#LOWERCASE); \
o->type = CompOptionTypeAction; \
o->value.action.initiate = wall##LOWERCASE##WithWindow; \
@@ -1802,10 +1897,10 @@ static void wallDisplayInitOptions(WallDisplay * wd)
o = &wd->opt[WALL_DISPLAY_OPTION_WHEEL_UP];
o->advanced = False;
o->name = "wall_up_wheel";
- o->group = N_("Viewport switching");
+ o->group = N_("Viewport Switching");
o->subGroup = N_("");
o->displayHints = "";
- o->shortDesc = N_("Mousewheel up");
+ o->shortDesc = N_("Mousewheel Up");
o->longDesc = N_("Mousewheel up");
o->type = CompOptionTypeAction;
o->value.action.initiate = wallUpWheel;
@@ -1820,11 +1915,11 @@ static void wallDisplayInitOptions(WallDisplay * wd)
o = &wd->opt[WALL_DISPLAY_OPTION_WHEEL_DOWN];
o->advanced = False;
o->name = "wall_down_wheel";
- o->group = N_("Viewport switching");
+ o->group = N_("Viewport Switching");
o->subGroup = N_("");
o->displayHints = "";
- o->shortDesc = N_("Mousewheel down");
- o->longDesc = N_("Mousehwheel down");
+ o->shortDesc = N_("Mousewheel Down");
+ o->longDesc = N_("Mousewheel down");
o->type = CompOptionTypeAction;
o->value.action.initiate = wallDownWheel;
o->value.action.terminate = 0;
@@ -1852,7 +1947,7 @@ static void wallDisplayInitOptions(WallDisplay * wd)
o->group = N_("Misc. Settings");
o->subGroup = N_("");
o->displayHints = "";
- o->shortDesc = N_("Expo mode aspect ratio");
+ o->shortDesc = N_("Expo Mode Aspect Ratio");
o->longDesc = N_("Expo mode wall aspect ratio");
o->type = CompOptionTypeFloat;
o->value.f = WALL_ASPECT_DEFAULT;
@@ -1863,10 +1958,10 @@ static void wallDisplayInitOptions(WallDisplay * wd)
o = &wd->opt[WALL_DISPLAY_OPTION_MINISCREEN];
o->advanced = False;
o->name = "miniscreen";
- o->group = N_("Viewport switching");
+ o->group = N_("Viewport Switching");
o->subGroup = N_("");
o->displayHints = "";
- o->shortDesc = N_("Show viewport previews");
+ o->shortDesc = N_("Show Viewport Previews");
o->longDesc = N_("Show viewport previews in switch window");
o->type = CompOptionTypeBool;
o->value.b = WALL_MINISCREEN_DEFAULT;
@@ -1874,10 +1969,10 @@ static void wallDisplayInitOptions(WallDisplay * wd)
o = &wd->opt[WALL_DISPLAY_OPTION_PREVIEW_TIMEOUT];
o->advanced = False;
o->name = "preview_timeout";
- o->group = N_("Viewport switching");
+ o->group = N_("Viewport Switching");
o->subGroup = N_("");
o->displayHints = "";
- o->shortDesc = N_("Switch target preview visibility time");
+ o->shortDesc = N_("Switch Target Preview Visibility Time");
o->longDesc = N_("Duration (in seconds) the switch target preview should remain"
"visible after switching ends.");
o->type = CompOptionTypeFloat;
@@ -1938,7 +2033,6 @@ wallSetDisplayOption(CompDisplay * d, char *name, CompOptionValue * value)
return TRUE;
break;
case WALL_DISPLAY_OPTION_ROTATE:
- case WALL_DISPLAY_OPTION_SIMPLE_ANIMATION:
case WALL_DISPLAY_OPTION_MIPMAPS:
case WALL_DISPLAY_OPTION_MINISCREEN:
if (compSetBoolOption(o, value))
@@ -1950,6 +2044,20 @@ wallSetDisplayOption(CompDisplay * d, char *name, CompOptionValue * value)
if (compSetFloatOption(o, value))
return TRUE;
break;
+ case WALL_DISPLAY_OPTION_EXPO_ANIMATION:
+ if (compSetStringOption(o, value))
+ {
+ int i;
+ for (i = 0; i < ExpoAnimationNum; i++)
+ {
+ if (strcmp(o->value.s, expoAnimationName[i]) == 0)
+ {
+ wd->expoAnimationType = i;
+ return TRUE;
+ }
+ }
+ }
+ break;
default:
break;
}
@@ -1972,6 +2080,8 @@ static Bool wallInitDisplay(CompPlugin * p, CompDisplay * d)
return FALSE;
}
+ wd->expoAnimationType = WALL_EXPO_ANIMATION_DEFAULT;
+
wallDisplayInitOptions(wd);
WRAP(wd, d, handleEvent, wallHandleEvent);
@@ -2055,6 +2165,8 @@ static void wallFiniScreen(CompPlugin * p, CompScreen * s)
WALL_SCREEN(s);
WALL_DISPLAY(s->display);
+ free(wd->opt[WALL_DISPLAY_OPTION_EXPO_ANIMATION].value.s);
+
removeScreenAction(s, &wd->opt[WALL_DISPLAY_OPTION_EXPO].value.action);
UNWRAP(ws, s, paintScreen);