CompBool initCore(void) { CompPlugin *corePlugin; compObjectInit(&core.base, 0, COMP_OBJECT_TYPE_CORE); core.displays = NULL; core.tmpRegion = XCreateRegion(); if(!core.tmpRegion) { return FALSE; } core.outputRegion = XCreateRegion(); if(!core.outputRegion) { XDestroyRegion(core.tmpRegion); return FALSE; } core.fileWatch = NULL; core.lastFileWatchHandle = 1; core.timeouts = NULL; core.lastTimeoutHandle = 1; core.watchFds = NULL; core.lastWatchFdHandle = 1; core.watchPollFds = NULL; core.nWatchFds = 0; gettimeofday(&core.lastTimeout, 0); setCoreProcs(); corePlugin = loadPlugin("core"); if(!corePlugin) { compLogMessage("core", CompLogLevelFatal, "Couldn't load core plugin"); return FALSE; } if(!pushPlugin(corePlugin)) { compLogMessage("core", CompLogLevelFatal, "Couldn't activate core plugin"); return FALSE; } return TRUE; }
static void updatePlugins (CompDisplay *d) { CompOption *o; CompPlugin *p, **pop = 0; int nPop, i, j; d->dirtyPluginList = FALSE; o = &d->opt[COMP_DISPLAY_OPTION_ACTIVE_PLUGINS]; for (i = 0; i < d->plugin.list.nValue && i < o->value.list.nValue; i++) { if (strcmp (d->plugin.list.value[i].s, o->value.list.value[i].s)) break; } nPop = d->plugin.list.nValue - i; if (nPop) { pop = malloc (sizeof (CompPlugin *) * nPop); if (!pop) { (*d->setDisplayOption) (d, o->name, &d->plugin); return; } } for (j = 0; j < nPop; j++) { pop[j] = popPlugin (); d->plugin.list.nValue--; free (d->plugin.list.value[d->plugin.list.nValue].s); } for (; i < o->value.list.nValue; i++) { p = 0; for (j = 0; j < nPop; j++) { if (pop[j] && strcmp (pop[j]->vTable->name, o->value.list.value[i].s) == 0) { if (pushPlugin (pop[j])) { p = pop[j]; pop[j] = 0; break; } } } if (p == 0) { p = loadPlugin (o->value.list.value[i].s); if (p) { if (!pushPlugin (p)) { unloadPlugin (p); p = 0; } } } if (p) { CompOptionValue *value; value = realloc (d->plugin.list.value, sizeof (CompOption) * (d->plugin.list.nValue + 1)); if (value) { value[d->plugin.list.nValue].s = strdup (p->vTable->name); d->plugin.list.value = value; d->plugin.list.nValue++; } else { p = popPlugin (); unloadPlugin (p); } } } for (j = 0; j < nPop; j++) { if (pop[j]) unloadPlugin (pop[j]); } if (nPop) free (pop); (*d->setDisplayOption) (d, o->name, &d->plugin); }
CompBool initCore (void) { CompPlugin *corePlugin; compObjectInit (&core.base, 0, COMP_OBJECT_TYPE_CORE); core.displays = NULL; core.tmpRegion = XCreateRegion (); if (!core.tmpRegion) return FALSE; core.outputRegion = XCreateRegion (); if (!core.outputRegion) { XDestroyRegion (core.tmpRegion); return FALSE; } core.fileWatch = NULL; core.lastFileWatchHandle = 1; core.timeouts = NULL; core.lastTimeoutHandle = 1; core.watchFds = NULL; core.lastWatchFdHandle = 1; core.watchPollFds = NULL; core.nWatchFds = 0; gettimeofday (&core.lastTimeout, 0); core.initPluginForObject = initCorePluginForObject; core.finiPluginForObject = finiCorePluginForObject; core.setOptionForPlugin = setOptionForPlugin; core.objectAdd = coreObjectAdd; core.objectRemove = coreObjectRemove; core.fileWatchAdded = fileWatchAdded; core.fileWatchRemoved = fileWatchRemoved; core.sessionEvent = sessionEvent; core.logMessage = logMessage; corePlugin = loadPlugin ("core"); if (!corePlugin) { compLogMessage ("core", CompLogLevelFatal, "Couldn't load core plugin"); return FALSE; } if (!pushPlugin (corePlugin)) { compLogMessage ("core", CompLogLevelFatal, "Couldn't activate core plugin"); return FALSE; } return TRUE; }