diff options
author | Søren Sandmann Pedersen <ssp@src.gnome.org> | 2005-11-28 21:00:35 +0000 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@src.gnome.org> | 2005-11-28 21:00:35 +0000 |
commit | 89b24dd7eb5f7c36ca0ea69459cc4e4f44be5740 (patch) | |
tree | 0444fd3ce2e281569cfd73e8c56d3fd3b416b19b | |
parent | 2278db497968b1029acc7dd3a1d575d57e393d0f (diff) | |
download | metacity-89b24dd7eb5f7c36ca0ea69459cc4e4f44be5740.tar.gz |
*** empty log message ***
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/compositor.c | 127 | ||||
-rw-r--r-- | src/compositor.h | 8 | ||||
-rw-r--r-- | src/cwindow.h | 1 | ||||
-rw-r--r-- | src/window.c | 8 |
5 files changed, 132 insertions, 14 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 89d4ab41..d2e10d2a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -137,7 +137,7 @@ bin_PROGRAMS=metacity metacity-theme-viewer libexec_PROGRAMS=metacity-dialog EFENCE= -metacity_LDADD=@METACITY_LIBS@ $(EFENCE) -lGL -lGLU -lcm +metacity_LDADD=@METACITY_LIBS@ $(EFENCE) -lGL -lGLU -lcm -lXtst metacity_theme_viewer_LDADD= @METACITY_LIBS@ libmetacity-private.la metacity_dialog_LDADD=@METACITY_LIBS@ diff --git a/src/compositor.c b/src/compositor.c index bbb4e8b5..c2fb9aa4 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -807,8 +807,7 @@ meta_compositor_manage_screen (MetaCompositor *compositor, WsWindow *root = ws_screen_get_root_window (ws_screen); Info *info; WsRegion *region; - - + compositor->glw = ws_window_new_gl (root); ws_init_composite (compositor->ws); @@ -872,24 +871,128 @@ window_to_node (MetaCompositor *compositor, return node; } -void -meta_compositor_stop_compositing (MetaCompositor *compositor, - MetaWindow *window) +typedef struct +{ + double x; + double y; + double width; + double height; +} DoubleRect; + +typedef struct { + DrawableNode *node; + + DoubleRect start; + DoubleRect target; + + double start_time; + int idle_id; +} MiniInfo; + +static gdouble +interpolate (gdouble t, gdouble begin, gdouble end, double power) +{ + return begin + (end - begin) * pow (t, power); +} + +static gboolean +stop_minimize (gpointer data) +{ + MiniInfo *info = data; + + drawable_node_set_deformation_func (info->node, NULL, NULL); + g_free (info); + + return FALSE; +} + +static void +minimize_deformation (gdouble time, + double in_x, + double in_y, + double *out_x, + double *out_y, + gpointer data) +{ +#define MINIMIZE_TIME 3.0 + MiniInfo *info = data; + gdouble elapsed; + gdouble pos; + + if (info->start_time == -1) + info->start_time = time; + + elapsed = time - info->start_time; + pos = elapsed / MINIMIZE_TIME; + #if 0 - DrawableNode *node = window_to_node (compositor, window); + g_print ("%f\n", info->target.width * ((in_x - info->start.x) / info->start.width)); +#endif - if (cwindow) - cwindow_freeze (cwindow); + *out_x = interpolate (pos, in_x, info->target.x + info->target.width * ((in_x - info->start.x) / info->start.width), 3 * (1 - in_y)); + *out_y = interpolate (pos, in_y, info->target.y + info->target.height * ((in_y - info->start.y) / info->start.height), 1.0); + +#if 0 + g_print ("%f %f => %f %f\n", in_x, in_y, *out_x, *out_y); #endif + + if (elapsed > MINIMIZE_TIME) + { + g_assert (info->node); + if (!info->idle_id) + info->idle_id = g_idle_add (stop_minimize, info); + } +} + +static void +convert (MetaScreen *screen, + int x, int y, int width, int height, + DoubleRect *rect) +{ + rect->x = x / (double)screen->width; + rect->y = y / (double)screen->height; + rect->width = width / (double)screen->width; + rect->height = height / (double)screen->height; } void -meta_compositor_start_compositing (MetaCompositor *compositor, - MetaWindow *window) +meta_compositor_minimize (MetaCompositor *compositor, + MetaWindow *window, + int x, + int y, + int width, + int height) { - DrawableNode *node; - node = window_to_node (compositor, window); + MiniInfo *info = g_new (MiniInfo, 1); + DrawableNode *node = window_to_node (compositor, window); + WsRectangle start; + MetaScreen *screen = window->screen; + + info->node = node; + + info->idle_id = 0; + + ws_drawable_query_geometry (node->drawable, &start); + + convert (screen, start.x, start.y, start.width, start.height, + &info->start); + convert (screen, x, y, width, height, + &info->target); + + g_print ("start: %f %f %f %f\n", + info->start.x, info->start.y, + info->start.width, info->start.height); + + g_print ("target: %f %f %f %f\n", + info->target.x, info->target.y, + info->target.width, info->target.height); + + info->target.y = 1 - info->target.y - info->target.height; + + info->start_time = -1; + + drawable_node_set_deformation_func (node, minimize_deformation, info); } MetaDisplay * diff --git a/src/compositor.h b/src/compositor.h index 75a8b07d..f6e8a451 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -69,4 +69,12 @@ meta_compositor_repair_now (MetaCompositor *compositor); XID meta_compositor_get_gl_window (MetaCompositor *compositor); +void +meta_compositor_minimize (MetaCompositor *compositor, + MetaWindow *window, + int x, + int y, + int width, + int height); + #endif /* META_COMPOSITOR_H */ diff --git a/src/cwindow.h b/src/cwindow.h index b2224faf..7820c96e 100644 --- a/src/cwindow.h +++ b/src/cwindow.h @@ -40,7 +40,6 @@ void cwindow_set_transformation (CWindow *window int n_distortions); void cwindow_free (CWindow *cwindow); XserverRegion cwindow_extents (CWindow *cwindow); -XserverRegion cwindow_get_opaque_region (CWindow *cwindow); Drawable cwindow_get_drawable (CWindow *cwindow); Window cwindow_get_xwindow (CWindow *cwindow); gboolean cwindow_get_viewable (CWindow *cwindow); diff --git a/src/window.c b/src/window.c index 33b2466b..7dbe3556 100644 --- a/src/window.c +++ b/src/window.c @@ -1335,11 +1335,19 @@ implement_showing (MetaWindow *window, meta_window_get_outer_rect (window, &window_rect); /* Draw a nice cool animation */ + meta_compositor_minimize (window->display->compositor, + window, + icon_rect.x, + icon_rect.y, + icon_rect.width, + icon_rect.height); +#if 0 meta_effects_draw_box_animation (window->screen, &window_rect, &icon_rect, META_MINIMIZE_ANIMATION_LENGTH, META_BOX_ANIM_SCALE); +#endif } meta_window_hide (window); |