summaryrefslogtreecommitdiff
path: root/beryl-plugins/src/rotate.c
diff options
context:
space:
mode:
authormaniac <maniac@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2006-11-23 13:58:59 +0000
committermaniac <maniac@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2006-11-23 13:58:59 +0000
commit1d380f54b3ac5058ed9a0d172223bf8b1baf1654 (patch)
treedd75d0a2fa070354a811535876728b99c59cb958 /beryl-plugins/src/rotate.c
parent83f098080e95bbe1053190402546c0f0e501257d (diff)
downloadmarex-dev-1d380f54b3ac5058ed9a0d172223bf8b1baf1654.tar.gz
marex-dev-1d380f54b3ac5058ed9a0d172223bf8b1baf1654.tar.bz2
rotate plugin: code cleanup
- don't cache option values where unneeded - reduce code duplication git-svn-id: file:///beryl/trunk@1391 d7aaf104-2d23-0410-ae22-9d23157bf5a3
Diffstat (limited to 'beryl-plugins/src/rotate.c')
-rw-r--r--beryl-plugins/src/rotate.c629
1 files changed, 170 insertions, 459 deletions
diff --git a/beryl-plugins/src/rotate.c b/beryl-plugins/src/rotate.c
index 41cf937..769ed5c 100644
--- a/beryl-plugins/src/rotate.c
+++ b/beryl-plugins/src/rotate.c
@@ -175,8 +175,6 @@ typedef struct _RotateDisplay
CompOption opt[ROTATE_DISPLAY_OPTION_NUM];
- int flipTime;
- int wheelings;
unsigned int leftWheelings, rightWheelings;
} RotateDisplay;
@@ -207,15 +205,10 @@ typedef struct _RotateScreen
CompOption opt[ROTATE_SCREEN_OPTION_NUM];
- Bool pointerInvertY;
float pointerSensitivity;
Bool snapTop;
Bool snapBottom;
- float acceleration;
- float speed;
- float timestep;
- float mantimestep;
float zoom;
int grabIndex;
@@ -233,8 +226,6 @@ typedef struct _RotateScreen
GLfloat moveTo;
Bool zooming;
Bool rotating;
- Bool zoomBeforeRotate;
- Bool zoomOnInitiateOnly;
Bool movingVert;
GLfloat moveToY;
@@ -252,9 +243,6 @@ typedef struct _RotateScreen
unsigned int grabMask;
CompWindow *grabWindow;
- Bool wheelOnEdges;
- int wheelMaxDist;
-
int previousRotationAtom;
} RotateScreen;
@@ -288,11 +276,11 @@ rotateSetScreenOption (CompScreen * screen,
switch (index)
{
case ROTATE_SCREEN_OPTION_POINTER_INVERT_Y:
+ case ROTATE_SCREEN_OPTION_ZOOM_BEFORE_ROTATE:
+ case ROTATE_SCREEN_OPTION_ZOOM_ONLY_ON_INITIATE:
+ case ROTATE_SCREEN_OPTION_WHEEL_ON_EDGES:
if (compSetBoolOption (o, value))
- {
- rs->pointerInvertY = o->value.b;
return TRUE;
- }
break;
case ROTATE_SCREEN_OPTION_POINTER_SENSITIVITY:
if (compSetFloatOption (o, value))
@@ -302,13 +290,6 @@ rotateSetScreenOption (CompScreen * screen,
return TRUE;
}
break;
- case ROTATE_SCREEN_OPTION_ACCELERATION:
- if (compSetFloatOption (o, value))
- {
- rs->acceleration = o->value.f;
- return TRUE;
- }
- break;
case ROTATE_SCREEN_OPTION_SNAP_TOP:
if (compSetBoolOption (o, value))
{
@@ -323,26 +304,12 @@ rotateSetScreenOption (CompScreen * screen,
return TRUE;
}
break;
+ case ROTATE_SCREEN_OPTION_ACCELERATION:
case ROTATE_SCREEN_OPTION_SPEED:
- if (compSetFloatOption (o, value))
- {
- rs->speed = o->value.f;
- return TRUE;
- }
- break;
case ROTATE_SCREEN_OPTION_TIMESTEP:
- if (compSetFloatOption (o, value))
- {
- rs->timestep = o->value.f;
- return TRUE;
- }
- break;
case ROTATE_SCREEN_OPTION_MANTIMESTEP:
if (compSetFloatOption (o, value))
- {
- rs->mantimestep = o->value.f;
return TRUE;
- }
break;
case ROTATE_SCREEN_OPTION_ZOOM:
if (compSetFloatOption (o, value))
@@ -361,33 +328,9 @@ rotateSetScreenOption (CompScreen * screen,
return TRUE;
}
break;
- case ROTATE_SCREEN_OPTION_ZOOM_BEFORE_ROTATE:
- if (compSetBoolOption (o, value))
- {
- rs->zoomBeforeRotate = o->value.b;
- return TRUE;
- }
- break;
- case ROTATE_SCREEN_OPTION_ZOOM_ONLY_ON_INITIATE:
- if (compSetBoolOption (o, value))
- {
- rs->zoomOnInitiateOnly = o->value.b;
- return TRUE;
- }
- break;
- case ROTATE_SCREEN_OPTION_WHEEL_ON_EDGES:
- if (compSetBoolOption (o, value))
- {
- rs->wheelOnEdges = o->value.b;
- return TRUE;
- }
- break;
case ROTATE_SCREEN_OPTION_WHEELMAXDIST:
if (compSetIntOption (o, value))
- {
- rs->wheelMaxDist = o->value.i;
return TRUE;
- }
default:
break;
}
@@ -551,7 +494,7 @@ adjustVelocity (RotateScreen * rs, int size)
xrot = rs->xrot - 360.0f / size;
}
- adjust = -xrot * 0.05f * rs->acceleration;
+ adjust = -xrot * 0.05f * rs->opt[ROTATE_SCREEN_OPTION_ACCELERATION].value.f;
amount = fabs (xrot);
if (amount < 10.0f)
amount = 10.0f;
@@ -577,7 +520,7 @@ adjustVelocity (RotateScreen * rs, int size)
yrot = rs->yrot;
}
- adjust = -yrot * 0.05f * rs->acceleration;
+ adjust = -yrot * 0.05f * rs->opt[ROTATE_SCREEN_OPTION_ACCELERATION].value.f;
amount = fabs (rs->yrot);
if (amount < 10.0f)
amount = 10.0f;
@@ -610,9 +553,8 @@ rotatePreparePaintScreen (CompScreen * s, int msSinceLastPaint)
ROTATE_SCREEN (s);
Bool performZooming = FALSE;
- if (rs->zooming &&
- (!otherScreenGrabExist (s, "rotate", 0) ||
- (rs->zoomTranslate != 0.0f && rs->zoomTranslate != rs->zoom)))
+ if (rs->zooming && (!otherScreenGrabExist (s, "rotate", 0) ||
+ (rs->zoomTranslate != 0.0f && rs->zoomTranslate != rs->zoom)))
performZooming = TRUE;
if (rs->grabIndex || rs->moving || rs->movingVert)
@@ -620,18 +562,17 @@ rotatePreparePaintScreen (CompScreen * s, int msSinceLastPaint)
int steps, stepsCount;
float amount, chunk;
- amount = msSinceLastPaint * 0.05f * rs->speed;
- if (rs->grabbed)
- {
- steps = stepsCount = amount / (0.5f * rs->mantimestep);
- } else {
- steps = stepsCount = amount / (0.5f * rs->timestep);
- }
+ amount = msSinceLastPaint * 0.05f * rs->opt[ROTATE_SCREEN_OPTION_SPEED].value.f;
+ steps = stepsCount = amount / (0.5f * (rs->grabbed ?
+ rs->opt[ROTATE_SCREEN_OPTION_MANTIMESTEP].value.f :
+ rs->opt[ROTATE_SCREEN_OPTION_TIMESTEP].value.f));
+
if (!steps)
steps = stepsCount = 1;
chunk = amount / (float)steps;
- if (performZooming && rs->zoomBeforeRotate && rs->rotating)
+ if (performZooming &&
+ rs->opt[ROTATE_SCREEN_OPTION_ZOOM_BEFORE_ROTATE].value.b && rs->rotating)
{
steps = stepsCount;
@@ -739,15 +680,14 @@ rotatePreparePaintScreen (CompScreen * s, int msSinceLastPaint)
rs->xrot = 0.0f;
rs->yrot = 0.0f;
rs->baseXrot = rs->moveTo = 0.0f;
- rs->moving = FALSE;
+ rs->baseYrot = rs->moveToY = 0.0f;
+ rs->moving = FALSE;
rs->movingVert = FALSE;
- rs->baseYrot = rs->moveToY = 0.0f;
if (rs->grabIndex)
{
- removeScreenGrab (s, rs->grabIndex,
- &rs->savedPointer);
+ removeScreenGrab (s, rs->grabIndex, &rs->savedPointer);
rs->grabIndex = 0;
}
@@ -758,8 +698,7 @@ rotatePreparePaintScreen (CompScreen * s, int msSinceLastPaint)
w = findWindowAtScreen (s, rs->moveWindow);
if (w)
{
- moveWindow (w, rs->moveWindowX - w->attrib.x, 0,
- TRUE, TRUE);
+ moveWindow (w, rs->moveWindowX - w->attrib.x, 0, TRUE, TRUE);
syncWindowPosition (w);
}
}
@@ -781,9 +720,7 @@ rotatePreparePaintScreen (CompScreen * s, int msSinceLastPaint)
{
float xrot = (s->hsize * (rs->baseXrot + rs->xrot)) / 360.0f;
- moveWindowToViewportPosition (w,
- rs->moveWindowX -
- xrot * s->width, FALSE);
+ moveWindowToViewportPosition (w, rs->moveWindowX - xrot * s->width, FALSE);
}
}
}
@@ -793,59 +730,17 @@ rotatePreparePaintScreen (CompScreen * s, int msSinceLastPaint)
else
rs->rotating = TRUE;
- if (FALSE && performZooming && !rs->zoomBeforeRotate
- && (rs->rotating || rs->zoomTranslate != 0.0f) && rs->moveTo == 0.0
- && rs->moveToY == 0.0)
- {
- int steps, stepsCount;
- float amount, chunk;
-
- amount = msSinceLastPaint * 0.05f * rs->speed;
- steps = stepsCount = amount / (0.5f * rs->timestep);
- if (!steps)
- steps = stepsCount = 1;
- chunk = amount / (float)steps;
-
- while (steps--)
- {
- float dt, adjust, tamount;
- if (rs->rotating && rs->grabbed)
- dt = rs->zoom - 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->rotating)
- rs->zoomTranslate = rs->zoom;
- else
- rs->zoomTranslate = 0.0f;
- break;
- }
- rs->zoomTranslate += rs->zoomVelocity * chunk;
- }
- }
-
- if (performZooming && !rs->zoomBeforeRotate
+ if (performZooming && !rs->opt[ROTATE_SCREEN_OPTION_ZOOM_BEFORE_ROTATE].value.b
&& (rs->rotating || rs->zoomTranslate != 0.0f)
- && (!rs->zoomOnInitiateOnly || (rs->zoomOnInitiateOnly && (rs->grabbed || rs->zoomTranslate != 0.0f))))
+ && !(rs->opt[ROTATE_SCREEN_OPTION_ZOOM_ONLY_ON_INITIATE].value.b && !(rs->grabbed
+ || rs->zoomTranslate != 0.0f)))
{
int steps, stepsCount;
float amount, chunk;
- amount = msSinceLastPaint * 0.05f * rs->speed;
- steps = stepsCount = amount / (0.5f * rs->timestep);
+ 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;
@@ -897,14 +792,14 @@ rotatePreparePaintScreen (CompScreen * s, int msSinceLastPaint)
}
}
- if (performZooming && rs->zoomBeforeRotate && !rs->rotating
- && rs->zoomTranslate != 0.0f && rs->yrot == 0.0f)
+ if (performZooming && rs->opt[ROTATE_SCREEN_OPTION_ZOOM_BEFORE_ROTATE].value.b
+ && !rs->rotating && rs->zoomTranslate != 0.0f && rs->yrot == 0.0f)
{
int steps, stepsCount;
float amount, chunk;
- amount = msSinceLastPaint * 0.05f * rs->speed;
- steps = stepsCount = amount / (0.5f * rs->timestep);
+ 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;
@@ -1347,27 +1242,39 @@ pointerNearScreenEdge (CompScreen * s,
}
static Bool
-rotateLeftWheel (CompDisplay * d,
- CompAction * action,
- CompActionState state, CompOption * option, int nOption)
+rotateWheel (CompDisplay * d, int direction, CompOption * option, int nOption)
{
ROTATE_DISPLAY (d);
- CompScreen *s =
- findScreenAtDisplay (d,
+ CompScreen *s = findScreenAtDisplay (d,
getIntOptionNamed (option, nOption, "root", 0));
if (s)
{
ROTATE_SCREEN (s);
int x, y;
+ unsigned int *wheelings;
+
+ if (direction == -1)
+ {
+ wheelings = &rd->rightWheelings;
+ rd->leftWheelings = 0;
+ }
+ else
+ {
+ wheelings = &rd->leftWheelings;
+ rd->rightWheelings = 0;
+ }
+
x = getIntOptionNamed (option, nOption, "x", 0);
y = getIntOptionNamed (option, nOption, "y", 0);
- rd->rightWheelings = 0;
+
if (pointerOnlyOnDesktop (s, x, y)
- || (rs->wheelOnEdges && pointerNearScreenEdge (s, x, y, rs->wheelMaxDist)))
+ || (rs->opt[ROTATE_SCREEN_OPTION_WHEEL_ON_EDGES].value.b
+ && pointerNearScreenEdge (s, x, y,
+ rs->opt[ROTATE_SCREEN_OPTION_WHEELMAXDIST].value.i)))
{
- if (++(rd->leftWheelings) == rd->wheelings)
+ if (++(*wheelings) == rd->opt[ROTATE_DISPLAY_OPTION_WHEELINGS].value.i)
{
- rd->leftWheelings = 0;
+ *wheelings = 0;
CompOption o[4];
@@ -1385,75 +1292,37 @@ rotateLeftWheel (CompDisplay * d,
o[3].type = CompOptionTypeInt;
o[3].name = "direction";
- o[3].value.i = 1;
+ o[3].value.i = direction;
rotate (d, NULL, 0, o, 4);
}
}
else
- rd->leftWheelings = 0;
+ *wheelings = 0;
}
return FALSE;
}
static Bool
+rotateLeftWheel (CompDisplay * d,
+ CompAction * action,
+ CompActionState state, CompOption * option, int nOption)
+{
+ return rotateWheel (d, 1, option, nOption);
+}
+
+static Bool
rotateRightWheel (CompDisplay * d,
CompAction * action,
CompActionState state, CompOption * option, int nOption)
{
- ROTATE_DISPLAY (d);
- CompScreen *s =
- findScreenAtDisplay (d,
- getIntOptionNamed (option, nOption, "root", 0));
- if (s)
- {
- ROTATE_SCREEN (s);
- int x, y;
- x = getIntOptionNamed (option, nOption, "x", 0);
- y = getIntOptionNamed (option, nOption, "y", 0);
- rd->leftWheelings = 0;
- if (pointerOnlyOnDesktop (s, x, y)
- || (rs->wheelOnEdges && pointerNearScreenEdge (s, x, y, rs->wheelMaxDist)))
- {
- if (++(rd->rightWheelings) == rd->wheelings)
- {
- rd->rightWheelings = 0;
-
- CompOption o[4];
-
- o[0].type = CompOptionTypeInt;
- o[0].name = "x";
- o[0].value.i = getIntOptionNamed (option, nOption, "x", 0);
-
- o[1].type = CompOptionTypeInt;
- o[1].name = "y";
- o[1].value.i = getIntOptionNamed (option, nOption, "y", 0);
-
- o[2].type = CompOptionTypeInt;
- o[2].name = "root";
- o[2].value.i = getIntOptionNamed (option, nOption, "root", 0);
-
- o[3].type = CompOptionTypeInt;
- o[3].name = "direction";
- o[3].value.i = -1;
-
- rotate (d, NULL, 0, o, 4);
- }
-
- }
- else
- rd->rightWheelings = 0;
- }
-
- return FALSE;
+ return rotateWheel (d, -1, option, nOption);
}
-
static Bool
-rotateLeft (CompDisplay * d,
- CompAction * action,
- CompActionState state, CompOption * option, int nOption)
+rotateReal (CompDisplay * d, Bool vert, int direction,
+ CompOption * option, int nOption)
{
CompOption o[4];
@@ -1471,39 +1340,30 @@ rotateLeft (CompDisplay * d,
o[3].type = CompOptionTypeInt;
o[3].name = "direction";
- o[3].value.i = -1;
+ o[3].value.i = direction;
- rotate (d, NULL, 0, o, 4);
+ if (vert)
+ rotateVert (d, NULL, 0, o, 4);
+ else
+ rotate (d, NULL, 0, o, 4);
return FALSE;
}
static Bool
+rotateLeft (CompDisplay * d,
+ CompAction * action,
+ CompActionState state, CompOption * option, int nOption)
+{
+ return rotateReal (d, FALSE, -1, option, nOption);
+}
+
+static Bool
rotateRight (CompDisplay * d,
CompAction * action,
CompActionState state, CompOption * option, int nOption)
{
- CompOption o[4];
-
- o[0].type = CompOptionTypeInt;
- o[0].name = "x";
- o[0].value.i = getIntOptionNamed (option, nOption, "x", 0);
-
- o[1].type = CompOptionTypeInt;
- o[1].name = "y";
- o[1].value.i = getIntOptionNamed (option, nOption, "y", 0);
-
- o[2].type = CompOptionTypeInt;
- o[2].name = "root";
- o[2].value.i = getIntOptionNamed (option, nOption, "root", 0);
-
- o[3].type = CompOptionTypeInt;
- o[3].name = "direction";
- o[3].value.i = 1;
-
- rotate (d, NULL, 0, o, 4);
-
- return FALSE;
+ return rotateReal (d, FALSE, 1, option, nOption);
}
static Bool
@@ -1511,27 +1371,7 @@ rotateTop (CompDisplay * d,
CompAction * action,
CompActionState state, CompOption * option, int nOption)
{
- CompOption o[4];
-
- o[0].type = CompOptionTypeInt;
- o[0].name = "x";
- o[0].value.i = getIntOptionNamed (option, nOption, "x", 0);
-
- o[1].type = CompOptionTypeInt;
- o[1].name = "y";
- o[1].value.i = getIntOptionNamed (option, nOption, "y", 0);
-
- o[2].type = CompOptionTypeInt;
- o[2].name = "root";
- o[2].value.i = getIntOptionNamed (option, nOption, "root", 0);
-
- o[3].type = CompOptionTypeInt;
- o[3].name = "direction";
- o[3].value.i = 1;
-
- rotateVert (d, NULL, 0, o, 4);
-
- return FALSE;
+ return rotateReal (d, TRUE, 1, option, nOption);
}
static Bool
@@ -1539,33 +1379,11 @@ rotateDown (CompDisplay * d,
CompAction * action,
CompActionState state, CompOption * option, int nOption)
{
- CompOption o[4];
-
- o[0].type = CompOptionTypeInt;
- o[0].name = "x";
- o[0].value.i = getIntOptionNamed (option, nOption, "x", 0);
-
- o[1].type = CompOptionTypeInt;
- o[1].name = "y";
- o[1].value.i = getIntOptionNamed (option, nOption, "y", 0);
-
- o[2].type = CompOptionTypeInt;
- o[2].name = "root";
- o[2].value.i = getIntOptionNamed (option, nOption, "root", 0);
-
- o[3].type = CompOptionTypeInt;
- o[3].name = "direction";
- o[3].value.i = -1;
-
- rotateVert (d, NULL, 0, o, 4);
-
- return FALSE;
+ return rotateReal (d, TRUE, -1, option, nOption);
}
static Bool
-rotateLeftWithWindow (CompDisplay * d,
- CompAction * action,
- CompActionState state, CompOption * option, int nOption)
+rotateWithWindowReal (CompDisplay * d, int direction, CompOption * option, int nOption)
{
CompOption o[5];
@@ -1583,7 +1401,7 @@ rotateLeftWithWindow (CompDisplay * d,
o[3].type = CompOptionTypeInt;
o[3].name = "direction";
- o[3].value.i = -1;
+ o[3].value.i = direction;
o[4].type = CompOptionTypeInt;
o[4].name = "window";
@@ -1595,42 +1413,25 @@ rotateLeftWithWindow (CompDisplay * d,
}
static Bool
+rotateLeftWithWindow (CompDisplay * d,
+ CompAction * action,
+ CompActionState state, CompOption * option, int nOption)
+{
+ return rotateWithWindowReal (d, -1, option, nOption);
+}
+
+static Bool
rotateRightWithWindow (CompDisplay * d,
CompAction * action,
CompActionState state,
CompOption * option, int nOption)
{
- CompOption o[5];
-
- o[0].type = CompOptionTypeInt;
- o[0].name = "x";
- o[0].value.i = getIntOptionNamed (option, nOption, "x", 0);
-
- o[1].type = CompOptionTypeInt;
- o[1].name = "y";
- o[1].value.i = getIntOptionNamed (option, nOption, "y", 0);
-
- o[2].type = CompOptionTypeInt;
- o[2].name = "root";
- o[2].value.i = getIntOptionNamed (option, nOption, "root", 0);
-
- o[3].type = CompOptionTypeInt;
- o[3].name = "direction";
- o[3].value.i = 1;
-
- o[4].type = CompOptionTypeInt;
- o[4].name = "window";
- o[4].value.i = getIntOptionNamed (option, nOption, "window", 0);
-
- rotateWithWindow (d, NULL, 0, o, 5);
-
- return FALSE;
+ return rotateWithWindowReal (d, 1, option, nOption);
}
static Bool
-rotateFlipLeft (void *closure)
+rotateFlip (CompScreen * s, int direction)
{
- CompScreen *s = closure;
int warpX;
CompOption o[4];
@@ -1642,9 +1443,19 @@ rotateFlipLeft (void *closure)
if (otherScreenGrabExist (s, "rotate", "move", 0))
return FALSE;
- warpX = s->display->pointerX + s->width;
- warpPointer (s->display, s->width - 10, 0);
- s->display->lastPointerX = warpX;
+ if (direction == 1)
+ {
+ //rotation to right
+ warpX = s->display->pointerX - s->width;
+ warpPointer (s->display, 10 - s->width, 0);
+ s->display->lastPointerX = warpX;
+ }
+ else
+ {
+ warpX = s->display->pointerX + s->width;
+ warpPointer (s->display, s->width - 10, 0);
+ s->display->lastPointerX = warpX;
+ }
o[0].type = CompOptionTypeInt;
o[0].name = "x";
@@ -1660,12 +1471,16 @@ rotateFlipLeft (void *closure)
o[3].type = CompOptionTypeInt;
o[3].name = "direction";
- o[3].value.i = -1;
+ o[3].value.i = direction;
rotate (s->display, NULL, 0, o, 4);
- XWarpPointer (s->display->display, None, None, 0, 0, 0, 0, -1, 0);
- rs->savedPointer.x = s->display->lastPointerX - 9;
+ XWarpPointer (s->display->display, None, None, 0, 0, 0, 0, direction, 0);
+
+ if (direction == 1)
+ rs->savedPointer.x = s->display->lastPointerX + 9;
+ else
+ rs->savedPointer.x = s->display->lastPointerX - 9;
rs->rotateHandle = 0;
@@ -1673,49 +1488,19 @@ rotateFlipLeft (void *closure)
}
static Bool
-rotateFlipRight (void *closure)
+rotateFlipLeft (void *closure)
{
CompScreen *s = closure;
- int warpX;
- CompOption o[4];
-
- ROTATE_SCREEN (s);
- rs->moveTo = 0.0f;
- rs->slow = FALSE;
-
- if (otherScreenGrabExist (s, "rotate", "move", 0))
- return FALSE;
-
- warpX = s->display->pointerX - s->width;
- warpPointer (s->display, 10 - s->width, 0);
- s->display->lastPointerX = warpX;
-
- o[0].type = CompOptionTypeInt;
- o[0].name = "x";
- o[0].value.i = 0;
-
- o[1].type = CompOptionTypeInt;
- o[1].name = "y";
- o[1].value.i = s->display->pointerY;
-
- o[2].type = CompOptionTypeInt;
- o[2].name = "root";
- o[2].value.i = s->root;
-
- o[3].type = CompOptionTypeInt;
- o[3].name = "direction";
- o[3].value.i = 1;
-
- rotate (s->display, NULL, 0, o, 4);
-
- XWarpPointer (s->display->display, None, None, 0, 0, 0, 0, 1, 0);
-
- rs->savedPointer.x = s->display->lastPointerX + 9;
+ return rotateFlip (s, -1);
+}
- rs->rotateHandle = 0;
+static Bool
+rotateFlipRight (void *closure)
+{
+ CompScreen *s = closure;
- return FALSE;
+ return rotateFlip (s, 1);
}
static void
@@ -1725,8 +1510,10 @@ rotateEdgeFlip (CompScreen * s,
CompActionState state, CompOption * option, int nOption)
{
CompOption o[4];
+ int direction;
ROTATE_DISPLAY (s->display);
+ ROTATE_SCREEN (s);
if (s->hsize < 2)
return;
@@ -1744,8 +1531,6 @@ rotateEdgeFlip (CompScreen * s,
}
else if (screenGrabExist (s, "move", 0))
{
- ROTATE_SCREEN (s);
-
if (!rd->opt[ROTATE_DISPLAY_OPTION_EDGEFLIP_WINDOW].value.b)
return;
@@ -1779,82 +1564,52 @@ rotateEdgeFlip (CompScreen * s,
o[3].name = "direction";
if (edge == SCREEN_EDGE_LEFT)
- {
- ROTATE_SCREEN (s);
-
- if (rd->flipTime == 0 || (rs->moving && !rs->slow))
- {
- int pointerDx = s->display->pointerX - s->display->lastPointerX;
- int warpX;
+ direction = -1;
+ else
+ direction = 1;
+ if (rd->opt[ROTATE_DISPLAY_OPTION_FLIPTIME].value.i == 0 || (rs->moving && !rs->slow))
+ {
+ int pointerDx, warpX;
+ if (edge == SCREEN_EDGE_LEFT)
+ {
+ pointerDx = s->display->pointerX - s->display->lastPointerX;
warpX = s->display->pointerX + s->width;
warpPointer (s->display, s->width - 10, 0);
s->display->lastPointerX = warpX - pointerDx;
-
- o[3].value.i = -1;
-
- rotate (s->display, NULL, 0, o, 4);
-
- XWarpPointer (s->display->display, None, None, 0, 0, 0, 0, -1, 0);
- rs->savedPointer.x = s->display->lastPointerX - 9;
- }
- else
- {
- if (!rs->rotateHandle)
- rs->rotateHandle =
- compAddTimeout (rd->flipTime, rotateFlipLeft, s);
-
- rs->moving = TRUE;
- rs->moveTo -= 360.0f / s->hsize;
- rs->slow = TRUE;
-
- if (state & CompActionStateInitEdge)
- action->state |= CompActionStateTermEdge;
-
- if (state & CompActionStateInitEdgeDnd)
- action->state |= CompActionStateTermEdgeDnd;
-
- damageScreen (s);
- }
- }
- else
- {
- ROTATE_SCREEN (s);
-
- if (rd->flipTime == 0 || (rs->moving && !rs->slow))
- {
- int pointerDx = s->display->pointerX - s->display->lastPointerX;
- int warpX;
-
+ }
+ else
+ {
+ pointerDx = s->display->pointerX - s->display->lastPointerX;
warpX = s->display->pointerX - s->width;
warpPointer (s->display, 10 - s->width, 0);
s->display->lastPointerX = warpX - pointerDx;
+ }
- o[3].value.i = 1;
+ o[3].value.i = direction;
+ rotate (s->display, NULL, 0, o, 4);
- rotate (s->display, NULL, 0, o, 4);
-
- XWarpPointer (s->display->display, None, None, 0, 0, 0, 0, 1, 0);
- rs->savedPointer.x = s->display->lastPointerX + 9;
- }
- else
- {
- if (!rs->rotateHandle)
- rs->rotateHandle =
- compAddTimeout (rd->flipTime, rotateFlipRight, s);
+ XWarpPointer (s->display->display, None, None, 0, 0, 0, 0, direction, 0);
+ rs->savedPointer.x = s->display->lastPointerX + (direction * 9);
+ }
+ else
+ {
+ if (!rs->rotateHandle)
+ rs->rotateHandle = compAddTimeout (
+ rd->opt[ROTATE_DISPLAY_OPTION_FLIPTIME].value.i,
+ (edge == SCREEN_EDGE_LEFT) ? rotateFlipLeft : rotateFlipRight, s);
- rs->moving = TRUE;
- rs->moveTo += 360.0f / s->hsize;
- rs->slow = TRUE;
+ rs->moving = TRUE;
+ rs->moveTo += (direction * 360.0f / s->hsize);
+ rs->slow = TRUE;
- if (state & CompActionStateInitEdge)
- action->state |= CompActionStateTermEdge;
+ if (state & CompActionStateInitEdge)
+ action->state |= CompActionStateTermEdge;
- if (state & CompActionStateInitEdgeDnd)
- action->state |= CompActionStateTermEdgeDnd;
+ if (state & CompActionStateInitEdgeDnd)
+ action->state |= CompActionStateTermEdgeDnd;
- damageScreen (s);
- }
+ damageScreen (s);
}
}
@@ -2094,7 +1849,7 @@ rotateHandleEvent (CompDisplay * d, XEvent * event)
(s->height / 2) - d->pointerY);
}
- if (rs->pointerInvertY)
+ if (rs->opt[ROTATE_SCREEN_OPTION_POINTER_INVERT_Y].value.b)
pointerDy = -pointerDy;
rs->xVelocity += pointerDx * rs->pointerSensitivity *
@@ -2350,11 +2105,9 @@ rotateSetDisplayOption (CompDisplay * display,
return TRUE;
break;
case ROTATE_DISPLAY_OPTION_WHEELINGS:
+ case ROTATE_DISPLAY_OPTION_FLIPTIME:
if (compSetIntOption (o, value))
- {
- rd->wheelings = o->value.i;
return TRUE;
- }
break;
case ROTATE_DISPLAY_OPTION_TO:
case ROTATE_DISPLAY_OPTION_WINDOW:
@@ -2367,12 +2120,6 @@ rotateSetDisplayOption (CompDisplay * display,
if (compSetBoolOption (o, value))
return TRUE;
break;
- case ROTATE_DISPLAY_OPTION_FLIPTIME:
- if (compSetIntOption (o, value))
- {
- rd->flipTime = o->value.i;
- return TRUE;
- }
default:
break;
}
@@ -2719,9 +2466,6 @@ rotateInitDisplay (CompPlugin * p, CompDisplay * d)
return FALSE;
}
- rd->flipTime = ROTATE_FLIPTIME_DEFAULT;
-
- rd->wheelings = ROTATE_WHEELINGS_DEFAULT;
rd->leftWheelings = 0;
rd->rightWheelings = 0;
@@ -2786,25 +2530,13 @@ rotateInitScreen (CompPlugin * p, CompScreen * s)
rs->grabMask = FALSE;
rs->grabWindow = NULL;
- rs->acceleration = ROTATE_ACCELERATION_DEFAULT;
-
- rs->pointerInvertY = ROTATE_POINTER_INVERT_Y_DEFAULT;
rs->pointerSensitivity = ROTATE_POINTER_SENSITIVITY_DEFAULT *
ROTATE_POINTER_SENSITIVITY_FACTOR;
- rs->speed = ROTATE_SPEED_DEFAULT;
- rs->timestep = ROTATE_TIMESTEP_DEFAULT;
- rs->mantimestep = ROTATE_MANTIMESTEP_DEFAULT;
-
rs->zoom = ROTATE_ZOOM_DEFAULT / 30.0f;
rs->zooming = (ROTATE_ZOOM_DEFAULT > 0.05f) ? TRUE : FALSE;
rs->zoomTranslate = 0.0f;
rs->zoomVelocity = 0.0f;
- rs->zoomBeforeRotate = ROTATE_ZOOM_BEFORE_ROTATE_DEFAULT;
- rs->zoomOnInitiateOnly = FALSE;
-
- rs->wheelOnEdges = ROTATE_WHEEL_ON_EDGES_DEFAULT;
- rs->wheelMaxDist = ROTATE_WHEELMAXDIST_DEFAULT;
rs->rotateHandle = 0;
rs->rotating = FALSE;
@@ -2814,28 +2546,17 @@ rotateInitScreen (CompPlugin * p, CompScreen * s)
rotateScreenInitOptions (rs);
- addScreenAction (s,
- &rd->opt[ROTATE_DISPLAY_OPTION_INITIATE].value.action);
+ addScreenAction (s, &rd->opt[ROTATE_DISPLAY_OPTION_INITIATE].value.action);
addScreenAction (s, &rd->opt[ROTATE_DISPLAY_OPTION_LEFT].value.action);
addScreenAction (s, &rd->opt[ROTATE_DISPLAY_OPTION_RIGHT].value.action);
addScreenAction (s, &rd->opt[ROTATE_DISPLAY_OPTION_UP].value.action);
addScreenAction (s, &rd->opt[ROTATE_DISPLAY_OPTION_DOWN].value.action);
- addScreenAction (s,
- &rd->opt[ROTATE_DISPLAY_OPTION_LEFT_WINDOW].value.
- action);
- addScreenAction (s,
- &rd->opt[ROTATE_DISPLAY_OPTION_RIGHT_WINDOW].value.
- action);
- addScreenAction (s,
- &rd->opt[ROTATE_DISPLAY_OPTION_FLIP_LEFT].value.action);
- addScreenAction (s,
- &rd->opt[ROTATE_DISPLAY_OPTION_FLIP_RIGHT].value.action);
- addScreenAction (s,
- &rd->opt[ROTATE_DISPLAY_OPTION_LEFT_WHEEL].value.action);
- addScreenAction (s,
- &rd->opt[ROTATE_DISPLAY_OPTION_RIGHT_WHEEL].value.
- action);
-
+ addScreenAction (s, &rd->opt[ROTATE_DISPLAY_OPTION_LEFT_WINDOW].value.action);
+ addScreenAction (s, &rd->opt[ROTATE_DISPLAY_OPTION_RIGHT_WINDOW].value.action);
+ addScreenAction (s, &rd->opt[ROTATE_DISPLAY_OPTION_FLIP_LEFT].value.action);
+ addScreenAction (s, &rd->opt[ROTATE_DISPLAY_OPTION_FLIP_RIGHT].value.action);
+ addScreenAction (s, &rd->opt[ROTATE_DISPLAY_OPTION_LEFT_WHEEL].value.action);
+ addScreenAction (s, &rd->opt[ROTATE_DISPLAY_OPTION_RIGHT_WHEEL].value.action);
WRAP (rs, s, preparePaintScreen, rotatePreparePaintScreen);
WRAP (rs, s, donePaintScreen, rotateDonePaintScreen);
@@ -2864,27 +2585,17 @@ rotateFiniScreen (CompPlugin * p, CompScreen * s)
UNWRAP (rs, s, windowGrabNotify);
UNWRAP (rs, s, windowUngrabNotify);
- removeScreenAction (s,
- &rd->opt[ROTATE_DISPLAY_OPTION_INITIATE].value.action);
+ removeScreenAction (s, &rd->opt[ROTATE_DISPLAY_OPTION_INITIATE].value.action);
removeScreenAction (s, &rd->opt[ROTATE_DISPLAY_OPTION_LEFT].value.action);
removeScreenAction (s, &rd->opt[ROTATE_DISPLAY_OPTION_RIGHT].value.action);
removeScreenAction (s, &rd->opt[ROTATE_DISPLAY_OPTION_UP].value.action);
removeScreenAction (s, &rd->opt[ROTATE_DISPLAY_OPTION_DOWN].value.action);
- removeScreenAction (s,
- &rd->opt[ROTATE_DISPLAY_OPTION_LEFT_WINDOW].value.
- action);
- removeScreenAction (s,
- &rd->opt[ROTATE_DISPLAY_OPTION_RIGHT_WINDOW].value.
- action);
- removeScreenAction (s,
- &rd->opt[ROTATE_DISPLAY_OPTION_FLIP_LEFT].value.action);
- removeScreenAction (s,
- &rd->opt[ROTATE_DISPLAY_OPTION_FLIP_RIGHT].value.action);
- removeScreenAction (s,
- &rd->opt[ROTATE_DISPLAY_OPTION_LEFT_WHEEL].value.action);
- removeScreenAction (s,
- &rd->opt[ROTATE_DISPLAY_OPTION_RIGHT_WHEEL].value.
- action);
+ removeScreenAction (s, &rd->opt[ROTATE_DISPLAY_OPTION_LEFT_WINDOW].value.action);
+ removeScreenAction (s, &rd->opt[ROTATE_DISPLAY_OPTION_RIGHT_WINDOW].value.action);
+ removeScreenAction (s, &rd->opt[ROTATE_DISPLAY_OPTION_FLIP_LEFT].value.action);
+ removeScreenAction (s, &rd->opt[ROTATE_DISPLAY_OPTION_FLIP_RIGHT].value.action);
+ removeScreenAction (s, &rd->opt[ROTATE_DISPLAY_OPTION_LEFT_WHEEL].value.action);
+ removeScreenAction (s, &rd->opt[ROTATE_DISPLAY_OPTION_RIGHT_WHEEL].value.action);
free (rs);
}