summaryrefslogtreecommitdiff
path: root/beryl-plugins/src/wobbly.c
diff options
context:
space:
mode:
authorquinn <quinn@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2006-11-24 23:38:53 +0000
committerquinn <quinn@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2006-11-24 23:38:53 +0000
commit9166f0b686fd229f94d2c6f06f0fe59b05598275 (patch)
tree18479e0c97e36d2b37a13eed6103550ee592b99c /beryl-plugins/src/wobbly.c
parent8e30f24d9ee0fd36eb7c2ec33e818a4e832643de (diff)
downloadmarex-dev-9166f0b686fd229f94d2c6f06f0fe59b05598275.tar.gz
marex-dev-9166f0b686fd229f94d2c6f06f0fe59b05598275.tar.bz2
beryl-core, beryl-plugins:
-merge in the "unfinished updates" branch git-svn-id: file:///beryl/trunk@1420 d7aaf104-2d23-0410-ae22-9d23157bf5a3
Diffstat (limited to 'beryl-plugins/src/wobbly.c')
-rw-r--r--beryl-plugins/src/wobbly.c179
1 files changed, 41 insertions, 138 deletions
diff --git a/beryl-plugins/src/wobbly.c b/beryl-plugins/src/wobbly.c
index b119535..db2906d 100644
--- a/beryl-plugins/src/wobbly.c
+++ b/beryl-plugins/src/wobbly.c
@@ -277,7 +277,6 @@ typedef struct _WobblyScreen
AddWindowGeometryProc addWindowGeometry;
DrawWindowGeometryProc drawWindowGeometry;
DrawWindowTextureProc drawWindowTexture;
- SetWindowScaleProc setWindowScale;
WindowResizeNotifyProc windowResizeNotify;
WindowMoveNotifyProc windowMoveNotify;
@@ -1424,10 +1423,7 @@ modelAddSpring (Model * model,
static void
modelSetMiddleAnchor (Model * model, int x, int y, int width, int height)
{
- float gx, gy, x0, y0;
-
- x0 = model->scaleOrigin.x;
- y0 = model->scaleOrigin.y;
+ float gx, gy;
gx = ((GRID_WIDTH - 1) / 2 * width) / (float)(GRID_WIDTH - 1);
gy = ((GRID_HEIGHT - 1) / 2 * height) / (float)(GRID_HEIGHT - 1);
@@ -1438,8 +1434,8 @@ modelSetMiddleAnchor (Model * model, int x, int y, int width, int height)
model->anchorObject = &model->objects[GRID_WIDTH *
((GRID_HEIGHT - 1) / 2) +
(GRID_WIDTH - 1) / 2];
- model->anchorObject->position.x = x + (gx - x0) * model->scale.x + x0;
- model->anchorObject->position.y = y + (gy - y0) * model->scale.y + y0;
+ model->anchorObject->position.x = x + gx;
+ model->anchorObject->position.y = y + gy;
model->anchorObject->immobile = TRUE;
}
@@ -1448,29 +1444,25 @@ static void
modelAddEdgeAnchors (Model * model, int x, int y, int width, int height)
{
Object *o;
- float x0, y0;
-
- x0 = model->scaleOrigin.x;
- y0 = model->scaleOrigin.y;
o = &model->objects[0];
- o->position.x = x + (0 - x0) * model->scale.x + x0;
- o->position.y = y + (0 - y0) * model->scale.y + y0;
+ o->position.x = x;
+ o->position.y = y;
o->immobile = TRUE;
o = &model->objects[GRID_WIDTH - 1];
- o->position.x = x + (width - x0) * model->scale.x + x0;
- o->position.y = y + (0 - y0) * model->scale.y + y0;
+ o->position.x = x + width;
+ o->position.y = y;
o->immobile = TRUE;
o = &model->objects[GRID_WIDTH * (GRID_HEIGHT - 1)];
- o->position.x = x + (0 - x0) * model->scale.x + x0;
- o->position.y = y + (height - y0) * model->scale.y + y0;
+ o->position.x = x;
+ o->position.y = y + height;
o->immobile = TRUE;
o = &model->objects[model->numObjects - 1];
- o->position.x = x + (width - x0) * model->scale.x + x0;
- o->position.y = y + (height - y0) * model->scale.y + y0;
+ o->position.x = x + width;
+ o->position.y = y + height;
o->immobile = TRUE;
if (!model->anchorObject)
@@ -1481,32 +1473,28 @@ static void
modelRemoveEdgeAnchors (Model * model, int x, int y, int width, int height)
{
Object *o;
- float x0, y0;
-
- x0 = model->scaleOrigin.x;
- y0 = model->scaleOrigin.y;
o = &model->objects[0];
- o->position.x = x + (0 - x0) * model->scale.x + x0;
- o->position.y = y + (0 - y0) * model->scale.y + y0;
+ o->position.x = x;
+ o->position.y = y;
if (o != model->anchorObject)
o->immobile = FALSE;
o = &model->objects[GRID_WIDTH - 1];
- o->position.x = x + (width - x0) * model->scale.x + x0;
- o->position.y = y + (0 - y0) * model->scale.y + y0;
+ o->position.x = x + width;
+ o->position.y = y;
if (o != model->anchorObject)
o->immobile = FALSE;
o = &model->objects[GRID_WIDTH * (GRID_HEIGHT - 1)];
- o->position.x = x + (0 - x0) * model->scale.x + x0;
- o->position.y = y + (height - y0) * model->scale.y + y0;
+ o->position.x = x;
+ o->position.y = y + height;
if (o != model->anchorObject)
o->immobile = FALSE;
o = &model->objects[model->numObjects - 1];
- o->position.x = x + (width - x0) * model->scale.x + x0;
- o->position.y = y + (height - y0) * model->scale.y + y0;
+ o->position.x = x + width;
+ o->position.y = y + height;
if (o != model->anchorObject)
o->immobile = FALSE;
}
@@ -1517,12 +1505,8 @@ modelAdjustObjectPosition (Model * model,
int x, int y, int width, int height)
{
Object *o;
- float x0, y0;
int gridX, gridY, i = 0;
- x0 = model->scaleOrigin.x;
- y0 = model->scaleOrigin.y;
-
for (gridY = 0; gridY < GRID_HEIGHT; gridY++)
{
for (gridX = 0; gridX < GRID_WIDTH; gridX++)
@@ -1530,12 +1514,8 @@ modelAdjustObjectPosition (Model * model,
o = &model->objects[i];
if (o == object)
{
- o->position.x = x +
- (((gridX * width) / (GRID_WIDTH - 1)) - x0) *
- model->scale.x + x0;
- o->position.y = y +
- (((gridY * height) / (GRID_HEIGHT - 1)) - y0) *
- model->scale.y + y0;
+ o->position.x = x + (gridX * width) / (GRID_WIDTH - 1);
+ o->position.y = y + (gridY * height) / (GRID_HEIGHT - 1);
return;
}
@@ -1549,10 +1529,7 @@ static void
modelInitObjects (Model * model, int x, int y, int width, int height)
{
int gridX, gridY, i = 0;
- float gw, gh, x0, y0;
-
- x0 = model->scaleOrigin.x;
- y0 = model->scaleOrigin.y;
+ float gw, gh;
gw = GRID_WIDTH - 1;
gh = GRID_HEIGHT - 1;
@@ -1562,10 +1539,9 @@ modelInitObjects (Model * model, int x, int y, int width, int height)
for (gridX = 0; gridX < GRID_WIDTH; gridX++)
{
objectInit (&model->objects[i],
- x + (((gridX * width) / gw) - x0) *
- model->scale.x + x0,
- y + (((gridY * height) / gh) - y0) *
- model->scale.y + y0, 0, 0);
+ x + (gridX * width) / gw,
+ y + (gridY * height) / gh,
+ 0, 0);
i++;
}
}
@@ -1702,8 +1678,8 @@ modelAdjustObjectsForShiver (Model * model,
float scale;
float w, h;
- w = (float)width *model->scale.x;
- h = (float)height *model->scale.y;
+ w = width;
+ h = height;
for (gridY = 0; gridY < GRID_HEIGHT; gridY++)
{
@@ -1736,8 +1712,8 @@ modelInitSprings (Model * model, int x, int y, int width, int height)
model->numSprings = 0;
- hpad = ((float)width * model->scale.x) / (GRID_WIDTH - 1);
- vpad = ((float)height * model->scale.y) / (GRID_HEIGHT - 1);
+ hpad = ((float)width) / (GRID_WIDTH - 1);
+ vpad = ((float)height) / (GRID_HEIGHT - 1);
for (gridY = 0; gridY < GRID_HEIGHT; gridY++)
{
@@ -1792,14 +1768,6 @@ createModel (int x, int y, int width, int height, unsigned int edgeMask)
model->steps = 0;
- model->scale.x = 1.0f;
- model->scale.y = 1.0f;
-
- model->scaleOrigin.x = 0.0f;
- model->scaleOrigin.y = 0.0f;
-
- model->transformed = FALSE;
-
memset (model->snapCnt, 0, sizeof (model->snapCnt));
model->edgeMask = edgeMask;
@@ -2276,14 +2244,11 @@ wobblyPreparePaintScreen (CompScreen * s, int msSinceLastPaint)
if (ws->wobblyWindows & (WobblyInitial | WobblyVelocity))
{
- REGION region;
+ BoxRec box;
Point topLeft, bottomRight;
float friction, springK;
Model *model;
- region.rects = &region.extents;
- region.numRects = region.size = 1;
-
ws->wobblyWindows = 0;
for (w = s->windows; w; w = w->next)
{
@@ -2318,7 +2283,7 @@ wobblyPreparePaintScreen (CompScreen * s, int msSinceLastPaint)
ww->wobbly |= WobblyInitial;
}
}
- else if (!ww->model->transformed)
+ else
{
ww->model = NULL;
@@ -2347,12 +2312,17 @@ wobblyPreparePaintScreen (CompScreen * s, int msSinceLastPaint)
else
addWindowDamage (w);
- region.extents.x1 = topLeft.x;
- region.extents.y1 = topLeft.y;
- region.extents.x2 = bottomRight.x + 0.5f;
- region.extents.y2 = bottomRight.y + 0.5f;
+ box.x1 = topLeft.x;
+ box.y1 = topLeft.y;
+ box.x2 = bottomRight.x + 0.5f;
+ box.y2 = bottomRight.y + 0.5f;
+
+ box.x1 -= w->attrib.x + w->attrib.border_width;
+ box.y1 -= w->attrib.y + w->attrib.border_width;
+ box.x2 -= w->attrib.x + w->attrib.border_width;
+ box.y2 -= w->attrib.y + w->attrib.border_width;
- damageScreenRegion (s, &region);
+ addWindowDamageRect (w, &box);
}
}
@@ -2598,35 +2568,6 @@ wobblyDrawWindowGeometry (CompWindow * w)
}
}
-static void
-wobblyDrawWindowTexture (CompWindow *w,
- CompTexture *texture,
- const WindowPaintAttrib *attrib,
- unsigned int mask)
-{
- WOBBLY_SCREEN (w->screen);
- WOBBLY_WINDOW (w);
-
- if (ww->wobbly)
- {
- WindowPaintAttrib wAttrib = *attrib;
-
- /* remove scale that is applied at the add geometry stage */
- wAttrib.xScale = attrib->xScale / ww->model->scale.x;
- wAttrib.yScale = attrib->yScale / ww->model->scale.y;
-
- UNWRAP (ws, w->screen, drawWindowTexture);
- (*w->screen->drawWindowTexture) (w, texture, &wAttrib, mask);
- WRAP (ws, w->screen, drawWindowTexture, wobblyDrawWindowTexture);
- }
- else
- {
- UNWRAP (ws, w->screen, drawWindowTexture);
- (*w->screen->drawWindowTexture) (w, texture, attrib, mask);
- WRAP (ws, w->screen, drawWindowTexture, wobblyDrawWindowTexture);
- }
-}
-
static Bool
wobblyPaintWindow (CompWindow * w,
const WindowPaintAttrib * attrib,
@@ -3084,40 +3025,6 @@ wobblyDamageWindowRect (CompWindow * w, Bool initial, BoxPtr rect)
}
static void
-wobblySetWindowScale (CompWindow * w, float xScale, float yScale)
-{
- WOBBLY_WINDOW (w);
- WOBBLY_SCREEN (w->screen);
-
- UNWRAP (ws, w->screen, setWindowScale);
- (*w->screen->setWindowScale) (w, xScale, yScale);
- WRAP (ws, w->screen, setWindowScale, wobblySetWindowScale);
-
- if (wobblyEnsureModel (w))
- {
- if (ww->model->scale.x != xScale || ww->model->scale.y != yScale)
- {
- ww->model->scale.x = xScale;
- ww->model->scale.y = yScale;
-
- ww->model->scaleOrigin.x = w->output.left;
- ww->model->scaleOrigin.y = w->output.top;
-
- modelInitObjects (ww->model,
- WIN_X (w), WIN_Y (w), WIN_W (w), WIN_H (w));
-
- modelInitSprings (ww->model,
- WIN_X (w), WIN_Y (w), WIN_W (w), WIN_H (w));
- }
-
- if (ww->model->scale.x != 1.0f || ww->model->scale.y != 1.0f)
- ww->model->transformed = 1;
- else
- ww->model->transformed = 0;
- }
-}
-
-static void
wobblyWindowResizeNotify (CompWindow * w)
{
WOBBLY_SCREEN (w->screen);
@@ -3614,8 +3521,6 @@ wobblyInitScreen (CompPlugin * p, CompScreen * s)
WRAP (ws, s, damageWindowRect, wobblyDamageWindowRect);
WRAP (ws, s, addWindowGeometry, wobblyAddWindowGeometry);
WRAP (ws, s, drawWindowGeometry, wobblyDrawWindowGeometry);
- WRAP (ws, s, drawWindowTexture, wobblyDrawWindowTexture);
- WRAP (ws, s, setWindowScale, wobblySetWindowScale);
WRAP (ws, s, windowResizeNotify, wobblyWindowResizeNotify);
WRAP (ws, s, windowMoveNotify, wobblyWindowMoveNotify);
WRAP (ws, s, windowGrabNotify, wobblyWindowGrabNotify);
@@ -3643,8 +3548,6 @@ wobblyFiniScreen (CompPlugin * p, CompScreen * s)
UNWRAP (ws, s, damageWindowRect);
UNWRAP (ws, s, addWindowGeometry);
UNWRAP (ws, s, drawWindowGeometry);
- UNWRAP (ws, s, drawWindowTexture);
- UNWRAP (ws, s, setWindowScale);
UNWRAP (ws, s, windowResizeNotify);
UNWRAP (ws, s, windowMoveNotify);
UNWRAP (ws, s, windowGrabNotify);