Example #1
0
static void
scalefilterUpdateFilter (CompScreen *s,
	   		 CompMatch  *match)
{
    char         filterMatch[2 * MAX_FILTER_TEXT_LEN];
    unsigned int offset;

    FILTER_SCREEN (s);

    matchFini (match);
    matchInit (match);

    if (scalefilterGetFilterCaseInsensitive (s))
    {
	strncpy (filterMatch, "ititle=", MAX_FILTER_TEXT_LEN);
	offset = 7;
    }
    else
    {
    	strncpy (filterMatch, "title=", MAX_FILTER_TEXT_LEN);
	offset = 6;
    }

    wcstombs (filterMatch + offset, fs->filterInfo->filterString,
	      MAX_FILTER_STRING_LEN);
    matchAddExp (match, 0, filterMatch);
    matchAddGroup (match, MATCH_OP_AND_MASK, &fs->scaleMatch);
    matchUpdate (s->display, match);
}
Example #2
0
File: fade.c Project: 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;
}
Example #3
0
/*
  Add match expressions from string. Special characters are
  '(', ')', '!', '&', '|'. Escape character is '\'.

  Example:

  "type=desktop | !type=dock"
  "!type=dock & (state=fullscreen | state=shaded)"
*/
void
matchAddFromString (CompMatch  *match,
		    const char *str)
{
    char *value;
    int	 j, i = 0;
    int	 flags = 0;

    while (str[i] != '\0')
    {
	while (str[i] == ' ')
	    i++;

	if (str[i] == '!')
	{
	    flags |= MATCH_OP_NOT_MASK;

	    i++;
	    while (str[i] == ' ')
		i++;
	}

	if (str[i] == '(')
	{
	    int	level = 1;
	    int length;

	    j = ++i;

	    while (str[j] != '\0')
	    {
		if (str[j] == '(')
		{
		    level++;
		}
		else if (str[j] == ')')
		{
		    level--;
		    if (level == 0)
			break;
		}

		j = nextIndex (str, ++j);
	    }

	    length = j - i;

	    value = malloc (sizeof (char) * (length + 1));
	    if (value)
	    {
		CompMatch group;

		strncpy (value, &str[i], length);
		value[length] = '\0';

		matchInit (&group);
		matchAddFromString (&group, value);
		matchAddGroup (match, flags, &group);
		matchFini (&group);

		free (value);
	    }

	    while (str[j] != '\0' && str[j] != '|' && str[j] != '&')
		j++;
	}
	else
	{
	    j = i;

	    while (str[j] != '\0' && str[j] != '|' && str[j] != '&')
		j = nextIndex (str, ++j);

	    value = strndupValue (&str[i], j - i);
	    if (value)
	    {
		matchAddExp (match, flags, value);

		free (value);
	    }
	}

	i = j;

	if (str[i] != '\0')
	{
	    if (str[i] == '&')
		flags = MATCH_OP_AND_MASK;

	    i++;
	}
    }
}