Esempio n. 1
0
static Bool
snowInitScreen (CompPlugin *p,
		CompScreen *s)
{
    SnowScreen *ss;
    int        i, numFlakes = starGetNumSnowflakes (s->display);
    SnowFlake  *snowFlake;

    SNOW_DISPLAY (s->display);

    ss = calloc (1, sizeof(SnowScreen));

    s->base.privates[sd->screenPrivateIndex].ptr = ss;

    ss->s = s;
    ss->snowTexturesLoaded = 0;
    ss->snowTex = NULL;
    ss->active = FALSE;
    ss->displayListNeedsUpdate = FALSE;

    ss->allSnowFlakes = snowFlake = malloc (numFlakes * sizeof (SnowFlake));

    for (i = 0; i < numFlakes; i++)
    {
	initiateSnowFlake (ss, snowFlake);
	setSnowflakeTexture (ss, snowFlake);
	snowFlake++;
    }

    updateSnowTextures (s);
    setupDisplayList (ss);

    WRAP (ss, s, paintOutput, snowPaintOutput);
    WRAP (ss, s, drawWindow, snowDrawWindow);

    ss->timeoutHandle = compAddTimeout (starGetSnowUpdateDelay (s->display),
					starGetSnowUpdateDelay (s->display) * 1.2, stepSnowPositions, s);

    return TRUE;
}
Esempio n. 2
0
static void
snowDisplayOptionChanged (CompDisplay        *d,
			  CompOption         *opt,
			  StarDisplayOptions num)
{
    SNOW_DISPLAY (d);

    switch (num)
    {
    case StarDisplayOptionSnowSize:
	{
	    CompScreen *s;

	    for (s = d->screens; s; s = s->next)
	    {
		SNOW_SCREEN (s);
		ss->displayListNeedsUpdate = TRUE;
		updateSnowTextures (s);
	    }
	}
	break;
    case StarDisplayOptionSnowUpdateDelay:
	{
	    CompScreen *s;

	    for (s = d->screens; s; s = s->next)
	    {
		SNOW_SCREEN (s);

		if (ss->timeoutHandle)
		    compRemoveTimeout (ss->timeoutHandle);
		ss->timeoutHandle =
		    compAddTimeout (starGetSnowUpdateDelay (d),
									   starGetSnowUpdateDelay (d) *1.2,  stepSnowPositions, s);
	    }
	}
	break;
    case StarDisplayOptionNumSnowflakes:
	{
	    CompScreen *s;
	    int        i, numFlakes;
	    SnowFlake  *snowFlake;

	    numFlakes = starGetNumSnowflakes (d);
	    for (s = d->screens; s; s = s->next)
	    {
		SNOW_SCREEN (s);
		ss->allSnowFlakes = realloc (ss->allSnowFlakes,
					     numFlakes * sizeof (SnowFlake));
		snowFlake = ss->allSnowFlakes;

		for (i = 0; i < numFlakes; i++)
		{
		    initiateSnowFlake (ss, snowFlake);
		    setSnowflakeTexture (ss, snowFlake);
		    snowFlake++;
		}
	    }
	}
	break;
    case StarDisplayOptionSnowTextures:
	{
	    CompScreen *s;
	    CompOption *texOpt;

	    texOpt = starGetSnowTexturesOption (d);

	    sd->snowTexFiles = texOpt->value.list.value;
	    sd->snowTexNFiles = texOpt->value.list.nValue;

	    for (s = d->screens; s; s = s->next)
		updateSnowTextures (s);
	}
	break;
    default:
	break;
    }
}
Esempio n. 3
0
static void
snowChangeNotify (const char        *optionName,
                  BananaType        optionType,
                  const BananaValue *optionValue,
                  int               screenNum)
{
	SNOW_DISPLAY (&display);

	if (strcasecmp (optionName, "snow_size") == 0)
	{
		CompScreen *s;

		for (s = display.screens; s; s = s->next)
		{
			SNOW_SCREEN (s);
			ss->displayListNeedsUpdate = TRUE;
			updateSnowTextures (s);
		}
	}
	else if (strcasecmp (optionName, "snow_update_delay") == 0)
	{
		CompScreen *s;

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

			if (ss->timeoutHandle)
				compRemoveTimeout (ss->timeoutHandle);
			ss->timeoutHandle =
			    compAddTimeout (optionValue->i,
			            (float) optionValue->i * 1.2,
			            stepSnowPositions, s);
		}
	}
	else if (strcasecmp (optionName, "num_snowflakes") == 0)
	{
		CompScreen *s;
		int        i, numFlakes;
		SnowFlake  *snowFlake;

		numFlakes = optionValue->i;
		for (s = display.screens; s; s = s->next)
		{
			SNOW_SCREEN (s);
			ss->allSnowFlakes = realloc (ss->allSnowFlakes,
			                             numFlakes * sizeof (SnowFlake));
			snowFlake = ss->allSnowFlakes;

			for (i = 0; i < numFlakes; i++)
			{
				initiateSnowFlake (ss, snowFlake);
				setSnowflakeTexture (ss, snowFlake);
				snowFlake++;
			}
		}
	}
	else if (strcasecmp (optionName, "snow_textures") == 0)
	{
		CompScreen *s;

		for (s = display.screens; s; s = s->next)
			updateSnowTextures (s);
	}
	else if (strcasecmp (optionName, "toggle_key") == 0)
		updateKey (optionValue->s, &sd->toggle_key);

}
Esempio n. 4
0
static Bool
snowInitScreen (CompPlugin *p,
                CompScreen *s)
{
	SnowScreen *ss;

	const BananaValue *
	option_num_snowflakes = bananaGetOption (bananaIndex,
	                                         "num_snowflakes",
	                                         -1);

	const BananaValue *
	option_snow_update_delay = bananaGetOption (bananaIndex,
	                                            "snow_update_delay",
	                                            -1);

	int        i, numFlakes = option_num_snowflakes->i;
	SnowFlake  *snowFlake;

	SNOW_DISPLAY (&display);

	ss = calloc (1, sizeof(SnowScreen));
	if (!ss)
		return FALSE;

	s->privates[sd->screenPrivateIndex].ptr = ss;

	ss->s = s;
	ss->snowTexturesLoaded = 0;
	ss->snowTex = NULL;
	ss->active = FALSE;
	ss->displayListNeedsUpdate = FALSE;

	ss->allSnowFlakes = snowFlake = malloc (numFlakes * sizeof (SnowFlake));
	if (!snowFlake)
	{
		free (ss);
		return FALSE;
	}

	for (i = 0; i < numFlakes; i++)
	{
		initiateSnowFlake (ss, snowFlake);
		setSnowflakeTexture (ss, snowFlake);
		snowFlake++;
	}

	updateSnowTextures (s);
	setupDisplayList (ss);

	WRAP (ss, s, paintOutput, snowPaintOutput);
	WRAP (ss, s, drawWindow, snowDrawWindow);

	ss->timeoutHandle = compAddTimeout (option_snow_update_delay->i,
	                (float)
	                option_snow_update_delay->i *
	                1.2,
	                stepSnowPositions, s);

	return TRUE;
}