- if (iconifying) {
- if (self->iconify_animation_step == 0) /* wasnt doing anything */
- self->iconify_animation_step = FRAME_ANIMATE_ICONIFY_STEPS;
- else if (self->iconify_animation_step < 0) /* was deiconifying */
- self->iconify_animation_step =
- FRAME_ANIMATE_ICONIFY_STEPS + self->iconify_animation_step;
- } else {
- if (self->iconify_animation_step == 0) /* wasnt doing anything */
- self->iconify_animation_step = -FRAME_ANIMATE_ICONIFY_STEPS;
- else if (self->iconify_animation_step > 0) /* was iconifying */
- self->iconify_animation_step =
- -FRAME_ANIMATE_ICONIFY_STEPS + self->iconify_animation_step;
+ gulong time;
+ gboolean new_anim = FALSE;
+ gboolean set_end = TRUE;
+ GTimeVal now;
+
+ /* if there is no titlebar, just don't animate for now
+ XXX it would be nice tho.. */
+ if (!(self->decorations & OB_FRAME_DECOR_TITLEBAR))
+ return;
+
+ /* get the current time */
+ g_get_current_time(&now);
+
+ /* get how long until the end */
+ time = FRAME_ANIMATE_ICONIFY_TIME;
+ if (self->iconify_animation_going) {
+ if (!!iconifying != (self->iconify_animation_going > 0)) {
+ /* animation was already going on in the opposite direction */
+ time = time - frame_animate_iconify_time_left(self, &now);
+ } else
+ /* animation was already going in the same direction */
+ set_end = FALSE;
+ } else
+ new_anim = TRUE;
+ self->iconify_animation_going = iconifying ? 1 : -1;
+
+ /* set the ending time */
+ if (set_end) {
+ self->iconify_animation_end.tv_sec = now.tv_sec;
+ self->iconify_animation_end.tv_usec = now.tv_usec;
+ g_time_val_add(&self->iconify_animation_end, time);