Basic CM minimize effect

Added minimize hook to the compositor, hooked up into MetaWindow, implemented
in the clutter compositor.
This commit is contained in:
Tomas Frydrych 2008-08-19 11:47:30 +01:00
parent 99b547bc1d
commit 1f29679c0d
5 changed files with 139 additions and 14 deletions

View File

@ -40,6 +40,7 @@
#define TILE_HEIGHT (3*MAX_TILE_SZ) #define TILE_HEIGHT (3*MAX_TILE_SZ)
#define DESTROY_TIMEOUT 300 #define DESTROY_TIMEOUT 300
#define MINIMIZE_TIMEOUT 600
ClutterActor* ClutterActor*
tidy_texture_frame_new (ClutterTexture *texture, tidy_texture_frame_new (ClutterTexture *texture,
@ -111,6 +112,7 @@ typedef struct _MetaCompScreen
GSList *dock_windows; GSList *dock_windows;
ClutterEffectTemplate *destroy_effect; ClutterEffectTemplate *destroy_effect;
ClutterEffectTemplate *minimize_effect;
ClutterActor *shadow_src; ClutterActor *shadow_src;
@ -131,10 +133,11 @@ typedef struct _MetaCompWindow
guint8 opacity; guint8 opacity;
gboolean needs_shadow : 1; gboolean needs_shadow : 1;
gboolean shaped : 1; gboolean shaped : 1;
gboolean destroy_pending : 1; gboolean destroy_pending : 1;
gboolean argb32 : 1; gboolean argb32 : 1;
gboolean minimize_in_progress : 1;
} MetaCompWindow; } MetaCompWindow;
@ -543,6 +546,8 @@ map_win (MetaDisplay *display,
cw->back_pixmap = None; cw->back_pixmap = None;
} }
cw->minimize_in_progress = FALSE;
if (cw->shadow) if (cw->shadow)
clutter_actor_show (cw->shadow); clutter_actor_show (cw->shadow);
@ -570,10 +575,13 @@ unmap_win (MetaDisplay *display,
free_win (cw, FALSE); free_win (cw, FALSE);
clutter_actor_hide (cw->actor); if (!cw->minimize_in_progress)
{
clutter_actor_hide (cw->actor);
if (cw->shadow) if (cw->shadow)
clutter_actor_hide (cw->shadow); clutter_actor_hide (cw->shadow);
}
} }
@ -1135,6 +1143,12 @@ clutter_cmp_manage_screen (MetaCompositor *compositor,
= clutter_effect_template_new (clutter_timeline_new_for_duration ( = clutter_effect_template_new (clutter_timeline_new_for_duration (
DESTROY_TIMEOUT), DESTROY_TIMEOUT),
CLUTTER_ALPHA_SINE_INC); CLUTTER_ALPHA_SINE_INC);
info->minimize_effect
= clutter_effect_template_new (clutter_timeline_new_for_duration (
MINIMIZE_TIMEOUT),
CLUTTER_ALPHA_SINE_INC);
#endif #endif
} }
@ -1355,6 +1369,93 @@ clutter_cmp_destroy_window (MetaCompositor *compositor,
#endif #endif
} }
static void
on_minimize_effect_complete (ClutterActor *actor,
gpointer user_data)
{
MetaCompWindow *cw = (MetaCompWindow *)user_data;
/*
* Must reverse the effect of the effect once we hide the actor.
*/
clutter_actor_hide (cw->actor);
clutter_actor_set_opacity (cw->actor, cw->opacity);
clutter_actor_set_scale (cw->actor, 1.0, 1.0);
clutter_actor_move_anchor_point_from_gravity (cw->actor,
CLUTTER_GRAVITY_NORTH_WEST);
if (cw->shadow)
{
clutter_actor_hide (cw->shadow);
clutter_actor_set_opacity (cw->shadow, 0xff);
clutter_actor_set_scale (cw->shadow, 1.0, 1.0);
clutter_actor_move_anchor_point_from_gravity (cw->shadow,
CLUTTER_GRAVITY_NORTH_WEST);
}
}
static void
clutter_cmp_minimize_window (MetaCompositor *compositor,
MetaWindow *window)
{
#ifdef HAVE_COMPOSITE_EXTENSIONS
MetaCompWindow *cw = NULL;
MetaCompScreen *info;
MetaScreen *screen;
MetaFrame *f = meta_window_get_frame (window);
screen = meta_window_get_screen (window);
info = meta_screen_get_compositor_data (screen);
/* Chances are we actually get the window frame here */
cw = find_window_for_screen (screen,
f ? meta_frame_get_xwindow (f) :
meta_window_get_xwindow (window));
if (!cw)
return;
meta_verbose ("Animating minimize of 0x%x\n",
(guint)meta_window_get_xwindow (window));
cw->minimize_in_progress = TRUE;
clutter_actor_move_anchor_point_from_gravity (cw->actor,
CLUTTER_GRAVITY_SOUTH_WEST);
clutter_effect_fade (info->minimize_effect,
cw->actor,
0,
on_minimize_effect_complete,
(gpointer)cw);
clutter_effect_scale (info->minimize_effect,
cw->actor,
0.0,
0.0,
NULL,
NULL);
if (cw->shadow)
{
clutter_actor_move_anchor_point_from_gravity (cw->shadow,
CLUTTER_GRAVITY_SOUTH_WEST);
clutter_effect_fade (info->minimize_effect,
cw->shadow,
0,
NULL,
NULL);
clutter_effect_scale (info->minimize_effect,
cw->shadow,
0.0,
0.0,
NULL,
NULL);
}
#endif
}
static MetaCompositor comp_info = { static MetaCompositor comp_info = {
clutter_cmp_destroy, clutter_cmp_destroy,
@ -1366,7 +1467,8 @@ static MetaCompositor comp_info = {
clutter_cmp_process_event, clutter_cmp_process_event,
clutter_cmp_get_window_pixmap, clutter_cmp_get_window_pixmap,
clutter_cmp_set_active_window, clutter_cmp_set_active_window,
clutter_cmp_destroy_window clutter_cmp_destroy_window,
clutter_cmp_minimize_window
}; };
MetaCompositor * MetaCompositor *

View File

@ -53,6 +53,8 @@ struct _MetaCompositor
void (*destroy_window) (MetaCompositor *compositor, void (*destroy_window) (MetaCompositor *compositor,
MetaWindow *window); MetaWindow *window);
void (*minimize_window) (MetaCompositor *compositor,
MetaWindow *window);
}; };
#endif #endif

View File

@ -116,7 +116,7 @@ meta_compositor_get_window_pixmap (MetaCompositor *compositor,
#ifdef HAVE_COMPOSITE_EXTENSIONS #ifdef HAVE_COMPOSITE_EXTENSIONS
if (compositor && compositor->get_window_pixmap) if (compositor && compositor->get_window_pixmap)
return compositor->get_window_pixmap (compositor, window); return compositor->get_window_pixmap (compositor, window);
else else
return None; return None;
#else #else
return None; return None;
@ -129,7 +129,7 @@ meta_compositor_set_active_window (MetaCompositor *compositor,
MetaWindow *window) MetaWindow *window)
{ {
#ifdef HAVE_COMPOSITE_EXTENSIONS #ifdef HAVE_COMPOSITE_EXTENSIONS
if (compositor && compositor->set_active_window) if (compositor && compositor->set_active_window)
compositor->set_active_window (compositor, screen, window); compositor->set_active_window (compositor, screen, window);
#endif #endif
} }
@ -138,14 +138,14 @@ meta_compositor_set_active_window (MetaCompositor *compositor,
void meta_compositor_begin_move (MetaCompositor *compositor, void meta_compositor_begin_move (MetaCompositor *compositor,
MetaWindow *window, MetaWindow *window,
MetaRectangle *initial, MetaRectangle *initial,
int grab_x, int grab_x,
int grab_y) int grab_y)
{ {
} }
void meta_compositor_update_move (MetaCompositor *compositor, void meta_compositor_update_move (MetaCompositor *compositor,
MetaWindow *window, MetaWindow *window,
int x, int x,
int y) int y)
{ {
} }
@ -160,7 +160,7 @@ void meta_compositor_free_window (MetaCompositor *compositor,
{ {
} }
void void
meta_compositor_destroy_window (MetaCompositor *compositor, meta_compositor_destroy_window (MetaCompositor *compositor,
MetaWindow *window) MetaWindow *window)
{ {
@ -169,3 +169,13 @@ meta_compositor_destroy_window (MetaCompositor *compositor,
compositor->destroy_window (compositor, window); compositor->destroy_window (compositor, window);
#endif #endif
} }
void
meta_compositor_minimize_window (MetaCompositor *compositor,
MetaWindow *window)
{
#ifdef HAVE_COMPOSITE_EXTENSIONS
if (compositor && compositor->minimize_window)
compositor->minimize_window (compositor, window);
#endif
}

View File

@ -1475,6 +1475,13 @@ implement_showing (MetaWindow *window,
meta_window_get_outer_rect (window, &window_rect); meta_window_get_outer_rect (window, &window_rect);
if (window->display->compositor)
{
meta_compositor_minimize_window (window->display->compositor,
window);
finish_minimize (window);
}
else
meta_effect_run_minimize (window, meta_effect_run_minimize (window,
&window_rect, &window_rect,
&icon_rect, &icon_rect,

View File

@ -68,10 +68,14 @@ void meta_compositor_end_move (MetaCompositor *compositor,
void meta_compositor_free_window (MetaCompositor *compositor, void meta_compositor_free_window (MetaCompositor *compositor,
MetaWindow *window); MetaWindow *window);
void void
meta_compositor_destroy_window (MetaCompositor *compositor, meta_compositor_destroy_window (MetaCompositor *compositor,
MetaWindow *window); MetaWindow *window);
void
meta_compositor_minimize_window (MetaCompositor *compositor,
MetaWindow *window);
#endif #endif