Fixed up for new plugin API; changed private key not to colide with default plugin.

This commit is contained in:
Tomas Frydrych 2008-10-08 12:33:24 +01:00
parent 1addb6ddc1
commit 306a7497fc

View File

@ -23,6 +23,7 @@
#define META_COMPOSITOR_CLUTTER_BUILDING_PLUGIN 1 #define META_COMPOSITOR_CLUTTER_BUILDING_PLUGIN 1
#include "compositor-clutter-plugin.h" #include "compositor-clutter-plugin.h"
#include "compositor-clutter.h"
#include <libintl.h> #include <libintl.h>
#define _(x) dgettext (GETTEXT_PACKAGE, x) #define _(x) dgettext (GETTEXT_PACKAGE, x)
@ -38,27 +39,22 @@
#define MAP_TIMEOUT 250 #define MAP_TIMEOUT 250
#define SWITCH_TIMEOUT 500 #define SWITCH_TIMEOUT 500
#define ACTOR_DATA_KEY "MCCP-Simple-actor-data" #define ACTOR_DATA_KEY "MCCP-Moblin-actor-data"
typedef struct PluginPrivate PluginPrivate; typedef struct PluginPrivate PluginPrivate;
typedef struct ActorPrivate ActorPrivate; typedef struct ActorPrivate ActorPrivate;
static void minimize (ClutterActor *actor, MetaCompWindowType type, static void minimize (MetaCompWindow *actor);
gint workspace); static void map (MetaCompWindow *actor);
static void map (ClutterActor *actor, MetaCompWindowType type, static void destroy (MetaCompWindow *actor);
gint workspace); static void maximize (MetaCompWindow *actor,
static void destroy (ClutterActor *actor, MetaCompWindowType type,
gint workspace);
static void maximize (ClutterActor *actor, MetaCompWindowType type,
gint workspace,
gint x, gint y, gint width, gint height); gint x, gint y, gint width, gint height);
static void unmaximize (ClutterActor *actor, MetaCompWindowType type, static void unmaximize (MetaCompWindow *actor,
gint workspace,
gint x, gint y, gint width, gint height); gint x, gint y, gint width, gint height);
static void switch_workspace (const GList **actors, gint from, gint to); static void switch_workspace (const GList **actors, gint from, gint to);
static void kill_effect (ClutterActor *actor, gulong event); static void kill_effect (MetaCompWindow *actor, gulong event);
static gboolean reload (void); static gboolean reload (void);
@ -78,7 +74,7 @@ MetaCompositorClutterPlugin META_COMPOSITOR_CLUTTER_PLUGIN_STRUCT =
.version_api = METACITY_CLUTTER_PLUGIN_API_VERSION, .version_api = METACITY_CLUTTER_PLUGIN_API_VERSION,
/* Human readable name (for use in UI) */ /* Human readable name (for use in UI) */
.name = "Simple Effects", .name = "Default Effects",
/* Which types of events this plugin supports */ /* Which types of events this plugin supports */
.features = META_COMPOSITOR_CLUTTER_PLUGIN_MINIMIZE | .features = META_COMPOSITOR_CLUTTER_PLUGIN_MINIMIZE |
@ -146,7 +142,7 @@ struct ActorPrivate
* Actor private data accessor * Actor private data accessor
*/ */
static ActorPrivate * static ActorPrivate *
get_actor_private (ClutterActor *actor) get_actor_private (MetaCompWindow *actor)
{ {
ActorPrivate * priv = g_object_get_data (G_OBJECT (actor), ACTOR_DATA_KEY); ActorPrivate * priv = g_object_get_data (G_OBJECT (actor), ACTOR_DATA_KEY);
@ -165,12 +161,13 @@ on_switch_workspace_effect_complete (ClutterActor *group, gpointer data)
MetaCompositorClutterPlugin *plugin = &META_COMPOSITOR_CLUTTER_PLUGIN_STRUCT; MetaCompositorClutterPlugin *plugin = &META_COMPOSITOR_CLUTTER_PLUGIN_STRUCT;
PluginPrivate *ppriv = plugin->plugin_private; PluginPrivate *ppriv = plugin->plugin_private;
GList *l = *((GList**)data); GList *l = *((GList**)data);
ClutterActor *actor_for_cb = l->data; MetaCompWindow *actor_for_cb = l->data;
while (l) while (l)
{ {
ClutterActor *a = l->data; ClutterActor *a = l->data;
ActorPrivate *priv = get_actor_private (a); MetaCompWindow *mcw = META_COMP_WINDOW (a);
ActorPrivate *priv = get_actor_private (mcw);
if (priv->orig_parent) if (priv->orig_parent)
{ {
@ -234,12 +231,12 @@ switch_workspace (const GList **actors, gint from, gint to)
while (l) while (l)
{ {
ClutterActor *a = l->data; MetaCompWindow *mcw = l->data;
ActorPrivate *priv = get_actor_private (a); ActorPrivate *priv = get_actor_private (mcw);
ClutterActor *a = CLUTTER_ACTOR (mcw);
gint workspace; gint workspace;
workspace = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (a), workspace = meta_comp_window_get_workspace (mcw);
META_COMPOSITOR_CLUTTER_PLUGIN_WORKSPACE_KEY));
priv->workspace = workspace; priv->workspace = workspace;
@ -301,8 +298,10 @@ on_minimize_effect_complete (ClutterActor *actor, gpointer data)
* that the restoration will not be visible. * that the restoration will not be visible.
*/ */
MetaCompositorClutterPlugin *plugin = &META_COMPOSITOR_CLUTTER_PLUGIN_STRUCT; MetaCompositorClutterPlugin *plugin = &META_COMPOSITOR_CLUTTER_PLUGIN_STRUCT;
ActorPrivate *apriv = get_actor_private (actor); ActorPrivate *apriv;
MetaCompWindow *mcw = META_COMP_WINDOW (actor);
apriv = get_actor_private (META_COMP_WINDOW (actor));
apriv->tml_minimize = NULL; apriv->tml_minimize = NULL;
clutter_actor_hide (actor); clutter_actor_hide (actor);
@ -316,7 +315,7 @@ on_minimize_effect_complete (ClutterActor *actor, gpointer data)
/* Now notify the manager that we are done with this effect */ /* Now notify the manager that we are done with this effect */
if (plugin->completed) if (plugin->completed)
plugin->completed (plugin, actor, META_COMPOSITOR_CLUTTER_PLUGIN_MINIMIZE); plugin->completed (plugin, mcw, META_COMPOSITOR_CLUTTER_PLUGIN_MINIMIZE);
} }
/* /*
@ -324,15 +323,19 @@ on_minimize_effect_complete (ClutterActor *actor, gpointer data)
* completion). * completion).
*/ */
static void static void
minimize (ClutterActor *actor, MetaCompWindowType type, gint workspace) minimize (MetaCompWindow *mcw)
{ {
MetaCompositorClutterPlugin *plugin = &META_COMPOSITOR_CLUTTER_PLUGIN_STRUCT; MetaCompositorClutterPlugin *plugin = &META_COMPOSITOR_CLUTTER_PLUGIN_STRUCT;
PluginPrivate *priv = plugin->plugin_private; PluginPrivate *priv = plugin->plugin_private;
MetaCompWindowType type;
ClutterActor *actor = CLUTTER_ACTOR (mcw);
type = meta_comp_window_get_window_type (mcw);
if (type == META_COMP_WINDOW_NORMAL) if (type == META_COMP_WINDOW_NORMAL)
{ {
ActorPrivate *apriv = get_actor_private (actor); ActorPrivate *apriv = get_actor_private (mcw);
apriv->is_minimized = TRUE; apriv->is_minimized = TRUE;
@ -350,7 +353,7 @@ minimize (ClutterActor *actor, MetaCompWindowType type, gint workspace)
NULL); NULL);
} }
else if (plugin->completed) else if (plugin->completed)
plugin->completed (plugin, actor, META_COMPOSITOR_CLUTTER_PLUGIN_MINIMIZE); plugin->completed (plugin, mcw, META_COMPOSITOR_CLUTTER_PLUGIN_MINIMIZE);
} }
/* /*
@ -364,7 +367,8 @@ on_maximize_effect_complete (ClutterActor *actor, gpointer data)
* Must reverse the effect of the effect. * Must reverse the effect of the effect.
*/ */
MetaCompositorClutterPlugin *plugin = &META_COMPOSITOR_CLUTTER_PLUGIN_STRUCT; MetaCompositorClutterPlugin *plugin = &META_COMPOSITOR_CLUTTER_PLUGIN_STRUCT;
ActorPrivate *apriv = get_actor_private (actor); MetaCompWindow *mcw = META_COMP_WINDOW (actor);
ActorPrivate *apriv = get_actor_private (mcw);
apriv->tml_maximize = NULL; apriv->tml_maximize = NULL;
@ -377,7 +381,7 @@ on_maximize_effect_complete (ClutterActor *actor, gpointer data)
/* Now notify the manager that we are done with this effect */ /* Now notify the manager that we are done with this effect */
if (plugin->completed) if (plugin->completed)
plugin->completed (plugin, actor, META_COMPOSITOR_CLUTTER_PLUGIN_MAXIMIZE); plugin->completed (plugin, mcw, META_COMPOSITOR_CLUTTER_PLUGIN_MAXIMIZE);
} }
/* /*
@ -389,20 +393,24 @@ on_maximize_effect_complete (ClutterActor *actor, gpointer data)
* (Something like a sound would be more appropriate.) * (Something like a sound would be more appropriate.)
*/ */
static void static void
maximize (ClutterActor *actor, MetaCompWindowType type, gint workspace, maximize (MetaCompWindow *mcw,
gint end_x, gint end_y, gint end_width, gint end_height) gint end_x, gint end_y, gint end_width, gint end_height)
{ {
MetaCompositorClutterPlugin *plugin = &META_COMPOSITOR_CLUTTER_PLUGIN_STRUCT; MetaCompositorClutterPlugin *plugin = &META_COMPOSITOR_CLUTTER_PLUGIN_STRUCT;
PluginPrivate *priv = plugin->plugin_private; PluginPrivate *priv = plugin->plugin_private;
MetaCompWindowType type;
ClutterActor *actor = CLUTTER_ACTOR (mcw);
gdouble scale_x = 1.0; gdouble scale_x = 1.0;
gdouble scale_y = 1.0; gdouble scale_y = 1.0;
gint anchor_x = 0; gint anchor_x = 0;
gint anchor_y = 0; gint anchor_y = 0;
type = meta_comp_window_get_window_type (mcw);
if (type == META_COMP_WINDOW_NORMAL) if (type == META_COMP_WINDOW_NORMAL)
{ {
ActorPrivate *apriv = get_actor_private (actor); ActorPrivate *apriv = get_actor_private (mcw);
guint width, height; guint width, height;
gint x, y; gint x, y;
@ -437,7 +445,7 @@ maximize (ClutterActor *actor, MetaCompWindowType type, gint workspace,
} }
if (plugin->completed) if (plugin->completed)
plugin->completed (plugin, actor, META_COMPOSITOR_CLUTTER_PLUGIN_MAXIMIZE); plugin->completed (plugin, mcw, META_COMPOSITOR_CLUTTER_PLUGIN_MAXIMIZE);
} }
/* /*
@ -446,23 +454,23 @@ maximize (ClutterActor *actor, MetaCompWindowType type, gint workspace,
* (Just a skeleton code.) * (Just a skeleton code.)
*/ */
static void static void
unmaximize (ClutterActor *actor, MetaCompWindowType type, gint workspace, unmaximize (MetaCompWindow *mcw,
gint end_x, gint end_y, gint end_width, gint end_height) gint end_x, gint end_y, gint end_width, gint end_height)
{ {
MetaCompositorClutterPlugin *plugin = &META_COMPOSITOR_CLUTTER_PLUGIN_STRUCT; MetaCompositorClutterPlugin *plugin = &META_COMPOSITOR_CLUTTER_PLUGIN_STRUCT;
MetaCompWindowType type;
type = meta_comp_window_get_window_type (mcw);
if (type == META_COMP_WINDOW_NORMAL) if (type == META_COMP_WINDOW_NORMAL)
{ {
ActorPrivate *apriv = get_actor_private (actor); ActorPrivate *apriv = get_actor_private (mcw);
apriv->is_maximized = FALSE; apriv->is_maximized = FALSE;
printf ("Doing unmaximize to target %d,%d;%dx%d\n",
end_x, end_y, end_width, end_height);
} }
/* Do this conditionally, if the effect requires completion callback. */ /* Do this conditionally, if the effect requires completion callback. */
plugin->completed (plugin, actor, META_COMPOSITOR_CLUTTER_PLUGIN_UNMAXIMIZE); plugin->completed (plugin, mcw, META_COMPOSITOR_CLUTTER_PLUGIN_UNMAXIMIZE);
} }
static void static void
@ -472,7 +480,8 @@ on_map_effect_complete (ClutterActor *actor, gpointer data)
* Must reverse the effect of the effect. * Must reverse the effect of the effect.
*/ */
MetaCompositorClutterPlugin *plugin = &META_COMPOSITOR_CLUTTER_PLUGIN_STRUCT; MetaCompositorClutterPlugin *plugin = &META_COMPOSITOR_CLUTTER_PLUGIN_STRUCT;
ActorPrivate *apriv = get_actor_private (actor); MetaCompWindow *mcw = META_COMP_WINDOW (actor);
ActorPrivate *apriv = get_actor_private (mcw);
apriv->tml_map = NULL; apriv->tml_map = NULL;
@ -484,7 +493,7 @@ on_map_effect_complete (ClutterActor *actor, gpointer data)
/* Now notify the manager that we are done with this effect */ /* Now notify the manager that we are done with this effect */
if (plugin->completed) if (plugin->completed)
plugin->completed (plugin, actor, META_COMPOSITOR_CLUTTER_PLUGIN_MAP); plugin->completed (plugin, mcw, META_COMPOSITOR_CLUTTER_PLUGIN_MAP);
} }
/* /*
@ -492,14 +501,18 @@ on_map_effect_complete (ClutterActor *actor, gpointer data)
* completion). * completion).
*/ */
static void static void
map (ClutterActor *actor, MetaCompWindowType type, gint workspace) map (MetaCompWindow *mcw)
{ {
MetaCompositorClutterPlugin *plugin = &META_COMPOSITOR_CLUTTER_PLUGIN_STRUCT; MetaCompositorClutterPlugin *plugin = &META_COMPOSITOR_CLUTTER_PLUGIN_STRUCT;
PluginPrivate *priv = plugin->plugin_private; PluginPrivate *priv = plugin->plugin_private;
MetaCompWindowType type;
ClutterActor *actor = CLUTTER_ACTOR (mcw);
type = meta_comp_window_get_window_type (mcw);
if (type == META_COMP_WINDOW_NORMAL) if (type == META_COMP_WINDOW_NORMAL)
{ {
ActorPrivate *apriv = get_actor_private (actor); ActorPrivate *apriv = get_actor_private (mcw);
clutter_actor_move_anchor_point_from_gravity (actor, clutter_actor_move_anchor_point_from_gravity (actor,
CLUTTER_GRAVITY_CENTER); CLUTTER_GRAVITY_CENTER);
@ -521,7 +534,7 @@ map (ClutterActor *actor, MetaCompWindowType type, gint workspace)
} }
else if (plugin->completed) else if (plugin->completed)
plugin->completed (plugin, actor, META_COMPOSITOR_CLUTTER_PLUGIN_MAP); plugin->completed (plugin, mcw, META_COMPOSITOR_CLUTTER_PLUGIN_MAP);
} }
/* /*
@ -533,28 +546,33 @@ static void
on_destroy_effect_complete (ClutterActor *actor, gpointer data) on_destroy_effect_complete (ClutterActor *actor, gpointer data)
{ {
MetaCompositorClutterPlugin *plugin = &META_COMPOSITOR_CLUTTER_PLUGIN_STRUCT; MetaCompositorClutterPlugin *plugin = &META_COMPOSITOR_CLUTTER_PLUGIN_STRUCT;
ActorPrivate *apriv = get_actor_private (actor); MetaCompWindow *mcw = META_COMP_WINDOW (actor);
ActorPrivate *apriv = get_actor_private (mcw);
apriv->tml_destroy = NULL; apriv->tml_destroy = NULL;
plugin->running--; plugin->running--;
if (plugin->completed) if (plugin->completed)
plugin->completed (plugin, actor, META_COMPOSITOR_CLUTTER_PLUGIN_DESTROY); plugin->completed (plugin, mcw, META_COMPOSITOR_CLUTTER_PLUGIN_DESTROY);
} }
/* /*
* Simple TV-out like effect. * Simple TV-out like effect.
*/ */
static void static void
destroy (ClutterActor *actor, MetaCompWindowType type, gint workspace) destroy (MetaCompWindow *mcw)
{ {
MetaCompositorClutterPlugin *plugin = &META_COMPOSITOR_CLUTTER_PLUGIN_STRUCT; MetaCompositorClutterPlugin *plugin = &META_COMPOSITOR_CLUTTER_PLUGIN_STRUCT;
PluginPrivate *priv = plugin->plugin_private; PluginPrivate *priv = plugin->plugin_private;
MetaCompWindowType type;
ClutterActor *actor = CLUTTER_ACTOR (mcw);
type = meta_comp_window_get_window_type (mcw);
if (type == META_COMP_WINDOW_NORMAL) if (type == META_COMP_WINDOW_NORMAL)
{ {
ActorPrivate *apriv = get_actor_private (actor); ActorPrivate *apriv = get_actor_private (mcw);
clutter_actor_move_anchor_point_from_gravity (actor, clutter_actor_move_anchor_point_from_gravity (actor,
CLUTTER_GRAVITY_CENTER); CLUTTER_GRAVITY_CENTER);
@ -570,14 +588,15 @@ destroy (ClutterActor *actor, MetaCompWindowType type, gint workspace)
NULL); NULL);
} }
else if (plugin->completed) else if (plugin->completed)
plugin->completed (plugin, actor, META_COMPOSITOR_CLUTTER_PLUGIN_DESTROY); plugin->completed (plugin, mcw, META_COMPOSITOR_CLUTTER_PLUGIN_DESTROY);
} }
static void static void
kill_effect (ClutterActor *actor, gulong event) kill_effect (MetaCompWindow *mcw, gulong event)
{ {
MetaCompositorClutterPlugin *plugin = &META_COMPOSITOR_CLUTTER_PLUGIN_STRUCT; MetaCompositorClutterPlugin *plugin = &META_COMPOSITOR_CLUTTER_PLUGIN_STRUCT;
ActorPrivate *apriv; ActorPrivate *apriv;
ClutterActor *actor = CLUTTER_ACTOR (mcw);
if (!(plugin->features & event)) if (!(plugin->features & event))
{ {
@ -603,7 +622,7 @@ kill_effect (ClutterActor *actor, gulong event)
} }
} }
apriv = get_actor_private (actor); apriv = get_actor_private (mcw);
if ((event & META_COMPOSITOR_CLUTTER_PLUGIN_MINIMIZE) && apriv->tml_minimize) if ((event & META_COMPOSITOR_CLUTTER_PLUGIN_MINIMIZE) && apriv->tml_minimize)
{ {