Exemplo n.º 1
0
static Bool
colorFilterInitScreen (CompPlugin *p,
                       CompScreen *s)
{
	ColorFilterScreen *cfs;

	FILTER_DISPLAY (&display);

	if (!s->fragmentProgram)
	{
		compLogMessage ("colorfilter", CompLogLevelFatal,
		                "Fragment program support missing.");
		return TRUE;
	}

	cfs = malloc (sizeof (ColorFilterScreen));
	if (!cfs)
		return FALSE;

	cfs->windowPrivateIndex = allocateWindowPrivateIndex (s);
	if (cfs->windowPrivateIndex < 0)
	{
		free (cfs);
		return FALSE;
	}

	cfs->isFiltered = FALSE;
	cfs->currentFilter = 0;

	cfs->filtersLoaded = FALSE;
	cfs->filtersFunctions = NULL;
	cfs->filtersCount = 0;	

	WRAP (cfs, s, drawWindowTexture, colorFilterDrawWindowTexture);
	WRAP (cfs, s, windowAddNotify, colorFilterWindowAddNotify);

	s->privates[cfd->screenPrivateIndex].ptr = cfs;

	const BananaValue *
	option_filter_match = bananaGetOption (bananaIndex,
	                                       "filter_match",
	                                       s->screenNum);

	matchInit (&cfs->filter_match);
	matchAddFromString (&cfs->filter_match, option_filter_match->s);
	matchUpdate (&cfs->filter_match);

	const BananaValue *
	option_exclude_match = bananaGetOption (bananaIndex,
	                                        "exclude_match",
	                                        s->screenNum);

	matchInit (&cfs->exclude_match);
	matchAddFromString (&cfs->exclude_match, option_exclude_match->s);
	matchUpdate (&cfs->exclude_match);

	return TRUE;
}
Exemplo n.º 2
0
static void
opacifyChangeNotify (const char        *optionName,
                     BananaType        optionType,
                     const BananaValue *optionValue,
                     int               screenNum)
{
	OPACIFY_DISPLAY (&display);

	if (strcasecmp (optionName, "toggle_key") == 0)
		updateKey (optionValue->s, &od->toggle_key);

	else if (strcasecmp (optionName, "init_toggle") == 0)
		od->toggle = optionValue->b;

	else if (strcasecmp (optionName, "window_match") == 0)
	{
		CompScreen *s = getScreenFromScreenNum (screenNum);
		OPACIFY_SCREEN (s);

		matchFini (&os->window_match);
		matchInit (&os->window_match);
		matchAddFromString (&os->window_match, optionValue->s);
		matchUpdate (&os->window_match);
	}
}
Exemplo n.º 3
0
static void
minChangeNotify (const char        *optionName,
                 BananaType        optionType,
                 const BananaValue *optionValue,
                 int               screenNum)
{
	CompScreen *screen = getScreenFromScreenNum (screenNum);

	MIN_SCREEN (screen);

	if (strcasecmp (optionName, "shade_resistance") == 0)
	{
		if (optionValue->i)
			ms->shadeStep = 100 - optionValue->i + 1;
		else
			ms->shadeStep = 0;
	}
	else if (strcasecmp (optionName, "window_match") == 0)
	{
		matchFini (&ms->match);
		matchInit (&ms->match);
		matchAddFromString (&ms->match, optionValue->s);
		matchUpdate (&ms->match);
	}
}
Exemplo n.º 4
0
static Bool
kconfigStringToValue (CompObject      *object,
		      QString	      str,
		      CompOptionType  type,
		      CompOptionValue *value)
{
    switch (type) {
    case CompOptionTypeBool:
	value->b = str.toInt () ? TRUE : FALSE;
	break;
    case CompOptionTypeFloat:
	value->f = str.toFloat ();
	break;
    case CompOptionTypeString:
	value->s = strdup (str.ascii ());
	if (!value->s)
	    return FALSE;
	break;
    case CompOptionTypeColor:
	if (!stringToColor (str.ascii (), value->c))
	    return FALSE;
	break;
    case CompOptionTypeKey:
	while (object && object->type != COMP_OBJECT_TYPE_DISPLAY)
	    object = object->parent;

	if (!object)
	    return FALSE;

	stringToKeyAction (GET_CORE_DISPLAY (object), str.ascii (),
			   &value->action);
	break;
    case CompOptionTypeButton:
	while (object && object->type != COMP_OBJECT_TYPE_DISPLAY)
	    object = object->parent;

	if (!object)
	    return FALSE;

	stringToButtonAction (GET_CORE_DISPLAY (object), str.ascii (),
			      &value->action);
	break;
    case CompOptionTypeEdge:
	value->action.edgeMask = stringToEdgeMask (str.ascii ());
	break;
    case CompOptionTypeBell:
	value->action.bell = str.toInt () ? TRUE : FALSE;
	break;
    case CompOptionTypeMatch:
	matchInit (&value->match);
	matchAddFromString (&value->match, str.ascii ());
	break;
    default:
	return FALSE;
    }

    return TRUE;
}
Exemplo n.º 5
0
Arquivo: fade.c Projeto: zmike/compiz
static void
fadeUpdateWindowFadeMatch(CompDisplay *display,
                          CompOptionValue *value,
                          CompMatch *match)
{
   matchFini(match);
   matchInit(match);
   matchAddFromString(match, "!type=desktop");
   matchAddGroup(match, MATCH_OP_AND_MASK, &value->match);
   matchUpdate(display, match);
}
Exemplo n.º 6
0
static Bool
minInitScreen (CompPlugin *p,
               CompScreen *s)
{
	MinScreen *ms;

	MIN_DISPLAY (&display);

	ms = malloc (sizeof (MinScreen));
	if (!ms)
		return FALSE;

	ms->windowPrivateIndex = allocateWindowPrivateIndex (s);
	if (ms->windowPrivateIndex < 0)
	{
		free (ms);
		return FALSE;
	}

	ms->moreAdjust = FALSE;

	const BananaValue *
	option_shade_resistance = bananaGetOption (bananaIndex,
	                                           "shade_resistance",
	                                           s->screenNum);

	ms->shadeStep  = 100 - option_shade_resistance->i + 1;

	const BananaValue *
	option_window_match = bananaGetOption (bananaIndex,
	                                       "window_match",
	                                       s->screenNum);

	matchInit (&ms->match);
	matchAddFromString (&ms->match, option_window_match->s);
	matchUpdate (&ms->match);

	WRAP (ms, s, preparePaintScreen, minPreparePaintScreen);
	WRAP (ms, s, donePaintScreen, minDonePaintScreen);
	WRAP (ms, s, paintOutput, minPaintOutput);
	WRAP (ms, s, paintWindow, minPaintWindow);
	WRAP (ms, s, damageWindowRect, minDamageWindowRect);
	WRAP (ms, s, focusWindow, minFocusWindow);

	s->privates[md->screenPrivateIndex].ptr = ms;

	return TRUE;
}
Exemplo n.º 7
0
static Bool
opacifyInitScreen (CompPlugin *p,
                   CompScreen *s)
{
	OpacifyScreen *os;

	OPACIFY_DISPLAY (&display);

	os = malloc (sizeof (OpacifyScreen));
	if (!os)
		return FALSE;

	os->windowPrivateIndex = allocateWindowPrivateIndex (s);
	if (os->windowPrivateIndex < 0)
	{
		free (os);
		return FALSE;
	}

	WRAP (os, s, paintWindow, opacifyPaintWindow);

	const BananaValue *
	option_window_match = bananaGetOption (bananaIndex,
	                                       "window_match",
	                                       s->screenNum);

	matchInit (&os->window_match);
	matchAddFromString (&os->window_match, option_window_match->s);
	matchUpdate (&os->window_match);

	s->privates[od->screenPrivateIndex].ptr = os;

	os->intersect = XCreateRegion ();

	os->justMoved = FALSE;

	os->passiveNum = 0;

	os->active = 0;

	return TRUE;
}
Exemplo n.º 8
0
static void
initMatchValue (CompDisplay     *d,
		CompOptionValue *v,
		Bool		helper,
		xmlDocPtr       doc,
		xmlNodePtr      node)
{
    xmlChar *value;

    matchInit (&v->match);

    if (!doc)
	return;

    value = xmlNodeListGetString (doc, node->xmlChildrenNode, 1);
    if (value)
    {
	matchAddFromString (&v->match, (char *) value);
	xmlFree (value);
    }

    if (!helper)
	matchUpdate (d, &v->match);
}
Exemplo n.º 9
0
static void
groupChangeNotify (const char        *optionName,
                   BananaType        optionType,
                   const BananaValue *optionValue,
                   int               screenNum)
{
    GROUP_DISPLAY (&display);

    if (strcasecmp (optionName, "window_match") == 0)
    {
        CompScreen *s = getScreenFromScreenNum (screenNum);
        GROUP_SCREEN (s);

        matchFini (&gs->window_match);
        matchInit (&gs->window_match);
        matchAddFromString (&gs->window_match, optionValue->s);
        matchUpdate (&gs->window_match);
    }
    else if (strcasecmp (optionName, "tab_base_color") == 0 ||
             strcasecmp (optionName, "tab_highlight_color") == 0 ||
             strcasecmp (optionName, "tab_border_color") == 0 ||
             strcasecmp (optionName, "tab_style") == 0 ||
             strcasecmp (optionName, "border_radius") == 0 ||
             strcasecmp (optionName, "border_width") == 0)
    {
        GroupSelection *group;

        CompScreen *s = getScreenFromScreenNum (screenNum);
        GROUP_SCREEN (s);

        for (group = gs->groups; group; group = group->next)
            if (group->tabBar)
                groupRenderTabBarBackground (group);
    }
    else if (strcasecmp (optionName, "tabbar_font_size") == 0 ||
             strcasecmp (optionName, "tabbar_font_color") == 0)
    {
        GroupSelection *group;

        CompScreen *s = getScreenFromScreenNum (screenNum);
        GROUP_SCREEN (s);

        for (group = gs->groups; group; group = group->next)
            groupRenderWindowTitle (group);
    }
    else if (strcasecmp (optionName, "thumb_size") == 0 ||
             strcasecmp (optionName, "thumb_space") == 0)
    {
        GroupSelection *group;

        CompScreen *s = getScreenFromScreenNum (screenNum);
        GROUP_SCREEN (s);

        for (group = gs->groups; group; group = group->next)
            if (group->tabBar)
            {
                BoxPtr box = &group->tabBar->region->extents;
                groupRecalcTabBarPos (group, (box->x1 + box->x2 ) / 2,
                                      box->x1, box->x2);
            }
    }
    else if (strcasecmp (optionName, "glow") == 0 ||
             strcasecmp (optionName, "glow_size") == 0)
    {
        CompScreen *s = getScreenFromScreenNum (screenNum);
        GROUP_SCREEN (s);

        CompWindow *w;

        for (w = s->windows; w; w = w->next)
        {
            GROUP_WINDOW (w);

            groupComputeGlowQuads (w, &gs->glowTexture.matrix);
            if (gw->glowQuads)
            {
                damageWindowOutputExtents (w);
                updateWindowOutputExtents (w);
                damageWindowOutputExtents (w);
            }
        }
    }
    else if (strcasecmp (optionName, "glow_type") == 0)
    {
        CompScreen *s = getScreenFromScreenNum (screenNum);
        GROUP_SCREEN (s);

        int glowType;
        GlowTextureProperties *glowProperty;

        GROUP_DISPLAY (&display);

        const BananaValue *
        option_glow_type = bananaGetOption (bananaIndex,
                                            "glow_type",
                                            s->screenNum);

        glowType = option_glow_type->i;
        glowProperty = &gd->glowTextureProperties[glowType];

        finiTexture (s, &gs->glowTexture);
        initTexture (s, &gs->glowTexture);

        imageDataToTexture (s, &gs->glowTexture,
                            glowProperty->textureData,
                            glowProperty->textureSize,
                            glowProperty->textureSize,
                            GL_RGBA, GL_UNSIGNED_BYTE);

        const BananaValue *
        option_glow = bananaGetOption (bananaIndex,
                                       "glow",
                                       s->screenNum);

        if (option_glow->b && gs->groups)
        {
            CompWindow *w;

            for (w = s->windows; w; w = w->next)
                groupComputeGlowQuads (w, &gs->glowTexture.matrix);

            damageScreen (s);
        }
    }
    else if (strcasecmp (optionName, "select_button") == 0)
        updateButton (optionValue->s, &gd->select_button);
    else if (strcasecmp (optionName, "select_single_key") == 0)
        updateKey (optionValue->s, &gd->select_single_key);
    else if (strcasecmp (optionName, "group_key") == 0)
        updateKey (optionValue->s, &gd->group_key);
    else if (strcasecmp (optionName, "ungroup_key") == 0)
        updateKey (optionValue->s, &gd->ungroup_key);
    else if (strcasecmp (optionName, "remove_key") == 0)
        updateKey (optionValue->s, &gd->remove_key);
    else if (strcasecmp (optionName, "close_key") == 0)
        updateKey (optionValue->s, &gd->close_key);
    else if (strcasecmp (optionName, "ignore_key") == 0)
        updateKey (optionValue->s, &gd->ignore_key);
    else if (strcasecmp (optionName, "tabmode_key") == 0)
        updateKey (optionValue->s, &gd->tabmode_key);
    else if (strcasecmp (optionName, "change_tab_left_key") == 0)
        updateKey (optionValue->s, &gd->change_tab_left_key);
    else if (strcasecmp (optionName, "change_tab_right_key") == 0)
        updateKey (optionValue->s, &gd->change_tab_right_key);
    else if (strcasecmp (optionName, "change_color_key") == 0)
        updateKey (optionValue->s, &gd->change_color_key);
    else if (strcasecmp (optionName, "autotab_windows") == 0)
    {
        CompScreen *s = getScreenFromScreenNum (screenNum);

        GROUP_SCREEN (s);

        int i;
        if (gs->autotab && gs->autotabCount != 0)
        {
            for (i = 0; i <= gs->autotabCount - 1; i++)
                matchFini (&gs->autotab[i]);

            free (gs->autotab);
        }

        gs->autotabCount = optionValue->list.nItem;
        gs->autotab = malloc (gs->autotabCount * sizeof (CompMatch));

        for (i = 0; i <= gs->autotabCount - 1; i++)
        {
            matchInit (&gs->autotab[i]);
            matchAddFromString (&gs->autotab[i], optionValue->list.item[i].s);
            matchUpdate (&gs->autotab[i]);
        }
    }
}
Exemplo n.º 10
0
static Bool
winrulesInitScreen (CompPlugin *p,
                    CompScreen *s)
{
	WinrulesScreen *ws;

	WINRULES_DISPLAY (&display);

	ws = malloc (sizeof (WinrulesScreen));
	if (!ws)
		return FALSE;

	ws->windowPrivateIndex = allocateWindowPrivateIndex (s);
	if (ws->windowPrivateIndex < 0)
	{
		free (ws);
		return FALSE;
	}

	WRAP (ws, s, getAllowedActionsForWindow,
	      winrulesGetAllowedActionsForWindow);

	const BananaValue *
	option_skiptaskbar_match = bananaGetOption (bananaIndex,
	                                            "skiptaskbar_match",
	                                            s->screenNum);

	matchInit (&ws->skiptaskbar_match);
	matchAddFromString (&ws->skiptaskbar_match, option_skiptaskbar_match->s);
	matchUpdate (&ws->skiptaskbar_match);

	const BananaValue *
	option_skippager_match = bananaGetOption (bananaIndex,
	                                          "skippager_match",
	                                          s->screenNum);

	matchInit (&ws->skippager_match);
	matchAddFromString (&ws->skippager_match, option_skippager_match->s);
	matchUpdate (&ws->skippager_match);

	const BananaValue *
	option_above_match = bananaGetOption (bananaIndex,
	                                      "above_match",
	                                      s->screenNum);

	matchInit (&ws->above_match);
	matchAddFromString (&ws->above_match, option_above_match->s);
	matchUpdate (&ws->above_match);

	const BananaValue *
	option_below_match = bananaGetOption (bananaIndex,
	                                      "below_match",
	                                      s->screenNum);

	matchInit (&ws->below_match);
	matchAddFromString (&ws->below_match, option_below_match->s);
	matchUpdate (&ws->below_match);

	const BananaValue *
	option_sticky_match = bananaGetOption (bananaIndex,
	                                       "sticky_match",
	                                       s->screenNum);

	matchInit (&ws->sticky_match);
	matchAddFromString (&ws->sticky_match, option_sticky_match->s);
	matchUpdate (&ws->sticky_match);

	const BananaValue *
	option_fullscreen_match = bananaGetOption (bananaIndex,
	                                           "fullscreen_match",
	                                           s->screenNum);

	matchInit (&ws->fullscreen_match);
	matchAddFromString (&ws->fullscreen_match, option_fullscreen_match->s);
	matchUpdate (&ws->fullscreen_match);

	const BananaValue *
	option_maximize_match = bananaGetOption (bananaIndex,
	                                         "maximize_match",
	                                         s->screenNum);

	matchInit (&ws->maximize_match);
	matchAddFromString (&ws->maximize_match, option_maximize_match->s);
	matchUpdate (&ws->maximize_match);

	const BananaValue *
	option_no_argb_match = bananaGetOption (bananaIndex,
	                                        "no_argb_match",
	                                         s->screenNum);

	matchInit (&ws->no_argb_match);
	matchAddFromString (&ws->no_argb_match, option_no_argb_match->s);
	matchUpdate (&ws->no_argb_match);

	const BananaValue *
	option_no_move_match = bananaGetOption (bananaIndex,
	                                        "no_move_match",
	                                        s->screenNum);

	matchInit (&ws->no_move_match);
	matchAddFromString (&ws->no_move_match, option_no_move_match->s);
	matchUpdate (&ws->no_move_match);

	const BananaValue *
	option_no_resize_match = bananaGetOption (bananaIndex,
	                                          "no_resize_match",
	                                          s->screenNum);

	matchInit (&ws->no_resize_match);
	matchAddFromString (&ws->no_resize_match, option_no_resize_match->s);
	matchUpdate (&ws->no_resize_match);

	const BananaValue *
	option_no_minimize_match = bananaGetOption (bananaIndex,
	                                            "no_minimize_match",
	                                            s->screenNum);

	matchInit (&ws->no_minimize_match);
	matchAddFromString (&ws->no_minimize_match, option_no_minimize_match->s);
	matchUpdate (&ws->no_minimize_match);

	const BananaValue *
	option_no_maximize_match = bananaGetOption (bananaIndex,
	                                            "no_maximize_match",
	                                            s->screenNum);

	matchInit (&ws->no_maximize_match);
	matchAddFromString (&ws->no_maximize_match, option_no_maximize_match->s);
	matchUpdate (&ws->no_maximize_match);

	const BananaValue *
	option_no_close_match = bananaGetOption (bananaIndex,
	                                         "no_close_match",
	                                         s->screenNum);

	matchInit (&ws->no_close_match);
	matchAddFromString (&ws->no_close_match, option_no_close_match->s);
	matchUpdate (&ws->no_close_match);

	const BananaValue *
	option_no_focus_match = bananaGetOption (bananaIndex,
	                                         "no_focus_match",
	                                         s->screenNum);

	matchInit (&ws->no_focus_match);
	matchAddFromString (&ws->no_focus_match, option_no_focus_match->s);
	matchUpdate (&ws->no_focus_match);

	const BananaValue *
	option_size_matches = bananaGetOption (bananaIndex,
	                                       "size_matches",
	                                       s->screenNum);

	ws->size_matches_count = option_size_matches->list.nItem;
	int i;
	for (i = 0; i < option_size_matches->list.nItem; i++)
	{
		matchInit (&ws->size_matches[i]);
		matchAddFromString (&ws->size_matches[i],
		                    option_size_matches->list.item[i].s);
		matchUpdate (&ws->size_matches[i]);
	}

	s->privates[wd->screenPrivateIndex].ptr = ws;

	return TRUE;
}
Exemplo n.º 11
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;
}
Exemplo n.º 12
0
static Bool
csvToList (CompDisplay *d, char *csv, CompListValue *list, CompOptionType type)
{
    char *splitStart = NULL;
    char *splitEnd = NULL;
    char *item = NULL;
    int  itemLength, count, i;

    if (csv[0] == '\0')
    {
	list->nValue = 0;
	return FALSE;
    }

    int length = strlen (csv);
    count = 1;
    for (i = 0; csv[i] != '\0'; i++)
	if (csv[i] == ',' && i != length-1)
	    count++;

    splitStart = csv;
    list->value = malloc (sizeof (CompOptionValue) * count);
    list->nValue = count;

    if (list->value)
    {
	for (i = 0; i < count; i++)
	{
	    splitEnd = strchr (splitStart, ',');

	    if (splitEnd)
	    {
		itemLength = strlen (splitStart) - strlen (splitEnd);
		item = malloc (sizeof (char) * (itemLength + 1));
		if (item)
		{
		   strncpy (item, splitStart, itemLength);
		   item[itemLength] = 0;
		}
	    }
	    else // last value
	    {
		item = strdup (splitStart);
	    }

	    if (!item) {
	        compLogMessage ("ini", CompLogLevelError, "Not enough memory");
	        list->nValue = 0;
	        return FALSE;
	    }

	    switch (type)
	    {
		case CompOptionTypeString:
		    list->value[i].s = strdup (item);
		    break;
		case CompOptionTypeBool:
		    list->value[i].b = item[0] ? (Bool) atoi (item) : FALSE;
		    break;
		case CompOptionTypeInt:
		    list->value[i].i = item[0] ? atoi (item) : 0;
		    break;
		case CompOptionTypeFloat:
		    list->value[i].f = item[0] ? atof (item) : 0.0f;
		    break;
		case CompOptionTypeKey:
		    stringToKeyAction (d, item, &list->value[i].action);
		    break;
		case CompOptionTypeButton:
		    stringToButtonAction (d, item, &list->value[i].action);
		    break;
		case CompOptionTypeEdge:
		    list->value[i].action.edgeMask = stringToEdgeMask (item);
		    break;
		case CompOptionTypeBell:
		    list->value[i].action.bell = (Bool) atoi (item);
		    break;
		case CompOptionTypeMatch:
		    matchInit (&list->value[i].match);
		    matchAddFromString (&list->value[i].match, item);
		    break;
		default:
		    break;
	    }

	    splitStart = ++splitEnd;
	    if (item)
	    {
		free (item);
		item = NULL;
	    }
	}
    }

    return TRUE;
}
Exemplo n.º 13
0
static void
winrulesChangeNotify (const char        *optionName,
                      BananaType        optionType,
                      const BananaValue *optionValue,
                      int               screenNum)
{
	unsigned int updateStateMask = 0, updateActionsMask = 0;

	CompScreen *screen = getScreenFromScreenNum (screenNum);

	WINRULES_SCREEN (screen);

	CompMatch *match;

	if (strcasecmp (optionName, "skiptaskbar_match") == 0)
	{
		match = &ws->skiptaskbar_match;

		matchFini (match);
		matchInit (match);
		matchAddFromString (match, optionValue->s);
		matchUpdate (match);

		updateStateMask = CompWindowStateSkipTaskbarMask;
	}
	else if (strcasecmp (optionName, "skippager_match") == 0)
	{
		match = &ws->skippager_match;

		matchFini (match);
		matchInit (match);
		matchAddFromString (match, optionValue->s);
		matchUpdate (match);

		updateStateMask = CompWindowStateSkipPagerMask;
	}
	else if (strcasecmp (optionName, "above_match") == 0)
	{
		match = &ws->above_match;

		matchFini (match);
		matchInit (match);
		matchAddFromString (match, optionValue->s);
		matchUpdate (match);

		updateStateMask = CompWindowStateAboveMask;
	}
	else if (strcasecmp (optionName, "below_match") == 0)
	{
		match = &ws->below_match;

		matchFini (match);
		matchInit (match);
		matchAddFromString (match, optionValue->s);
		matchUpdate (match);

		updateStateMask = CompWindowStateBelowMask;
	}
	else if (strcasecmp (optionName, "sticky_match") == 0)
	{
		match = &ws->sticky_match;

		matchFini (match);
		matchInit (match);
		matchAddFromString (match, optionValue->s);
		matchUpdate (match);

		updateStateMask = CompWindowStateStickyMask;
	}
	else if (strcasecmp (optionName, "fullscreen_match") == 0)
	{
		match = &ws->fullscreen_match;

		matchFini (match);
		matchInit (match);
		matchAddFromString (match, optionValue->s);
		matchUpdate (match);

		updateStateMask = CompWindowStateFullscreenMask;
	}
	else if (strcasecmp (optionName, "maximize_match") == 0)
	{
		match = &ws->maximize_match;

		matchFini (match);
		matchInit (match);
		matchAddFromString (match, optionValue->s);
		matchUpdate (match);

		updateStateMask = CompWindowStateMaximizedHorzMask |
		                  CompWindowStateMaximizedVertMask;
	}
	else if (strcasecmp (optionName, "no_move_match") == 0)
	{
		match = &ws->no_move_match;

		matchFini (match);
		matchInit (match);
		matchAddFromString (match, optionValue->s);
		matchUpdate (match);

		updateActionsMask = CompWindowActionMoveMask;
	}
	else if (strcasecmp (optionName, "no_resize_match") == 0)
	{
		match = &ws->no_resize_match;

		matchFini (match);
		matchInit (match);
		matchAddFromString (match, optionValue->s);
		matchUpdate (match);

		updateActionsMask = CompWindowActionResizeMask;
	}
	else if (strcasecmp (optionName, "no_minimize_match") == 0)
	{
		match = &ws->no_minimize_match;

		matchFini (match);
		matchInit (match);
		matchAddFromString (match, optionValue->s);
		matchUpdate (match);

		updateActionsMask = CompWindowActionMinimizeMask;
	}
	else if (strcasecmp (optionName, "no_maximize_match") == 0)
	{
		match = &ws->no_maximize_match;

		matchFini (match);
		matchInit (match);
		matchAddFromString (match, optionValue->s);
		matchUpdate (match);

		updateActionsMask = CompWindowActionMaximizeVertMask |
		                    CompWindowActionMaximizeHorzMask;
	}
	else if (strcasecmp (optionName, "no_close_match") == 0)
	{
		match = &ws->no_close_match;

		matchFini (match);
		matchInit (match);
		matchAddFromString (match, optionValue->s);
		matchUpdate (match);

		updateActionsMask = CompWindowActionCloseMask;
	}
	else if (strcasecmp (optionName, "no_argb_match") == 0)
	{
		match = &ws->no_argb_match;

		matchFini (match);
		matchInit (match);
		matchAddFromString (match, optionValue->s);
		matchUpdate (match);

		CompWindow *w;

		for (w = screen->windows; w; w = w->next)
			winrulesSetNoAlpha (w, match);
	}
	else if (strcasecmp (optionName, "no_focus_match") == 0)
	{
		match = &ws->no_focus_match;

		matchFini (match);
		matchInit (match);
		matchAddFromString (match, optionValue->s);
		matchUpdate (match);

		CompWindow *w;

		for (w = screen->windows; w; w = w->next)
			winrulesSetNoFocus (w, match);
	}
	else if (strcasecmp (optionName, "size_matches") == 0)
	{
		int i;
		for (i = 0; i < ws->size_matches_count; i++)
			matchFini (&ws->size_matches[i]);

		ws->size_matches_count = optionValue->list.nItem;
		for (i = 0; i < ws->size_matches_count; i++)
		{
			matchInit (&ws->size_matches[i]);
			matchAddFromString (&ws->size_matches[i],
			                    optionValue->list.item[i].s);
			matchUpdate (&ws->size_matches[i]);
		}
	}

	if (strcasecmp (optionName, "size_matches") == 0 ||
	    strcasecmp (optionName, "size_width_values") == 0 ||
	    strcasecmp (optionName, "size_height_values") == 0)
	{
		CompWindow *w;

		for (w = screen->windows; w; w = w->next)
		{
			int width, height;

			if (winrulesMatchSize (w, &width, &height))
				winrulesUpdateWindowSize (w, width, height);
		}
	}

	if (updateStateMask)
	{
		CompWindow *w;

		for (w = screen->windows; w; w = w->next)
			winrulesUpdateState (w, match, updateStateMask);
	}

	if (updateActionsMask)
	{
		CompWindow *w;

		for (w = screen->windows; w; w = w->next)
			winrulesSetAllowedActions (w, match, updateActionsMask);
	}
}
Exemplo n.º 14
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.º 15
0
static void
ccpSetValueToValue (CompObject      *object,
		    CCSSettingValue *sv,
		    CompOptionValue *v,
		    CCSSettingType  type)
{
    switch (type)
    {
    case TypeInt:
	v->i = sv->value.asInt;
	break;
    case TypeFloat:
	v->f = sv->value.asFloat;
	break;
    case TypeBool:
	v->b = sv->value.asBool;
	break;
    case TypeColor:
	{
	    int i;

	    for (i = 0; i < 4; i++)
		v->c[i] = sv->value.asColor.array.array[i];
	}
	break;
    case TypeString:
	v->s = strdup (sv->value.asString);
	break;
    case TypeMatch:
	matchInit (&v->match);
	matchAddFromString (&v->match, sv->value.asMatch);
	break;
    case TypeKey:
	{
	    CompDisplay *d;

	    while (object && object->type != COMP_OBJECT_TYPE_DISPLAY)
		object = object->parent;

	    if (!object)
		return;

	    d = GET_CORE_DISPLAY (object);

	    v->action.key.keycode =
		(sv->value.asKey.keysym != NoSymbol) ?
		XKeysymToKeycode (d->display, sv->value.asKey.keysym) : 0;

	    v->action.key.modifiers = sv->value.asKey.keyModMask;

	    if (v->action.key.keycode || v->action.key.modifiers)
		v->action.type = CompBindingTypeKey;
	    else
		v->action.type = CompBindingTypeNone;
	}
	break;
    case TypeButton:
	{
	    v->action.button.button = sv->value.asButton.button;
	    v->action.button.modifiers = sv->value.asButton.buttonModMask;
	    v->action.edgeMask = sv->value.asButton.edgeMask;

	    if (v->action.button.button || v->action.button.modifiers)
	    {
		if (sv->value.asButton.edgeMask)
		    v->action.type = CompBindingTypeEdgeButton;
		else
		    v->action.type = CompBindingTypeButton;
	    }
	    else
		v->action.type = CompBindingTypeNone;
	}
	break;
    case TypeEdge:
	{
	    v->action.edgeMask = sv->value.asEdge;
	}
	break;
    case TypeBell:
	{
	    v->action.bell = sv->value.asBell;
	}
	break;
    default:
	break;
    }
}
Exemplo n.º 16
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++;
	}
    }
}
Exemplo n.º 17
0
Arquivo: fuse.c Projeto: zmike/compiz
static Bool
fuseInitValueFromString(CompObject *object,
                        CompOptionValue *value,
                        CompOptionType type,
                        char *str)
{
   switch (type)
     {
      case CompOptionTypeBool:
        value->b = strcmp(str, "true") ? FALSE : TRUE;
        break;

      case CompOptionTypeInt:
        value->i = atoi(str);
        break;

      case CompOptionTypeFloat:
        value->f = strtod(str, NULL);
        break;

      case CompOptionTypeString:
        value->s = strdup(str);
        break;

      case CompOptionTypeColor:
        if (!stringToColor(str, value->c))
          return FALSE;
        break;

      case CompOptionTypeKey:
        while (object && object->type != COMP_OBJECT_TYPE_DISPLAY)
          object = object->parent;

        if (!object)
          return FALSE;

        stringToKeyAction(GET_CORE_DISPLAY(object), str, &value->action);
        break;

      case CompOptionTypeButton:
        while (object && object->type != COMP_OBJECT_TYPE_DISPLAY)
          object = object->parent;

        if (!object)
          return FALSE;

        stringToButtonAction(GET_CORE_DISPLAY(object), str, &value->action);
        break;

      case CompOptionTypeEdge:
        value->action.edgeMask = stringToEdgeMask(str);
        break;

      case CompOptionTypeBell:
        value->action.bell = strcmp(str, "true") ? FALSE : TRUE;
        break;

      case CompOptionTypeMatch:
        matchInit(&value->match);
        matchAddFromString(&value->match, str);
        break;

      default:
        return FALSE;
     }

   return TRUE;
}
Exemplo n.º 18
0
/*
 * groupInitScreen
 *
 */
static Bool
groupInitScreen (CompPlugin *p,
                 CompScreen *s)
{
    GroupScreen       *gs;
    int glowType;

    GROUP_DISPLAY (&display);

    gs = malloc (sizeof (GroupScreen));
    if (!gs)
        return FALSE;

    gs->windowPrivateIndex = allocateWindowPrivateIndex (s);
    if (gs->windowPrivateIndex < 0)
    {
        free (gs);
        return FALSE;
    }

    WRAP (gs, s, windowMoveNotify, groupWindowMoveNotify);
    WRAP (gs, s, windowResizeNotify, groupWindowResizeNotify);
    WRAP (gs, s, getOutputExtentsForWindow, groupGetOutputExtentsForWindow);
    WRAP (gs, s, preparePaintScreen, groupPreparePaintScreen);
    WRAP (gs, s, paintOutput, groupPaintOutput);
    WRAP (gs, s, drawWindow, groupDrawWindow);
    WRAP (gs, s, paintWindow, groupPaintWindow);
    WRAP (gs, s, paintTransformedOutput, groupPaintTransformedOutput);
    WRAP (gs, s, donePaintScreen, groupDonePaintScreen);
    WRAP (gs, s, windowGrabNotify, groupWindowGrabNotify);
    WRAP (gs, s, windowUngrabNotify, groupWindowUngrabNotify);
    WRAP (gs, s, damageWindowRect, groupDamageWindowRect);
    WRAP (gs, s, windowStateChangeNotify, groupWindowStateChangeNotify);
    WRAP (gs, s, activateWindow, groupActivateWindow);

    s->privates[gd->screenPrivateIndex].ptr = gs;

    gs->groups = NULL;

    gs->tmpSel.windows = NULL;
    gs->tmpSel.nWins   = 0;

    gs->grabIndex = 0;
    gs->grabState = ScreenGrabNone;

    gs->lastHoveredGroup = NULL;

    gs->queued          = FALSE;
    gs->pendingMoves    = NULL;
    gs->pendingGrabs    = NULL;
    gs->pendingUngrabs  = NULL;

    gs->dequeueTimeoutHandle = 0;

    gs->draggedSlot            = NULL;
    gs->dragged                = FALSE;
    gs->dragHoverTimeoutHandle = 0;

    gs->prevX = 0;
    gs->prevY = 0;

    gs->showDelayTimeoutHandle = 0;

    /* one-shot timeout for stuff that needs to be initialized after
       all screens and windows are initialized */
    gs->initialActionsTimeoutHandle =
        compAddTimeout (0, 0, groupApplyInitialActions, (void *) s);

    initTexture (s, &gs->glowTexture);

    const BananaValue *
    option_glow_type = bananaGetOption (bananaIndex,
                                        "glow_type",
                                        s->screenNum);

    glowType = option_glow_type->i;
    imageDataToTexture (s, &gs->glowTexture,
                        glowTextureProperties[glowType].textureData,
                        glowTextureProperties[glowType].textureSize,
                        glowTextureProperties[glowType].textureSize,
                        GL_RGBA, GL_UNSIGNED_BYTE);

    const BananaValue *
    option_window_match = bananaGetOption (bananaIndex,
                                           "window_match",
                                           s->screenNum);

    matchInit (&gs->window_match);
    matchAddFromString (&gs->window_match, option_window_match->s);
    matchUpdate (&gs->window_match);

    const BananaValue *
    option_autotab_windows = bananaGetOption (bananaIndex,
                             "autotab_windows",
                             s->screenNum);

    gs->autotabCount = option_autotab_windows->list.nItem;
    gs->autotab = malloc (gs->autotabCount * sizeof (CompMatch));

    int i;
    for (i = 0; i <= gs->autotabCount - 1; i++)
    {
        matchInit (&gs->autotab[i]);
        matchAddFromString (&gs->autotab[i],
                            option_autotab_windows->list.item[i].s);
        matchUpdate (&gs->autotab[i]);
    }

    return TRUE;
}