[beryl-commits] r1548 - branches/beryl-plugins-with-snow/src
corner at server.beryl-project.org
corner at server.beryl-project.org
Tue Dec 5 16:56:03 CET 2006
Author: corner
Date: 2006-12-05 16:55:02 +0100 (Tue, 05 Dec 2006)
New Revision: 1548
Added:
branches/beryl-plugins-with-snow/src/snow.c
Log:
adding version 0.1.2 of snow plugin
Added: branches/beryl-plugins-with-snow/src/snow.c
===================================================================
--- branches/beryl-plugins-with-snow/src/snow.c (rev 0)
+++ branches/beryl-plugins-with-snow/src/snow.c 2006-12-05 15:55:02 UTC (rev 1548)
@@ -0,0 +1,665 @@
+/**
+ *
+ * Beryl snow plugin
+ *
+ * snow.c
+ *
+ * Copyright (c) 2006 Eckhart P. <beryl at cornergraf.net>
+ * Copyright (c) 2006 Brian Jørgensen <qte at fundanemt.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ **/
+
+/*
+ * Many thanks to Atie H. <atie.at.matrix at gmail.com> for providing
+ * a clean plugin template
+ * Also thanks to the folks from #beryl-dev, especially Quinn_Storm
+ * for helping me make this possible
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <math.h>
+
+#include <X11/Xatom.h>
+#include <X11/extensions/Xrender.h>
+
+#include <beryl.h>
+
+
+// ------------------------------------------------------------ CONSTANTS -----------------------------------------------------
+#define MAX_SNOWFLAKES 10000
+#define PI 3.1415
+
+// ------------------------------------------------------------ WRAPPERS -----------------------------------------------------
+#define GET_SNOW_DISPLAY(d) \
+ ((SnowDisplay *) (d)->privates[displayPrivateIndex].ptr)
+
+#define SNOW_DISPLAY(d) \
+ SnowDisplay *hd = GET_SNOW_DISPLAY (d)
+
+#define GET_SNOW_SCREEN(s, hd) \
+ ((SnowScreen *) (s)->privates[(hd)->screenPrivateIndex].ptr)
+
+#define SNOW_SCREEN(s) \
+ SnowScreen *hs = GET_SNOW_SCREEN (s, GET_SNOW_DISPLAY (s->display))
+
+// ------------------------------------------------------------ OPTIONS -----------------------------------------------------
+#define SNOW_DISPLAY_OPTION_NUM_SNOWFLAKES 0
+#define SNOW_DISPLAY_OPTION_SNOW_SIZE 1
+#define SNOW_DISPLAY_OPTION_SNOW_SPEED 2
+#define SNOW_DISPLAY_OPTION_SCREEN_BOXING 3
+#define SNOW_DISPLAY_OPTION_SCREEN_DEPTH 4
+#define SNOW_DISPLAY_OPTION_MAX_FRAMES 5
+#define SNOW_DISPLAY_OPTION_SNOW_TEXTURE 6
+#define SNOW_DISPLAY_OPTION_NUM 7
+
+
+#define SNOW_DISPLAY_OPTION_NUM_SNOWFLAKES_DEFAULT 2000.0
+
+#define SNOW_DISPLAY_OPTION_SNOW_SIZE_DEFAULT 10.0
+#define SNOW_DISPLAY_OPTION_SNOW_SPEED_DEFAULT 75.0
+#define SNOW_DISPLAY_OPTION_SCREEN_BOXING_DEFAULT 600.0
+#define SNOW_DISPLAY_OPTION_SCREEN_DEPTH_DEFAULT 500.0
+#define SNOW_DISPLAY_OPTION_MAX_FRAMES_DEFAULT 40.0
+//#define SNOW_DISPLAY_OPTION_SNOW_TEXTURE_DEFAULT strcat(getenv("HOME"), "/.beryl/plugins/snowflake2.png")
+
+#define HOME_IMAGEDIR ".beryl/plugins" // Change to .beryl/images
+#define SNOWFLAKE_IMAGE "snowflake2.png"
+
+#define NUM_OPTIONS(s) (sizeof ((s)->opt) / sizeof (CompOption))
+
+static int displayPrivateIndex = 0;
+
+static int numFlakes;
+static float snowSize;
+static float snowSpeed;
+static float boxing;
+static float depth;
+static char *fileName = NULL;
+
+
+// ------------------------------------------------------------ STRUCTS -----------------------------------------------------
+typedef struct _SnowDisplay {
+ int screenPrivateIndex;
+ Bool active;
+ float snowSize;
+
+ CompOption opt[SNOW_DISPLAY_OPTION_NUM];
+
+} SnowDisplay;
+
+typedef struct _SnowScreen SnowScreen;
+
+static void InitiateSnowFlake(SnowScreen * hs, int i);
+static void renderSnowflake(SnowScreen * hs, int i);
+void snowThink(SnowScreen * hs, int i);
+void snowMove(SnowScreen * hs, int i) ;
+
+struct _SnowScreen {
+ float alpha;
+
+ CompScreen * s;
+
+ int lastMsCount;
+
+ PreparePaintScreenProc preparePaintScreen;
+ DonePaintScreenProc donePaintScreen;
+ PaintScreenProc paintScreen;
+ PaintWindowProc paintWindow;
+
+ CompTexture snowTexture;
+ unsigned int snowTextureSize[2];
+
+ // TODO: make snowflakes move in spiral/tumbling like fashion with sinus/cosinus functions.
+ float allSnowFlakes[MAX_SNOWFLAKES][6]; // [i][0] = xPos, [i][1] = yPos, [i][2] = zPos, [i][3] = xSpeed, [i][4] = ySpeed, [i][5] = zSpeed,
+ // TODO: make number of snowflakes configurabe;
+ unsigned int numSnowflakes;
+ //Snowflake *snowFlakes[MAX_SNOWFLAKES];
+} ;
+
+void snowThink(SnowScreen * hs, int i)
+{
+ if ( hs->allSnowFlakes[i][1] >= hs->s->height + boxing
+ || hs->allSnowFlakes[i][0] <= -boxing
+ || hs->allSnowFlakes[i][0] >= hs->s->width + boxing
+ || hs->allSnowFlakes[i][2] <= -(depth / 500.0)
+ || hs->allSnowFlakes[i][2] >= 1)
+
+ {
+ InitiateSnowFlake(hs, i);
+ }
+ snowMove(hs, i);
+}
+
+void snowMove(SnowScreen * hs, int i)
+{
+ hs->allSnowFlakes[i][0] += (float)(hs->allSnowFlakes[i][3] * hs->lastMsCount) / (100 - snowSpeed);
+ hs->allSnowFlakes[i][1] += (float)(hs->allSnowFlakes[i][4] * hs->lastMsCount) / (100 - snowSpeed);
+ hs->allSnowFlakes[i][2] += (float)(hs->allSnowFlakes[i][5] * hs->lastMsCount) / (100 - snowSpeed);
+}
+
+// ------------------------------------------------- HELPER FUNCTIONS ----------------------------------------------------
+
+int GetRand(int min, int max);
+int GetRand(int min, int max)
+{
+ return (rand() % (max - min + 1) + min);
+}
+
+float mmrand(int min, int max, float divisor);
+float mmrand(int min, int max, float divisor)
+{
+ return ((float)GetRand(min, max)) / divisor;
+};
+
+void setFileName()
+{
+ // Check if we should load the image path.
+ if (fileName == NULL)
+ {
+ char *home;
+ home = getenv("HOME");
+ if (home)
+ {
+ fileName = malloc(strlen(home) + strlen(HOME_IMAGEDIR) + strlen(SNOWFLAKE_IMAGE) + 3);
+ if (fileName)
+ {
+ sprintf(fileName, "%s/%s/%s", home, HOME_IMAGEDIR, SNOWFLAKE_IMAGE);
+ }
+ }
+ }
+};
+// ------------------------------------------------- FUNCTIONS ----------------------------------------------------
+
+static void snowPreparePaintScreen(CompScreen * s, int msSinceLastPaint)
+{
+ SNOW_SCREEN(s);
+
+ hs->lastMsCount += msSinceLastPaint;
+
+ UNWRAP(hs, s, preparePaintScreen);
+ (*s->preparePaintScreen) (s, 0);
+ WRAP(hs, s, preparePaintScreen, snowPreparePaintScreen);
+
+ hs->alpha = MIN(1.0, MAX(0.0, hs->alpha));
+}
+
+static void snowDonePaintScreen(CompScreen * s)
+{
+ SNOW_SCREEN(s);
+
+// if (hs->lastMsCount > 15)
+// {
+ // TODO: I Don't quite know which of the following is easiest on
+ // CPU/GPU cycles... ought to be the second, but I am no expert.
+
+ //// if (hs->alpha > 0.0) {
+ // damageScreen(s);
+ // // XSync(s->display->display, FALSE);
+ //// }
+
+ CompWindow *w;
+ for (w = s->windows; w; w = w->next)
+ {
+ if (w->type & CompWindowTypeDesktopMask)
+ {
+ addWindowDamage(w);
+ hs->lastMsCount = 0;
+ }
+ }
+// }
+
+ UNWRAP(hs, s, donePaintScreen);
+ (*s->donePaintScreen) (s);
+ WRAP(hs, s, donePaintScreen, snowDonePaintScreen);
+}
+
+static Bool
+snowPaintScreen(CompScreen * s, const ScreenPaintAttrib * sa,
+ Region region, int output, unsigned int mask)
+{
+ Bool status;
+
+ SNOW_SCREEN(s);
+
+ // This line is essential. Without it the snow will be rendered above (some) other windows.
+ mask |= PAINT_SCREEN_ORDER_BACK_TO_FRONT_MASK;
+
+ UNWRAP(hs, s, paintScreen);
+ status = (*s->paintScreen) (s, sa, region, output, mask);
+ WRAP(hs, s, paintScreen, snowPaintScreen);
+
+ if (hs->alpha <= 0.0)
+ return status;
+
+ return status;
+}
+
+static void renderSnowflake(SnowScreen *hs, int i)
+{
+ // TODO: make snowSize an option;
+
+ glTexCoord2f (0, 0);
+ glVertex3f (hs->allSnowFlakes[i][0], hs->allSnowFlakes[i][1], hs->allSnowFlakes[i][2]);
+
+ glTexCoord2f (0, hs->snowTextureSize[1]);
+ glVertex3f (hs->allSnowFlakes[i][0], hs->allSnowFlakes[i][1] + snowSize, hs->allSnowFlakes[i][2]);
+
+ glTexCoord2f (hs->snowTextureSize[0], hs->snowTextureSize[1]);
+ glVertex3f (hs->allSnowFlakes[i][0] + snowSize, hs->allSnowFlakes[i][1] + snowSize, hs->allSnowFlakes[i][2]);
+
+ glTexCoord2f (hs->snowTextureSize[0], 0);
+ glVertex3f (hs->allSnowFlakes[i][0] + snowSize, hs->allSnowFlakes[i][1], hs->allSnowFlakes[i][2]);
+}
+
+static void
+RenderAdvancedSnow(SnowScreen *hs)
+{
+ glBegin (GL_QUADS);
+
+ int i = 0;
+ for (i = 0; i < numFlakes; i++)
+ {
+ snowThink(hs, i);
+ renderSnowflake(hs, i);
+ }
+
+ glEnd ();
+}
+
+static Bool
+snowPaintWindow (CompWindow * w, const WindowPaintAttrib * attrib,
+ Region region, unsigned int mask)
+{
+ int status;
+
+ SNOW_SCREEN (w->screen);
+
+ // First draw Window as usual
+ UNWRAP (hs, w->screen, paintWindow);
+ status = (*w->screen->paintWindow) (w, attrib, region, mask);
+ WRAP (hs, w->screen, paintWindow, snowPaintWindow);
+
+ // Check whether this is the Desktop Window
+ if (w->type & CompWindowTypeDesktopMask)
+ {
+ // If so begin rendering snow effect.
+ CompScreen *s = w->screen;
+
+ glPushMatrix ();
+ glLoadIdentity ();
+ glTranslatef (-0.5f, -0.5f, -DEFAULT_Z_CAMERA);
+ glScalef (1.0f / s->width, -1.0f / s->height, 1.0f);
+ glTranslatef (0.0f, -s->height, 0.0f);
+
+ float alpha = 1.0;
+
+ glEnable (GL_BLEND);
+ glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+ glColor4f (1.0, 1.0, 1.0, alpha);
+ glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
+ enableTexture (s, &hs->snowTexture, COMP_TEXTURE_FILTER_GOOD);
+ glColor4f (1.0, 1.0, 1.0, 1.0);
+
+ RenderAdvancedSnow(hs);
+
+ disableTexture (s, &hs->snowTexture);
+
+ glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ glDisable (GL_BLEND);
+ glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ glPopMatrix ();
+ }
+ return status;
+}
+
+static void InitiateSnowFlake(SnowScreen * hs, int i)
+{
+ //TODO: place snowflakes based on FOV, instead of a cube.
+ hs->allSnowFlakes[i][0] = mmrand(-boxing, hs->s->width + boxing, 1);
+ hs->allSnowFlakes[i][1] = mmrand(-600, -500, 1);
+ hs->allSnowFlakes[i][2] = mmrand(-depth, depth/10.0, 5000);
+ hs->allSnowFlakes[i][3] = mmrand(-1000, 1000, 500000);
+ hs->allSnowFlakes[i][4] = mmrand(1000, 3000, 1000);
+ hs->allSnowFlakes[i][5] = mmrand(-1000, 1000, 500000);
+}
+
+static Bool snowInitScreen(CompPlugin * p, CompScreen * s)
+{
+ SNOW_DISPLAY(s->display);
+
+ SnowScreen *hs = (SnowScreen *) calloc(1, sizeof(SnowScreen));
+ hs->s = s;
+ s->privates[hd->screenPrivateIndex].ptr = hs;
+
+ // TODO: configurable texture path.
+ Bool success = readImageToTexture (s, &hs->snowTexture, fileName, &hs->snowTextureSize[0], &hs->snowTextureSize[1]);
+
+ if (!success)
+ {
+ printf("texture not found : %s\n", fileName);
+ }
+
+ hs->numSnowflakes = 2000;
+ hs->lastMsCount = 0;
+
+ int i = 0;
+ for (i = 0; i < MAX_SNOWFLAKES; i++)
+ {
+ InitiateSnowFlake(hs, i);
+ }
+
+ WRAP(hs, s, paintScreen, snowPaintScreen);
+ WRAP(hs, s, preparePaintScreen, snowPreparePaintScreen);
+ WRAP(hs, s, donePaintScreen, snowDonePaintScreen);
+ WRAP(hs, s, paintWindow, snowPaintWindow);
+
+ return TRUE;
+}
+
+static void snowFiniScreen(CompPlugin * p, CompScreen * s)
+{
+ SNOW_SCREEN(s);
+
+ //Restore the original function
+ UNWRAP(hs, s, paintScreen);
+ UNWRAP(hs, s, preparePaintScreen);
+ UNWRAP(hs, s, donePaintScreen);
+ UNWRAP(hs, s, paintWindow);
+
+ //Free the pointer
+ free(hs);
+}
+
+static Bool
+snowSetDisplayOption(CompDisplay * display, char *name,
+ CompOptionValue * value)
+{
+ CompOption *o;
+ int index;
+
+ SNOW_DISPLAY(display);
+
+ o = compFindOption(hd->opt, NUM_OPTIONS(hd), name, &index);
+ if (!o)
+ return FALSE;
+
+switch (index)
+ {
+ case SNOW_DISPLAY_OPTION_NUM_SNOWFLAKES:
+ if (compSetFloatOption (o, value))
+ {
+ numFlakes = (int) hd->opt[SNOW_DISPLAY_OPTION_NUM_SNOWFLAKES].value.f;
+ return TRUE;
+ }
+ break;
+ case SNOW_DISPLAY_OPTION_SNOW_SIZE:
+ if (compSetFloatOption (o, value))
+ {
+ snowSize = hd->opt[SNOW_DISPLAY_OPTION_SNOW_SIZE].value.f;
+ return TRUE;
+ }
+ break;
+ case SNOW_DISPLAY_OPTION_SNOW_SPEED:
+ if (compSetFloatOption (o, value))
+ {
+ snowSpeed = hd->opt[SNOW_DISPLAY_OPTION_SNOW_SPEED].value.f;
+ return TRUE;
+ }
+ break;
+ case SNOW_DISPLAY_OPTION_SCREEN_BOXING:
+ if (compSetFloatOption (o, value))
+ {
+ boxing = hd->opt[SNOW_DISPLAY_OPTION_SCREEN_BOXING].value.f;
+ return TRUE;
+ }
+ break;
+ case SNOW_DISPLAY_OPTION_SCREEN_DEPTH:
+ if (compSetFloatOption (o, value))
+ {
+ depth = hd->opt[SNOW_DISPLAY_OPTION_SCREEN_DEPTH].value.f;
+ return TRUE;
+ }
+ break;
+ case SNOW_DISPLAY_OPTION_MAX_FRAMES:
+ if (compSetFloatOption (o, value))
+ return TRUE;
+ break;
+ /*
+ case SNOW_DISPLAY_OPTION_SNOW_TEXTURE:
+ if (compSetStringOption (o, value))
+ {
+ if (hd->opt[SNOW_DISPLAY_OPTION_SNOW_TEXTURE].value.s)
+ {
+ fileName = hd->opt[SNOW_DISPLAY_OPTION_SNOW_TEXTURE].value.s;
+ printf("Line 437: '%s'\n", fileName);
+ }
+ else
+ {
+ fileName = SNOW_DISPLAY_OPTION_SNOW_TEXTURE_DEFAULT;
+ printf("Line 442: '%s'\n", fileName);
+ }
+ return TRUE;
+ }
+ break;
+ */
+ default:
+ break;
+ }
+ return FALSE;
+}
+
+static void snowDisplayInitOptions(SnowDisplay * hd)
+{
+ CompOption *o;
+
+ o = &hd->opt[SNOW_DISPLAY_OPTION_NUM_SNOWFLAKES];
+ o->name = "num_snowflakes";
+ o->group=N_("");
+ o->subGroup=N_("");
+ o->displayHints="";
+ o->shortDesc = N_("Number of Snowflakes");
+ o->longDesc = N_("Number of Snowflakes");
+ o->type = CompOptionTypeFloat;
+ o->value.f = SNOW_DISPLAY_OPTION_NUM_SNOWFLAKES_DEFAULT;
+ o->rest.f.min = 0;
+ o->rest.f.max = 10000;
+ o->rest.f.precision = 1;
+
+ o = &hd->opt[SNOW_DISPLAY_OPTION_SNOW_SIZE];
+ o->name = "snow_size";
+ o->group=N_("");
+ o->subGroup=N_("");
+ o->displayHints="";
+ o->shortDesc = N_("Size of snowflakes");
+ o->longDesc = N_("Size of snowflakes");
+ o->type = CompOptionTypeFloat;
+ o->value.f = SNOW_DISPLAY_OPTION_SNOW_SIZE_DEFAULT;
+ o->rest.f.min = 0;
+ o->rest.f.max = 50;
+ o->rest.f.precision = 0.1;
+
+ o = &hd->opt[SNOW_DISPLAY_OPTION_SNOW_SPEED];
+ o->name = "snow_speed";
+ o->group=N_("");
+ o->subGroup=N_("");
+ o->displayHints="";
+ o->shortDesc = N_("Speed of falling snow");
+ o->longDesc = N_("Speed of falling snow");
+ o->type = CompOptionTypeFloat;
+ o->value.f = SNOW_DISPLAY_OPTION_SNOW_SPEED_DEFAULT;
+ o->rest.f.min = 0;
+ o->rest.f.max = 100;
+ o->rest.f.precision = 1;
+
+ o = &hd->opt[SNOW_DISPLAY_OPTION_SCREEN_BOXING];
+ o->name = "screen_boxing";
+ o->group=N_("");
+ o->subGroup=N_("");
+ o->displayHints="";
+ o->shortDesc = N_("Screen Boxing");
+ o->longDesc = N_("How far outside the screen resolution snowflakes can be before being removed. Needed because of FOV.");
+ o->type = CompOptionTypeFloat;
+ o->value.f = SNOW_DISPLAY_OPTION_SCREEN_BOXING_DEFAULT;
+ o->rest.f.min = -2000;
+ o->rest.f.max = 2000;
+ o->rest.f.precision = 1;
+
+ o = &hd->opt[SNOW_DISPLAY_OPTION_SCREEN_DEPTH];
+ o->name = "screen_depth";
+ o->group=N_("");
+ o->subGroup=N_("");
+ o->displayHints="";
+ o->shortDesc = N_("Screen Depth");
+ o->longDesc = N_("How deep into the screen snowflakes can be drawn before being removed.");
+ o->type = CompOptionTypeFloat;
+ o->value.f = SNOW_DISPLAY_OPTION_SCREEN_DEPTH_DEFAULT;
+ o->rest.f.min = 0;
+ o->rest.f.max = 1000;
+ o->rest.f.precision = 1;
+
+ o = &hd->opt[SNOW_DISPLAY_OPTION_MAX_FRAMES];
+ o->name = "max_frames";
+ o->group=N_("");
+ o->subGroup=N_("");
+ o->displayHints="";
+ o->shortDesc = N_("Max Frames");
+ o->longDesc = N_("Maximum FPS to save resources. Not Implemented yet.");
+ o->type = CompOptionTypeFloat;
+ o->value.f = SNOW_DISPLAY_OPTION_MAX_FRAMES_DEFAULT;
+ o->rest.f.min = 0;
+ o->rest.f.max = 100;
+ o->rest.f.precision = 1;
+
+ o = &hd->opt[SNOW_DISPLAY_OPTION_SNOW_TEXTURE];
+ o->name = "snow_texture";
+ o->group=N_("");
+ o->subGroup=N_("");
+ o->displayHints="";
+ o->shortDesc = N_("Snow Texture");
+ o->longDesc = N_("Snow Texture");
+ o->type = CompOptionTypeString;
+ setFileName();
+ o->value.s = fileName;
+ o->rest.s.string = 0;
+ o->rest.s.nString = 0;
+
+}
+
+static CompOption *snowGetDisplayOptions(CompDisplay * display, int *count)
+{
+ if (display) {
+ SNOW_DISPLAY(display);
+
+ *count = NUM_OPTIONS(hd);
+ return hd->opt;
+ }
+ else {
+ SnowDisplay *hd = malloc(sizeof(SnowDisplay));
+ snowDisplayInitOptions(hd);
+
+ *count = NUM_OPTIONS(hd);
+ return hd->opt;
+ }
+}
+
+static Bool snowInitDisplay(CompPlugin * p, CompDisplay * d)
+{
+ //Generate a snow display
+ SnowDisplay *hd = (SnowDisplay *) malloc(sizeof(SnowDisplay));
+ //Allocate a private index
+ hd->screenPrivateIndex = allocateScreenPrivateIndex(d);
+
+ //Check if its valid
+ if (hd->screenPrivateIndex < 0) {
+ free(hd);
+ return FALSE;
+ }
+
+
+ numFlakes =SNOW_DISPLAY_OPTION_NUM_SNOWFLAKES_DEFAULT;
+ snowSize =SNOW_DISPLAY_OPTION_SNOW_SIZE_DEFAULT;
+ snowSpeed =SNOW_DISPLAY_OPTION_SNOW_SPEED_DEFAULT;
+ boxing =SNOW_DISPLAY_OPTION_SCREEN_BOXING_DEFAULT;
+ depth =SNOW_DISPLAY_OPTION_SCREEN_DEPTH_DEFAULT;
+ //fileName = SNOW_DISPLAY_OPTION_SNOW_TEXTURE_DEFAULT;
+ setFileName();
+
+ snowDisplayInitOptions(hd);
+
+ hd->active = FALSE;
+ //Record the display
+ d->privates[displayPrivateIndex].ptr = hd;
+
+ return TRUE;
+}
+
+static void snowFiniDisplay(CompPlugin * p, CompDisplay * d)
+{
+ SNOW_DISPLAY(d);
+
+ //Free the private index
+ freeScreenPrivateIndex(d, hd->screenPrivateIndex);
+ //Free the pointer
+ free(hd);
+}
+
+static Bool snowInit(CompPlugin * p)
+{
+ displayPrivateIndex = allocateDisplayPrivateIndex();
+
+
+
+ if (displayPrivateIndex < 0)
+ return FALSE;
+
+ return TRUE;
+}
+
+static void snowFini(CompPlugin * p)
+{
+ if (displayPrivateIndex >= 0)
+ freeDisplayPrivateIndex(displayPrivateIndex);
+}
+
+CompPluginVTable snowVTable = {
+ "snow",
+ N_("XglSnow"),
+ N_("XSnow for Beryl"),
+ snowInit,
+ snowFini,
+ snowInitDisplay,
+ snowFiniDisplay,
+ snowInitScreen,
+ snowFiniScreen,
+ 0,
+ 0,
+ snowGetDisplayOptions,
+ snowSetDisplayOption,
+ 0, /*snowGetScreenOptions */
+ 0, /*snowSetScreenOption */
+ 0,
+ 0,
+ 0,
+ 0,
+ BERYL_ABI_INFO,
+ "beryl-plugins"
+};
+
+CompPluginVTable *getCompPluginInfo(void)
+{
+ return &snowVTable;
+}
More information about the commits
mailing list