Exemplo n.º 1
0
static CompBool
kconfigSetOptionForPlugin (CompObject      *object,
			   const char	   *plugin,
			   const char	   *name,
			   CompOptionValue *value)
{
    CompBool status;

    KCONFIG_CORE (&core);

    UNWRAP (kc, &core, setOptionForPlugin);
    status = (*core.setOptionForPlugin) (object, plugin, name, value);
    WRAP (kc, &core, setOptionForPlugin, kconfigSetOptionForPlugin);

    if (status && !kc->reloadHandle)
    {
	CompPlugin *p;

	p = findActivePlugin (plugin);
	if (p && p->vTable->getObjectOptions)
	{
	    CompOption *option;
	    int	       nOption;

	    option = (*p->vTable->getObjectOptions) (p, object, &nOption);
	    option = compFindOption (option, nOption, name, 0);
	    if (option)
		kconfigSetOption (object, option, p->vTable->name);
	}
    }

    return status;
}
Exemplo n.º 2
0
Bool
pushPlugin (CompPlugin *p)
{
	if (findActivePlugin (p->vTable->name))
	{
		compLogMessage ("core", CompLogLevelWarn,
		                "Plugin '%s' already active",
		                p->vTable->name);

		return FALSE;
	}

	p->next = plugins;
	plugins = p;

	if (!initPlugin (p))
	{
		compLogMessage ("core", CompLogLevelError,
		                "Couldn't activate plugin '%s'", p->vTable->name);
		plugins = p->next;

		return FALSE;
	}

	return TRUE;
}
static CompBool
ccpSetOptionForPlugin (CompObject      *object,
		       const char      *plugin,
		       const char      *name,
		       CompOptionValue *value)
{
    CompBool status;

    CCP_CORE (&core);

    UNWRAP (cc, &core, setOptionForPlugin);
    status = (*core.setOptionForPlugin) (object, plugin, name, value);
    WRAP (cc, &core, setOptionForPlugin, ccpSetOptionForPlugin);

    if (status && !cc->applyingSettings && !cc->reloadHandle)
    {
	CompPlugin *p;

	p = findActivePlugin (plugin);
	if (p && p->vTable->getObjectOptions)
	{
	    CompOption *option;
	    int	       nOption;

	    option = (*p->vTable->getObjectOptions) (p, object, &nOption);
	    option = compFindOption (option, nOption, name, 0);
	    if (option)
		ccpSetContextFromOption (object, option, p->vTable->name);
	}
    }

    return status;
}
Exemplo n.º 4
0
static CompBool
iniSetOptionForPlugin (CompObject      *object,
		       const char      *plugin,
		       const char      *name,
		       CompOptionValue *value)
{
    CompBool status;

    INI_CORE (&core);

    UNWRAP (ic, &core, setOptionForPlugin);
    status = (*core.setOptionForPlugin) (object, plugin, name, value);
    WRAP (ic, &core, setOptionForPlugin, iniSetOptionForPlugin);

    if (status)
    {
	CompPlugin *p;

	p = findActivePlugin (plugin);
	if (p && p->vTable->getObjectOptions)
	    iniSaveOptions (object, plugin);
    }

    return status;
}
Exemplo n.º 5
0
static Bool
scalefilterInitDisplay (CompPlugin  *p,
	    		CompDisplay *d)
{
    ScaleFilterDisplay *fd;
    CompPlugin         *scale = findActivePlugin ("scale");
    CompOption         *option;
    int                nOption;

    if (!scale || !scale->vTable->getDisplayOptions)
	return FALSE;

    option = (*scale->vTable->getDisplayOptions) (scale, d, &nOption);

    if (getIntOptionNamed (option, nOption, "abi", 0) != SCALE_ABIVERSION)
    {
	compLogMessage (d, "scalefilter", CompLogLevelError,
			"scale ABI version mismatch");
	return FALSE;
    }

    scaleDisplayPrivateIndex = getIntOptionNamed (option, nOption, "index", -1);
    if (scaleDisplayPrivateIndex < 0)
	return FALSE;

    fd = malloc (sizeof (ScaleFilterDisplay));
    if (!fd)
	return FALSE;

    fd->screenPrivateIndex = allocateScreenPrivateIndex (d);
    if (fd->screenPrivateIndex < 0)
    {
	free (fd);
	return FALSE;
    }

    fd->xim = XOpenIM (d->display, NULL, NULL, NULL);
    if (fd->xim)
	fd->xic = XCreateIC (fd->xim,
			     XNClientWindow, d->screens->root,
			     XNInputStyle,
			     XIMPreeditNothing  | XIMStatusNothing,
			     NULL);
    else
	fd->xic = NULL;

    if (fd->xic)
	setlocale (LC_CTYPE, "");

    WRAP (fd, d, handleEvent, scalefilterHandleEvent);
    WRAP (fd, d, handleEcompEvent, scalefilterHandleEcompEvent);

    d->privates[displayPrivateIndex].ptr = fd;

    return TRUE;
}
static Bool
setDisplayOptionForPlugin (CompDisplay     *display,
			   char	           *plugin,
			   char	           *name,
			   CompOptionValue *value)
{
    CompPlugin *p;

    p = findActivePlugin (plugin);
    if (p && p->vTable->setDisplayOption)
	return (*p->vTable->setDisplayOption) (display, name, value);

    return FALSE;
}
Exemplo n.º 7
0
static CompBool
setOptionForPlugin (CompObject      *object,
		    const char	    *plugin,
		    const char	    *name,
		    CompOptionValue *value)
{
    CompPlugin *p;

    p = findActivePlugin (plugin);
    if (p && p->vTable->setObjectOption)
	return (*p->vTable->setObjectOption) (p, object, name, value);

    return FALSE;
}
static Bool
setScreenOptionForPlugin (CompScreen      *screen,
			  char	          *plugin,
			  char	          *name,
			  CompOptionValue *value)
{
    CompPlugin *p;

    p = findActivePlugin (plugin);
    if (p && p->vTable->setScreenOption)
	return (*p->vTable->setScreenOption) (screen, name, value);

    return FALSE;
}
Exemplo n.º 9
0
int
getPluginABI (const char *name)
{
    CompPlugin *p = findActivePlugin (name);
    CompOption	*option;
    int		nOption;

    if (!p || !p->vTable->getObjectOptions)
	return 0;

    /* MULTIDPYERROR: ABI options should be moved into core */
    option = (*p->vTable->getObjectOptions) (p, &core.displays->base,
					     &nOption);

    return getIntOptionNamed (option, nOption, "abi", 0);
}
Exemplo n.º 10
0
Arquivo: fuse.c Projeto: zmike/compiz
static CompOption *
fuseGetOptionsFromInode(CompObject *object,
                        FuseInode *inode,
                        int *nOption)
{
   CompOption *option = NULL;

   if (inode->type & FUSE_INODE_TYPE_PLUGIN)
     {
        CompPlugin *p;

        p = findActivePlugin(inode->name);
        if (p && p->vTable->getObjectOptions)
          option = (*p->vTable->getObjectOptions)(p, object, nOption);
     }

   return option;
}
Exemplo n.º 11
0
Arquivo: fade.c Projeto: zmike/compiz
static Bool
fadeInitDisplay(CompPlugin *p,
                CompDisplay *d)
{
   FadeDisplay *fd;

   if (!checkPluginABI("core", CORE_ABIVERSION))
     return FALSE;

   fd = malloc(sizeof (FadeDisplay));
   if (!fd)
     return FALSE;

   fd->screenPrivateIndex = allocateScreenPrivateIndex(d);
   if (fd->screenPrivateIndex < 0)
     {
        free(fd);
        return FALSE;
     }

   fd->displayModals = 0;

   fd->suppressMinimizeOpenClose = (findActivePlugin("animation") != NULL);

   /* Always fade opening and closing of screen-dimming layer of
      logout window and gksu. */
   matchInit(&fd->alwaysFadeWindowMatch);
   matchAddExp(&fd->alwaysFadeWindowMatch, 0, "title=gksu");
   matchAddExp(&fd->alwaysFadeWindowMatch, 0, "title=x-session-manager");
   matchAddExp(&fd->alwaysFadeWindowMatch, 0, "title=mate-session");
   matchUpdate(d, &fd->alwaysFadeWindowMatch);

   WRAP(fd, d, handleEvent, fadeHandleEvent);
   WRAP(fd, d, matchExpHandlerChanged, fadeMatchExpHandlerChanged);

   d->base.privates[displayPrivateIndex].ptr = fd;

   return TRUE;
}
Exemplo n.º 12
0
Bool
getPluginDisplayIndex (CompDisplay *d,
		       const char  *name,
		       int	   *index)
{
    CompPlugin *p = findActivePlugin (name);
    CompOption	*option;
    int		nOption, value;

    if (!p || !p->vTable->getObjectOptions)
	return FALSE;

    option = (*p->vTable->getObjectOptions) (p, &d->base, &nOption);

    value = getIntOptionNamed (option, nOption, "index", -1);
    if (value < 0)
	return FALSE;

    *index = value;

    return TRUE;
}
Exemplo n.º 13
0
static Bool
ccpTimeout (void *closure)
{
    unsigned int flags = 0;

    CCP_CORE (&core);

    if (findActivePlugin ("glib"))
	flags |= ProcessEventsNoGlibMainLoopMask;

    ccsProcessEvents (cc->context, flags);

    if (ccsSettingListLength (cc->context->changedSettings))
    {
	CCSSettingList list = cc->context->changedSettings;
	CCSSettingList l = list;	
	CCSSetting     *s;
	CompObject     *object;
    	CompPlugin     *p;
    	CompOption     *option;
    	int            nOption;

    	char tmp[256];

	cc->context->changedSettings = NULL;
	
	while (l)
	{
	    s = l->data;
	    l = l->next;

	    if (s->isScreen)
	    {
		snprintf (tmp, 256, "%d", s->screenNum);
		object = compObjectFind (&core.base, COMP_OBJECT_TYPE_DISPLAY,
					 NULL);
		object = compObjectFind (object, COMP_OBJECT_TYPE_SCREEN,
					 tmp);
	    }
	    else
	    {
		object = compObjectFind (&core.base, COMP_OBJECT_TYPE_DISPLAY,
					 NULL);
	    }

	    if (!object)
		continue;

	    p = findActivePlugin (s->parent->name);

	    if (!p)
		continue;

	    option = (*p->vTable->getObjectOptions) (p, object, &nOption);
	    option = compFindOption (option, nOption, s->name, 0);
	    if (option)
		ccpSetOptionFromContext (object, option, s->parent->name);
	    D (D_FULL, "Setting Update \"%s\"\n", s->name);
	}

	ccsSettingListFree (list, FALSE);
	cc->context->changedSettings =
	    ccsSettingListFree (cc->context->changedSettings, FALSE);
    }

    return TRUE;
}
Exemplo n.º 14
0
static Bool
iniSaveOptions (CompObject *object,
		const char *plugin)
{
    CompOption *option = NULL;
    int	       nOption = 0;
    char       *filename, *directory, *fullPath, *strVal = NULL;

    if (plugin)
    {
	CompPlugin *p;
	p = findActivePlugin (plugin);
	if (!p)
	    return FALSE;

	option = (*p->vTable->getObjectOptions) (p, object, &nOption);
    }
    else
    {
	return FALSE;
    }

    if (!option)
	return FALSE;

    if (!iniGetFilename (object, plugin, &filename))
	return FALSE;

    IniFileData *fileData;

    fileData = iniGetFileDataFromFilename (filename);
    if (!fileData || (fileData && fileData->blockWrites))
    {
	free (filename);
	return FALSE;
    }

    if (!iniGetHomeDir (&directory))
	return FALSE;

    fullPath = malloc (sizeof (char) * (strlen (filename) + strlen (directory) + 2));
    if (!fullPath)
    {
	free (filename);
	free (directory);
	return FALSE;
    }

    sprintf (fullPath, "%s/%s", directory, filename);

    FILE *optionFile = fopen (fullPath, "w");

    if (!optionFile && iniMakeDirectories ())
	optionFile = fopen (fullPath, "w");

    if (!optionFile)
    {
	compLogMessage ("ini", CompLogLevelError,
			"Failed to write to %s, check you " \
			"have the correct permissions", fullPath);
	free (filename);
	free (directory);
	free (fullPath);
	return FALSE;
    }

    fileData->blockReads = TRUE;

    Bool status, firstInList;
    while (nOption--)
    {
	status = FALSE;
	int i;

	switch (option->type)
	{
	case CompOptionTypeBool:
	case CompOptionTypeInt:
	case CompOptionTypeFloat:
	case CompOptionTypeString:
	case CompOptionTypeColor:
	case CompOptionTypeKey:
	case CompOptionTypeButton:
	case CompOptionTypeEdge:
	case CompOptionTypeBell:
	case CompOptionTypeMatch:
	    strVal = iniOptionValueToString (GET_CORE_DISPLAY (object),
					     &option->value, option->type);
		if (strVal)
		{
		    fprintf (optionFile, "%s=%s\n", option->name, strVal);
		    free (strVal);
		}
		else
		    fprintf (optionFile, "%s=\n", option->name);
		break;
	case CompOptionTypeList:
	    firstInList = TRUE;
	    switch (option->value.list.type)
	    {
	    case CompOptionTypeBool:
	    case CompOptionTypeInt:
	    case CompOptionTypeFloat:
	    case CompOptionTypeString:
	    case CompOptionTypeColor:
	    case CompOptionTypeMatch:
	    {
		int stringLen = MAX_OPTION_LENGTH * option->value.list.nValue;
		char *itemVal;

		strVal = malloc (sizeof(char) * stringLen);
		if (!strVal) {
		    fclose(optionFile);
		    free(fullPath);
		    return FALSE;
		}
		strcpy (strVal, "");
		firstInList = TRUE;

		for (i = 0; i < option->value.list.nValue; i++)
		{
		    itemVal =
			iniOptionValueToString (GET_CORE_DISPLAY (object),
						&option->value.list.value[i],
						option->value.list.type);
		    if (!firstInList)
		        strncat (strVal, ",", stringLen);
		    firstInList = FALSE;
			
		    if (itemVal)
		    {
			strncat (strVal, itemVal, stringLen);
			free (itemVal);
		    }
		}

		fprintf (optionFile, "%s=%s\n", option->name, strVal);
		free (strVal);
		break;
	    }
	    default:
		compLogMessage ("ini", CompLogLevelWarn,
				"Unknown list option type %d, %s\n",
				option->value.list.type,
				optionTypeToString (option->value.list.type));
		break;
	    }
		break;
	default:
		break;
	}

	option++;
    }

    fileData->blockReads = FALSE;

    fclose (optionFile);

    free (filename);
    free (directory);
    free (fullPath);

    return TRUE;
}
Exemplo n.º 15
0
static Bool
iniLoadOptionsFromFile (FILE       *optionFile,
			CompObject *object,
			const char *plugin,
			Bool       *reSave)
{
    CompOption      *option = NULL, *o;
    CompPlugin      *p = NULL;
    CompOptionValue value;
    char            *optionName = NULL, *optionValue = NULL;
    char            tmp[MAX_OPTION_LENGTH];
    int             nOption, nOptionRead = 0;
    Bool            status = FALSE, hasValue = FALSE;

    if (plugin)
    {
	p = findActivePlugin (plugin);
	if (!p)
	{
	    compLogMessage ("ini", CompLogLevelWarn,
			    "Could not find running plugin " \
			    "%s (iniLoadOptionsFromFile)", plugin);
	    return FALSE;
	}
    }
    else
    {
	return FALSE;
    }

    if (p->vTable->getObjectOptions)
	option = (*p->vTable->getObjectOptions) (p, object, &nOption);

    while (fgets (tmp, MAX_OPTION_LENGTH, optionFile) != NULL)
    {
	status = FALSE;

	if (!iniParseLine (tmp, &optionName, &optionValue))
	{
	    compLogMessage ("ini", CompLogLevelWarn,
			    "Ignoring line '%s' in %s", tmp, plugin);
	    continue;
	}

	if (option)
	{
	    o = compFindOption (option, nOption, optionName, 0);
	    if (o)
	    {
		value = o->value;

		switch (o->type)
		{
		case CompOptionTypeBool:
		    hasValue = TRUE;
		    value.b = (Bool) atoi (optionValue);
			break;
		case CompOptionTypeInt:
		    hasValue = TRUE;
		    value.i = atoi (optionValue);
			break;
		case CompOptionTypeFloat:
		    hasValue = TRUE;
		    value.f = atof (optionValue);
			break;
		case CompOptionTypeString:
		    hasValue = TRUE;
		    value.s = strdup (optionValue);
			break;
		case CompOptionTypeColor:
		    hasValue = stringToColor (optionValue, value.c);
			break;
		case CompOptionTypeKey:
		    hasValue = TRUE;
		    stringToKeyAction (GET_CORE_DISPLAY (object),
				       optionValue, &value.action);
		    break;
		case CompOptionTypeButton:
		    hasValue = TRUE;
		    stringToButtonAction (GET_CORE_DISPLAY (object),
					  optionValue, &value.action);
		    break;
		case CompOptionTypeEdge:
		    hasValue = TRUE;
		    value.action.edgeMask = stringToEdgeMask (optionValue);
		    break;
		case CompOptionTypeBell:
		    hasValue = TRUE;
		    value.action.bell = (Bool) atoi (optionValue);
		    break;
		case CompOptionTypeList:
		    hasValue = csvToList (GET_CORE_DISPLAY (object),
					  optionValue,
					  &value.list, value.list.type);
			break;
		case CompOptionTypeMatch:
		    hasValue = TRUE;
		    matchInit (&value.match);
		    matchAddFromString (&value.match, optionValue);
			break;
		default:
			break;
		}

		if (hasValue)
		{
		    status = (*core.setOptionForPlugin) (object,
							 plugin,
							 optionName,
							 &value);

		    if (o->type == CompOptionTypeMatch)
		    {
			matchFini (&value.match);
		    }
		}

		nOptionRead++;
	    }
	}

	/* clear up */
	if (optionName)
	    free (optionName);
	if (optionValue)
	    free (optionValue);
    }

    if (nOption != nOptionRead)
    {
	*reSave = TRUE;
    }

    return TRUE;
}
Exemplo n.º 16
0
Arquivo: fuse.c Projeto: zmike/compiz
static void
fuseUpdateInode(CompDisplay *d,
                FuseInode *inode)
{
   CompScreen *s;
   CompPlugin *p;
   CompOption *option;
   char str[256];

   if (inode->type & FUSE_INODE_TYPE_ROOT)
     {
        FuseInode *c;

        for (c = inode->child; c; c = c->sibling)
          {
             if (!findActivePlugin(c->name))
               fuseRemoveInode(inode, c);
          }

        for (p = getPlugins(); p; p = p->next)
          if (!fuseLookupChild(inode, p->vTable->name))
            fuseAddInode(inode, FUSE_INODE_TYPE_PLUGIN,
                         p->vTable->name);
     }
   else if (inode->type & FUSE_INODE_TYPE_PLUGIN)
     {
        int n;

        if (fuseGetOptionsFromInode(&d->base, inode, &n))
          fuseAddInode(inode, FUSE_INODE_TYPE_DISPLAY, "allscreens");

        for (s = d->screens; s; s = s->next)
          {
             if (fuseGetOptionsFromInode(&s->base, inode, &n))
               {
                  sprintf(str, "screen%d", s->screenNum);
                  fuseAddInode(inode, FUSE_INODE_TYPE_SCREEN, str);
               }
          }
     }
   else if (inode->type & (FUSE_INODE_TYPE_DISPLAY | FUSE_INODE_TYPE_SCREEN))
     {
        CompObject *object;

        object = fuseGetObjectFromInode(inode);
        if (object)
          {
             int nOption;

             option = fuseGetOptionsFromInode(object, inode->parent, &nOption);
             if (option)
               {
                  while (nOption--)
                    {
                       fuseAddInode(inode, FUSE_INODE_TYPE_OPTION, option->name);

                       option++;
                    }
               }
          }
     }
   else if (inode->type & FUSE_INODE_TYPE_OPTION)
     {
        option = fuseGetOptionFromInode(inode);
        if (option)
          {
             fuseAddInode(inode, FUSE_INODE_TYPE_TYPE, "type");

             switch (option->type)
               {
                case CompOptionTypeFloat:
                  fuseAddInode(inode, FUSE_INODE_TYPE_PRECISION, "precision");

                /* fall-through */
                case CompOptionTypeInt:
                  fuseAddInode(inode, FUSE_INODE_TYPE_MIN, "min");
                  fuseAddInode(inode, FUSE_INODE_TYPE_MAX, "max");

                /* fall-through */
                case CompOptionTypeBool:
                case CompOptionTypeString:
                case CompOptionTypeColor:
                case CompOptionTypeKey:
                case CompOptionTypeButton:
                case CompOptionTypeEdge:
                case CompOptionTypeBell:
                case CompOptionTypeMatch:
                  fuseAddInode(inode, FUSE_INODE_TYPE_VALUE, "value");
                  break;

                case CompOptionTypeList:
                  fuseAddInode(inode, FUSE_INODE_TYPE_ITEMS, "items");
                  fuseAddInode(inode, FUSE_INODE_TYPE_ITEM_COUNT,
                               "number_of_items");
                  fuseAddInode(inode, FUSE_INODE_TYPE_ITEM_TYPE, "item_type");

                default:
                  break;
               }
          }
     }
   else if (inode->type & FUSE_INODE_TYPE_ITEMS)
     {
        option = fuseGetOptionFromInode(inode->parent);
        if (option && option->type == CompOptionTypeList)
          {
             FuseInode *c, *next;
             int i, nValue = option->value.list.nValue;

             for (i = 0; i < option->value.list.nValue; i++)
               {
                  sprintf(str, "value%d", i);
                  if (!fuseLookupChild(inode, str))
                    fuseAddInode(inode, FUSE_INODE_TYPE_ITEM_VALUE, str);
               }

             for (c = inode->child; c; c = next)
               {
                  next = c->sibling;

                  if (sscanf(c->name, "value%d", &i) == 0 || i >= nValue)
                    fuseRemoveInode(inode, c);
               }
          }
     }
}