diff options
author | Dennis Kasprzyk <onestone@beryl-project.org> | 2007-05-17 13:04:40 +0200 |
---|---|---|
committer | Dennis Kasprzyk <onestone@beryl-project.org> | 2007-05-17 13:04:40 +0200 |
commit | bb4908cdebfd352eff04afcc52394b82de88c929 (patch) | |
tree | 889d313c9b8d468955f8a035dd9ae40f314f0efc | |
parent | 2fd76878a0ff50de27ae8433b0732c85d0797ef4 (diff) | |
download | splash-bb4908cdebfd352eff04afcc52394b82de88c929.tar.gz splash-bb4908cdebfd352eff04afcc52394b82de88c929.tar.bz2 |
initial commit
-rw-r--r-- | Makefile | 218 | ||||
-rw-r--r-- | dummy | 0 | ||||
-rw-r--r-- | splash.c | 647 | ||||
-rw-r--r-- | splash.xml | 76 |
4 files changed, 941 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5a0939a --- /dev/null +++ b/Makefile @@ -0,0 +1,218 @@ +## +# +# Compiz plugin Makefile +# +# Copyright : (C) 2006 by Dennis Kasprzyk +# E-mail : onestone@deltatauchi.de +# +# +# 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. +# +## + +## configuration + +#enter plugin name here +PLUGIN = splash + +#enter dependencies here +PKG_DEP = + +## end of configuration + +#enter beryl or compiz here +TARGET = compiz + +ifeq ($(BUILD_GLOBAL),true) + DESTDIR = $(shell pkg-config --variable=libdir compiz)/compiz + XMLDIR = $(shell pkg-config --variable=prefix compiz)/share/compiz +else + DESTDIR = $(HOME)/.$(TARGET)/plugins + XMLDIR = $(HOME)/.$(TARGET)/metadata +endif + +BUILDDIR = build + +CC = gcc +LIBTOOL = libtool +INSTALL = install + +BCOP = `pkg-config --variable=bin bcop` + +CFLAGS = -g -Wall `pkg-config --cflags $(PKG_DEP) $(TARGET) ` +LDFLAGS = `pkg-config --libs $(PKG_DEP) $(TARGET) ` + +is-bcop-target := $(shell if [ -e $(PLUGIN).xml ]; then cat $(PLUGIN).xml | grep "useBcop=\"true\"";fi ) + +bcop-target := $(shell if [ -n "$(is-bcop-target)" ]; then echo $(PLUGIN).xml; fi ) +bcop-target-src := $(shell if [ -n "$(is-bcop-target)" ]; then echo $(PLUGIN)_options.c; fi ) +bcop-target-hdr := $(shell if [ -n "$(is-bcop-target)" ]; then echo $(PLUGIN)_options.h; fi ) + +gen-schemas := $(shell if [ -e $(PLUGIN).xml ] && [ -n `pkg-config --variable=xsltdir compiz-gconf` ]; then echo true; fi ) +schema-target := $(shell if [ -n "$(gen-schemas)" ]; then echo $(PLUGIN).xml; fi ) +schema-output := $(shell if [ -n "$(gen-schemas)" ]; then echo compiz-$(PLUGIN).schema; fi ) + +# find all the object files (including those from .moc.cpp files) + +c-objs := $(patsubst %.c,%.lo,$(shell find -name '*.c' 2> /dev/null | grep -v "$(BUILDDIR)/" | sed -e 's/^.\///')) +c-objs := $(filter-out $(bcop-target-src:.c=.lo),$(c-objs)) +c-objs += $(bcop-target-src:.c=.lo) + +# system include path parameter, -isystem doesn't work on old gcc's +inc-path-param = $(shell if [ -z "`gcc --version | head -n 1 | grep ' 3'`" ]; then echo "-isystem"; else echo "-I"; fi) + +# default color settings +color := $(shell if [ $$TERM = "dumb" ]; then echo "no"; else echo "yes"; fi) + +# +# Do it. +# + +.PHONY: $(BUILDDIR) build-dir bcop-build schema-creation c-build-objs c-link-plugin + +all: $(BUILDDIR) build-dir bcop-build schema-creation c-build-objs c-link-plugin + +bcop-build: $(bcop-target-hdr) $(bcop-target-src) + +schema-creation: $(schema-output) + +c-build-objs: $(addprefix $(BUILDDIR)/,$(cxx-objs)) + +c-link-plugin: $(BUILDDIR)/lib$(PLUGIN).la + +# +# Create build directory +# + +$(BUILDDIR) : + @mkdir -p $(BUILDDIR) + +$(DESTDIR) : + @mkdir -p $(DESTDIR) + +# +# BCOP'ing + +%_options.h: %.xml + @if [ '$(color)' != 'no' ]; then \ + echo -e -n "\033[0;1;5mbcop'ing \033[0;1;37m: \033[0;32m$< \033[0;1;37m-> \033[0;31m$@\033[0m"; \ + else \ + echo "bcop'ing $< -> $@"; \ + fi + @$(BCOP) --header=$@ $< + @if [ '$(color)' != 'no' ]; then \ + echo -e "\r\033[0mbcop'ing : \033[34m$< -> $@\033[0m"; \ + fi + +%_options.c: %.xml + @if [ '$(color)' != 'no' ]; then \ + echo -e -n "\033[0;1;5mbcop'ing \033[0;1;37m: \033[0;32m$< \033[0;1;37m-> \033[0;31m$@\033[0m"; \ + else \ + echo "bcop'ing $< -> $@"; \ + fi + @$(BCOP) --source=$@ $< + @if [ '$(color)' != 'no' ]; then \ + echo -e "\r\033[0mbcop'ing : \033[34m$< -> $@\033[0m"; \ + fi + +# +# Schema generation + +compiz-%.schema: %.xml + @if [ '$(color)' != 'no' ]; then \ + echo -e -n "\033[0;1;5mschema \033[0;1;37m: \033[0;32m$< \033[0;1;37m-> \033[0;31m$@\033[0m"; \ + else \ + echo "schema'ing $< -> $@"; \ + fi + @xsltproc `pkg-config --variable=xsltdir compiz-gconf`/schemas.xslt $< > $@ + @if [ '$(color)' != 'no' ]; then \ + echo -e "\r\033[0mschema : \033[34m$< -> $@\033[0m"; \ + fi + + + +# +# Compiling +# + +$(BUILDDIR)/%.lo: %.c + @if [ '$(color)' != 'no' ]; then \ + echo -n -e "\033[0;1;5mcompiling \033[0;1;37m: \033[0;32m$< \033[0;1;37m-> \033[0;31m$@\033[0m"; \ + else \ + echo "compiling $< -> $@"; \ + fi + @$(LIBTOOL) --quiet --mode=compile $(CC) $(CFLAGS) -c -o $@ $< + @if [ '$(color)' != 'no' ]; then \ + echo -e "\r\033[0mcompiling : \033[34m$< -> $@\033[0m"; \ + fi + +# +# Linking +# + +cxx-rpath-prefix := -Wl,-rpath, + +$(BUILDDIR)/lib$(PLUGIN).la: $(addprefix $(BUILDDIR)/,$(c-objs)) + @if [ '$(color)' != 'no' ]; then \ + echo -e -n "\033[0;1;5mlinking -> \033[0;31m$@\033[0m"; \ + else \ + echo "linking -> $@"; \ + fi + @$(LIBTOOL) --quiet --mode=link $(CC) $(LDFLAGS) -rpath $(DESTDIR) -o $@ $(addprefix $(BUILDDIR)/,$(c-objs)) + @if [ '$(color)' != 'no' ]; then \ + echo -e "\r\033[0mlinking -> \033[34m$@\033[0m"; \ + fi + + +clean: + rm -rf $(BUILDDIR) + rm -f $(bcop-target-src) + rm -f $(bcop-target-hdr) + rm -f $(schema-output) + +install: $(DESTDIR) all + @if [ '$(color)' != 'no' ]; then \ + echo -n -e "\033[0;1;5minstall \033[0;1;37m: \033[0;31m$(DESTDIR)/lib$(PLUGIN).so\033[0m"; \ + else \ + echo "install : $(DESTDIR)/lib$(PLUGIN).so"; \ + fi + @mkdir -p $(DESTDIR) + @$(INSTALL) $(BUILDDIR)/.libs/lib$(PLUGIN).so $(DESTDIR)/lib$(PLUGIN).so + @if [ '$(color)' != 'no' ]; then \ + echo -e "\r\033[0minstall : \033[34m$(DESTDIR)/lib$(PLUGIN).so\033[0m"; \ + fi + @if [ -e $(PLUGIN).xml ]; then \ + if [ '$(color)' != 'no' ]; then \ + echo -n -e "\033[0;1;5minstall \033[0;1;37m: \033[0;31m$(XMLDIR)/$(PLUGIN).xml\033[0m"; \ + else \ + echo "install : $(XMLDIR)/$(PLUGIN).xml"; \ + fi; \ + mkdir -p $(XMLDIR); \ + cp $(PLUGIN).xml $(XMLDIR)/$(PLUGIN).xml; \ + if [ '$(color)' != 'no' ]; then \ + echo -e "\r\033[0minstall : \033[34m$(XMLDIR)/$(PLUGIN).xml\033[0m"; \ + fi; \ + fi + @if [ -e $(schema-output) ]; then \ + if [ '$(color)' != 'no' ]; then \ + echo -n -e "\033[0;1;5minstall \033[0;1;37m: \033[0;31m$(schema-output)\033[0m"; \ + else \ + echo "install : $(schema-output)"; \ + fi; \ + gconftool-2 --install-schema-file=$(schema-output) > /dev/null; \ + if [ '$(color)' != 'no' ]; then \ + echo -e "\r\033[0minstall : \033[34m$(schema-output)\033[0m"; \ + fi; \ + fi + + + + diff --git a/splash.c b/splash.c new file mode 100644 index 0000000..9e028bf --- /dev/null +++ b/splash.c @@ -0,0 +1,647 @@ +/* + * Beryl splash plugin + * + * splash.c + * + * Copyright : (C) 2006 by Dennis Kasprzyk + * E-mail : onestone@beryl-project.org + * + * + * 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. + * + */ + +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <math.h> +#include <X11/Xatom.h> +#include <X11/extensions/Xrender.h> + +#include <compiz.h> + +#include "splash_options.h" + +#define SPLASH_BACKGROUND_DEFAULT "" +#define SPLASH_LOGO_DEFAULT "" + +#define GET_SPLASH_DISPLAY(d) \ + ((SplashDisplay *) (d)->privates[displayPrivateIndex].ptr) + +#define SPLASH_DISPLAY(d) \ + SplashDisplay *sd = GET_SPLASH_DISPLAY (d) + +#define GET_SPLASH_SCREEN(s, sd) \ + ((SplashScreen *) (s)->privates[(sd)->screenPrivateIndex].ptr) + +#define SPLASH_SCREEN(s) \ + SplashScreen *ss = GET_SPLASH_SCREEN (s, GET_SPLASH_DISPLAY (s->display)) + + +static int displayPrivateIndex = 0; + +typedef struct _SplashDisplay +{ + Atom splashAtom; + int screenPrivateIndex; +} SplashDisplay; + +#define MESH_W 16 +#define MESH_H 16 + +typedef struct _SplashScreen +{ + PreparePaintScreenProc preparePaintScreen; + DonePaintScreenProc donePaintScreen; + PaintScreenProc paintScreen; + PaintWindowProc paintWindow; + + int fade_in; + int fade_out; + int time; + + CompTexture back_img, logo_img; + unsigned int backSize[2], logoSize[2]; + Bool hasInit, hasLogo, hasBack; + + float mesh[MESH_W][MESH_H][2]; + float mMove; + + float brightness; + float saturation; + + Bool initiate; + + Bool active; + + +} SplashScreen; + + +static void +splashPreparePaintScreen (CompScreen * s, int ms) +{ + SPLASH_SCREEN (s); + CompDisplay *d = s->display; + + Bool lastShot = FALSE; + + + ss->fade_in -= ms; + if (ss->fade_in < 0) + { + ss->time += ss->fade_in; + ss->fade_in = 0; + if (ss->time < 0) + { + if (ss->fade_out > 0 && ss->fade_out <= ms) + lastShot = TRUE; + ss->fade_out += ss->time; + ss->time = 0; + if (ss->fade_out < 0) + ss->fade_out = 0; + } + } + + if (ss->initiate) + { + ss->fade_in = ss->fade_out = splashGetFadeTime (d) * 1000.0; + ss->time = splashGetDisplayTime (d) * 1000.0; + ss->initiate = FALSE; + } + + if (ss->fade_in || ss->fade_out || ss->time || lastShot) + { + ss->active = TRUE; + ss->mMove += ms / 500.0; + if (!ss->hasInit) + { + ss->hasInit = TRUE; + ss->mMove = 0.0; + + ss->hasBack = + readImageToTexture (s, &ss->back_img, splashGetBackground (d), + &ss->backSize[0], &ss->backSize[1]); + ss->hasLogo = + readImageToTexture (s, &ss->logo_img, splashGetLogo (d), + &ss->logoSize[0], &ss->logoSize[1]); + if (!ss->hasBack) + { + ss->hasBack = + readImageToTexture (s, &ss->back_img, + SPLASH_BACKGROUND_DEFAULT, + &ss->backSize[0], &ss->backSize[1]); + if (ss->hasBack) + { + fprintf (stderr, + "[SPLASH]: Could not load splash background image \"%s\" using default!\n", + splashGetBackground (d)); + } + } + if (!ss->hasLogo) + { + ss->hasLogo = + readImageToTexture (s, &ss->logo_img, + SPLASH_LOGO_DEFAULT, + &ss->logoSize[0], &ss->logoSize[1]); + if (ss->hasLogo) + { + fprintf (stderr, + "[SPLASH]: Could not load splash logo image \"%s\" using default!\n", + splashGetLogo (d)); + } + } + if (!ss->hasBack) + fprintf (stderr, + "[SPLASH]: Could not load splash background image \"%s\" !\n", + splashGetBackground (d)); + if (!ss->hasLogo) + fprintf (stderr, + "[SPLASH]: Could not load splash logo image \"%s\" !\n", + splashGetLogo (d)); + } + } + else + { + ss->active = FALSE; + if (ss->hasInit) + { + ss->hasInit = FALSE; + + if (ss->hasBack) + { + finiTexture (s, &ss->back_img); + initTexture (s, &ss->back_img); + ss->hasBack = FALSE; + } + if (ss->hasLogo) + { + finiTexture (s, &ss->logo_img); + initTexture (s, &ss->logo_img); + ss->hasLogo = FALSE; + } + } + } + + UNWRAP (ss, s, preparePaintScreen); + (*s->preparePaintScreen) (s, ms); + WRAP (ss, s, preparePaintScreen, splashPreparePaintScreen); + +} + +static void +splashDonePaintScreen (CompScreen * s) +{ + SPLASH_SCREEN (s); + + if (ss->fade_in || ss->fade_out || ss->time) + damageScreen (s); + + UNWRAP (ss, s, donePaintScreen); + (*s->donePaintScreen) (s); + WRAP (ss, s, donePaintScreen, splashDonePaintScreen); +} + +static void +splashGetCurrentOutputRect (CompScreen * s, XRectangle * outputRect) +{ + int root_x = 0, root_y = 0; + int ignore_i; + unsigned int ignore_ui; + int output; + Window ignore_w; + + + if (s->nOutputDev == 1) + output = 0; + else + { + XQueryPointer (s->display->display, s->root, &ignore_w, &ignore_w, + &root_x, &root_y, &ignore_i, &ignore_i, &ignore_ui); + output = outputDeviceForPoint (s, root_x, root_y); + } + + outputRect->x = s->outputDev[output].region.extents.x1; + outputRect->y = s->outputDev[output].region.extents.y1; + outputRect->width = + s->outputDev[output].region.extents.x2 - + s->outputDev[output].region.extents.x1; + outputRect->height = + s->outputDev[output].region.extents.y2 - + s->outputDev[output].region.extents.y1; + +} + + +static Bool +splashPaintScreen (CompScreen * s, const ScreenPaintAttrib * sa, + const CompTransform * transform, + Region region, int output, unsigned int mask) +{ + + SPLASH_SCREEN (s); + CompDisplay *d = s->display; + + Bool status = TRUE; + + float alpha = 0.0; + + if (ss->active) + { + alpha = (1.0 - (ss->fade_in / (splashGetFadeTime (d) * 1000.0))) * + (ss->fade_out / (splashGetFadeTime (d) * 1000.0)); + ss->saturation = 1.0 - + ((1.0 - (splashGetSaturation (d) / 100.0)) * alpha); + ss->brightness = 1.0 - + ((1.0 - (splashGetBrightness (d) / 100.0)) * alpha); + } + + UNWRAP (ss, s, paintScreen); + status = (*s->paintScreen) (s, sa, transform, region, output, mask); + WRAP (ss, s, paintScreen, splashPaintScreen); + + if (!ss->active) + return status; + + CompTransform sTransform = *transform; + + transformToScreenSpace (s, output, -DEFAULT_Z_CAMERA, &sTransform); + + glPushMatrix (); + glLoadMatrixf (sTransform.m); + + 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); + + if (ss->hasBack) + { + int x, y; + + for (x = 0; x < MESH_W; x++) + { + for (y = 0; y < MESH_H; y++) + { + ss->mesh[x][y][0] = + (x / (MESH_W - 1.0)) + + (0.02 * sin ((y / (MESH_H - 1.0) * 8) + ss->mMove)); + ss->mesh[x][y][1] = + (y / (MESH_H - 1.0)) + + (0.02 * sin ((ss->mesh[x][y][0] * 8) + ss->mMove));; + } + } + + enableTexture (s, &ss->back_img, COMP_TEXTURE_FILTER_GOOD); + + if (s->nOutputDev > 1) + { + XRectangle headOutputRect; + + splashGetCurrentOutputRect (s, &headOutputRect); + + x = (headOutputRect.width - ss->backSize[0]) / 2; + y = (headOutputRect.height - ss->backSize[1]) / 2; + + x += headOutputRect.x; + y += headOutputRect.y; + } + else + { + x = (s->width - ss->backSize[0]) / 2; + y = (s->height - ss->backSize[1]) / 2; + } + CompMatrix mat = ss->back_img.matrix; + + glTranslatef (x, y, 0); + + float cx1, cx2, cy1, cy2; + + glBegin (GL_QUADS); + for (x = 0; x < MESH_W - 1; x++) + { + for (y = 0; y < MESH_H - 1; y++) + { + cx1 = (x / (MESH_W - 1.0)) * ss->backSize[0]; + cx2 = ((x + 1) / (MESH_W - 1.0)) * ss->backSize[0]; + cy1 = (y / (MESH_H - 1.0)) * ss->backSize[1]; + cy2 = ((y + 1) / (MESH_H - 1.0)) * ss->backSize[1]; + + glTexCoord2f (COMP_TEX_COORD_X (&mat, cx1), + COMP_TEX_COORD_Y (&mat, cy1)); + glVertex2f (ss->mesh[x][y][0] * + ss->backSize[0], + ss->mesh[x][y][1] * ss->backSize[1]); + glTexCoord2f (COMP_TEX_COORD_X (&mat, cx1), + COMP_TEX_COORD_Y (&mat, cy2)); + glVertex2f (ss->mesh[x][y + 1][0] * + ss->backSize[0], + ss->mesh[x][y + 1][1] * ss->backSize[1]); + glTexCoord2f (COMP_TEX_COORD_X (&mat, cx2), + COMP_TEX_COORD_Y (&mat, cy2)); + glVertex2f (ss->mesh[x + 1][y + 1][0] * + ss->backSize[0], + ss->mesh[x + 1][y + 1][1] * ss->backSize[1]); + glTexCoord2f (COMP_TEX_COORD_X (&mat, cx2), + COMP_TEX_COORD_Y (&mat, cy1)); + glVertex2f (ss->mesh[x + 1][y][0] * + ss->backSize[0], + ss->mesh[x + 1][y][1] * ss->backSize[1]); + } + } + glEnd (); + + if (s->nOutputDev > 1) + { + XRectangle headOutputRect; + + splashGetCurrentOutputRect (s, &headOutputRect); + + x = (headOutputRect.width - ss->backSize[0]) / 2; + y = (headOutputRect.height - ss->backSize[1]) / 2; + + x += headOutputRect.x; + y += headOutputRect.y; + } + else + { + x = (s->width - ss->backSize[0]) / 2; + y = (s->height - ss->backSize[1]) / 2; + } + glTranslatef (-x, -y, 0); + + disableTexture (s, &ss->back_img); + } + + if (ss->hasLogo) + { + enableTexture (s, &ss->logo_img, COMP_TEXTURE_FILTER_GOOD); + int x, y; + + if (s->nOutputDev > 1) + { + XRectangle headOutputRect; + + splashGetCurrentOutputRect (s, &headOutputRect); + x = (headOutputRect.width - ss->logoSize[0]) / 2; + y = (headOutputRect.height - ss->logoSize[1]) / 2; + + x += headOutputRect.x; + y += headOutputRect.y; + } + else + { + x = (s->width - ss->logoSize[0]) / 2; + y = (s->height - ss->logoSize[1]) / 2; + } + + CompMatrix mat = ss->logo_img.matrix; + + glTranslatef (x, y, 0); + + glBegin (GL_QUADS); + glTexCoord2f (COMP_TEX_COORD_X (&mat, 0), COMP_TEX_COORD_Y (&mat, 0)); + glVertex2f (0, 0); + glTexCoord2f (COMP_TEX_COORD_X (&mat, 0), + COMP_TEX_COORD_Y (&mat, ss->logoSize[1])); + glVertex2f (0, ss->logoSize[1]); + glTexCoord2f (COMP_TEX_COORD_X (&mat, ss->logoSize[0]), + COMP_TEX_COORD_Y (&mat, ss->logoSize[1])); + glVertex2f (ss->logoSize[0], ss->logoSize[1]); + glTexCoord2f (COMP_TEX_COORD_X (&mat, ss->logoSize[0]), + COMP_TEX_COORD_Y (&mat, 0)); + glVertex2f (ss->logoSize[0], 0); + glEnd (); + + glTranslatef (-x, -y, 0); + + disableTexture (s, &ss->logo_img); + } + + 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 Bool +splashPaintWindow (CompWindow * w, + const WindowPaintAttrib * attrib, + const CompTransform * transform, + Region region, unsigned int mask) +{ + CompScreen *s = w->screen; + Bool status; + + SPLASH_SCREEN (s); + + if (ss->active) + { + WindowPaintAttrib pA = *attrib; + pA.brightness = attrib->brightness * ss->brightness; + pA.saturation = attrib->saturation * ss->saturation; + + UNWRAP (ss, s, paintWindow); + status = (*s->paintWindow) (w, &pA, transform, region, mask); + WRAP (ss, s, paintWindow, splashPaintWindow); + } + else + { + UNWRAP (ss, s, paintWindow); + status = (*s->paintWindow) (w, attrib, transform, region, mask); + WRAP (ss, s, paintWindow, splashPaintWindow); + } + + return status; +} + +static Bool +splashInitScreen (CompPlugin * p, CompScreen * s) +{ + + SPLASH_DISPLAY (s->display); + + SplashScreen *ss = (SplashScreen *) calloc (1, sizeof (SplashScreen)); + + s->privates[sd->screenPrivateIndex].ptr = ss; + + WRAP (ss, s, paintScreen, splashPaintScreen); + WRAP (ss, s, preparePaintScreen, splashPreparePaintScreen); + WRAP (ss, s, donePaintScreen, splashDonePaintScreen); + WRAP (ss, s, paintWindow, splashPaintWindow); + + initTexture (s, &ss->back_img); + initTexture (s, &ss->logo_img); + + ss->initiate = FALSE; + + if (splashGetFirststart (s->display)) + { + Atom actual; + int result, format; + unsigned long n, left; + unsigned char *propData; + + result = XGetWindowProperty (s->display->display, s->root, + sd->splashAtom, 0L, 8192L, FALSE, + XA_INTEGER, &actual, &format, + &n, &left, &propData); + + if (result == Success && n && propData) + { + XFree (propData); + } + else + { + int value = 1; + XChangeProperty (s->display->display, s->root, sd->splashAtom, + XA_INTEGER, 32, PropModeReplace, + (unsigned char *)&value, 1); + ss->initiate = TRUE; + } + } + + return TRUE; +} + + +static void +splashFiniScreen (CompPlugin * p, CompScreen * s) +{ + + SPLASH_SCREEN (s); + + //Restore the original function + UNWRAP (ss, s, paintScreen); + UNWRAP (ss, s, preparePaintScreen); + UNWRAP (ss, s, donePaintScreen); + UNWRAP (ss, s, paintWindow); + + finiTexture (s, &ss->back_img); + finiTexture (s, &ss->logo_img); + + //Free the pointer + free (ss); +} + + + +static Bool +splashInitiate (CompDisplay * d, CompAction * ac, CompActionState state, + CompOption * option, int nOption) +{ + CompScreen *s; + + s = findScreenAtDisplay (d, + getIntOptionNamed (option, nOption, "root", 0)); + if (s) + { + SPLASH_SCREEN (s); + ss->initiate = TRUE; + damageScreen (s); + } + return FALSE; +} + + +static Bool +splashInitDisplay (CompPlugin * p, CompDisplay * d) +{ + //Generate a splash display + SplashDisplay *sd = (SplashDisplay *) malloc (sizeof (SplashDisplay)); + + //Allocate a private index + sd->screenPrivateIndex = allocateScreenPrivateIndex (d); + //Check if its valid + if (sd->screenPrivateIndex < 0) + { + //Its invalid so free memory and return + free (sd); + return FALSE; + } + + sd->splashAtom = XInternAtom (d->display, "_COMPIZ_WM_SPLASH", 0); + + splashSetInitiateInitiate (d, splashInitiate); + + d->privates[displayPrivateIndex].ptr = sd; + return TRUE; +} + +static void +splashFiniDisplay (CompPlugin * p, CompDisplay * d) +{ + SPLASH_DISPLAY (d); + //Free the private index + freeScreenPrivateIndex (d, sd->screenPrivateIndex); + //Free the pointer + free (sd); +} + + + +static Bool +splashInit (CompPlugin * p) +{ + displayPrivateIndex = allocateDisplayPrivateIndex (); + + if (displayPrivateIndex < 0) + return FALSE; + + return TRUE; +} + +static void +splashFini (CompPlugin * p) +{ + if (displayPrivateIndex >= 0) + freeDisplayPrivateIndex (displayPrivateIndex); +} + +CompPluginDep splashDeps[] = { + {CompPluginRuleAfter, "png"} +}; + +static int +splashGetVersion (CompPlugin * plugin, int version) +{ + return ABIVERSION; +} + +CompPluginVTable splashVTable = { + "splash", + splashGetVersion, + 0, + splashInit, + splashFini, + splashInitDisplay, + splashFiniDisplay, + splashInitScreen, + splashFiniScreen, + 0, + 0, + 0, + 0, + 0, + 0, + splashDeps, + sizeof (splashDeps) / sizeof (splashDeps[0]), + 0, + 0, +}; + +CompPluginVTable * +getCompPluginInfo (void) +{ + return &splashVTable; +} diff --git a/splash.xml b/splash.xml new file mode 100644 index 0000000..2d2202d --- /dev/null +++ b/splash.xml @@ -0,0 +1,76 @@ +<?xml version="1.0"?> +<compiz> + <plugin name="splash" useBcop="true"> + <short>Splash</short> + <long>A simple splash plugin</long> + <category>Extras</category> + <display> + <group> + <short>Main</short> + <option name="initiate" type="action"> + <short>Initiate Splash</short> + <long>Start Splash.</long> + <allowed key="true"/> + <default> + <key><Control>F11</key> + </default> + </option> + <option name="firststart" type="bool"> + <short>Show on first start</short> + <long>Show splash on first start.</long> + <default>true</default> + </option> + </group> + <group> + <short>Images</short> + <option name="background" type="string"> + <short>Background File</short> + <long>Background image File.</long> + <hints>file;image;pngonly;</hints> + <default>/data/splash_background.png</default> + </option> + <option name="logo" type="string"> + <short>Logo File</short> + <long>Logo image File.</long> + <hints>file;image;pngonly;</hints> + <default>/data/splash_logo.png</default> + </option> + </group> + <group> + <short>Appearance</short> + <option name="fade_time" type="float"> + <short>Fade Time</short> + <long>Fade In/Out Time.</long> + <default>1.0</default> + <min>0.0</min> + <max>100.0</max> + <precision>0.1</precision> + </option> + <option name="display_time" type="float"> + <short>Display Time</short> + <long>Display In/Out Time.</long> + <default>2.0</default> + <min>0.0</min> + <max>100.0</max> + <precision>0.1</precision> + </option> + <option name="saturation" type="float"> + <short>Saturation</short> + <long>Background saturation.</long> + <default>50.0</default> + <min>0.0</min> + <max>100.0</max> + <precision>0.1</precision> + </option> + <option name="brightness" type="float"> + <short>Brightness</short> + <long>Background brightness.</long> + <default>50.0</default> + <min>0.0</min> + <max>100.0</max> + <precision>0.1</precision> + </option> + </group> + </display> + </plugin> +</compiz> |