diff --git a/src/compositor/mutter/plugins/default.c b/src/compositor/mutter/plugins/default.c index 172d0a92c..36a7435a8 100644 --- a/src/compositor/mutter/plugins/default.c +++ b/src/compositor/mutter/plugins/default.c @@ -63,35 +63,7 @@ static gboolean reload (const char *params); * Any dynamically allocated data should be initialized in the * init () function below. */ -G_MODULE_EXPORT MutterPlugin mutter_plugin = - { - /* - * These are predefined values; do not modify. - */ - .version_major = METACITY_MAJOR_VERSION, - .version_minor = METACITY_MINOR_VERSION, - .version_micro = METACITY_MICRO_VERSION, - .version_api = METACITY_CLUTTER_PLUGIN_API_VERSION, - - /* Human readable name (for use in UI) */ - .name = "Default Effects", - - /* Plugin load time initialiser */ - .do_init = do_init, - - /* Effect handlers */ - .minimize = minimize, - .destroy = destroy, - .map = map, - .maximize = maximize, - .unmaximize = unmaximize, - .switch_workspace = switch_workspace, - - .kill_effect = kill_effect, - - /* The reload handler */ - .reload = reload - }; +MUTTER_DECLARE_PLUGIN(); /* * Plugin private data that we store in the .plugin_private member. @@ -114,6 +86,13 @@ typedef struct _PluginState gboolean debug_mode : 1; } PluginState; +static inline MutterPlugin * +get_plugin () +{ + return &mutter_plugin; +} + + /* * Per actor private data we attach to each actor. */ @@ -193,7 +172,7 @@ on_switch_workspace_effect_complete (ClutterActor *group, gpointer data) state->desktop1 = NULL; state->desktop2 = NULL; - mutter_plugin_effect_completed (&mutter_plugin, actor_for_cb, + mutter_plugin_effect_completed (get_plugin(), actor_for_cb, MUTTER_PLUGIN_SWITCH_WORKSPACE); } @@ -201,7 +180,7 @@ static void switch_workspace (const GList **actors, gint from, gint to, MetaMotionDirection direction) { - MutterPlugin *plugin = &mutter_plugin; + MutterPlugin *plugin = get_plugin(); PluginState *state = plugin_state; GList *l; gint n_workspaces; @@ -229,7 +208,7 @@ switch_workspace (const GList **actors, gint from, gint to, if (from == to) { - mutter_plugin_effect_completed (&mutter_plugin, NULL, + mutter_plugin_effect_completed (get_plugin(), NULL, MUTTER_PLUGIN_SWITCH_WORKSPACE); return; } @@ -320,7 +299,7 @@ on_minimize_effect_complete (ClutterActor *actor, gpointer data) CLUTTER_GRAVITY_NORTH_WEST); /* Now notify the manager that we are done with this effect */ - mutter_plugin_effect_completed (&mutter_plugin, mc_window, + mutter_plugin_effect_completed (get_plugin(), mc_window, MUTTER_PLUGIN_MINIMIZE); } @@ -355,7 +334,7 @@ minimize (MutterWindow *mc_window) NULL); } else - mutter_plugin_effect_completed (&mutter_plugin, mc_window, + mutter_plugin_effect_completed (get_plugin(), mc_window, MUTTER_PLUGIN_MINIMIZE); } @@ -380,7 +359,7 @@ on_maximize_effect_complete (ClutterActor *actor, gpointer data) CLUTTER_GRAVITY_NORTH_WEST); /* Now notify the manager that we are done with this effect */ - mutter_plugin_effect_completed (&mutter_plugin, mc_window, + mutter_plugin_effect_completed (get_plugin(), mc_window, MUTTER_PLUGIN_MAXIMIZE); } @@ -443,7 +422,7 @@ maximize (MutterWindow *mc_window, return; } - mutter_plugin_effect_completed (&mutter_plugin, mc_window, + mutter_plugin_effect_completed (get_plugin(), mc_window, MUTTER_PLUGIN_MAXIMIZE); } @@ -466,7 +445,7 @@ unmaximize (MutterWindow *mc_window, } /* Do this conditionally, if the effect requires completion callback. */ - mutter_plugin_effect_completed (&mutter_plugin, mc_window, + mutter_plugin_effect_completed (get_plugin(), mc_window, MUTTER_PLUGIN_UNMAXIMIZE); } @@ -485,7 +464,7 @@ on_map_effect_complete (ClutterActor *actor, gpointer data) CLUTTER_GRAVITY_NORTH_WEST); /* Now notify the manager that we are done with this effect */ - mutter_plugin_effect_completed (&mutter_plugin, mc_window, MUTTER_PLUGIN_MAP); + mutter_plugin_effect_completed (get_plugin(), mc_window, MUTTER_PLUGIN_MAP); } /* @@ -522,7 +501,7 @@ map (MutterWindow *mc_window) } else - mutter_plugin_effect_completed (&mutter_plugin, mc_window, + mutter_plugin_effect_completed (get_plugin(), mc_window, MUTTER_PLUGIN_MAP); } @@ -533,7 +512,7 @@ map (MutterWindow *mc_window) static void on_destroy_effect_complete (ClutterActor *actor, gpointer data) { - MutterPlugin *plugin = &mutter_plugin; + MutterPlugin *plugin = get_plugin(); MutterWindow *mc_window = MUTTER_WINDOW (actor); ActorPrivate *apriv = get_actor_private (mc_window); @@ -570,14 +549,13 @@ destroy (MutterWindow *mc_window) NULL); } else - mutter_plugin_effect_completed (&mutter_plugin, mc_window, + mutter_plugin_effect_completed (get_plugin(), mc_window, MUTTER_PLUGIN_DESTROY); } static void kill_effect (MutterWindow *mc_window, gulong event) { - MutterPlugin *plugin = &mutter_plugin; ActorPrivate *apriv; ClutterActor *actor = CLUTTER_ACTOR (mc_window); @@ -627,21 +605,32 @@ kill_effect (MutterWindow *mc_window, gulong event) } -#if 0 const gchar * g_module_check_init (GModule *module); const gchar * g_module_check_init (GModule *module) { - /* - * Unused; left here for documentation purposes. - * - * NB: this function is called *before* the plugin manager does its own - * initialization of the plugin struct, so you cannot process fields - * like .params in here; use the init function below instead. - */ + MutterPlugin *plugin = get_plugin (); + + /* Human readable name (for use in UI) */ + plugin->name = "Default Effects"; + + /* Plugin load time initialiser */ + plugin->do_init = do_init; + + /* Effect handlers */ + plugin->minimize = minimize; + plugin->destroy = destroy; + plugin->map = map; + plugin->maximize = maximize; + plugin->unmaximize = unmaximize; + plugin->switch_workspace = switch_workspace; + plugin->kill_effect = kill_effect; + + /* The reload handler */ + plugin->reload = reload; + return NULL; } -#endif /* * Core of the plugin init function, called for initial initialization and @@ -662,7 +651,7 @@ do_init (const char *params) { if (strstr (params, "debug")) { - g_debug ("%s: Entering debug mode.", mutter_plugin.name); + g_debug ("%s: Entering debug mode.", get_plugin()->name); plugin_state->debug_mode = TRUE; diff --git a/src/compositor/mutter/plugins/scratch.c b/src/compositor/mutter/plugins/scratch.c index 72ea6c5f8..4ec6aca74 100644 --- a/src/compositor/mutter/plugins/scratch.c +++ b/src/compositor/mutter/plugins/scratch.c @@ -77,35 +77,7 @@ static gboolean reload (const char *params); * Any dynamically allocated data should be initialized in the * init () function below. */ -G_MODULE_EXPORT MutterPlugin mutter_plugin = - { - /* - * These are predefined values; do not modify. - */ - .version_major = METACITY_MAJOR_VERSION, - .version_minor = METACITY_MINOR_VERSION, - .version_micro = METACITY_MICRO_VERSION, - .version_api = METACITY_CLUTTER_PLUGIN_API_VERSION, - - /* Human readable name (for use in UI) */ - .name = "Experimental effects", - - /* Plugin load time initialiser */ - .do_init = do_init, - - /* Effect handlers */ - .minimize = minimize, - .destroy = destroy, - .map = map, - .maximize = maximize, - .unmaximize = unmaximize, - .switch_workspace = switch_workspace, - .kill_effect = kill_effect, - .xevent_filter = xevent_filter, - - /* The reload handler */ - .reload = reload - }; +MUTTER_DECLARE_PLUGIN (); /* * Plugin private data that we store in the .plugin_private member. @@ -798,21 +770,33 @@ kill_effect (MutterWindow *mcw, gulong event) } -#if 0 const gchar * g_module_check_init (GModule *module); const gchar * g_module_check_init (GModule *module) { - /* - * Unused; left here for documentation purposes. - * - * NB: this function is called *before* the plugin manager does its own - * initialization of the plugin struct, so you cannot process fields - * like .params in here; use the init function below instead. - */ + MutterPlugin *plugin = get_plugin (); + + /* Human readable name (for use in UI) */ + plugin->name = "Experimental effects", + + /* Plugin load time initialiser */ + plugin->do_init = do_init; + + /* Effect handlers */ + plugin->minimize = minimize; + plugin->destroy = destroy; + plugin->map = map; + plugin->maximize = maximize; + plugin->unmaximize = unmaximize; + plugin->switch_workspace = switch_workspace; + plugin->kill_effect = kill_effect; + plugin->xevent_filter = xevent_filter; + + /* The reload handler */ + plugin->reload = reload; + return NULL; } -#endif static void switcher_clone_weak_notify (gpointer data, GObject *object); diff --git a/src/include/mutter-plugin.h b/src/include/mutter-plugin.h index a54e8093b..cc64bf118 100644 --- a/src/include/mutter-plugin.h +++ b/src/include/mutter-plugin.h @@ -56,6 +56,15 @@ typedef struct MutterPlugin MutterPlugin; #define MUTTER_PLUGIN_ALL_EFFECTS (~0) +#define MUTTER_DECLARE_PLUGIN() G_MODULE_EXPORT MutterPlugin mutter_plugin = \ + { \ + METACITY_MAJOR_VERSION, \ + METACITY_MINOR_VERSION, \ + METACITY_MICRO_VERSION, \ + METACITY_CLUTTER_PLUGIN_API_VERSION \ + } + + struct MutterPlugin { /*