Add code to destroy compositor. Implement unmanage_screen() functionality.
Wed Feb 15 18:42:03 2006 Søren Sandmann <sandmann@redhat.com> * src/compositor.[ch]: Add code to destroy compositor. Implement unmanage_screen() functionality.
This commit is contained in:
parent
ca539199b2
commit
0f48ff448c
@ -1,3 +1,8 @@
|
|||||||
|
Wed Feb 15 18:42:03 2006 Søren Sandmann <sandmann@redhat.com>
|
||||||
|
|
||||||
|
* src/compositor.[ch]: Add code to destroy compositor. Implement
|
||||||
|
unmanage_screen() functionality.
|
||||||
|
|
||||||
Wed Feb 15 14:47:50 2006 Søren Sandmann <sandmann@redhat.com>
|
Wed Feb 15 14:47:50 2006 Søren Sandmann <sandmann@redhat.com>
|
||||||
|
|
||||||
* src/compositor.c (meta_compositor_unminimize): Add unused wobbly
|
* src/compositor.c (meta_compositor_unminimize): Add unused wobbly
|
||||||
|
592
src/compositor.c
592
src/compositor.c
@ -90,6 +90,8 @@ free_window_hash_value (void *v)
|
|||||||
}
|
}
|
||||||
#endif /* HAVE_COMPOSITE_EXTENSIONS */
|
#endif /* HAVE_COMPOSITE_EXTENSIONS */
|
||||||
|
|
||||||
|
static WsDisplay *compositor_display;
|
||||||
|
|
||||||
MetaCompositor*
|
MetaCompositor*
|
||||||
meta_compositor_new (MetaDisplay *display)
|
meta_compositor_new (MetaDisplay *display)
|
||||||
{
|
{
|
||||||
@ -98,9 +100,11 @@ meta_compositor_new (MetaDisplay *display)
|
|||||||
|
|
||||||
compositor = g_new0 (MetaCompositor, 1);
|
compositor = g_new0 (MetaCompositor, 1);
|
||||||
|
|
||||||
compositor->display = ws_display_new (NULL);
|
if (!compositor_display)
|
||||||
|
compositor_display = ws_display_new (NULL);
|
||||||
|
compositor->display = compositor_display;
|
||||||
|
|
||||||
ws_display_set_synchronize (compositor->display,
|
ws_display_set_synchronize (compositor_display,
|
||||||
getenv ("METACITY_SYNC") != NULL);
|
getenv ("METACITY_SYNC") != NULL);
|
||||||
|
|
||||||
ws_display_init_test (compositor->display);
|
ws_display_init_test (compositor->display);
|
||||||
@ -109,10 +113,10 @@ meta_compositor_new (MetaDisplay *display)
|
|||||||
compositor->meta_display = display;
|
compositor->meta_display = display;
|
||||||
|
|
||||||
compositor->window_hash = g_hash_table_new_full (
|
compositor->window_hash = g_hash_table_new_full (
|
||||||
meta_unsigned_long_hash,
|
meta_unsigned_long_hash,
|
||||||
meta_unsigned_long_equal,
|
meta_unsigned_long_equal,
|
||||||
NULL,
|
NULL,
|
||||||
free_window_hash_value);
|
free_window_hash_value);
|
||||||
|
|
||||||
compositor->enabled = TRUE;
|
compositor->enabled = TRUE;
|
||||||
|
|
||||||
@ -293,8 +297,8 @@ static void queue_repaint (CmDrawableNode *node, gpointer data);
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
CmDrawableNode *node;
|
CmDrawableNode *node;
|
||||||
GTimer *timer;
|
GTimer *timer;
|
||||||
} FadeInfo;
|
} FadeInfo;
|
||||||
|
|
||||||
#define FADE_TIME 0.3
|
#define FADE_TIME 0.3
|
||||||
@ -302,56 +306,56 @@ typedef struct
|
|||||||
static gboolean
|
static gboolean
|
||||||
fade_in (gpointer data)
|
fade_in (gpointer data)
|
||||||
{
|
{
|
||||||
FadeInfo *info = data;
|
FadeInfo *info = data;
|
||||||
gdouble elapsed = g_timer_elapsed (info->timer, NULL);
|
gdouble elapsed = g_timer_elapsed (info->timer, NULL);
|
||||||
gdouble alpha;
|
gdouble alpha;
|
||||||
|
|
||||||
if (elapsed > FADE_TIME)
|
if (elapsed > FADE_TIME)
|
||||||
alpha = 1.0;
|
alpha = 1.0;
|
||||||
else
|
else
|
||||||
alpha = elapsed / FADE_TIME;
|
alpha = elapsed / FADE_TIME;
|
||||||
|
|
||||||
cm_drawable_node_set_alpha (info->node, alpha);
|
cm_drawable_node_set_alpha (info->node, alpha);
|
||||||
|
|
||||||
if (elapsed >= FADE_TIME)
|
if (elapsed >= FADE_TIME)
|
||||||
{
|
{
|
||||||
g_object_unref (info->node);
|
g_object_unref (info->node);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
fade_out (gpointer data)
|
fade_out (gpointer data)
|
||||||
{
|
{
|
||||||
FadeInfo *info = data;
|
FadeInfo *info = data;
|
||||||
gdouble elapsed = g_timer_elapsed (info->timer, NULL);
|
gdouble elapsed = g_timer_elapsed (info->timer, NULL);
|
||||||
gdouble alpha;
|
gdouble alpha;
|
||||||
|
|
||||||
if (elapsed > FADE_TIME)
|
if (elapsed > FADE_TIME)
|
||||||
alpha = 0.0;
|
alpha = 0.0;
|
||||||
else
|
else
|
||||||
alpha = 1 - (elapsed / FADE_TIME);
|
alpha = 1 - (elapsed / FADE_TIME);
|
||||||
|
|
||||||
cm_drawable_node_set_alpha (info->node, alpha);
|
cm_drawable_node_set_alpha (info->node, alpha);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
g_print ("fade out: %f\n", alpha);
|
g_print ("fade out: %f\n", alpha);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (elapsed >= FADE_TIME)
|
if (elapsed >= FADE_TIME)
|
||||||
{
|
{
|
||||||
cm_drawable_node_set_viewable (info->node, FALSE);
|
cm_drawable_node_set_viewable (info->node, FALSE);
|
||||||
|
|
||||||
g_object_unref (info->node);
|
g_object_unref (info->node);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -496,8 +500,8 @@ process_create (MetaCompositor *compositor,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
g_print (//META_DEBUG_COMPOSITOR,
|
g_print (//META_DEBUG_COMPOSITOR,
|
||||||
"Create window 0x%lx, adding\n", event->window);
|
"Create window 0x%lx, adding\n", event->window);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
meta_compositor_add_window (compositor,
|
meta_compositor_add_window (compositor,
|
||||||
@ -557,8 +561,8 @@ process_reparent (MetaCompositor *compositor,
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
g_print (//META_DEBUG_COMPOSITOR,
|
g_print (//META_DEBUG_COMPOSITOR,
|
||||||
"Reparent window 0x%lx new parent 0x%lx received on 0x%lx\n",
|
"Reparent window 0x%lx new parent 0x%lx received on 0x%lx\n",
|
||||||
event->window, event->parent, event->event);
|
event->window, event->parent, event->event);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
parent_screen = meta_display_screen_for_root (compositor->meta_display,
|
parent_screen = meta_display_screen_for_root (compositor->meta_display,
|
||||||
@ -669,27 +673,27 @@ static void
|
|||||||
update_frame_counter (void)
|
update_frame_counter (void)
|
||||||
{
|
{
|
||||||
#define BUFSIZE 128
|
#define BUFSIZE 128
|
||||||
static GTimer *timer;
|
static GTimer *timer;
|
||||||
static double buffer [BUFSIZE];
|
static double buffer [BUFSIZE];
|
||||||
static int next = 0;
|
static int next = 0;
|
||||||
|
|
||||||
if (!timer)
|
if (!timer)
|
||||||
timer = g_timer_new ();
|
timer = g_timer_new ();
|
||||||
|
|
||||||
buffer[next++] = g_timer_elapsed (timer, NULL);
|
buffer[next++] = g_timer_elapsed (timer, NULL);
|
||||||
|
|
||||||
if (next == BUFSIZE)
|
if (next == BUFSIZE)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
double total;
|
double total;
|
||||||
|
|
||||||
next = 0;
|
next = 0;
|
||||||
|
|
||||||
total = 0.0;
|
total = 0.0;
|
||||||
for (i = 1; i < BUFSIZE; ++i)
|
for (i = 1; i < BUFSIZE; ++i)
|
||||||
total += buffer[i] - buffer[i - 1];
|
total += buffer[i] - buffer[i - 1];
|
||||||
|
|
||||||
g_print ("frames per second: %f\n", 1 / (total / (BUFSIZE - 1)));
|
g_print ("frames per second: %f\n", 1 / (total / (BUFSIZE - 1)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -772,24 +776,30 @@ update (gpointer data)
|
|||||||
static void
|
static void
|
||||||
queue_repaint (CmDrawableNode *node, gpointer data)
|
queue_repaint (CmDrawableNode *node, gpointer data)
|
||||||
{
|
{
|
||||||
MetaScreen *screen = data;
|
MetaScreen *screen = data;
|
||||||
ScreenInfo *scr_info = screen->compositor_data;
|
ScreenInfo *scr_info = screen->compositor_data;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
g_print ("metacity queueing repaint for %p\n", node);
|
g_print ("metacity queueing repaint for %p\n", node);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!scr_info->idle_id)
|
if (!scr_info)
|
||||||
{
|
{
|
||||||
scr_info->idle_id = g_idle_add (update, screen);
|
/* compositor has been turned off */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!scr_info->idle_id)
|
||||||
|
{
|
||||||
|
scr_info->idle_id = g_idle_add (update, screen);
|
||||||
#if 0
|
#if 0
|
||||||
g_print ("done\n");
|
g_print ("done\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
g_print ("one was queued already\n");
|
g_print ("one was queued already\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -799,15 +809,15 @@ queue_repaint (CmDrawableNode *node, gpointer data)
|
|||||||
static void
|
static void
|
||||||
dump_stacking_order (GList *nodes)
|
dump_stacking_order (GList *nodes)
|
||||||
{
|
{
|
||||||
GList *list;
|
GList *list;
|
||||||
|
|
||||||
for (list = nodes; list != NULL; list = list->next)
|
for (list = nodes; list != NULL; list = list->next)
|
||||||
{
|
{
|
||||||
CmDrawableNode *node = list->data;
|
CmDrawableNode *node = list->data;
|
||||||
|
|
||||||
g_print ("%lx, ", WS_RESOURCE_XID (node->drawable));
|
g_print ("%lx, ", WS_RESOURCE_XID (node->drawable));
|
||||||
}
|
}
|
||||||
g_print ("\n");
|
g_print ("\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -838,7 +848,7 @@ meta_compositor_add_window (MetaCompositor *compositor,
|
|||||||
|
|
||||||
if (node != NULL)
|
if (node != NULL)
|
||||||
{
|
{
|
||||||
g_print ("window %lx already added\n", xwindow);
|
g_print ("window %lx already added\n", xwindow);
|
||||||
meta_topic (META_DEBUG_COMPOSITOR,
|
meta_topic (META_DEBUG_COMPOSITOR,
|
||||||
"Window 0x%lx already added\n", xwindow);
|
"Window 0x%lx already added\n", xwindow);
|
||||||
return;
|
return;
|
||||||
@ -853,7 +863,7 @@ meta_compositor_add_window (MetaCompositor *compositor,
|
|||||||
ws_display_end_error_trap (compositor->display);
|
ws_display_end_error_trap (compositor->display);
|
||||||
|
|
||||||
if (!drawable)
|
if (!drawable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
g_assert (scr_info);
|
g_assert (scr_info);
|
||||||
|
|
||||||
@ -862,7 +872,7 @@ meta_compositor_add_window (MetaCompositor *compositor,
|
|||||||
if (ws_window_query_input_only ((WsWindow *)drawable) ||
|
if (ws_window_query_input_only ((WsWindow *)drawable) ||
|
||||||
drawable == (WsDrawable *)scr_info->glw)
|
drawable == (WsDrawable *)scr_info->glw)
|
||||||
{
|
{
|
||||||
ws_display_end_error_trap (compositor->display);
|
ws_display_end_error_trap (compositor->display);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -932,7 +942,7 @@ meta_compositor_manage_screen (MetaCompositor *compositor,
|
|||||||
ScreenInfo *scr_info = g_new0 (ScreenInfo, 1);
|
ScreenInfo *scr_info = g_new0 (ScreenInfo, 1);
|
||||||
|
|
||||||
WsScreen *ws_screen =
|
WsScreen *ws_screen =
|
||||||
ws_display_get_screen_from_number (compositor->display, screen->number);
|
ws_display_get_screen_from_number (compositor->display, screen->number);
|
||||||
WsWindow *root = ws_screen_get_root_window (ws_screen);
|
WsWindow *root = ws_screen_get_root_window (ws_screen);
|
||||||
WsRegion *region;
|
WsRegion *region;
|
||||||
Window current_cm_sn_owner;
|
Window current_cm_sn_owner;
|
||||||
@ -941,7 +951,7 @@ meta_compositor_manage_screen (MetaCompositor *compositor,
|
|||||||
Atom cm_sn_atom;
|
Atom cm_sn_atom;
|
||||||
char buf[128];
|
char buf[128];
|
||||||
|
|
||||||
scr_info->glw = ws_window_new_gl (root);
|
scr_info->glw = ws_screen_get_gl_window (ws_screen);
|
||||||
scr_info->compositor_nodes = NULL;
|
scr_info->compositor_nodes = NULL;
|
||||||
scr_info->idle_id = 0;
|
scr_info->idle_id = 0;
|
||||||
|
|
||||||
@ -966,15 +976,15 @@ meta_compositor_manage_screen (MetaCompositor *compositor,
|
|||||||
current_cm_sn_owner = XGetSelectionOwner (xdisplay, cm_sn_atom);
|
current_cm_sn_owner = XGetSelectionOwner (xdisplay, cm_sn_atom);
|
||||||
|
|
||||||
if (current_cm_sn_owner != None)
|
if (current_cm_sn_owner != None)
|
||||||
{
|
{
|
||||||
meta_warning (_("Screen %d on display \"%s\" already has a compositing manager\n"),
|
meta_warning (_("Screen %d on display \"%s\" already has a compositing manager\n"),
|
||||||
screen->number, ",madgh");
|
screen->number, ",madgh");
|
||||||
}
|
}
|
||||||
|
|
||||||
new_cm_sn_owner = ws_screen_get_root_window (ws_screen);
|
new_cm_sn_owner = ws_screen_get_root_window (ws_screen);
|
||||||
|
|
||||||
XSetSelectionOwner (xdisplay, cm_sn_atom, WS_RESOURCE_XID (new_cm_sn_owner),
|
XSetSelectionOwner (xdisplay, cm_sn_atom, WS_RESOURCE_XID (new_cm_sn_owner),
|
||||||
CurrentTime);
|
CurrentTime);
|
||||||
|
|
||||||
ws_window_map (scr_info->glw);
|
ws_window_map (scr_info->glw);
|
||||||
|
|
||||||
@ -993,6 +1003,9 @@ meta_compositor_unmanage_screen (MetaCompositor *compositor,
|
|||||||
{
|
{
|
||||||
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
||||||
ScreenInfo *scr_info = screen->compositor_data;
|
ScreenInfo *scr_info = screen->compositor_data;
|
||||||
|
WsScreen *ws_screen =
|
||||||
|
ws_display_get_screen_from_number (compositor->display, screen->number);
|
||||||
|
WsWindow *root = ws_screen_get_root_window (ws_screen);
|
||||||
|
|
||||||
if (!compositor->enabled)
|
if (!compositor->enabled)
|
||||||
return; /* no extension */
|
return; /* no extension */
|
||||||
@ -1004,7 +1017,13 @@ meta_compositor_unmanage_screen (MetaCompositor *compositor,
|
|||||||
meta_compositor_remove_window (compositor,
|
meta_compositor_remove_window (compositor,
|
||||||
WS_RESOURCE (node->drawable)->xid);
|
WS_RESOURCE (node->drawable)->xid);
|
||||||
}
|
}
|
||||||
/* FIXME: free scr_info */
|
|
||||||
|
ws_window_raise (scr_info->glw);
|
||||||
|
|
||||||
|
ws_window_unredirect_subwindows (root);
|
||||||
|
ws_window_unmap (scr_info->glw);
|
||||||
|
|
||||||
|
screen->compositor_data = NULL;
|
||||||
|
|
||||||
#endif /* HAVE_COMPOSITE_EXTENSIONS */
|
#endif /* HAVE_COMPOSITE_EXTENSIONS */
|
||||||
}
|
}
|
||||||
@ -1108,13 +1127,13 @@ interpolate_rectangle (gdouble t,
|
|||||||
WsRectangle * to,
|
WsRectangle * to,
|
||||||
WsRectangle * result)
|
WsRectangle * result)
|
||||||
{
|
{
|
||||||
if (!result)
|
if (!result)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
result->x = interpolate (t, from->x, to->x, 1);
|
result->x = interpolate (t, from->x, to->x, 1);
|
||||||
result->y = interpolate (t, from->y, to->y, 1);
|
result->y = interpolate (t, from->y, to->y, 1);
|
||||||
result->width = interpolate (t, from->width, to->width, 1);
|
result->width = interpolate (t, from->width, to->width, 1);
|
||||||
result->height = interpolate (t, from->height, to->height, 1);
|
result->height = interpolate (t, from->height, to->height, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MINIMIZE_STYLE 3
|
#define MINIMIZE_STYLE 3
|
||||||
@ -1142,82 +1161,82 @@ meta_compositor_minimize (MetaCompositor *compositor,
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
CmDrawableNode *node;
|
CmDrawableNode *node;
|
||||||
GTimer *timer;
|
GTimer *timer;
|
||||||
|
|
||||||
MetaCompositor *compositor;
|
MetaCompositor *compositor;
|
||||||
ScreenInfo *scr_info;
|
ScreenInfo *scr_info;
|
||||||
|
|
||||||
MetaMinimizeFinishedFunc finished_func;
|
MetaMinimizeFinishedFunc finished_func;
|
||||||
gpointer finished_data;
|
gpointer finished_data;
|
||||||
|
|
||||||
gdouble aspect_ratio;
|
gdouble aspect_ratio;
|
||||||
|
|
||||||
WsRectangle current_geometry;
|
WsRectangle current_geometry;
|
||||||
WsRectangle target_geometry;
|
WsRectangle target_geometry;
|
||||||
gdouble current_alpha;
|
gdouble current_alpha;
|
||||||
gdouble target_alpha;
|
gdouble target_alpha;
|
||||||
|
|
||||||
int button_x;
|
int button_x;
|
||||||
int button_y;
|
int button_y;
|
||||||
int button_width;
|
int button_width;
|
||||||
int button_height;
|
int button_height;
|
||||||
|
|
||||||
/* FIXME: maybe would be simpler if all of this was an array */
|
/* FIXME: maybe would be simpler if all of this was an array */
|
||||||
gboolean phase_1_started;
|
gboolean phase_1_started;
|
||||||
gboolean phase_2_started;
|
gboolean phase_2_started;
|
||||||
gboolean phase_3_started;
|
gboolean phase_3_started;
|
||||||
gboolean phase_4_started;
|
gboolean phase_4_started;
|
||||||
gboolean phase_5_started;
|
gboolean phase_5_started;
|
||||||
} MiniInfo;
|
} MiniInfo;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_geometry (MiniInfo *info, gdouble elapsed)
|
set_geometry (MiniInfo *info, gdouble elapsed)
|
||||||
{
|
{
|
||||||
WsRectangle rect;
|
WsRectangle rect;
|
||||||
|
|
||||||
interpolate_rectangle (elapsed, &info->current_geometry, &info->target_geometry, &rect);
|
interpolate_rectangle (elapsed, &info->current_geometry, &info->target_geometry, &rect);
|
||||||
|
|
||||||
g_print ("y: %d %d (%f => %d)\n", info->current_geometry.y, info->target_geometry.y,
|
g_print ("y: %d %d (%f => %d)\n", info->current_geometry.y, info->target_geometry.y,
|
||||||
elapsed, rect.y);
|
elapsed, rect.y);
|
||||||
|
|
||||||
g_print ("setting: %d %d %d %d\n", rect.x, rect.y, rect.width, rect.height);
|
g_print ("setting: %d %d %d %d\n", rect.x, rect.y, rect.width, rect.height);
|
||||||
|
|
||||||
cm_drawable_node_set_geometry (info->node,
|
cm_drawable_node_set_geometry (info->node,
|
||||||
rect.x, rect.y,
|
rect.x, rect.y,
|
||||||
rect.width, rect.height);
|
rect.width, rect.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
center (gdouble what, gdouble in)
|
center (gdouble what, gdouble in)
|
||||||
{
|
{
|
||||||
return (in - what) / 2.0 + 0.5;
|
return (in - what) / 2.0 + 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
run_phase_1 (MiniInfo *info, gdouble elapsed)
|
run_phase_1 (MiniInfo *info, gdouble elapsed)
|
||||||
{
|
{
|
||||||
if (!info->phase_1_started)
|
if (!info->phase_1_started)
|
||||||
{
|
{
|
||||||
GList *next;
|
GList *next;
|
||||||
g_print ("starting phase 1\n");
|
g_print ("starting phase 1\n");
|
||||||
info->phase_1_started = TRUE;
|
info->phase_1_started = TRUE;
|
||||||
|
|
||||||
info->current_geometry.x = info->node->real_x;
|
info->current_geometry.x = info->node->real_x;
|
||||||
info->current_geometry.y = info->node->real_y;
|
info->current_geometry.y = info->node->real_y;
|
||||||
info->current_geometry.width = info->node->real_width;
|
info->current_geometry.width = info->node->real_width;
|
||||||
info->current_geometry.height = info->node->real_height;
|
info->current_geometry.height = info->node->real_height;
|
||||||
|
|
||||||
info->target_geometry.height = info->button_height;
|
info->target_geometry.height = info->button_height;
|
||||||
info->target_geometry.width = info->button_height * info->aspect_ratio;
|
info->target_geometry.width = info->button_height * info->aspect_ratio;
|
||||||
info->target_geometry.x = info->button_x + center (info->target_geometry.width, info->button_width);
|
info->target_geometry.x = info->button_x + center (info->target_geometry.width, info->button_width);
|
||||||
info->target_geometry.y = info->node->real_y + center (info->button_height, info->node->real_height);
|
info->target_geometry.y = info->node->real_y + center (info->button_height, info->node->real_height);
|
||||||
|
|
||||||
handle_restacking (info->compositor, info->node,
|
handle_restacking (info->compositor, info->node,
|
||||||
info->scr_info->compositor_nodes->data);
|
info->scr_info->compositor_nodes->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_geometry (info, elapsed);
|
set_geometry (info, elapsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1225,97 +1244,97 @@ run_phase_2 (MiniInfo *info, gdouble elapsed)
|
|||||||
{
|
{
|
||||||
#define WOBBLE_FACTOR 3
|
#define WOBBLE_FACTOR 3
|
||||||
|
|
||||||
if (!info->phase_2_started)
|
if (!info->phase_2_started)
|
||||||
{
|
{
|
||||||
WsRectangle cur = info->target_geometry;
|
WsRectangle cur = info->target_geometry;
|
||||||
|
|
||||||
g_print ("starting phase 2\n");
|
g_print ("starting phase 2\n");
|
||||||
|
|
||||||
info->phase_2_started = TRUE;
|
info->phase_2_started = TRUE;
|
||||||
|
|
||||||
info->current_geometry = cur;
|
info->current_geometry = cur;
|
||||||
|
|
||||||
info->target_geometry.x = cur.x + center (WOBBLE_FACTOR * cur.width, cur.width);
|
info->target_geometry.x = cur.x + center (WOBBLE_FACTOR * cur.width, cur.width);
|
||||||
info->target_geometry.y = cur.y + center (WOBBLE_FACTOR * cur.height, cur.height);
|
info->target_geometry.y = cur.y + center (WOBBLE_FACTOR * cur.height, cur.height);
|
||||||
info->target_geometry.width = cur.width * WOBBLE_FACTOR;
|
info->target_geometry.width = cur.width * WOBBLE_FACTOR;
|
||||||
info->target_geometry.height = cur.height * WOBBLE_FACTOR;
|
info->target_geometry.height = cur.height * WOBBLE_FACTOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_geometry (info, elapsed);
|
set_geometry (info, elapsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
run_phase_3 (MiniInfo *info, gdouble elapsed)
|
run_phase_3 (MiniInfo *info, gdouble elapsed)
|
||||||
{
|
{
|
||||||
if (!info->phase_3_started)
|
if (!info->phase_3_started)
|
||||||
{
|
{
|
||||||
WsRectangle cur = info->target_geometry;
|
WsRectangle cur = info->target_geometry;
|
||||||
|
|
||||||
g_print ("starting phase 3\n");
|
g_print ("starting phase 3\n");
|
||||||
info->phase_3_started = TRUE;
|
info->phase_3_started = TRUE;
|
||||||
|
|
||||||
info->current_geometry = cur;
|
info->current_geometry = cur;
|
||||||
|
|
||||||
info->target_geometry.height = info->button_height;
|
info->target_geometry.height = info->button_height;
|
||||||
info->target_geometry.width = info->button_height * info->aspect_ratio;
|
info->target_geometry.width = info->button_height * info->aspect_ratio;
|
||||||
info->target_geometry.x = info->button_x + center (info->target_geometry.width, info->button_width);
|
info->target_geometry.x = info->button_x + center (info->target_geometry.width, info->button_width);
|
||||||
info->target_geometry.y = info->node->real_y + center (info->button_height, info->node->real_height);
|
info->target_geometry.y = info->node->real_y + center (info->button_height, info->node->real_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_geometry (info, elapsed);
|
set_geometry (info, elapsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
run_phase_4 (MiniInfo *info, gdouble elapsed)
|
run_phase_4 (MiniInfo *info, gdouble elapsed)
|
||||||
{
|
{
|
||||||
if (!info->phase_4_started)
|
if (!info->phase_4_started)
|
||||||
{
|
{
|
||||||
WsRectangle cur = info->target_geometry;
|
WsRectangle cur = info->target_geometry;
|
||||||
|
|
||||||
g_print ("starting phase 4\n");
|
g_print ("starting phase 4\n");
|
||||||
info->phase_4_started = TRUE;
|
info->phase_4_started = TRUE;
|
||||||
|
|
||||||
info->current_geometry = cur;
|
info->current_geometry = cur;
|
||||||
|
|
||||||
info->target_geometry.height = info->button_height;
|
info->target_geometry.height = info->button_height;
|
||||||
info->target_geometry.width = info->button_height * info->aspect_ratio;
|
info->target_geometry.width = info->button_height * info->aspect_ratio;
|
||||||
info->target_geometry.x = cur.x;
|
info->target_geometry.x = cur.x;
|
||||||
g_print ("button y: %d\n", info->button_y);
|
g_print ("button y: %d\n", info->button_y);
|
||||||
info->target_geometry.y = info->button_y;
|
info->target_geometry.y = info->button_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_geometry (info, elapsed);
|
set_geometry (info, elapsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
run_phase_5 (MiniInfo *info, gdouble elapsed)
|
run_phase_5 (MiniInfo *info, gdouble elapsed)
|
||||||
{
|
{
|
||||||
if (!info->phase_5_started)
|
if (!info->phase_5_started)
|
||||||
{
|
{
|
||||||
WsRectangle cur = info->target_geometry;
|
WsRectangle cur = info->target_geometry;
|
||||||
|
|
||||||
g_print ("starting phase 5\n");
|
g_print ("starting phase 5\n");
|
||||||
info->phase_5_started = TRUE;
|
info->phase_5_started = TRUE;
|
||||||
|
|
||||||
info->current_geometry = cur;
|
info->current_geometry = cur;
|
||||||
info->target_geometry.x = info->button_x;
|
info->target_geometry.x = info->button_x;
|
||||||
info->target_geometry.y = info->button_y;
|
info->target_geometry.y = info->button_y;
|
||||||
info->target_geometry.width = info->button_width;
|
info->target_geometry.width = info->button_width;
|
||||||
info->target_geometry.height = info->button_height;
|
info->target_geometry.height = info->button_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_geometry (info, elapsed);
|
set_geometry (info, elapsed);
|
||||||
|
|
||||||
cm_drawable_node_set_alpha (info->node, 1 - elapsed);
|
cm_drawable_node_set_alpha (info->node, 1 - elapsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
run_animation_01 (gpointer data)
|
run_animation_01 (gpointer data)
|
||||||
{
|
{
|
||||||
MiniInfo *info = data;
|
MiniInfo *info = data;
|
||||||
gdouble elapsed;
|
gdouble elapsed;
|
||||||
|
|
||||||
elapsed = g_timer_elapsed (info->timer, NULL);
|
elapsed = g_timer_elapsed (info->timer, NULL);
|
||||||
|
|
||||||
#define PHASE_0 0.0
|
#define PHASE_0 0.0
|
||||||
#define PHASE_1 0.225 /* scale to size of button */
|
#define PHASE_1 0.225 /* scale to size of button */
|
||||||
@ -1324,46 +1343,46 @@ run_animation_01 (gpointer data)
|
|||||||
#define PHASE_4 0.650 /* move to button */
|
#define PHASE_4 0.650 /* move to button */
|
||||||
#define PHASE_5 1.0 /* fade out */
|
#define PHASE_5 1.0 /* fade out */
|
||||||
|
|
||||||
if (elapsed < PHASE_1)
|
if (elapsed < PHASE_1)
|
||||||
{
|
{
|
||||||
/* phase one */
|
/* phase one */
|
||||||
run_phase_1 (info, (elapsed - PHASE_0)/(PHASE_1 - PHASE_0));
|
run_phase_1 (info, (elapsed - PHASE_0)/(PHASE_1 - PHASE_0));
|
||||||
}
|
}
|
||||||
else if (elapsed < PHASE_2)
|
else if (elapsed < PHASE_2)
|
||||||
{
|
{
|
||||||
/* phase two */
|
/* phase two */
|
||||||
run_phase_2 (info, (elapsed - PHASE_1)/(PHASE_2 - PHASE_1));
|
run_phase_2 (info, (elapsed - PHASE_1)/(PHASE_2 - PHASE_1));
|
||||||
}
|
}
|
||||||
else if (elapsed < PHASE_3)
|
else if (elapsed < PHASE_3)
|
||||||
{
|
{
|
||||||
/* phase three */
|
/* phase three */
|
||||||
run_phase_3 (info, (elapsed - PHASE_2)/(PHASE_3 - PHASE_2));
|
run_phase_3 (info, (elapsed - PHASE_2)/(PHASE_3 - PHASE_2));
|
||||||
}
|
}
|
||||||
else if (elapsed < PHASE_4)
|
else if (elapsed < PHASE_4)
|
||||||
{
|
{
|
||||||
/* phase four */
|
/* phase four */
|
||||||
run_phase_4 (info, (elapsed - PHASE_3)/(PHASE_4 - PHASE_3));
|
run_phase_4 (info, (elapsed - PHASE_3)/(PHASE_4 - PHASE_3));
|
||||||
}
|
}
|
||||||
else if (elapsed < PHASE_5)
|
else if (elapsed < PHASE_5)
|
||||||
{
|
{
|
||||||
/* phase five */
|
/* phase five */
|
||||||
run_phase_5 (info, (elapsed - PHASE_4)/(PHASE_5 - PHASE_4));
|
run_phase_5 (info, (elapsed - PHASE_4)/(PHASE_5 - PHASE_4));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cm_drawable_node_set_viewable (info->node, FALSE);
|
cm_drawable_node_set_viewable (info->node, FALSE);
|
||||||
|
|
||||||
cm_drawable_node_unset_geometry (info->node);
|
cm_drawable_node_unset_geometry (info->node);
|
||||||
|
|
||||||
cm_drawable_node_set_alpha (info->node, 1.0);
|
cm_drawable_node_set_alpha (info->node, 1.0);
|
||||||
|
|
||||||
if (info->finished_func)
|
if (info->finished_func)
|
||||||
info->finished_func (info->finished_data);
|
info->finished_func (info->finished_data);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1429,52 +1448,52 @@ meta_compositor_unminimize (MetaCompositor *compositor,
|
|||||||
static gboolean
|
static gboolean
|
||||||
do_minimize_animation (gpointer data)
|
do_minimize_animation (gpointer data)
|
||||||
{
|
{
|
||||||
MiniInfo *info = data;
|
MiniInfo *info = data;
|
||||||
double elapsed;
|
double elapsed;
|
||||||
gboolean done = FALSE;
|
gboolean done = FALSE;
|
||||||
|
|
||||||
#define FADE_TIME 0.5
|
#define FADE_TIME 0.5
|
||||||
|
|
||||||
elapsed = g_timer_elapsed (info->timer, NULL);
|
elapsed = g_timer_elapsed (info->timer, NULL);
|
||||||
elapsed = elapsed / FADE_TIME;
|
elapsed = elapsed / FADE_TIME;
|
||||||
|
|
||||||
if (elapsed >= 1.0)
|
if (elapsed >= 1.0)
|
||||||
{
|
{
|
||||||
elapsed = 1.0;
|
elapsed = 1.0;
|
||||||
done = TRUE;
|
done = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_print ("%f\n", elapsed);
|
g_print ("%f\n", elapsed);
|
||||||
|
|
||||||
cm_drawable_node_set_geometry (info->node,
|
cm_drawable_node_set_geometry (info->node,
|
||||||
info->node->real_x + interpolate (elapsed, 0, info->node->real_width / 2, 1),
|
info->node->real_x + interpolate (elapsed, 0, info->node->real_width / 2, 1),
|
||||||
info->node->real_y + interpolate (elapsed, 0, info->node->real_height / 2, 1),
|
info->node->real_y + interpolate (elapsed, 0, info->node->real_height / 2, 1),
|
||||||
interpolate (elapsed, info->node->real_width, 0, 1),
|
interpolate (elapsed, info->node->real_width, 0, 1),
|
||||||
interpolate (elapsed, info->node->real_height, 0, 1));
|
interpolate (elapsed, info->node->real_height, 0, 1));
|
||||||
|
|
||||||
if (done)
|
if (done)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
g_print ("inter: %f %f %f\n", 0, 735, interpolate (0.0, 735.0, 0.5, 1.0));
|
g_print ("inter: %f %f %f\n", 0, 735, interpolate (0.0, 735.0, 0.5, 1.0));
|
||||||
|
|
||||||
g_print ("inter x .5: %f (%d %d)\n", info->node->real_x + interpolate (0, info->node->real_width / 2, .5, 1), 0, info->node->real_width);
|
g_print ("inter x .5: %f (%d %d)\n", info->node->real_x + interpolate (0, info->node->real_width / 2, .5, 1), 0, info->node->real_width);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cm_drawable_node_set_alpha (info->node, 1 - elapsed);
|
cm_drawable_node_set_alpha (info->node, 1 - elapsed);
|
||||||
|
|
||||||
if (done)
|
if (done)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
queue_repaint (info->node,
|
queue_repaint (info->node,
|
||||||
node_get_screen (info->window->display->xdisplay,
|
node_get_screen (info->window->display->xdisplay,
|
||||||
info->node));
|
info->node));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1542,23 +1561,23 @@ struct Model {
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
CmDrawableNode *node;
|
CmDrawableNode *node;
|
||||||
GTimer *timer;
|
GTimer *timer;
|
||||||
gboolean expand;
|
gboolean expand;
|
||||||
|
|
||||||
MetaCompositor *compositor;
|
MetaCompositor *compositor;
|
||||||
ScreenInfo *scr_info;
|
ScreenInfo *scr_info;
|
||||||
MetaRectangle rect;
|
MetaRectangle rect;
|
||||||
|
|
||||||
MetaAnimationFinishedFunc finished_func;
|
MetaAnimationFinishedFunc finished_func;
|
||||||
gpointer finished_data;
|
gpointer finished_data;
|
||||||
|
|
||||||
Model model;
|
Model model;
|
||||||
|
|
||||||
int button_x;
|
int button_x;
|
||||||
int button_y;
|
int button_y;
|
||||||
int button_width;
|
int button_width;
|
||||||
int button_height;
|
int button_height;
|
||||||
} MiniInfo;
|
} MiniInfo;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1774,57 +1793,57 @@ model_step (Model *model)
|
|||||||
static gboolean
|
static gboolean
|
||||||
run_animation (gpointer data)
|
run_animation (gpointer data)
|
||||||
{
|
{
|
||||||
MiniInfo *info = data;
|
MiniInfo *info = data;
|
||||||
gdouble t, blend;
|
gdouble t, blend;
|
||||||
CmPoint points[4][4];
|
CmPoint points[4][4];
|
||||||
int i, j, steps, target_x, target_y;
|
int i, j, steps, target_x, target_y;
|
||||||
|
|
||||||
t = g_timer_elapsed (info->timer, NULL);
|
t = g_timer_elapsed (info->timer, NULL);
|
||||||
|
|
||||||
info->model.steps += (t - info->model.last_time) / 0.03;
|
info->model.steps += (t - info->model.last_time) / 0.03;
|
||||||
info->model.last_time = t;
|
info->model.last_time = t;
|
||||||
steps = floor(info->model.steps);
|
steps = floor(info->model.steps);
|
||||||
info->model.steps -= steps;
|
info->model.steps -= steps;
|
||||||
|
|
||||||
for (i = 0; i < steps; i++)
|
for (i = 0; i < steps; i++)
|
||||||
model_step (&info->model);
|
model_step (&info->model);
|
||||||
|
|
||||||
if (info->expand)
|
if (info->expand)
|
||||||
blend = t / WOBBLE_TIME;
|
blend = t / WOBBLE_TIME;
|
||||||
else
|
else
|
||||||
blend = 0;
|
blend = 0;
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
for (j = 0; j < 4; j++) {
|
for (j = 0; j < 4; j++) {
|
||||||
target_x = info->node->real_x + i * info->node->real_width / 3;
|
target_x = info->node->real_x + i * info->node->real_width / 3;
|
||||||
target_y = info->node->real_y + j * info->node->real_height / 3;
|
target_y = info->node->real_y + j * info->node->real_height / 3;
|
||||||
|
|
||||||
points[j][i].x =
|
points[j][i].x =
|
||||||
(1 - blend) * info->model.objects[j * 4 + i].position.x +
|
(1 - blend) * info->model.objects[j * 4 + i].position.x +
|
||||||
blend * target_x;
|
blend * target_x;
|
||||||
points[j][i].y =
|
points[j][i].y =
|
||||||
(1 - blend) * info->model.objects[j * 4 + i].position.y +
|
(1 - blend) * info->model.objects[j * 4 + i].position.y +
|
||||||
blend * target_y;
|
blend * target_y;
|
||||||
}
|
|
||||||
|
|
||||||
cm_drawable_node_set_patch (info->node, points);
|
|
||||||
if (info->expand)
|
|
||||||
cm_drawable_node_set_alpha (info->node, t / WOBBLE_TIME);
|
|
||||||
else
|
|
||||||
cm_drawable_node_set_alpha (info->node, 1.0 - t / WOBBLE_TIME);
|
|
||||||
|
|
||||||
if (t > WOBBLE_TIME) {
|
|
||||||
cm_drawable_node_set_viewable (info->node, info->expand);
|
|
||||||
cm_drawable_node_unset_geometry (info->node);
|
|
||||||
cm_drawable_node_set_alpha (info->node, 1.0);
|
|
||||||
|
|
||||||
if (info->finished_func)
|
|
||||||
info->finished_func (info->finished_data);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cm_drawable_node_set_patch (info->node, points);
|
||||||
|
if (info->expand)
|
||||||
|
cm_drawable_node_set_alpha (info->node, t / WOBBLE_TIME);
|
||||||
|
else
|
||||||
|
cm_drawable_node_set_alpha (info->node, 1.0 - t / WOBBLE_TIME);
|
||||||
|
|
||||||
|
if (t > WOBBLE_TIME) {
|
||||||
|
cm_drawable_node_set_viewable (info->node, info->expand);
|
||||||
|
cm_drawable_node_unset_geometry (info->node);
|
||||||
|
cm_drawable_node_set_alpha (info->node, 1.0);
|
||||||
|
|
||||||
|
if (info->finished_func)
|
||||||
|
info->finished_func (info->finished_data);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1980,4 +1999,23 @@ meta_compositor_delete_window (MetaCompositor *compositor,
|
|||||||
g_idle_add (blow_up, info);
|
g_idle_add (blow_up, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_compositor_destroy (MetaCompositor *compositor)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
||||||
|
GSList *list;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* FIXME */
|
||||||
|
ws_display_free (compositor->display);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
g_hash_table_destroy (compositor->window_hash);
|
||||||
|
|
||||||
|
g_free (compositor);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -67,5 +67,7 @@ void
|
|||||||
meta_compositor_set_updates (MetaCompositor *compositor,
|
meta_compositor_set_updates (MetaCompositor *compositor,
|
||||||
MetaWindow *window,
|
MetaWindow *window,
|
||||||
gboolean updates);
|
gboolean updates);
|
||||||
|
void
|
||||||
|
meta_compositor_destroy (MetaCompositor *compositor);
|
||||||
|
|
||||||
#endif /* META_COMPOSITOR_H */
|
#endif /* META_COMPOSITOR_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user