diff options
author | Sam Spilsbury <Sam@ACER-SUSE.SUSE> | 2007-11-26 20:00:08 +0900 |
---|---|---|
committer | Sam Spilsbury <Sam@ACER-SUSE.SUSE> | 2007-11-26 20:00:08 +0900 |
commit | 770e028ed5bd3e00f2a3f356985e0376aefe0830 (patch) | |
tree | 1020071b9546262fc2232a3e94bc65cf74e88a21 | |
parent | 445c374a07249a95c2afccb02dc55ca24119578b (diff) | |
download | basicblur-770e028ed5bd3e00f2a3f356985e0376aefe0830.tar.gz basicblur-770e028ed5bd3e00f2a3f356985e0376aefe0830.tar.bz2 |
* This import wont be like others where I periodically forget to git add....
-rw-r--r-- | Makefile | 463 | ||||
-rw-r--r-- | basicblur.c | 387 | ||||
-rw-r--r-- | basicblur.xml.in | 38 | ||||
-rw-r--r-- | dummy | 0 | ||||
-rw-r--r-- | plugin.info | 1 |
5 files changed, 889 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e1835ab --- /dev/null +++ b/Makefile @@ -0,0 +1,463 @@ +## +# +# Compiz plugin Makefile +# +# Copyright : (C) 2007 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. +# +## + +# plugin.info file contents +# +# PLUGIN = foo +# PKG_DEP = pango +# LDFLAGS_ADD = -lGLU +# CFLAGS_ADD = -I/usr/include/foo +# + +#load config file +include plugin.info + + +ifeq ($(BUILD_GLOBAL),true) + PREFIX = $(shell pkg-config --variable=prefix compiz) + CLIBDIR = $(shell pkg-config --variable=libdir compiz) + CINCDIR = $(shell pkg-config --variable=includedir compiz) + PKGDIR = $(CLIBDIR)/pkgconfig + DESTDIR = $(shell pkg-config --variable=libdir compiz)/compiz + XMLDIR = $(shell pkg-config --variable=prefix compiz)/share/compiz + IMAGEDIR = $(shell pkg-config --variable=prefix compiz)/share/compiz + DATADIR = $(shell pkg-config --variable=prefix compiz)/share/compiz +else + DESTDIR = $(HOME)/.compiz/plugins + XMLDIR = $(HOME)/.compiz/metadata + IMAGEDIR = $(HOME)/.compiz/images + DATADIR = $(HOME)/.compiz/data +endif + +BUILDDIR = build + +ECHO = `which echo` + +CC = gcc +CPP = g++ +LIBTOOL = libtool +INSTALL = install + +BCOP = `pkg-config --variable=bin bcop` + +CFLAGS = -g -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -fno-strict-aliasing `pkg-config --cflags $(PKG_DEP) compiz ` $(CFLAGS_ADD) +LDFLAGS = `pkg-config --libs $(PKG_DEP) compiz ` $(LDFLAGS_ADD) + +DEFINES = -DIMAGEDIR=$(IMAGEDIR) -DDATADIR=$(DATADIR) + +POFILEDIR = $(shell if [ -n "$(PODIR)" ]; then $(ECHO) $(PODIR); else $(ECHO) ./po;fi ) + +is-bcop-target := $(shell if [ -e $(PLUGIN).xml.in ]; then cat $(PLUGIN).xml.in | grep "useBcop=\"true\""; \ + else if [ -e $(PLUGIN).xml ]; then cat $(PLUGIN).xml | grep "useBcop=\"true\""; fi; fi) + +trans-target := $(shell if [ -e $(PLUGIN).xml.in -o -e $(PLUGIN).xml ]; then $(ECHO) $(BUILDDIR)/$(PLUGIN).xml;fi ) + +bcop-target := $(shell if [ -n "$(is-bcop-target)" ]; then $(ECHO) $(BUILDDIR)/$(PLUGIN).xml; fi ) +bcop-target-src := $(shell if [ -n "$(is-bcop-target)" ]; then $(ECHO) $(BUILDDIR)/$(PLUGIN)_options.c; fi ) +bcop-target-hdr := $(shell if [ -n "$(is-bcop-target)" ]; then $(ECHO) $(BUILDDIR)/$(PLUGIN)_options.h; fi ) + +gen-schemas := $(shell if [ -e $(PLUGIN).xml.in -o -e $(PLUGIN).xml -a -n "`pkg-config --variable=xsltdir compiz-gconf`" ]; then $(ECHO) true; fi ) +schema-target := $(shell if [ -n "$(gen-schemas)" ]; then $(ECHO) $(BUILDDIR)/$(PLUGIN).xml; fi ) +schema-output := $(shell if [ -n "$(gen-schemas)" ]; then $(ECHO) $(BUILDDIR)/compiz-$(PLUGIN).schema; fi ) + +ifeq ($(BUILD_GLOBAL),true) + pkg-target := $(shell if [ -e compiz-$(PLUGIN).pc.in -a -n "$(PREFIX)" -a -d "$(PREFIX)" ]; then $(ECHO) "$(BUILDDIR)/compiz-$(PLUGIN).pc"; fi ) + hdr-install-target := $(shell if [ -e compiz-$(PLUGIN).pc.in -a -n "$(PREFIX)" -a -d "$(PREFIX)" -a -e $(PLUGIN).h ]; then $(ECHO) "$(PLUGIN).h"; fi ) +endif + +# find all the object files + +c-objs := $(patsubst %.c,%.lo,$(shell find -name '*.c' 2> /dev/null | grep -v "$(BUILDDIR)/" | sed -e 's/^.\///')) +c-objs += $(patsubst %.cpp,%.lo,$(shell find -name '*.cpp' 2> /dev/null | grep -v "$(BUILDDIR)/" | sed -e 's/^.\///')) +c-objs += $(patsubst %.cxx,%.lo,$(shell find -name '*.cxx' 2> /dev/null | grep -v "$(BUILDDIR)/" | sed -e 's/^.\///')) +c-objs := $(filter-out $(bcop-target-src:.c=.lo),$(c-objs)) + +h-files := $(shell find -name '*.h' 2> /dev/null | grep -v "$(BUILDDIR)/" | sed -e 's/^.\///') +h-files += $(bcop-target-hdr) +h-files += $(shell pkg-config --variable=includedir compiz)/compiz/compiz.h + +all-c-objs := $(addprefix $(BUILDDIR)/,$(c-objs)) +all-c-objs += $(bcop-target-src:.c=.lo) + +# additional files + +data-files := $(shell find data/ -name '*' -type f 2> /dev/null | sed -e 's/data\///') +image-files := $(shell find images/ -name '*' -type f 2> /dev/null | sed -e 's/images\///') + +# 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 trans-target bcop-build pkg-creation schema-creation c-build-objs c-link-plugin + +all: $(BUILDDIR) build-dir trans-target bcop-build pkg-creation schema-creation c-build-objs c-link-plugin + +trans-build: $(trans-target) + +bcop-build: $(bcop-target-hdr) $(bcop-target-src) + +schema-creation: $(schema-output) + +c-build-objs: $(all-c-objs) + +c-link-plugin: $(BUILDDIR)/lib$(PLUGIN).la + +pkg-creation: $(pkg-target) + +# +# Create build directory +# + +$(BUILDDIR) : + @mkdir -p $(BUILDDIR) + +$(DESTDIR) : + @mkdir -p $(DESTDIR) + +# +# fallback if xml.in doesn't exists +# +$(BUILDDIR)/%.xml: %.xml + @cp $< $@ + +# +# Translating +# +$(BUILDDIR)/%.xml: %.xml.in + @if [ -d $(POFILEDIR) ]; then \ + if [ '$(color)' != 'no' ]; then \ + $(ECHO) -e -n "\033[0;1;5mtranslate \033[0m: \033[0;32m$< \033[0m-> \033[0;31m$@\033[0m"; \ + else \ + $(ECHO) "translate $< -> $@"; \ + fi; \ + intltool-merge -x -u $(POFILEDIR) $< $@ > /dev/null; \ + if [ '$(color)' != 'no' ]; then \ + $(ECHO) -e "\r\033[0mtranslate : \033[34m$< -> $@\033[0m"; \ + fi; \ + else \ + if [ '$(color)' != 'no' ]; then \ + $(ECHO) -e -n "\033[0;1;5mconvert \033[0m: \033[0;32m$< \033[0m-> \033[0;31m$@\033[0m"; \ + else \ + $(ECHO) "convert $< -> $@"; \ + fi; \ + cat $< | sed -e 's;<_;<;g' -e 's;</_;</;g' > $@; \ + if [ '$(color)' != 'no' ]; then \ + $(ECHO) -e "\r\033[0mconvert : \033[34m$< -> $@\033[0m"; \ + fi; \ + fi + +# +# BCOP'ing + +$(BUILDDIR)/%_options.h: $(BUILDDIR)/%.xml + @if [ '$(color)' != 'no' ]; then \ + $(ECHO) -e -n "\033[0;1;5mbcop'ing \033[0m: \033[0;32m$< \033[0m-> \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 + +$(BUILDDIR)/%_options.c: $(BUILDDIR)/%.xml + @if [ '$(color)' != 'no' ]; then \ + $(ECHO) -e -n "\033[0;1;5mbcop'ing \033[0m: \033[0;32m$< \033[0m-> \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 + +$(BUILDDIR)/compiz-%.schema: $(BUILDDIR)/%.xml + @if [ '$(color)' != 'no' ]; then \ + $(ECHO) -e -n "\033[0;1;5mschema'ing\033[0m: \033[0;32m$< \033[0m-> \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 + +# +# pkg config file generation + +$(BUILDDIR)/compiz-%.pc: compiz-%.pc.in + @if [ '$(color)' != 'no' ]; then \ + $(ECHO) -e -n "\033[0;1;5mpkgconfig \033[0m: \033[0;32m$< \033[0m-> \033[0;31m$@\033[0m"; \ + else \ + $(ECHO) "pkgconfig $< -> $@"; \ + fi + @COMPIZREQUIRES=`cat $(PKGDIR)/compiz.pc | grep Requires | sed -e 's;Requires: ;;g'`; \ + COMPIZCFLAGS=`cat $(PKGDIR)/compiz.pc | grep Cflags | sed -e 's;Cflags: ;;g'`; \ + sed -e 's;@prefix@;$(PREFIX);g' -e 's;\@libdir@;$(CLIBDIR);g' \ + -e 's;@includedir@;$(CINCDIR);g' -e 's;\@VERSION@;0.0.1;g' \ + -e "s;@COMPIZ_REQUIRES@;$$COMPIZREQUIRES;g" \ + -e "s;@COMPIZ_CFLAGS@;$$COMPIZCFLAGS;g" $< > $@; + @if [ '$(color)' != 'no' ]; then \ + $(ECHO) -e "\r\033[0mpkgconfig : \033[34m$< -> $@\033[0m"; \ + fi + +# +# Compiling +# + +$(BUILDDIR)/%.lo: %.c $(h-files) + @if [ '$(color)' != 'no' ]; then \ + $(ECHO) -n -e "\033[0;1;5mcompiling \033[0m: \033[0;32m$< \033[0m-> \033[0;31m$@\033[0m"; \ + else \ + $(ECHO) "compiling $< -> $@"; \ + fi + @$(LIBTOOL) --quiet --mode=compile $(CC) $(CFLAGS) $(DEFINES) -I$(BUILDDIR) -c -o $@ $< + @if [ '$(color)' != 'no' ]; then \ + $(ECHO) -e "\r\033[0mcompiling : \033[34m$< -> $@\033[0m"; \ + fi + +$(BUILDDIR)/%.lo: $(BUILDDIR)/%.c $(h-files) + @if [ '$(color)' != 'no' ]; then \ + $(ECHO) -n -e "\033[0;1;5mcompiling \033[0m: \033[0;32m$< \033[0m-> \033[0;31m$@\033[0m"; \ + else \ + $(ECHO) "compiling $< -> $@"; \ + fi + @$(LIBTOOL) --quiet --mode=compile $(CC) $(CFLAGS) $(DEFINES) -I$(BUILDDIR) -c -o $@ $< + @if [ '$(color)' != 'no' ]; then \ + $(ECHO) -e "\r\033[0mcompiling : \033[34m$< -> $@\033[0m"; \ + fi + +$(BUILDDIR)/%.lo: %.cpp $(h-files) + @if [ '$(color)' != 'no' ]; then \ + $(ECHO) -n -e "\033[0;1;5mcompiling \033[0m: \033[0;32m$< \033[0m-> \033[0;31m$@\033[0m"; \ + else \ + $(ECHO) "compiling $< -> $@"; \ + fi + @$(LIBTOOL) --quiet --mode=compile $(CPP) $(CFLAGS) $(DEFINES) -I$(BUILDDIR) -c -o $@ $< + @if [ '$(color)' != 'no' ]; then \ + $(ECHO) -e "\r\033[0mcompiling : \033[34m$< -> $@\033[0m"; \ + fi + +$(BUILDDIR)/%.lo: %.cxx $(h-files) + @if [ '$(color)' != 'no' ]; then \ + $(ECHO) -n -e "\033[0;1;5mcompiling \033[0m: \033[0;32m$< \033[0m-> \033[0;31m$@\033[0m"; \ + else \ + $(ECHO) "compiling $< -> $@"; \ + fi + @$(LIBTOOL) --quiet --mode=compile $(CPP) $(CFLAGS) $(DEFINES) -I$(BUILDDIR) -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: $(all-c-objs) + @if [ '$(color)' != 'no' ]; then \ + $(ECHO) -e -n "\033[0;1;5mlinking \033[0m: \033[0;31m$@\033[0m"; \ + else \ + $(ECHO) "linking : $@"; \ + fi + @$(LIBTOOL) --quiet --mode=link $(CC) $(LDFLAGS) -rpath $(DESTDIR) -o $@ $(all-c-objs) + @if [ '$(color)' != 'no' ]; then \ + $(ECHO) -e "\r\033[0mlinking : \033[34m$@\033[0m"; \ + fi + + +clean: + @if [ '$(color)' != 'no' ]; then \ + $(ECHO) -e -n "\033[0;1;5mremoving \033[0m: \033[0;31m./$(BUILDDIR)\033[0m"; \ + else \ + $(ECHO) "removing : ./$(BUILDDIR)"; \ + fi + @rm -rf $(BUILDDIR) + @if [ '$(color)' != 'no' ]; then \ + $(ECHO) -e "\r\033[0mremoving : \033[34m./$(BUILDDIR)\033[0m"; \ + fi + + +install: $(DESTDIR) all + @if [ '$(color)' != 'no' ]; then \ + $(ECHO) -n -e "\033[0;1;5minstall \033[0m: \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 $(BUILDDIR)/$(PLUGIN).xml ]; then \ + if [ '$(color)' != 'no' ]; then \ + $(ECHO) -n -e "\033[0;1;5minstall \033[0m: \033[0;31m$(XMLDIR)/$(PLUGIN).xml\033[0m"; \ + else \ + $(ECHO) "install : $(XMLDIR)/$(PLUGIN).xml"; \ + fi; \ + mkdir -p $(XMLDIR); \ + cp $(BUILDDIR)/$(PLUGIN).xml $(XMLDIR)/$(PLUGIN).xml; \ + if [ '$(color)' != 'no' ]; then \ + $(ECHO) -e "\r\033[0minstall : \033[34m$(XMLDIR)/$(PLUGIN).xml\033[0m"; \ + fi; \ + fi + @if [ -n "$(hdr-install-target)" ]; then \ + if [ '$(color)' != 'no' ]; then \ + $(ECHO) -n -e "\033[0;1;5minstall \033[0m: \033[0;31m$(CINCDIR)/compiz/$(hdr-install-target)\033[0m"; \ + else \ + $(ECHO) "install : $(CINCDIR)/compiz/$(hdr-install-target)"; \ + fi; \ + cp $(hdr-install-target) $(CINCDIR)/compiz/$(hdr-install-target); \ + if [ '$(color)' != 'no' ]; then \ + $(ECHO) -e "\r\033[0minstall : \033[34m$(CINCDIR)/compiz/$(hdr-install-target)\033[0m"; \ + fi; \ + fi + @if [ -n "$(pkg-target)" ]; then \ + if [ '$(color)' != 'no' ]; then \ + $(ECHO) -n -e "\033[0;1;5minstall \033[0m: \033[0;31m$(PKGDIR)/compiz-$(PLUGIN).pc\033[0m"; \ + else \ + $(ECHO) "install : $(PKGDIR)/compiz-$(PLUGIN).pc"; \ + fi; \ + cp $(pkg-target) $(PKGDIR)/compiz-$(PLUGIN).pc; \ + if [ '$(color)' != 'no' ]; then \ + $(ECHO) -e "\r\033[0minstall : \033[34m$(PKGDIR)/compiz-$(PLUGIN).pc\033[0m"; \ + fi; \ + fi + @if [ -n "$(schema-output)" -a -e "$(schema-output)" ]; then \ + if [ '$(color)' != 'no' ]; then \ + $(ECHO) -n -e "\033[0;1;5minstall \033[0m: \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 + @if [ -n "$(data-files)" ]; then \ + mkdir -p $(DATADIR); \ + for FILE in $(data-files); do \ + if [ '$(color)' != 'no' ]; then \ + $(ECHO) -n -e "\033[0;1;5minstall \033[0m: \033[0;31m$(DATADIR)/$$FILE\033[0m"; \ + else \ + $(ECHO) "install : $(DATADIR)/$$FILE"; \ + fi; \ + cp data/$$FILE $(DATADIR)/$$FILE; \ + if [ '$(color)' != 'no' ]; then \ + $(ECHO) -e "\r\033[0minstall : \033[34m$(DATADIR)/$$FILE\033[0m"; \ + fi; \ + done \ + fi + @if [ -n "$(image-files)" ]; then \ + mkdir -p $(IMAGEDIR); \ + for FILE in $(image-files); do \ + if [ '$(color)' != 'no' ]; then \ + $(ECHO) -n -e "\033[0;1;5minstall \033[0m: \033[0;31m$(IMAGEDIR)/$$FILE\033[0m"; \ + else \ + $(ECHO) "install : $(IMAGEDIR)/$$FILE"; \ + fi; \ + cp images/$$FILE $(IMAGEDIR)/$$FILE; \ + if [ '$(color)' != 'no' ]; then \ + $(ECHO) -e "\r\033[0minstall : \033[34m$(IMAGEDIR)/$$FILE\033[0m"; \ + fi; \ + done \ + fi + +uninstall: + @if [ -e $(DESTDIR)/lib$(PLUGIN).so ]; then \ + if [ '$(color)' != 'no' ]; then \ + $(ECHO) -n -e "\033[0;1;5muninstall \033[0m: \033[0;31m$(DESTDIR)/lib$(PLUGIN).so\033[0m"; \ + else \ + $(ECHO) "uninstall : $(DESTDIR)/lib$(PLUGIN).so"; \ + fi; \ + rm -f $(DESTDIR)/lib$(PLUGIN).so; \ + if [ '$(color)' != 'no' ]; then \ + $(ECHO) -e "\r\033[0muninstall : \033[34m$(DESTDIR)/lib$(PLUGIN).so\033[0m"; \ + fi; \ + fi + @if [ -e $(XMLDIR)/$(PLUGIN).xml ]; then \ + if [ '$(color)' != 'no' ]; then \ + $(ECHO) -n -e "\033[0;1;5muninstall \033[0m: \033[0;31m$(XMLDIR)/$(PLUGIN).xml\033[0m"; \ + else \ + $(ECHO) "uninstall : $(XMLDIR)/$(PLUGIN).xml"; \ + fi; \ + rm -f $(XMLDIR)/$(PLUGIN).xml; \ + if [ '$(color)' != 'no' ]; then \ + $(ECHO) -e "\r\033[0muninstall : \033[34m$(XMLDIR)/$(PLUGIN).xml\033[0m"; \ + fi; \ + fi + @if [ -n "$(hdr-install-target)" -a -e $(CINCDIR)/compiz/$(hdr-install-target) ]; then \ + if [ '$(color)' != 'no' ]; then \ + $(ECHO) -n -e "\033[0;1;5muninstall \033[0m: \033[0;31m$(CINCDIR)/compiz/$(hdr-install-target)\033[0m"; \ + else \ + $(ECHO) "uninstall : $(CINCDIR)/compiz/$(hdr-install-target)"; \ + fi; \ + rm -f $(CINCDIR)/compiz/$(hdr-install-target); \ + if [ '$(color)' != 'no' ]; then \ + $(ECHO) -e "\r\033[0muninstall : \033[34m$(CINCDIR)/compiz/$(hdr-install-target)\033[0m"; \ + fi; \ + fi + @if [ -n "$(pkg-target)" -a -e $(PKGDIR)/compiz-$(PLUGIN).pc ]; then \ + if [ '$(color)' != 'no' ]; then \ + $(ECHO) -n -e "\033[0;1;5muninstall \033[0m: \033[0;31m$(PKGDIR)/compiz-$(PLUGIN).pc\033[0m"; \ + else \ + $(ECHO) "uninstall : $(PKGDIR)/compiz-$(PLUGIN).pc"; \ + fi; \ + rm -f $(PKGDIR)/compiz-$(PLUGIN).pc; \ + if [ '$(color)' != 'no' ]; then \ + $(ECHO) -e "\r\033[0muninstall : \033[34m$(PKGDIR)/compiz-$(PLUGIN).pc\033[0m"; \ + fi; \ + fi + @if [ -n "$(data-files)" ]; then \ + for FILE in $(data-files); do \ + if [ '$(color)' != 'no' ]; then \ + $(ECHO) -n -e "\033[0;1;5muninstall \033[0m: \033[0;31m$(DATADIR)/$$FILE\033[0m"; \ + else \ + $(ECHO) "uninstall : $(DATADIR)/$$FILE"; \ + fi; \ + rm -f $(DATADIR)/$$FILE; \ + if [ '$(color)' != 'no' ]; then \ + $(ECHO) -e "\r\033[0muninstall : \033[34m$(DATADIR)/$$FILE\033[0m"; \ + fi; \ + done \ + fi + @if [ -n "$(image-files)" ]; then \ + for FILE in $(image-files); do \ + if [ '$(color)' != 'no' ]; then \ + $(ECHO) -n -e "\033[0;1;5muninstall \033[0m: \033[0;31m$(IMAGEDIR)/$$FILE\033[0m"; \ + else \ + $(ECHO) "uninstall : $(IMAGEDIR)/$$FILE"; \ + fi; \ + rm -f $(IMAGEDIR)/$$FILE; \ + if [ '$(color)' != 'no' ]; then \ + $(ECHO) -e "\r\033[0muninstall : \033[34m$(IMAGEDIR)/$$FILE\033[0m"; \ + fi; \ + done \ + fi diff --git a/basicblur.c b/basicblur.c new file mode 100644 index 0000000..3ed0987 --- /dev/null +++ b/basicblur.c @@ -0,0 +1,387 @@ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> + +#include <X11/Xatom.h> +#include <X11/extensions/Xrender.h> +#include <X11/extensions/Xcomposite.h> + +#include <compiz-core.h> +#include "basicblur_options.h" + +#include <math.h> +#include <GL/glext.h> + +#ifndef PAINT_WINDOW_DECORATION_MASK +#define PAINT_WINDOW_DECORATION_MASK (1 << 4) +#endif + +static int BasicBlurdisplayPrivateIndex; + +static GLfloat * convfilter; +static int fsize = 3 ;// should be an option. Hackers please help :D + + +typedef struct _basicblurDisplay { + int screenPrivateIndex; +} basicblurDisplay; + + +typedef struct _basicblurSCreen { + int windowPrivateIndex; + DrawWindowTextureProc drawWindowTexture; + DamageWindowRectProc damageWindowRect; + Bool isBlured; +} basicblurScreen; + +typedef struct _basicblurWindow { + Bool first; + Bool isBlured; +} basicblurWindow; + +#define GET_BASICBLUR_DISPLAY(d) ((basicblurDisplay *) (d)->base.privates[BasicBlurdisplayPrivateIndex].ptr) +#define BASICBLUR_DISPLAY(d) basicblurDisplay *nd = GET_BASICBLUR_DISPLAY (d) +#define GET_BASICBLUR_SCREEN(s, nd) ((basicblurScreen *) (s)->base.privates[(nd)->screenPrivateIndex].ptr) +#define BASICBLUR_SCREEN(s) basicblurScreen *ns = GET_BASICBLUR_SCREEN (s, GET_BASICBLUR_DISPLAY (s->display)) +#define GET_BASICBLUR_WINDOW(w, ns) ((basicblurWindow *) (w)->base.privates[(ns)->windowPrivateIndex].ptr) +#define BASICBLUR_WINDOW(w) basicblurWindow *nw = GET_BASICBLUR_WINDOW (w, GET_BASICBLUR_SCREEN (w->screen, GET_BASICBLUR_DISPLAY (w->screen->display))) + +#define NUM_OPTIONS(s) (sizeof ((s)->opt) / sizeof (CompOption)) + +static void +basicblurToggleWindow (CompWindow *w) +{ + if((w->type & CompWindowTypeNormalMask) || + (w->type & CompWindowTypeDesktopMask)) + { + BASICBLUR_WINDOW (w); + nw->isBlured = !nw->isBlured; + nw->first = TRUE; + + if(w->redirected) + { + unredirectWindow(w); + redirectWindow(w); + } + addWindowDamage(w); + } +} + +static void +basicblurToggleScreen (CompScreen *s) +{ + CompWindow *w; + BASICBLUR_SCREEN (s); + + ns->isBlured = !ns->isBlured; + for (w = s->windows; w; w = w->next) + if (w) basicblurToggleWindow (w); +} + +static Bool +basicblurToggle (CompDisplay *d, CompAction *action, CompActionState state, CompOption *option, int nOption) +{ + CompWindow *w; + Window xid; + + fprintf(stderr, "\nbasicblurToggle"); + + xid = getIntOptionNamed (option, nOption, "window", 0); + + w = findWindowAtDisplay (d, xid); + + if (w) + basicblurToggleWindow (w); + + return TRUE; +} + +static Bool +basicblurToggleAll (CompDisplay *d, CompAction *action, CompActionState state, CompOption *option, int nOption) +{ + CompScreen *s; + Window xid; + + fprintf(stderr, "\nbasicblurToggleAll"); + + xid = getIntOptionNamed (option, nOption, "root", 0); + + s = findScreenAtDisplay (d, xid); + + // We invert the active window. + // When calling the toggle all, the active window gets + // the focus because it will be the only one without blur. + Window xid2 = getIntOptionNamed (option, nOption, "window", 0); + CompWindow * w = findWindowAtDisplay (d, xid2); + + if((w->type & CompWindowTypeNormalMask) || + (w->type & CompWindowTypeDesktopMask)) + { + BASICBLUR_WINDOW (w); + nw->isBlured = !nw->isBlured; + nw->first = TRUE; + } + + if (s) + basicblurToggleScreen (s); + + return TRUE; +} + +static void +basicblurDrawWindowTexture (CompWindow *w, + CompTexture *texture, + const FragmentAttrib *attrib, + unsigned int mask) +{ + BASICBLUR_SCREEN (w->screen); + BASICBLUR_WINDOW (w); + + UNWRAP (ns, w->screen, drawWindowTexture); + + //fsize = basicblurGetBlurFactor(w->screen); + + //fprintf(stderr, "%i", fsize); + + if(nw->isBlured && !(mask & PAINT_WINDOW_DECORATION_MASK)) + { + // We use a convolution filter + glEnable(GL_CONVOLUTION_2D); + glConvolutionFilter2D (GL_CONVOLUTION_2D, GL_RGBA, fsize, fsize, GL_RGBA, GL_FLOAT, convfilter); + glConvolutionParameteri (GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_REPLICATE_BORDER); + + (*w->screen->drawWindowTexture) (w, texture, attrib, mask); + if(nw->first) + { + nw->first = FALSE; + } + glDisable(GL_CONVOLUTION_2D); + } + else + { + (*w->screen->drawWindowTexture)(w, texture, attrib, mask); + } + + WRAP (ns, w->screen, drawWindowTexture, basicblurDrawWindowTexture); + +} + +static Bool +basicblurDamageWindowRect (CompWindow *w, Bool initial, BoxPtr rect) +{ + int status; + + BASICBLUR_SCREEN (w->screen); + BASICBLUR_WINDOW (w); + + if (initial) + { + if (ns->isBlured && !nw->isBlured) + basicblurToggleWindow (w); + } + + UNWRAP (ns, w->screen, damageWindowRect); + status = (*w->screen->damageWindowRect) (w, initial, rect); + WRAP (ns, w->screen, damageWindowRect, basicblurDamageWindowRect); + + return status; +} + +static Bool +basicblurInitDisplay (CompPlugin *p, CompDisplay *d) +{ + basicblurDisplay *nd; + + nd = malloc (sizeof (basicblurDisplay)); + if (!nd) + return FALSE; + + nd->screenPrivateIndex = allocateScreenPrivateIndex (d); + if (nd->screenPrivateIndex < 0) + { + free (nd); + return FALSE; + } + + d->base.privates[BasicBlurdisplayPrivateIndex].ptr = nd; + + basicblurSetWindowToggleKeyInitiate (d, basicblurToggle); + basicblurSetScreenToggleKeyInitiate (d, basicblurToggleAll); + + return TRUE; +} + +static void +basicblurFiniDisplay (CompPlugin *p, CompDisplay *d) +{ + BASICBLUR_DISPLAY (d); + freeScreenPrivateIndex (d, nd->screenPrivateIndex); + free (nd); + +} + +static Bool +basicblurInitScreen (CompPlugin *p, CompScreen *s) +{ + basicblurScreen *ns; + BASICBLUR_DISPLAY (s->display); + + ns = malloc (sizeof (basicblurScreen)); + if (!ns) + return FALSE; + + ns->windowPrivateIndex = allocateWindowPrivateIndex (s); + if (ns->windowPrivateIndex < 0) + { + free (ns); + return FALSE; + } + + ns->isBlured = FALSE; + + WRAP (ns, s, drawWindowTexture, basicblurDrawWindowTexture); + WRAP (ns, s, damageWindowRect, basicblurDamageWindowRect); + + // We fill in the convolution filter (gaussian blur) + + //fsize = basicblurGetBlurFactor(s); + + //fprintf(stderr, "%i", fsize); + + unsigned int i = 0; + unsigned int j = 0; + double k = (((double)fsize)-1.)/2.; + double somme = 0.; + double sigma2 = fsize * fsize / 4.; + convfilter = malloc(4 * fsize * fsize * sizeof(GLfloat)); + GLfloat * gaussien = malloc(fsize * fsize * sizeof(GLfloat)); + + for(i=0; i<fsize;i++) + for(j=0; j<fsize;j++) + { + gaussien[fsize * i + j]=exp(-((double)(i-k)*(i-k)+(j-k)*(j-k))/ + (2.*sigma2)); + } + for(i=0; i<fsize;i++) + for(j=0; j<fsize;j++) + somme +=gaussien[fsize * i + j]; + for(i = 0; i < fsize; i++) + for(j = 0; j < fsize; j++) + { + convfilter[4 * (fsize * i + j) ] = + gaussien[(fsize * i + j)] / somme; + convfilter[4 * (fsize * i + j) + 1] = + gaussien[(fsize * i + j)] / somme; + convfilter[4 * (fsize * i + j) + 2] = + gaussien[(fsize * i + j)] / somme; + convfilter[4 * (fsize * i + j) + 3] = + gaussien[(fsize * i + j)] / somme; + } + + free(gaussien); + + s->base.privates[nd->screenPrivateIndex].ptr = ns; + + return TRUE; +} + + +static void +basicblurFiniScreen (CompPlugin *p, CompScreen *s) +{ + BASICBLUR_SCREEN (s); + freeWindowPrivateIndex (s, ns->windowPrivateIndex); + UNWRAP (ns, s, drawWindowTexture); + UNWRAP (ns, s, damageWindowRect); + free (ns); +} + +static Bool +basicblurInitWindow (CompPlugin *p, CompWindow *w) +{ + basicblurWindow *nw; + + BASICBLUR_SCREEN (w->screen); + + nw = malloc (sizeof (basicblurWindow)); + if (!nw) + return FALSE; + + nw->isBlured = FALSE; + nw->first = FALSE; + + w->base.privates[ns->windowPrivateIndex].ptr = nw; + + return TRUE; +} + +static void +basicblurFiniWindow (CompPlugin *p, CompWindow *w) +{ + BASICBLUR_WINDOW (w); + free (nw); +} + +static Bool +basicblurInit (CompPlugin *p) +{ + BasicBlurdisplayPrivateIndex = allocateDisplayPrivateIndex (); + if (BasicBlurdisplayPrivateIndex < 0) + return FALSE; + + return TRUE; +} + +static void +basicblurFini (CompPlugin *p) +{ + if (BasicBlurdisplayPrivateIndex >= 0) + freeDisplayPrivateIndex (BasicBlurdisplayPrivateIndex); + free(convfilter); +} + +static CompBool +basicblurInitObject (CompPlugin *p, + CompObject *o) +{ + static InitPluginObjectProc dispTab[] = { + (InitPluginObjectProc) 0, /* InitCore */ + (InitPluginObjectProc) basicblurInitDisplay, + (InitPluginObjectProc) basicblurInitScreen, + (InitPluginObjectProc) basicblurInitWindow + }; + + RETURN_DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), TRUE, (p, o)); +} + +static void +basicblurFiniObject (CompPlugin *p, + CompObject *o) +{ + static FiniPluginObjectProc dispTab[] = { + (FiniPluginObjectProc) 0, /* FiniCore */ + (FiniPluginObjectProc) basicblurFiniDisplay, + (FiniPluginObjectProc) basicblurFiniScreen, + (FiniPluginObjectProc) basicblurFiniWindow + }; + + DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), (p, o)); +} + + +CompPluginVTable basicblurVTable = { + "basicblur", + 0, + basicblurInit, + basicblurFini, + basicblurInitObject, + basicblurFiniObject, + 0, + 0 +}; + +CompPluginVTable * +getCompPluginInfo (void) +{ + return &basicblurVTable; +} diff --git a/basicblur.xml.in b/basicblur.xml.in new file mode 100644 index 0000000..7f476a6 --- /dev/null +++ b/basicblur.xml.in @@ -0,0 +1,38 @@ +<?xml version="1.0"?> +<compiz> + <plugin name="basicblur" useBcop="true"> + <_short>Basicblur</_short> + <_long>Make it slightly easier to concentrate by dimming all but the active window.</_long> + <category>Accessibility</category> + <deps> + <relation type="after"> + <plugin>fade</plugin> + </relation> + </deps> + <display> + <group> + <_short>Bindings</_short> + <option name="window_toggle_key" type="key"> + <_short>Toggle Window</_short> + <_long>Use this to enable/disable AddHelper on the fly.</_long> + <default><Super>b</default> + </option> + <option name="screen_toggle_key" type="key"> + <_short>Toggle Screen</_short> + <_long>Use this to enable/disable AddHelper on the fly.</_long> + <default><Super>b</default> + </option> + </group> + </display> + <screen> + <group> + <_short>Values</_short> + <option name="blur_factor" type="int"> + <_short>Blur Factor</_short> + <_long>Use this to enable/disable AddHelper on the fly.</_long>\ + <default><Super>b</default> + </option> + </group> + </screen> + </plugin> +</compiz> diff --git a/plugin.info b/plugin.info new file mode 100644 index 0000000..bd3d133 --- /dev/null +++ b/plugin.info @@ -0,0 +1 @@ +PLUGIN = basicblur |