From 378adaa94f0fac07dc65f0531e950c7ec8944cdf Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Sat, 5 May 2007 16:53:48 +0000 Subject: [PATCH] yay. way way cleaner code for iconify animations. let people show/hide the frame logically and it will do everything except during animations the frame will show what it needs to for visual display. --- openbox/action.c | 6 +++--- openbox/client.c | 35 +++++++++-------------------------- openbox/event.c | 2 +- openbox/frame.c | 33 ++++++++++----------------------- openbox/frame.h | 13 +------------ openbox/moveresize.c | 2 +- openbox/place.c | 3 +-- openbox/resist.c | 4 ++-- 8 files changed, 28 insertions(+), 70 deletions(-) diff --git a/openbox/action.c b/openbox/action.c index 2e348c7c..797552f6 100644 --- a/openbox/action.c +++ b/openbox/action.c @@ -1263,9 +1263,9 @@ void action_raiselower(union ActionData *data) if (cit == c) break; if (client_normal(cit) == client_normal(c) && - cit->layer == c->layer && - frame_visible(cit->frame) && - !client_search_transient(c, cit)) + cit->layer == c->layer && + cit->frame->visible && + !client_search_transient(c, cit)) { if (RECT_INTERSECTS_RECT(cit->frame->area, c->frame->area)) { raise = TRUE; diff --git a/openbox/client.c b/openbox/client.c index 02bd74b4..eb0289ac 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -2061,7 +2061,7 @@ static void client_change_wm_state(ObClient *self) old = self->wmstate; - if (self->shaded || self->iconic || !frame_visible(self->frame)) + if (self->shaded || !self->frame->visible) self->wmstate = IconicState; else self->wmstate = NormalState; @@ -2724,27 +2724,10 @@ static void client_iconify_recursive(ObClient *self, if (changed) { client_change_state(self); - if (iconic) { - if (ob_state() != OB_STATE_STARTING && config_animate_iconify) { - /* delay the showhide until the window is done the animation */ - frame_begin_iconify_animation - (self->frame, iconic, - (ObFrameIconifyAnimateFunc)client_showhide, self); - /* but focus a new window now please */ - focus_fallback(FALSE); - } else - client_showhide(self); - } else { - if (config_animate_iconify) - /* the animation will show the window when it is hidden, - but the window state needs to be adjusted after the - animation finishes, so call showhide when it's done to make - sure everything is updated appropriately - */ - frame_begin_iconify_animation - (self->frame, iconic, - (ObFrameIconifyAnimateFunc)client_showhide, self); - } + if (ob_state() != OB_STATE_STARTING && config_animate_iconify) + frame_begin_iconify_animation(self->frame, iconic); + /* do this after starting the animation so it doesn't flash */ + client_showhide(self); } /* iconify all direct transients, and deiconify all transients @@ -3188,7 +3171,7 @@ gboolean client_can_focus(ObClient *self) /* choose the correct target */ self = client_focus_target(self); - if (!frame_visible(self->frame)) + if (!self->frame->visible) return FALSE; if (!(self->can_focus || self->focus_notify)) @@ -3221,7 +3204,7 @@ gboolean client_focus(ObClient *self) self = client_focus_target(self); if (!client_can_focus(self)) { - if (!frame_visible(self->frame)) { + if (!self->frame->visible) { /* update the focus lists */ focus_order_to_top(self); } @@ -3306,7 +3289,7 @@ void client_activate(ObClient *self, gboolean here, gboolean user) client_set_desktop(self, screen_desktop, FALSE); else screen_set_desktop(self->desktop); - } else if (!frame_visible(self->frame)) + } else if (!self->frame->visible) /* if its not visible for other reasons, then don't mess with it */ return; @@ -3733,7 +3716,7 @@ ObClient* client_under_pointer() for (it = stacking_list; it; it = g_list_next(it)) { if (WINDOW_IS_CLIENT(it->data)) { ObClient *c = WINDOW_AS_CLIENT(it->data); - if (frame_visible(c->frame) && + if (c->frame->visible && /* ignore all animating windows */ !frame_iconify_animating(c->frame) && RECT_CONTAINS(c->frame->area, x, y)) diff --git a/openbox/event.c b/openbox/event.c index ec0789d1..49e1cc06 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -1386,7 +1386,7 @@ static void event_handle_user_input(ObClient *client, XEvent *e) { /* the frame may not be "visible" but they can still click on it in the case where it is animating before disappearing */ - if (client && frame_visible(client->frame)) + if (client && client->frame->visible) mouse_event(client, e); } else if (e->type == KeyPress) { keyboard_event((focus_cycle_target ? focus_cycle_target : diff --git a/openbox/frame.c b/openbox/frame.c index a5a07609..f93becb5 100644 --- a/openbox/frame.c +++ b/openbox/frame.c @@ -258,11 +258,12 @@ void frame_hide(ObFrame *self) { if (self->visible) { self->visible = FALSE; - self->client->ignore_unmaps += 1; + if (!frame_iconify_animating(self)) + XUnmapWindow(ob_display, self->window); /* we unmap the client itself so that we can get MapRequest events, and because the ICCCM tells us to! */ - XUnmapWindow(ob_display, self->window); XUnmapWindow(ob_display, self->client->window); + self->client->ignore_unmaps += 1; } } @@ -1121,13 +1122,12 @@ void frame_end_iconify_animation(ObFrame *self) /* see if there is an animation going */ if (self->iconify_animation_going == 0) return; - /* call the callback when it's done */ - if (self->iconify_animation_cb) - self->iconify_animation_cb(self->iconify_animation_data); + if (!self->visible) + XUnmapWindow(ob_display, self->window); + /* we're not animating any more ! */ self->iconify_animation_going = 0; - /* move after the callback for the animation ending */ XMoveResizeWindow(ob_display, self->window, self->area.x, self->area.y, self->area.width - self->bwidth * 2, @@ -1135,9 +1135,7 @@ void frame_end_iconify_animation(ObFrame *self) XFlush(ob_display); } -void frame_begin_iconify_animation(ObFrame *self, gboolean iconifying, - ObFrameIconifyAnimateFunc callback, - gpointer data) +void frame_begin_iconify_animation(ObFrame *self, gboolean iconifying) { gulong time; gboolean new_anim = FALSE; @@ -1146,10 +1144,8 @@ void frame_begin_iconify_animation(ObFrame *self, gboolean iconifying, /* if there is no titlebar, just don't animate for now XXX it would be nice tho.. */ - if (!(self->decorations & OB_FRAME_DECOR_TITLEBAR)) { - if (callback) callback(data); + if (!(self->decorations & OB_FRAME_DECOR_TITLEBAR)) return; - } /* get the current time */ g_get_current_time(&now); @@ -1167,9 +1163,6 @@ void frame_begin_iconify_animation(ObFrame *self, gboolean iconifying, new_anim = TRUE; self->iconify_animation_going = iconifying ? 1 : -1; - self->iconify_animation_cb = callback; - self->iconify_animation_data = data; - /* set the ending time */ if (set_end) { self->iconify_animation_end.tv_sec = now.tv_sec; @@ -1188,14 +1181,8 @@ void frame_begin_iconify_animation(ObFrame *self, gboolean iconifying, /* do the first step */ frame_animate_iconify(self); + /* show it during the animation even if it is not "visible" */ if (!self->visible) - frame_show(self); + XMapWindow(ob_display, self->window); } } - -gboolean frame_visible(ObFrame *self) -{ - /* if it is animating back from iconic state then it is considered - visible. but if it is iconifying then it is not visible. */ - return self->visible && self->iconify_animation_going <= 0; -} diff --git a/openbox/frame.h b/openbox/frame.h index 5f31b8c9..7be63d53 100644 --- a/openbox/frame.h +++ b/openbox/frame.h @@ -77,9 +77,6 @@ struct _ObFrame Strut size; Rect area; - /*! Is the frame visible? Don't read this directly ! Use frame_visible() - instead, because that takes into account if the frame is visible but - animating to the iconic (invisible) state. */ gboolean visible; guint decorations; @@ -154,8 +151,6 @@ struct _ObFrame */ gint iconify_animation_going; GTimeVal iconify_animation_end; - ObFrameIconifyAnimateFunc iconify_animation_cb; - gpointer iconify_animation_data; }; ObFrame *frame_new(struct _ObClient *c); @@ -195,15 +190,9 @@ void frame_flash_stop(ObFrame *self); /*! Start an animation for iconifying or restoring a frame. The callback will be called when the animation finishes. But if another animation is started in the meantime, the callback will never get called. */ -void frame_begin_iconify_animation(ObFrame *self, gboolean iconifying, - ObFrameIconifyAnimateFunc callback, - gpointer data); +void frame_begin_iconify_animation(ObFrame *self, gboolean iconifying); void frame_end_iconify_animation(ObFrame *self); -/* Returns true if the frame is visible (but false if it is only visible - because it is animating */ -gboolean frame_visible(ObFrame *self); - #define frame_iconify_animating(f) (f->iconify_animation_going != 0) #endif diff --git a/openbox/moveresize.c b/openbox/moveresize.c index 9f9d4dfd..b0b1f2a1 100644 --- a/openbox/moveresize.c +++ b/openbox/moveresize.c @@ -153,7 +153,7 @@ void moveresize_start(ObClient *c, gint x, gint y, guint b, guint32 cnr) moving = (cnr == prop_atoms.net_wm_moveresize_move || cnr == prop_atoms.net_wm_moveresize_move_keyboard); - if (moveresize_in_progress || !frame_visible(c->frame) || + if (moveresize_in_progress || !c->frame->visible || !(moving ? (c->functions & OB_CLIENT_FUNC_MOVE) : (c->functions & OB_CLIENT_FUNC_RESIZE))) diff --git a/openbox/place.c b/openbox/place.c index eada385f..ac902d2d 100644 --- a/openbox/place.c +++ b/openbox/place.c @@ -251,8 +251,7 @@ typedef enum } ObSmartType; #define SMART_IGNORE(placer, c) \ - (placer == c || c->shaded || !client_normal(c) || \ - !frame_visible(c->frame) || \ + (placer == c || c->shaded || !client_normal(c) || !c->frame->visible || \ (c->desktop != DESKTOP_ALL && \ c->desktop != (placer->desktop == DESKTOP_ALL ? \ screen_desktop : placer->desktop))) diff --git a/openbox/resist.c b/openbox/resist.c index 0c7ec87e..e5d49faa 100644 --- a/openbox/resist.c +++ b/openbox/resist.c @@ -57,7 +57,7 @@ void resist_move_windows(ObClient *c, gint *x, gint *y) target = it->data; /* don't snap to self or non-visibles */ - if (!frame_visible(target->frame) || target == c) continue; + if (!target->frame->visible || target == c) continue; /* don't snap to windows in layers beneath */ if(target->layer < c->layer && !config_resist_layers_below) @@ -199,7 +199,7 @@ void resist_size_windows(ObClient *c, gint *w, gint *h, ObCorner corn) target = it->data; /* don't snap to invisibles or ourself */ - if (!frame_visible(target->frame) || target == c) continue; + if (!target->frame->visible || target == c) continue; /* don't snap to windows in layers beneath */ if(target->layer < c->layer && !config_resist_layers_below) -- 2.39.2