summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Frank Erikson <kristian@kristian-desktop.(none)>2008-11-20 14:10:38 +1300
committerKristian Frank Erikson <kristian@kristian-desktop.(none)>2008-11-20 14:10:38 +1300
commit4de57960174db7eee8e74589cb218f528045f321 (patch)
tree87013bebc49700d6da7d11d24d682b663db1227e
parentb937e1bbb2caf03dea705ee544765fbf241b9076 (diff)
downloadcf-squeeze-4de57960174db7eee8e74589cb218f528045f321.tar.gz
cf-squeeze-4de57960174db7eee8e74589cb218f528045f321.tar.bz2
General code cleanup
-rw-r--r--squeeze.c183
1 files changed, 80 insertions, 103 deletions
diff --git a/squeeze.c b/squeeze.c
index b966afb..eed46e7 100644
--- a/squeeze.c
+++ b/squeeze.c
@@ -50,10 +50,6 @@
static int displayPrivateIndex;
-static int adjustSqueezeResize (CompWindow *w);
-
-static void squeezeDoWindowResize (CompDisplay *d, int newWidth, int newHeight);
-
typedef struct _SqueezeDisplay
{
int screenPrivateIndex;
@@ -64,7 +60,6 @@ typedef struct _SqueezeDisplay
Atom resizeInformationAtom;
CompWindow *w;
- XRectangle geometry;
} SqueezeDisplay;
@@ -110,22 +105,23 @@ resizeGetPaintRectangle (CompDisplay *d,
BoxPtr pBox)
{
SQUEEZE_DISPLAY (d);
+ SQUEEZE_WINDOW (sd->w);
+
+ // Very useful. Looks like sd->w->input.left is the left window border.
- pBox->x1 = sd->geometry.x - sd->w->input.left;
- pBox->y1 = sd->geometry.y - sd->w->input.top;
- pBox->x2 = sd->geometry.x +
- sd->geometry.width + sd->w->serverBorderWidth * 2 +
- sd->w->input.right;
+ pBox->x1 = sw->targetX + sd->w->input.left;
+ pBox->y1 = sw->targetY + sd->w->input.right;
+ pBox->x2 = sw->targetX + sw->lastWidth
+ + sd->w->serverBorderWidth * 2 + sd->w->input.right;
if (sd->w->shaded)
{
- pBox->y2 = sd->geometry.y + sd->w->height + sd->w->input.bottom;
+ pBox->y2 = sw->targetY + sd->w->height + sd->w->input.bottom;
}
else
{
- pBox->y2 = sd->geometry.y +
- sd->geometry.height + sd->w->serverBorderWidth * 2 +
- sd->w->input.bottom;
+ pBox->y2 = sw->targetY + sw->lastHeight
+ + sd->w->serverBorderWidth * 2 + sd->w->input.bottom;
}
}
@@ -171,12 +167,10 @@ adjustSqueezeResize (CompWindow *w)
if (percentComplete < 1)
{
-
sw->newWidth = (int) ((sw->targetWidth - sw->lastWidth)
* percentComplete) + sw->lastWidth;
sw->newHeight = (int) ((sw->targetHeight - sw->lastHeight)
- * percentComplete) + sw->lastHeight;
-
+ * percentComplete) + sw->lastHeight;
}
else
{
@@ -249,28 +243,18 @@ resizeUpdateWindowSize (CompDisplay *d)
SQUEEZE_WINDOW (sd->w);
-
- compLogMessage ("squeeze", CompLogLevelInfo,
- "sd->geometry.x is: %i", sd->geometry.x);
- compLogMessage ("squeeze", CompLogLevelInfo,
- "sw->targetX is: %i", sw->targetX);
- compLogMessage ("squeeze", CompLogLevelInfo,
- "sd->geometry.y is: %i", sd->geometry.y);
- compLogMessage ("squeeze", CompLogLevelInfo,
- "sw->targetY is: %i", sw->targetY);
-
if (sd->w->syncWait)
return;
- if (sd->w->serverWidth != sd->geometry.width ||
- sd->w->serverHeight != sd->geometry.height)
+ if (sd->w->serverWidth != sw->targetWidth ||
+ sd->w->serverHeight != sw->targetHeight)
{
XWindowChanges xwc;
xwc.x = sw->targetX;
xwc.y = sw->targetY;
- xwc.width = sd->geometry.width;
- xwc.height = sd->geometry.height;
+ xwc.width = sw->targetWidth;
+ xwc.height = sw->targetHeight;
sendSyncRequest (sd->w);
@@ -292,8 +276,8 @@ resizeUpdateWindowProperty (CompDisplay *d)
data[0] = sw->targetX;
data[1] = sw->targetY;
- data[2] = sd->geometry.width;
- data[3] = sd->geometry.height;
+ data[2] = sw->targetWidth;
+ data[3] = sw->targetHeight;
XChangeProperty (d->display, sd->w->id,
sd->resizeInformationAtom,
@@ -319,8 +303,8 @@ resizeSendResizeNotify (CompDisplay *d)
xev.xclient.data.l[0] = sw->targetX;
xev.xclient.data.l[1] = sw->targetY;
- xev.xclient.data.l[2] = sd->geometry.width;
- xev.xclient.data.l[3] = sd->geometry.height;
+ xev.xclient.data.l[2] = sw->targetWidth;
+ xev.xclient.data.l[3] = sw->targetHeight;
xev.xclient.data.l[4] = 0;
XSendEvent (d->display,
@@ -347,8 +331,6 @@ squeezeDoWindowResize (CompDisplay *d,
constrainNewWindowSize (sd->w, w, h, &w, &h);
- sd->geometry.width = w;
- sd->geometry.height = h;
resizeUpdateWindowSize (d);
resizeUpdateWindowProperty (d);
@@ -367,69 +349,70 @@ squeezePreparePaintScreen (CompScreen *s,
SQUEEZE_SCREEN (s);
if (ss->animationsActive && ss->grabIndex)
- {
- CompWindow *w;
- int steps;
- float amount, chunk;
-
- amount = msSinceLastPaint * 0.025f * squeezeGetSpeed (s);
- steps = amount / (0.5f * squeezeGetTimestep (s));
- if (!steps)
- steps = 1;
- chunk = amount / (float)steps;
-
- while (steps--)
- {
- Window endAnimationWindow = None;
-
- ss->animationsActive = 0;
- for (w = s->windows; w; w = w->next)
- {
- SQUEEZE_WINDOW (w);
-
- if (sw->putAnimActive)
- {
- sw->putAnimActive = adjustSqueezeVelocity (w);
- ss->animationsActive |= sw->putAnimActive;
+ {
+ CompWindow *w;
+ int steps;
+ float amount, chunk;
- sw->tx += sw->xVelocity * chunk;
- sw->ty += sw->yVelocity * chunk;
+ amount = msSinceLastPaint * 0.025f * squeezeGetSpeed (s);
+ steps = amount / (0.5f * squeezeGetTimestep (s));
+ if (!steps)
+ steps = 1;
+ chunk = amount / (float)steps;
- if (!sw->putAnimActive)
- {
- // animation done
- moveWindow (w, sw->targetX - w->attrib.x,
- sw->targetY - w->attrib.y, TRUE, TRUE);
- syncWindowPosition (w);
- updateWindowAttributes (w, CompStackingUpdateModeNone);
- endAnimationWindow = w->id;
- sw->tx = sw->ty = 0;
- }
- }
-
- // Do the resize animation
- if (sw->resizeAnimActive & !sw->putAnimActive)
- {
- sw->resizeAnimActive = adjustSqueezeResize (w);
-
- if (!sw->resizeAnimActive)
- {
- //If the animation is complete do the actual resize
- squeezeDoWindowResize(s->display,sw->newWidth,sw->newHeight);
- }
-
- // Make sure animation flag stays on
- ss->animationsActive |= sw->resizeAnimActive;
- }
+ while (steps--)
+ {
+ Window endAnimationWindow = None;
+
+ ss->animationsActive = 0;
+ for (w = s->windows; w; w = w->next)
+ {
+ SQUEEZE_WINDOW (w);
+
+ if (sw->putAnimActive)
+ {
+ sw->putAnimActive = adjustSqueezeVelocity (w);
+ ss->animationsActive |= sw->putAnimActive;
+
+ sw->tx += sw->xVelocity * chunk;
+ sw->ty += sw->yVelocity * chunk;
+
+ if (!sw->putAnimActive)
+ {
+ // animation done
+ moveWindow (w, sw->targetX - w->attrib.x,
+ sw->targetY - w->attrib.y, TRUE, TRUE);
+ syncWindowPosition (w);
+ updateWindowAttributes (w, CompStackingUpdateModeNone);
+ endAnimationWindow = w->id;
+ sw->tx = sw->ty = 0;
+ }
+ }
+
+ // Do the resize animation
+ if (sw->resizeAnimActive & !sw->putAnimActive)
+ {
+ sw->resizeAnimActive = adjustSqueezeResize (w);
+
+ if (!sw->resizeAnimActive)
+ {
+ //If the animation is complete do the actual resize
+ squeezeDoWindowResize(s->display,
+ sw->newWidth,sw->newHeight);
+ }
+
+ // Make sure animation flag stays on
+ ss->animationsActive |= sw->resizeAnimActive;
+ }
}
- if (!ss->animationsActive)
- {
- if (endAnimationWindow)
- sendWindowActivationRequest (s, endAnimationWindow);
- break;
+ if (!ss->animationsActive)
+ {
+ if (endAnimationWindow)
+ sendWindowActivationRequest (s, endAnimationWindow);
+ break;
}
- }
+ }
}
UNWRAP (ss, s, preparePaintScreen);
@@ -733,19 +716,13 @@ squeezeInitiateCommon (CompDisplay *d,
if (w->attrib.override_redirect)
return FALSE;
- // Save the window height, width and location for use later
- sd->geometry.x = w->serverX;
- sd->geometry.y = w->serverY;
- sd->geometry.width = w->serverWidth;
- sd->geometry.height = w->serverHeight;
-
//Set the animation flag
CompScreen *s = w->screen;
SQUEEZE_WINDOW (sd->w);
- sw->targetWidth = squeezeGetWidth (s) - sd->w->serverBorderWidth * 2.0f;
- sw->targetHeight = squeezeGetHeight (s) - sd->w->serverBorderWidth * 2.0f;
+ sw->targetWidth = squeezeGetWidth (s);
+ sw->targetHeight = squeezeGetHeight (s);
sw->lastWidth = w->serverWidth;
sw->lastHeight = w->serverHeight;