From 17e7276f73428c58827e457022af3b8dcbc657ab Mon Sep 17 00:00:00 2001 From: Benoit Gschwind Date: Thu, 21 Feb 2008 21:36:15 +0100 Subject: [PATCH] Remove animating from plugin --- engines/concept/plugin.c | 121 ------------------- engines/default/plugin.c | 233 +++---------------------------------- engines/default/plugin.h | 6 - engines/default/render.c | 3 +- openbox/client.c | 9 +- openbox/engine_interface.h | 3 - openbox/event.c | 8 +- openbox/moveresize.c | 2 - 8 files changed, 19 insertions(+), 366 deletions(-) diff --git a/engines/concept/plugin.c b/engines/concept/plugin.c index 9778c441..e23eed04 100644 --- a/engines/concept/plugin.c +++ b/engines/concept/plugin.c @@ -184,38 +184,6 @@ void frame_free(gpointer self) g_free(self); } -void frame_show(gpointer _self) -{ - ObConceptFrame * self = (ObConceptFrame *) _self; - if (!self->visible) { - self->visible = TRUE; - frame_update_skin(self); - /* Grab the server to make sure that the frame window is mapped before - the client gets its MapNotify, i.e. to make sure the client is - _visible_ when it gets MapNotify. */ - grab_server(TRUE); - XMapWindow(plugin.ob_display, self->client->window); - XMapWindow(plugin.ob_display, self->window); - grab_server(FALSE); - } -} - -gint frame_hide(gpointer self) -{ - if (OBCONCEPTFRAME(self)->visible) { - OBCONCEPTFRAME(self)->visible = FALSE; - if (!frame_iconify_animating(self)) - XUnmapWindow(plugin.ob_display, OBCONCEPTFRAME(self)->window); - /* we unmap the client itself so that we can get MapRequest - events, and because the ICCCM tells us to! */ - XUnmapWindow(plugin.ob_display, OBCONCEPTFRAME(self)->client->window); - /* We ignore 1 unmap */ - return 1; - } - else - return 0; -} - void frame_adjust_theme(gpointer self) { free_theme_statics(self); @@ -477,95 +445,6 @@ void frame_flash_stop(gpointer _self) self->flashing = FALSE; } -void frame_begin_iconify_animation(gpointer _self, gboolean iconifying) -{ - ObConceptFrame * self = (ObConceptFrame *) _self; - 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); - } - - if (new_anim) { - obt_main_loop_timeout_remove_data(plugin.ob_main_loop, - frame_animate_iconify, self, FALSE); - obt_main_loop_timeout_add(plugin.ob_main_loop, - FRAME_ANIMATE_ICONIFY_STEP_TIME, frame_animate_iconify, self, - g_direct_equal, NULL); - - /* do the first step */ - frame_animate_iconify(self); - - /* show it during the animation even if it is not "visible" */ - if (!self->visible) - XMapWindow(plugin.ob_display, self->window); - } -} - -void frame_end_iconify_animation(gpointer _self) -{ - ObConceptFrame * self = (ObConceptFrame *) _self; - /* see if there is an animation going */ - if (self->iconify_animation_going == 0) - return; - - if (!self->visible) - XUnmapWindow(plugin.ob_display, self->window); - else { - /* Send a ConfigureNotify when the animation is done, this fixes - KDE's pager showing the window in the wrong place. since the - window is mapped at a different location and is then moved, we - need to send the synthetic configurenotify, since apps may have - read the position when the client mapped, apparently. */ - client_reconfigure(self->client, TRUE); - } - - /* we're not animating any more ! */ - self->iconify_animation_going = 0; - - XMoveResizeWindow(plugin.ob_display, self->window, self->window_area.x, - self->window_area.y, self->window_area.width, - self->window_area.height); - /* we delay re-rendering until after we're done animating */ - frame_update_skin(self); - XFlush(plugin.ob_display); -} - -gboolean frame_iconify_animating(gpointer _self) -{ - ObConceptFrame * self = (ObConceptFrame *) _self; - return self->iconify_animation_going != 0; -} - void frame_set_decorations(gpointer self, ObFrameDecorations d) { OBCONCEPTFRAME(self)->decorations = d; diff --git a/engines/default/plugin.c b/engines/default/plugin.c index 69f4730b..cc3c1631 100644 --- a/engines/default/plugin.c +++ b/engines/default/plugin.c @@ -47,9 +47,6 @@ typedef enum ButtonMotionMask | PointerMotionMask | \ EnterWindowMask | LeaveWindowMask) -#define FRAME_ANIMATE_ICONIFY_TIME 150000 /* .15 seconds */ -#define FRAME_ANIMATE_ICONIFY_STEP_TIME (G_USEC_PER_SEC / 60) /* 60 Hz */ - #define FRAME_HANDLE_Y(f) (f->size.top + f->client_area.height + f->cbwidth_b) Display * obp_display; @@ -393,10 +390,6 @@ void frame_ungrab(gpointer _self, GHashTable * window_map) XEvent ev; gboolean reparent = TRUE; - /* if there was any animation going on, kill it */ - obt_main_loop_timeout_remove_data(plugin.ob_main_loop, - frame_animate_iconify, self, FALSE); - /* check if the app has already reparented its window away */ while (XCheckTypedWindowEvent(obp_display, self->client->w_client, ReparentNotify, &ev)) { @@ -662,94 +655,6 @@ void frame_flash_stop(gpointer _self) self->flashing = FALSE; } -void frame_begin_iconify_animation(gpointer _self, gboolean iconifying) -{ - ObDefaultFrame * self = (ObDefaultFrame *) _self; - 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); - } - - if (new_anim) { - obt_main_loop_timeout_remove_data(plugin.ob_main_loop, - frame_animate_iconify, self, FALSE); - obt_main_loop_timeout_add(plugin.ob_main_loop, - FRAME_ANIMATE_ICONIFY_STEP_TIME, frame_animate_iconify, self, - g_direct_equal, NULL); - - /* do the first step */ - frame_animate_iconify(self); - - /* show it during the animation even if it is not "visible" */ - if (!self->visible) - XMapWindow(obp_display, self->window); - } -} - -void frame_end_iconify_animation(gpointer _self) -{ - ObDefaultFrame * self = (ObDefaultFrame *) _self; - /* see if there is an animation going */ - if (self->iconify_animation_going == 0) - return; - - if (!self->visible) - XUnmapWindow(obp_display, self->window); - else { - /* Send a ConfigureNotify when the animation is done, this fixes - KDE's pager showing the window in the wrong place. since the - window is mapped at a different location and is then moved, we - need to send the synthetic configurenotify, since apps may have - read the position when the client mapped, apparently. */ - client_reconfigure(self->client, TRUE); - } - - /* we're not animating any more ! */ - self->iconify_animation_going = 0; - - XMoveResizeWindow(obp_display, self->window, self->area.x, self->area.y, - self->area.width, self->area.height); - /* we delay re-rendering until after we're done animating */ - frame_update_skin(self); - XFlush(obp_display); -} - -gboolean frame_iconify_animating(gpointer _self) -{ - ObDefaultFrame * self = (ObDefaultFrame *) _self; - return self->iconify_animation_going != 0; -} - void frame_set_decorations(gpointer self, ObFrameDecorations d) { OBDEFAULTFRAME(self)->decorations = d; @@ -1203,15 +1108,13 @@ void frame_update_layout(gpointer _self, gboolean is_resize, gboolean is_fake) } if (!is_fake) { - if (!frame_iconify_animating(self)) - /* move and resize the top level frame. - shading can change without being moved or resized. - - but don't do this during an iconify animation. it will be - reflected afterwards. - */ - XMoveResizeWindow(obp_display, self->window, self->area.x, - self->area.y, self->area.width, self->area.height); + /* move and resize the top level frame. + shading can change without being moved or resized. + but don't do this during an iconify animation. it will be + reflected afterwards. + */ + XMoveResizeWindow(obp_display, self->window, self->area.x, + self->area.y, self->area.width, self->area.height); /* when the client has StaticGravity, it likes to move around. also this correctly positions the client when it maps. @@ -1302,96 +1205,6 @@ gboolean frame_is_max_vert(gpointer self) return OBDEFAULTFRAME(self)->max_vert; } -gulong frame_animate_iconify_time_left(gpointer _self, const GTimeVal *now) -{ - ObDefaultFrame * self = (ObDefaultFrame *) _self; - glong sec, usec; - sec = self->iconify_animation_end.tv_sec - now->tv_sec; - usec = self->iconify_animation_end.tv_usec - now->tv_usec; - if (usec < 0) { - usec += G_USEC_PER_SEC; - sec--; - } - /* no negative values */ - return MAX(sec * G_USEC_PER_SEC + usec, 0); -} - -gboolean frame_animate_iconify(gpointer p) -{ - ObDefaultFrame *self = p; - gint x, y, w, h; - gint iconx, icony, iconw; - GTimeVal now; - gulong time; - gboolean iconifying; - - if (self->client->icon_geometry.width == 0) { - /* there is no icon geometry set so just go straight down */ - Rect *a = - screen_physical_area_monitor(screen_find_monitor(&self->area)); - iconx = self->area.x + self->area.width / 2 + 32; - icony = a->y + a->width; - iconw = 64; - g_free(a); - } - else { - iconx = self->client->icon_geometry.x; - icony = self->client->icon_geometry.y; - iconw = self->client->icon_geometry.width; - } - - iconifying = self->iconify_animation_going > 0; - - /* how far do we have left to go ? */ - g_get_current_time(&now); - time = frame_animate_iconify_time_left(self, &now); - - if (time == 0 || iconifying) { - /* start where the frame is supposed to be */ - x = self->area.x; - y = self->area.y; - w = self->area.width; - h = self->area.height; - } - else { - /* start at the icon */ - x = iconx; - y = icony; - w = iconw; - h = self->size.top; /* just the titlebar */ - } - - if (time > 0) { - glong dx, dy, dw; - glong elapsed; - - dx = self->area.x - iconx; - dy = self->area.y - icony; - dw = self->area.width - self->bwidth * 2 - iconw; - /* if restoring, we move in the opposite direction */ - if (!iconifying) { - dx = -dx; - dy = -dy; - dw = -dw; - } - - elapsed = FRAME_ANIMATE_ICONIFY_TIME - time; - x = x - (dx * elapsed) / FRAME_ANIMATE_ICONIFY_TIME; - y = y - (dy * elapsed) / FRAME_ANIMATE_ICONIFY_TIME; - w = w - (dw * elapsed) / FRAME_ANIMATE_ICONIFY_TIME; - h = self->size.top; /* just the titlebar */ - } - - if (time == 0) - frame_end_iconify_animation(self); - else { - XMoveResizeWindow(obp_display, self->window, x, y, w, h); - XFlush(obp_display); - } - - return time > 0; /* repeat until we're out of time */ -} - void frame_adjust_cursors(gpointer _self) { ObDefaultFrame * self = (ObDefaultFrame *) _self; @@ -1846,25 +1659,19 @@ ObFrameEngine plugin = { 0, /* */ frame_new, //gpointer (*frame_new) (struct _ObClient *c); frame_free, //void (*frame_free) (gpointer self); - frame_adjust_theme, //void (*frame_adjust_theme) (gpointer self); frame_adjust_shape, //void (*frame_adjust_shape) (gpointer self); frame_grab, //void (*frame_adjust_area) (gpointer self, gboolean moved, gboolean resized, gboolean fake); - frame_ungrab, frame_context, //void (*frame_adjust_state) (gpointer self); + frame_ungrab, /* */ + frame_context, //void (*frame_adjust_state) (gpointer self); frame_set_is_visible, /* */ frame_set_is_focus, /* */ frame_set_is_max_vert, /* */ frame_set_is_max_horz, /* */ frame_set_is_shaded, /* */ - frame_flash_start, /* */ frame_flash_stop, /* */ - frame_begin_iconify_animation, /* */ - frame_end_iconify_animation, /* */ - frame_iconify_animating, /* */ - frame_set_decorations, /* */ - frame_update_title, /* */ /* This give the window area */ frame_get_window_area, /* */ @@ -1872,33 +1679,23 @@ ObFrameEngine plugin = { /* Draw the frame */ frame_update_layout, /* */ frame_update_skin, /* */ - frame_set_hover_flag, /* */ frame_set_press_flag, /* */ - frame_get_window,/* */ - frame_get_size, /* */ frame_get_decorations, /* */ - frame_is_visible, /* */ frame_is_max_horz, /* */ frame_is_max_vert, /* */ - frame_trigger, /* */ - load_theme_config, /* */ - /* This fields are fill by openbox. */ - //0, //Display * ob_display; - //0, //gint ob_screen; - //0, //RrInstance *ob_rr_inst; - 0, //gboolean config_theme_keepborder; - 0, //struct _ObClient *focus_cycle_target; - 0, //gchar *config_title_layout; - FALSE, //gboolean moveresize_in_progress; - 0, //struct _ObMainLoop *ob_main_loop; - }; + 0, /*gboolean config_theme_keepborder; */ + 0, /*struct _ObClient *focus_cycle_target; */ + 0, /*gchar *config_title_layout; */ + FALSE, /*gboolean moveresize_in_progress;*/ + 0, /*struct _ObMainLoop *ob_main_loop;*/ +}; ObFrameEngine * get_info() { diff --git a/engines/default/plugin.h b/engines/default/plugin.h index 33d6d9e7..bf13e3e0 100644 --- a/engines/default/plugin.h +++ b/engines/default/plugin.h @@ -184,15 +184,10 @@ void frame_adjust_focus(gpointer self, gboolean hilite); void frame_adjust_title(gpointer self); void frame_adjust_icon(gpointer self); -gulong frame_animate_iconify_time_left(gpointer _self, const GTimeVal *now); - ObFrameContext frame_context(gpointer, Window win, gint x, gint y); void frame_flash_start(gpointer self); void frame_flash_stop(gpointer self); -void frame_begin_iconify_animation(gpointer self, gboolean iconifying); -void frame_end_iconify_animation(gpointer self); -gboolean frame_iconify_animating(gpointer _self); void frame_set_hover_flag(gpointer, ObFrameButton); void frame_set_press_flag(gpointer, ObFrameButton); @@ -215,7 +210,6 @@ gboolean flash_timeout(gpointer data); void layout_title(ObDefaultFrame *); void set_theme_statics(gpointer self); void free_theme_statics(gpointer self); -gboolean frame_animate_iconify(gpointer self); void frame_adjust_cursors(gpointer self); void frame_trigger(gpointer, ObFrameTrigger); diff --git a/engines/default/render.c b/engines/default/render.c index 78d0857f..e1f826c4 100644 --- a/engines/default/render.c +++ b/engines/default/render.c @@ -33,8 +33,7 @@ static void framerender_close(ObDefaultFrame *self, RrAppearance *a); void frame_update_skin(gpointer _self) { ObDefaultFrame * self = (ObDefaultFrame *) _self; - if (plugin.frame_iconify_animating(self)) - return; /* delay redrawing until the animation is done */ + if (!self->visible) return; diff --git a/openbox/client.c b/openbox/client.c index 8d1845c4..4f6f78a0 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -3265,8 +3265,6 @@ static void client_iconify_recursive(ObClient *self, if (changed) { client_change_state(self); - if (config_animate_iconify && !hide_animation) - frame_engine->frame_begin_iconify_animation(self->frame, iconic); /* do this after starting the animation so it doesn't flash */ client_showhide(self); } @@ -4453,9 +4451,7 @@ ObClient* client_under_pointer(void) switching and windows are shown/hidden status is not reliable */ (c->desktop == screen_desktop || - c->desktop == DESKTOP_ALL) && - /* ignore all animating windows */ - !(frame_engine->frame_iconify_animating(c->frame)) && + c->desktop == DESKTOP_ALL) && RECT_CONTAINS(frame_engine->frame_get_window_area(c->frame), x, y)) { ret = c; @@ -4489,8 +4485,7 @@ void client_show_frame(ObClient * self) void client_hide_frame(ObClient * self) { frame_engine->frame_set_is_visible(self->frame, FALSE); - if (!frame_engine->frame_iconify_animating(self)) - XUnmapWindow(obt_display, self->w_frame); + XUnmapWindow(obt_display, self->w_frame); /* we unmap the client itself so that we can get MapRequest events, and because the ICCCM tells us to! */ XUnmapWindow(obt_display, self->w_client); diff --git a/openbox/engine_interface.h b/openbox/engine_interface.h index 6406b8c6..04637da2 100644 --- a/openbox/engine_interface.h +++ b/openbox/engine_interface.h @@ -153,9 +153,6 @@ struct _ObFrameEngine void (*frame_flash_start)(gpointer self); void (*frame_flash_stop)(gpointer self); - void (*frame_begin_iconify_animation)(gpointer self, gboolean iconifying); - void (*frame_end_iconify_animation)(gpointer self); - gboolean (*frame_iconify_animating)(gpointer p); /* Set the layout wanted by client */ void (*frame_set_decorations)(gpointer, ObFrameDecorations); diff --git a/openbox/event.c b/openbox/event.c index fdc531af..e543b9b9 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -968,11 +968,6 @@ static void event_handle_client(ObClient *client, XEvent *e) frame_engine->frame_set_hover_flag(client->frame, OB_BUTTON_NONE); break; case OB_FRAME_CONTEXT_FRAME: - /* When the mouse leaves an animating window, don't use the - corresponding enter events. Pretend like the animating window - doesn't even exist..! */ - if (frame_engine->frame_iconify_animating(client->frame)) - event_end_ignore_all_enters(event_start_ignore_all_enters()); ob_debug_type(OB_DEBUG_FOCUS, "%sNotify mode %d detail %d on %lx", @@ -1880,8 +1875,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_engine->frame_iconify_animating(client->frame)) - mouse_event(client, e); + mouse_event(client, e); } else keyboard_event((frame_engine->focus_cycle_target ? frame_engine->focus_cycle_target : (client ? client : focus_client)), e); diff --git a/openbox/moveresize.c b/openbox/moveresize.c index 8a2543be..da087dbe 100644 --- a/openbox/moveresize.c +++ b/openbox/moveresize.c @@ -222,8 +222,6 @@ void moveresize_start(ObClient *c, gint x, gint y, guint b, guint32 cnr) return; } - frame_engine->frame_end_iconify_animation(c->frame); - moving = mv; moveresize_client = c; start_cx = c->area.x; -- 2.39.2