Implement animations
Squashed all the stuff: init Update README.md options performance Animation no longer jumps if started in the middle of an animation Doubled default transition length Minor bugfix, preformance Track x and y separately to aviod jumping in mid-animation repositioning Added video to readme docs docs fixed graphical glitch with non-transparent windows now animates window scaling too (but only if the window grows) added options for size transitions and actually respect the new options.. and actually respect the new options.. added center-spawn option added center-spawn-screen option fixed center spawn added no-scale-down goofed remember old windows remember old windows docs fixed shadow fixed shadow fixed shadow fixed shadow lost no-scale-down due to revert lost spawn-center due to revert Fixed #2 fix missing window borders
This commit is contained in:
committed by
Martin T. H. Sandsmark
parent
fd6ff8264c
commit
51fdb8bcaa
103
src/event.c
103
src/event.c
@@ -202,6 +202,106 @@ static void configure_win(session_t *ps, xcb_configure_notify_event_t *ce) {
|
||||
|
||||
auto mw = (struct managed_win *)w;
|
||||
|
||||
float t = get_time_ms();
|
||||
if (mw->oldX == -10000 && mw->oldY == -10000 && mw->oldW == 0 && mw->oldH == 0) {
|
||||
if (!mw->isOld) {
|
||||
/* mw->isOld = true; */
|
||||
|
||||
if (ps->o.spawn_center_screen) {
|
||||
mw->oldX = ps->root_width/2;
|
||||
mw->oldY = ps->root_height/2;
|
||||
mw->oldW = 1;
|
||||
mw->oldH = 1;
|
||||
} else if (ps->o.spawn_center) {
|
||||
mw->oldX = ce->x + ce->width/2;
|
||||
mw->oldY = ce->y + ce->height/2;
|
||||
mw->oldW = 1;
|
||||
mw->oldH = 1;
|
||||
} else {
|
||||
mw->oldX = ce->x;
|
||||
mw->oldY = ce->y;
|
||||
mw->oldW = ce->width;
|
||||
mw->oldH = ce->height;
|
||||
}
|
||||
} else {
|
||||
mw->oldX = ce->x;
|
||||
mw->oldY = ce->y;
|
||||
mw->oldW = ce->width;
|
||||
mw->oldH = ce->height;
|
||||
}
|
||||
|
||||
mw->newX = ce->x;
|
||||
mw->newY = ce->y;
|
||||
mw->newW = ce->width;
|
||||
mw->newH = ce->height;
|
||||
mw->moveTimeX = t;
|
||||
mw->moveTimeY = t;
|
||||
mw->moveTimeW = t;
|
||||
mw->moveTimeH = t;
|
||||
} else {
|
||||
if (mw->newX == mw->g.x && mw->newY == mw->g.y) {
|
||||
mw->oldX = mw->g.x;
|
||||
mw->oldY = mw->g.y;
|
||||
mw->oldW = mw->g.width;
|
||||
mw->oldH = mw->g.height;
|
||||
mw->moveTimeX = t;
|
||||
mw->moveTimeY = t;
|
||||
mw->moveTimeW = t;
|
||||
mw->moveTimeH = t;
|
||||
}
|
||||
if (mw->newX != ce->x || mw->newY != ce->y || mw->newW != ce->width || mw->newH != ce->height) {
|
||||
float moveDx = ((float) t - mw->moveTimeX) / ps->o.transition_length;
|
||||
float moveDy = ((float) t - mw->moveTimeY) / ps->o.transition_length;
|
||||
float moveDw = ((float) t - mw->moveTimeW) / ps->o.transition_length;
|
||||
float moveDh = ((float) t - mw->moveTimeH) / ps->o.transition_length;
|
||||
|
||||
if (mw->moveTimeX != 0.0 && moveDx < 1.0 && mw->oldX != mw->newX) {
|
||||
float oldMoveDx = pow((float) (mw->newX - mw->g.x) / (float) (mw->newX - ce->x), 1 / ps->o.transition_pow_x);
|
||||
float fakeT = (t - oldMoveDx * (float) ps->o.transition_length);
|
||||
/* printf("X: %f,%f\n", fakeT, t); */
|
||||
mw->moveTimeX = isnanf(fakeT)? t : fakeT;
|
||||
} else {
|
||||
mw->moveTimeX = t;
|
||||
}
|
||||
if (mw->moveTimeY != 0.0 && moveDy < 1.0 && mw->oldY != mw->newY) {
|
||||
float oldMoveDy = pow((float) (mw->newY - mw->g.y) / (float) (mw->newY - ce->y), 1 / ps->o.transition_pow_y);
|
||||
float fakeT = (t - oldMoveDy * (float) ps->o.transition_length);
|
||||
/* printf("Y: %f,%f\n", fakeT, t); */
|
||||
mw->moveTimeY = isnanf(fakeT)? t : fakeT;
|
||||
} else {
|
||||
mw->moveTimeY = t;
|
||||
}
|
||||
if (mw->moveTimeW != 0.0 && moveDw < 1.0 && mw->oldW != mw->newW) {
|
||||
float oldMoveDw = pow((float) (mw->newW - mw->g.width) / (float) (mw->newW - ce->width), 1 / ps->o.transition_pow_w);
|
||||
float fakeT = (t - oldMoveDw * (float) ps->o.transition_length);
|
||||
/* printf("Y: %f,%f\n", fakeT, t); */
|
||||
mw->moveTimeW = isnanf(fakeT)? t : fakeT;
|
||||
} else {
|
||||
mw->moveTimeW = t;
|
||||
}
|
||||
if (mw->moveTimeH != 0.0 && moveDh < 1.0 && mw->oldH != mw->newH) {
|
||||
float oldMoveDh = pow((float) (mw->newH - mw->g.height) / (float) (mw->newH - ce->height), 1 / ps->o.transition_pow_h);
|
||||
float fakeT = (t - oldMoveDh * (float) ps->o.transition_length);
|
||||
/* printf("Y: %f,%f\n", fakeT, t); */
|
||||
mw->moveTimeH = isnanf(fakeT)? t : fakeT;
|
||||
} else {
|
||||
mw->moveTimeH = t;
|
||||
}
|
||||
|
||||
mw->oldX = mw->newX;
|
||||
mw->oldY = mw->newY;
|
||||
mw->oldW = mw->newW;
|
||||
mw->oldH = mw->newH;
|
||||
mw->newX = ce->x;
|
||||
mw->newY = ce->y;
|
||||
mw->newW = ce->width;
|
||||
mw->newH = ce->height;
|
||||
|
||||
if (ps->o.no_scale_down && mw->newW < mw->oldW) { mw->oldW = mw->newW; }
|
||||
if (ps->o.no_scale_down && mw->newH < mw->oldH) { mw->oldH = mw->newH; }
|
||||
}
|
||||
}
|
||||
|
||||
if (mw->state == WSTATE_UNMAPPED || mw->state == WSTATE_UNMAPPING ||
|
||||
mw->state == WSTATE_DESTROYING) {
|
||||
// Only restack the window to make sure we can handle future restack
|
||||
@@ -218,9 +318,6 @@ static void configure_win(session_t *ps, xcb_configure_notify_event_t *ce) {
|
||||
factor_change = true;
|
||||
}
|
||||
|
||||
mw->g.x = ce->x;
|
||||
mw->g.y = ce->y;
|
||||
|
||||
if (mw->g.width != ce->width || mw->g.height != ce->height ||
|
||||
mw->g.border_width != ce->border_width) {
|
||||
log_trace("Window size changed, %dx%d -> %dx%d", mw->g.width,
|
||||
|
||||
Reference in New Issue
Block a user