Пример #1
0
Bool compSetOption(CompOption * option, CompOptionValue * value)
{
	switch (option->type) {
	case CompOptionTypeBool:
		return compSetBoolOption(option, value);
	case CompOptionTypeInt:
		return compSetIntOption(option, value);
	case CompOptionTypeFloat:
		return compSetFloatOption(option, value);
	case CompOptionTypeString:
		return compSetStringOption(option, value);
	case CompOptionTypeColor:
		return compSetColorOption(option, value);
	case CompOptionTypeMatch:
		return compSetMatchOption(option, value);
	case CompOptionTypeAction:
	case CompOptionTypeKey:
	case CompOptionTypeButton:
	case CompOptionTypeEdge:
	case CompOptionTypeBell:
		return compSetActionOption(option, value);
	case CompOptionTypeList:
		return compSetOptionList(option, value);
	}

	return FALSE;
}
Пример #2
0
static Bool
fuseSetDisplayOption(CompPlugin *plugin,
                     CompDisplay *display,
                     const char *name,
                     CompOptionValue *value)
{
   CompOption *o;
   int index;

   FUSE_DISPLAY(display);

   o = compFindOption(fd->opt, NUM_OPTIONS(fd), name, &index);
   if (!o)
     return FALSE;

   switch (index)
     {
      case FUSE_DISPLAY_OPTION_MOUNT_POINT:
        if (compSetStringOption(o, value))
          {
             fuseUnmount(display);
             fuseMount(display);
             return TRUE;
          }

      default:
        break;
     }

   return FALSE;
}
static Bool
setDisplayOption (CompDisplay     *display,
		  char	          *name,
		  CompOptionValue *value)
{
    CompOption *o;
    int	       index;

    o = compFindOption (display->opt, NUM_OPTIONS (display), name, &index);
    if (!o)
	return FALSE;

    switch (index) {
    case COMP_DISPLAY_OPTION_ACTIVE_PLUGINS:
	if (compSetOptionList (o, value))
	{
	    display->dirtyPluginList = TRUE;
	    return TRUE;
	}
	break;
    case COMP_DISPLAY_OPTION_TEXTURE_FILTER:
	if (compSetStringOption (o, value))
	{
	    CompScreen *s;

	    for (s = display->screens; s; s = s->next)
		damageScreen (s);

	    if (strcmp (o->value.s, "Fast") == 0)
		display->textureFilter = GL_NEAREST;
	    else
		display->textureFilter = GL_LINEAR;

	    return TRUE;
	}
    default:
	break;
    }

    return FALSE;
}
Пример #4
0
Bool compSetOptionList(CompOption * option, CompOptionValue * value)
{
	CompOption o;
	Bool status = FALSE;
	int i, min;

	if (value->list.nValue != option->value.list.nValue) {
		CompOptionValue *v;

		v = malloc(sizeof(CompOptionValue) * value->list.nValue);
		if (!v)
			return FALSE;

		min = MIN(value->list.nValue, option->value.list.nValue);

		for (i = min; i < option->value.list.nValue; i++) {
			switch (option->value.list.type) {
			case CompOptionTypeString:
				if (option->value.list.value[i].s)
					free(option->value.list.value[i].s);
				break;
			case CompOptionTypeMatch:
				matchFini(&option->value.list.value[i].match);
			default:
				break;
			}
		}

		memset(v, 0, sizeof(CompOptionValue) * value->list.nValue);

		if (min)
			memcpy(v, option->value.list.value,
			       sizeof(CompOptionValue) * min);

		if (option->value.list.value)
			free(option->value.list.value);

		option->value.list.value = v;
		option->value.list.nValue = value->list.nValue;

		status = TRUE;
	}

	o = *option;
	o.type = option->value.list.type;

	for (i = 0; i < value->list.nValue; i++) {
		o.value = option->value.list.value[i];

		switch (o.type) {
		case CompOptionTypeBool:
			status |= compSetBoolOption(&o, &value->list.value[i]);
			break;
		case CompOptionTypeInt:
			status |= compSetIntOption(&o, &value->list.value[i]);
			break;
		case CompOptionTypeFloat:
			status |= compSetFloatOption(&o, &value->list.value[i]);
			break;
		case CompOptionTypeString:
			status |=
			    compSetStringOption(&o, &value->list.value[i]);
			break;
		case CompOptionTypeColor:
			status |= compSetColorOption(&o, &value->list.value[i]);
			break;
		case CompOptionTypeMatch:
			status |= compSetMatchOption(&o, &value->list.value[i]);
		default:
			break;
		}

		option->value.list.value[i] = o.value;
	}

	return status;
}
Пример #5
0
static Bool
decorSetDisplayOption (CompPlugin      *plugin,
		       CompDisplay     *display,
		       const char      *name,
		       CompOptionValue *value)
{
    CompOption *o;
    int	       index;

    DECOR_DISPLAY (display);

    o = compFindOption (dd->opt, NUM_OPTIONS (dd), name, &index);
    if (!o)
	return FALSE;

    switch (index) {
    case DECOR_DISPLAY_OPTION_COMMAND:
	if (compSetStringOption (o, value))
	{
	    CompScreen *s;

	    for (s = display->screens; s; s = s->next)
	    {
		DECOR_SCREEN (s);

		if (!ds->dmWin)
		    runCommand (s, o->value.s);
	    }

	    return TRUE;
	}
	break;
    case DECOR_DISPLAY_OPTION_SHADOW_MATCH:
	{
	    char *matchString;

	    /*
	       Make sure RGBA matching is always present and disable shadows
	       for RGBA windows by default if the user didn't specify an
	       RGBA match.
	       Reasoning for that is that shadows are desired for some RGBA
	       windows (e.g. rectangular windows that just happen to have an
	       RGBA colormap), while it's absolutely undesired for others
	       (especially shaped ones) ... by enforcing no shadows for RGBA
	       windows by default, we are flexible to user desires while still
	       making sure we don't show ugliness by default
	     */

	    matchString = matchToString (&value->match);
	    if (matchString)
	    {
		if (!strstr (matchString, "rgba="))
		{
		    CompMatch rgbaMatch;

		    matchInit (&rgbaMatch);
		    matchAddFromString (&rgbaMatch, "rgba=0");
		    matchAddGroup (&value->match, MATCH_OP_AND_MASK,
				   &rgbaMatch);
		    matchFini (&rgbaMatch);
		}
		free (matchString);
	    }
	}
	/* fall-through intended */
    case DECOR_DISPLAY_OPTION_DECOR_MATCH:
	if (compSetMatchOption (o, value))
	{
	    CompScreen *s;
	    CompWindow *w;

	    for (s = display->screens; s; s = s->next)
		for (w = s->windows; w; w = w->next)
		    decorWindowUpdate (w, TRUE);
	}
	break;
    default:
	if (compSetOption (o, value))
	    return TRUE;
	break;
    }

    return FALSE;
}