Ejemplo n.º 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;
}
Ejemplo n.º 2
0
Archivo: fade.c Proyecto: zmike/compiz
static Bool
fadeSetScreenOption(CompPlugin *plugin,
                    CompScreen *screen,
                    const char *name,
                    CompOptionValue *value)
{
   CompOption *o;
   int index;

   FADE_SCREEN(screen);

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

   switch (index)
     {
      case FADE_SCREEN_OPTION_FADE_SPEED:
        if (compSetFloatOption(o, value))
          {
             fs->fadeTime = 1000.0f / o->value.f;
             return TRUE;
          }
        break;

      case FADE_SCREEN_OPTION_WINDOW_MATCH:
        if (compSetMatchOption(o, value))
          {
             fadeUpdateWindowFadeMatch(screen->display, &o->value, &fs->match);
             return TRUE;
          }
        break;

      default:
        if (compSetOption(o, value))
          return TRUE;
        break;
     }

   return FALSE;
}
Ejemplo n.º 3
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;
}
Ejemplo n.º 4
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;
}