void meta_plugin_manager_initialize (MetaPluginManager *plugin_mgr) { GList *iter; if (!plugin_mgr->plugins) { /* * If no plugins are specified, load the default plugin. */ meta_plugin_manager_load (plugin_mgr, "default"); } for (iter = plugin_mgr->plugins; iter; iter = iter->next) { MetaPlugin *plugin = (MetaPlugin*) iter->data; MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); g_object_set (plugin, "screen", plugin_mgr->screen, NULL); if (klass->start) klass->start (plugin); } }
/* * The public method that the compositor hooks into for desktop switching. * * Returns TRUE if the plugin handled the event type (i.e., * if the return value is FALSE, there will be no subsequent call to the * manager completed() callback, and the compositor must ensure that any * appropriate post-effect cleanup is carried out. */ gboolean meta_plugin_manager_switch_workspace (MetaPluginManager *plugin_mgr, gint from, gint to, MetaMotionDirection direction) { MetaPlugin *plugin = plugin_mgr->plugin; MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); MetaDisplay *display = meta_screen_get_display (plugin_mgr->screen); gboolean retval = FALSE; if (display->display_opening) return FALSE; if (klass->switch_workspace) { retval = TRUE; meta_plugin_manager_kill_switch_workspace (plugin_mgr); _meta_plugin_effect_started (plugin); klass->switch_workspace (plugin, from, to, direction); } return retval; }
static void meta_plugin_set_features (MetaPlugin *plugin) { MetaPluginPrivate *priv = plugin->priv; MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); priv->features = 0; /* * Feature flags: identify events that the plugin can handle; a plugin can * handle one or more events. */ if (klass->minimize) priv->features |= META_PLUGIN_MINIMIZE; if (klass->maximize) priv->features |= META_PLUGIN_MAXIMIZE; if (klass->unmaximize) priv->features |= META_PLUGIN_UNMAXIMIZE; if (klass->map) priv->features |= META_PLUGIN_MAP; if (klass->destroy) priv->features |= META_PLUGIN_DESTROY; if (klass->switch_workspace) priv->features |= META_PLUGIN_SWITCH_WORKSPACE; if (klass->tile) priv->features |= META_PLUGIN_TILE; }
static void meta_plugin_manager_kill_switch_workspace (MetaPluginManager *plugin_mgr) { MetaPlugin *plugin = plugin_mgr->plugin; MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); if (klass->kill_switch_workspace) klass->kill_switch_workspace (plugin); }
static void meta_plugin_manager_kill_window_effects (MetaPluginManager *plugin_mgr, MetaWindowActor *actor) { MetaPlugin *plugin = plugin_mgr->plugin; MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); if (klass->kill_window_effects) klass->kill_window_effects (plugin, actor); }
const MetaPluginInfo * meta_plugin_get_info (MetaPlugin *plugin) { MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); if (klass && klass->plugin_info) return klass->plugin_info (plugin); return NULL; }
void meta_plugin_manager_confirm_display_change (MetaPluginManager *plugin_mgr) { MetaPlugin *plugin = plugin_mgr->plugin; MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); if (klass->confirm_display_change) return klass->confirm_display_change (plugin); else return meta_plugin_complete_display_change (plugin, TRUE); }
gboolean _meta_plugin_xevent_filter (MetaPlugin *plugin, XEvent *xev) { MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); if (klass->xevent_filter && klass->xevent_filter (plugin, xev)) return TRUE; else return clutter_x11_handle_event (xev) != CLUTTER_X11_FILTER_CONTINUE; }
gboolean meta_plugin_manager_filter_keybinding (MetaPluginManager *plugin_mgr, MetaKeyBinding *binding) { MetaPlugin *plugin = plugin_mgr->plugin; MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); if (klass->keybinding_filter) return klass->keybinding_filter (plugin, binding); return FALSE; }
/* * The public method that the compositor hooks into for maximize and unmaximize * events. * * Returns TRUE if the plugin handled the event type (i.e., * if the return value is FALSE, there will be no subsequent call to the * manager completed() callback, and the compositor must ensure that any * appropriate post-effect cleanup is carried out. */ gboolean meta_plugin_manager_event_maximize (MetaPluginManager *plugin_mgr, MetaWindowActor *actor, unsigned long event, gint target_x, gint target_y, gint target_width, gint target_height) { MetaPlugin *plugin = plugin_mgr->plugin; MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); MetaDisplay *display = meta_screen_get_display (plugin_mgr->screen); gboolean retval = FALSE; if (display->display_opening) return FALSE; switch (event) { case META_PLUGIN_MAXIMIZE: if (klass->maximize) { retval = TRUE; meta_plugin_manager_kill_window_effects (plugin_mgr, actor); _meta_plugin_effect_started (plugin); klass->maximize (plugin, actor, target_x, target_y, target_width, target_height); } break; case META_PLUGIN_UNMAXIMIZE: if (klass->unmaximize) { retval = TRUE; meta_plugin_manager_kill_window_effects (plugin_mgr, actor); _meta_plugin_effect_started (plugin); klass->unmaximize (plugin, actor, target_x, target_y, target_width, target_height); } break; default: g_warning ("Incorrect handler called for event %lu", event); } return retval; }
/* * The public method that the compositor hooks into for desktop switching. * * Returns TRUE if at least one of the plugins handled the event type (i.e., * if the return value is FALSE, there will be no subsequent call to the * manager completed() callback, and the compositor must ensure that any * appropriate post-effect cleanup is carried out. */ gboolean meta_plugin_manager_xevent_filter (MetaPluginManager *plugin_mgr, XEvent *xev) { GList *l; gboolean have_plugin_xevent_func; if (!plugin_mgr) return FALSE; l = plugin_mgr->plugins; /* We need to make sure that clutter gets certain events, like * ConfigureNotify on the stage window. If there is a plugin that * provides an xevent_filter function, then it's the responsibility * of that plugin to pass events to Clutter. Otherwise, we send the * event directly to Clutter ourselves. * * What happens if there are two plugins with xevent_filter functions * is undefined; in general, multiple competing plugins are something * we don't support well or care much about. * * FIXME: Really, we should just always handle sending the event to * clutter if a plugin doesn't report the event as handled by * returning TRUE, but it doesn't seem worth breaking compatibility * of the plugin interface right now to achieve this; the way it is * now works fine in practice. */ have_plugin_xevent_func = FALSE; while (l) { MetaPlugin *plugin = l->data; MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); if (klass->xevent_filter) { have_plugin_xevent_func = TRUE; if (klass->xevent_filter (plugin, xev) == TRUE) return TRUE; } l = l->next; } if (!have_plugin_xevent_func) return clutter_x11_handle_event (xev) != CLUTTER_X11_FILTER_CONTINUE; return FALSE; }
MetaPluginManager * meta_plugin_manager_new (MetaScreen *screen) { MetaPluginManager *plugin_mgr; MetaPluginClass *klass; MetaPlugin *plugin; plugin_mgr = g_new0 (MetaPluginManager, 1); plugin_mgr->screen = screen; plugin_mgr->plugin = plugin = g_object_new (plugin_type, "screen", screen, NULL); klass = META_PLUGIN_GET_CLASS (plugin); if (klass->start) klass->start (plugin); return plugin_mgr; }
static void meta_plugin_manager_kill_switch_workspace (MetaPluginManager *plugin_mgr) { GList *l = plugin_mgr->plugins; while (l) { MetaPlugin *plugin = l->data; MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); if (!meta_plugin_disabled (plugin) && (meta_plugin_features (plugin) & META_PLUGIN_SWITCH_WORKSPACE) && klass->kill_switch_workspace) klass->kill_switch_workspace (plugin); l = l->next; } }
static void meta_plugin_manager_kill_window_effects (MetaPluginManager *plugin_mgr, MetaWindowActor *actor) { GList *l = plugin_mgr->plugins; while (l) { MetaPlugin *plugin = l->data; MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); if (!meta_plugin_disabled (plugin) && klass->kill_window_effects) klass->kill_window_effects (plugin, actor); l = l->next; } }
/* * The public method that the compositor hooks into for desktop switching. * * Returns TRUE if the plugin handled the event type (i.e., * if the return value is FALSE, there will be no subsequent call to the * manager completed() callback, and the compositor must ensure that any * appropriate post-effect cleanup is carried out. */ gboolean meta_plugin_manager_xevent_filter (MetaPluginManager *plugin_mgr, XEvent *xev) { MetaPlugin *plugin = plugin_mgr->plugin; MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); /* We need to make sure that clutter gets certain events, like * ConfigureNotify on the stage window. If there is a plugin that * provides an xevent_filter function, then it's the responsibility * of that plugin to pass events to Clutter. Otherwise, we send the * event directly to Clutter ourselves. */ if (klass->xevent_filter) return klass->xevent_filter (plugin, xev); else return clutter_x11_handle_event (xev) != CLUTTER_X11_FILTER_CONTINUE; }
gboolean meta_plugin_manager_hide_tile_preview (MetaPluginManager *plugin_mgr) { MetaPlugin *plugin = plugin_mgr->plugin; MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); MetaDisplay *display = meta_screen_get_display (plugin_mgr->screen); if (display->display_opening) return FALSE; if (klass->hide_tile_preview) { klass->hide_tile_preview (plugin); return TRUE; } return FALSE; }
gboolean meta_plugin_manager_show_tile_preview (MetaPluginManager *plugin_mgr, MetaWindow *window, MetaRectangle *tile_rect, int tile_monitor_number) { MetaPlugin *plugin = plugin_mgr->plugin; MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); MetaDisplay *display = meta_screen_get_display (plugin_mgr->screen); if (display->display_opening) return FALSE; if (klass->show_tile_preview) { klass->show_tile_preview (plugin, window, tile_rect, tile_monitor_number); return TRUE; } return FALSE; }
MetaPluginManager * meta_plugin_manager_new (MetaScreen *screen) { MetaPluginManager *plugin_mgr; MetaPluginClass *klass; MetaPlugin *plugin; MetaMonitorManager *monitors; plugin_mgr = g_new0 (MetaPluginManager, 1); plugin_mgr->screen = screen; plugin_mgr->plugin = plugin = g_object_new (plugin_type, "screen", screen, NULL); klass = META_PLUGIN_GET_CLASS (plugin); if (klass->start) klass->start (plugin); monitors = meta_monitor_manager_get (); g_signal_connect (monitors, "confirm-display-change", G_CALLBACK (on_confirm_display_change), plugin_mgr); return plugin_mgr; }
/* * The public method that the compositor hooks into for desktop switching. * * Returns TRUE if at least one of the plugins handled the event type (i.e., * if the return value is FALSE, there will be no subsequent call to the * manager completed() callback, and the compositor must ensure that any * appropriate post-effect cleanup is carried out. */ gboolean meta_plugin_manager_switch_workspace (MetaPluginManager *plugin_mgr, gint from, gint to, MetaMotionDirection direction) { GList *l = plugin_mgr->plugins; gboolean retval = FALSE; MetaDisplay *display = meta_screen_get_display (plugin_mgr->screen); if (display->display_opening) return FALSE; while (l) { MetaPlugin *plugin = l->data; MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); if (!meta_plugin_disabled (plugin) && (meta_plugin_features (plugin) & META_PLUGIN_SWITCH_WORKSPACE)) { if (klass->switch_workspace) { retval = TRUE; meta_plugin_manager_kill_switch_workspace (plugin_mgr); _meta_plugin_effect_started (plugin); klass->switch_workspace (plugin, from, to, direction); } } l = l->next; } return retval; }
/* * Public method that the compositor hooks into for events that require * no additional parameters. * * Returns TRUE if at least one of the plugins handled the event type (i.e., * if the return value is FALSE, there will be no subsequent call to the * manager completed() callback, and the compositor must ensure that any * appropriate post-effect cleanup is carried out. */ gboolean meta_plugin_manager_event_simple (MetaPluginManager *plugin_mgr, MetaWindowActor *actor, unsigned long event) { GList *l = plugin_mgr->plugins; gboolean retval = FALSE; MetaDisplay *display = meta_screen_get_display (plugin_mgr->screen); if (display->display_opening) return FALSE; while (l) { MetaPlugin *plugin = l->data; MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); if (!meta_plugin_disabled (plugin) && (meta_plugin_features (plugin) & event)) { retval = TRUE; switch (event) { case META_PLUGIN_MINIMIZE: if (klass->minimize) { meta_plugin_manager_kill_window_effects ( plugin_mgr, actor); _meta_plugin_effect_started (plugin); klass->minimize (plugin, actor); } break; case META_PLUGIN_MAP: if (klass->map) { meta_plugin_manager_kill_window_effects ( plugin_mgr, actor); _meta_plugin_effect_started (plugin); klass->map (plugin, actor); } break; case META_PLUGIN_DESTROY: if (klass->destroy) { _meta_plugin_effect_started (plugin); klass->destroy (plugin, actor); } break; default: g_warning ("Incorrect handler called for event %lu", event); } } l = l->next; } return retval; }
/** * meta_compositor_process_event: (skip) * */ gboolean meta_compositor_process_event (MetaCompositor *compositor, XEvent *event, MetaWindow *window) { if (compositor->modal_plugin && is_grabbed_event (event)) { MetaPluginClass *klass = META_PLUGIN_GET_CLASS (compositor->modal_plugin); if (klass->xevent_filter) klass->xevent_filter (compositor->modal_plugin, event); /* We always consume events even if the plugin says it didn't handle them; * exclusive is exclusive */ return TRUE; } if (window) { MetaCompScreen *info; MetaScreen *screen; screen = meta_window_get_screen (window); info = meta_screen_get_compositor_data (screen); if (meta_plugin_manager_xevent_filter (info->plugin_mgr, event)) { DEBUG_TRACE ("meta_compositor_process_event (filtered,window==NULL)\n"); return TRUE; } } else { GSList *l; l = meta_display_get_screens (compositor->display); while (l) { MetaScreen *screen = l->data; MetaCompScreen *info; info = meta_screen_get_compositor_data (screen); if (meta_plugin_manager_xevent_filter (info->plugin_mgr, event)) { DEBUG_TRACE ("meta_compositor_process_event (filtered,window==NULL)\n"); return TRUE; } l = l->next; } } switch (event->type) { case PropertyNotify: process_property_notify (compositor, (XPropertyEvent *) event, window); break; default: if (event->type == meta_display_get_damage_event_base (compositor->display) + XDamageNotify) { /* Core code doesn't handle damage events, so we need to extract the MetaWindow * ourselves */ if (window == NULL) { Window xwin = ((XDamageNotifyEvent *) event)->drawable; window = meta_display_lookup_x_window (compositor->display, xwin); } DEBUG_TRACE ("meta_compositor_process_event (process_damage)\n"); process_damage (compositor, (XDamageNotifyEvent *) event, window); } break; } /* Clutter needs to know about MapNotify events otherwise it will think the stage is invisible */ if (event->type == MapNotify) clutter_x11_handle_event (event); /* The above handling is basically just "observing" the events, so we return * FALSE to indicate that the event should not be filtered out; if we have * GTK+ windows in the same process, GTK+ needs the ConfigureNotify event, for example. */ return FALSE; }