summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <Sam@XPS-SUSE.site>2009-01-20 23:20:49 +0900
committerSam Spilsbury <Sam@XPS-SUSE.site>2009-01-20 23:20:49 +0900
commitf11de2c19cb3c0ca7fcb9b8a73d1370b5a407bf3 (patch)
tree9d0c90701e6d6bb4ece1aff046715dd4f29368d9
parent7a20fbce709bec43e46e7d6b459fae01c2617350 (diff)
downloadflash-f11de2c19cb3c0ca7fcb9b8a73d1370b5a407bf3.tar.gz
flash-f11de2c19cb3c0ca7fcb9b8a73d1370b5a407bf3.tar.bz2
Initial C++ Port
-rw-r--r--CMakeLists.txt3
-rw-r--r--Makefile513
-rw-r--r--flash.c1008
-rw-r--r--flash.cpp589
-rw-r--r--flash.h108
-rw-r--r--flash.xml.in (renamed from flash.xml)50
-rw-r--r--libflash.la35
-rw-r--r--plugin.info2
8 files changed, 1215 insertions, 1093 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..12641fa
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,3 @@
+include (CompizFusion)
+
+compiz_fusion_plugin (flash PLUGINDEPS composite opengl)
diff --git a/Makefile b/Makefile
index 0f8eb36..4b04c56 100644
--- a/Makefile
+++ b/Makefile
@@ -1,42 +1,507 @@
+##
+#
+# 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
+# CHK_HEADERS = compiz-cube.h
+#
+
+#load config file
+
+ECHO = `which echo`
+
+# default color settings
+color := $(shell if [ $$TERM = "dumb" ]; then $(ECHO) "no"; else $(ECHO) "yes"; fi)
+
+ifeq ($(shell if [ -f plugin.info ]; then $(ECHO) -n "found"; fi ),found)
+include plugin.info
+else
+$(error $(shell if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e "\033[1;31m[ERROR]\033[0m \"plugin.info\" file not found"; \
+ else \
+ $(ECHO) "[ERROR] \"plugin.info\" file not found"; \
+ fi;))
+endif
+
+ifneq ($(shell if pkg-config --exists compiz; then $(ECHO) -n "found"; fi ),found)
+$(error $(shell if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e -n "\033[1;31m[ERROR]\033[0m Compiz not installed"; \
+ else \
+ $(ECHO) -n "[ERROR] Compiz not installed"; \
+ fi))
+endif
+
+
+ifneq ($(shell if [ -n "$(PKG_DEP)" ]; then if pkg-config --exists $(PKG_DEP); then $(ECHO) -n "found"; fi; \
+ else $(ECHO) -n "found"; fi ),found)
+$(error $(shell if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e -n "\033[1;31m[ERROR]\033[0m "; \
+ else \
+ $(ECHO) -n "[ERROR] "; \
+ fi; \
+ pkg-config --print-errors --short-errors --errors-to-stdout $(PKG_DEP); ))
+endif
+
ifeq ($(BUILD_GLOBAL),true)
- DESTDIR = `pkg-config --variable=libdir compiz`/compiz
- XMLDIR = `pkg-config --variable=prefix compiz`/share/compiz
+ 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
- METADATADIR = $(HOME)/.compiz/metadata
+ XMLDIR = $(HOME)/.compiz/metadata
+ IMAGEDIR = $(HOME)/.compiz/images
+ DATADIR = $(HOME)/.compiz/data
+endif
+
+BUILDDIR = build
+
+CC = gcc
+CPP = g++
+LIBTOOL = libtool
+INSTALL = install
+
+BCOP = `pkg-config --variable=bin bcop`
+
+CFLAGS = -g -Wall -Wpointer-arith -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 )
+
+COMPIZ_HEADERS = compiz.h core/core.h
+COMPIZ_INC = $(shell pkg-config --variable=includedir compiz)/compiz/
+
+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-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 compiz-$(PLUGIN).h ]; then $(ECHO) "compiz-$(PLUGIN).h"; fi )
endif
-XSLTDIR = `pkg-config --variable=xsltdir compiz-gconf`
+# find all the object files
-PLUGIN = flash
+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/^.\///'))
-CC = gcc
-LIBTOOL = libtool
-INSTALL = install
+h-files := $(shell find -name '*.h' 2> /dev/null | grep -v "$(BUILDDIR)/" | sed -e 's/^.\///')
+h-files += $(bcop-target-hdr)
+h-files += $(foreach file,$(COMPIZ_HEADERS) $(CHK_HEADERS),$(shell $(ECHO) -n "$(COMPIZ_INC)$(file)"))
-CFLAGS = -Wall -g `pkg-config --cflags compiz cairo` -shared
-LDFLAGS = `pkg-config --libs compiz cairo`
+all-c-objs := $(addprefix $(BUILDDIR)/,$(c-objs))
-%.lo: %.c
- $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -c -o $@ $<
+# additional files
-%.la: $(PLUGIN).lo
- $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -rpath $(DESTDIR) -o $@ $<
+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\///')
-all: lib$(PLUGIN).la
+# 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)
-install: lib$(PLUGIN).la
+# Tests
+ifeq ($(shell if [ -n "$(is-bcop-target)" -a -z "$(BCOP)" ]; then $(ECHO) -n "error"; fi ),error)
+$(error $(shell if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e -n "\033[1;31m[ERROR]\033[0m BCOP not installed but is needed to build plugin"; \
+ else \
+ $(ECHO) -n "[ERROR] BCOP not installed but is needed to build plugin"; \
+ fi))
+endif
+
+ifeq ($(shell if [ "x$(BUILD_GLOBAL)" != "xtrue" -a -e compiz-$(PLUGIN).pc.in ]; then $(ECHO) -n "warn"; fi ),warn)
+$(warning $(shell if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e -n "\033[1;31m[WARNING]\033[0m This plugin might be needed by other plugins. Install it with \"BUILD_GLOBAL=true sudo make install\" "; \
+ else \
+ $(ECHO) -n "[WARNING] This plugin might be needed by other plugins. Install it with \"BUILD_GLOBAL=true sudo make install\""; \
+ fi))
+endif
+
+#
+# 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)
- $(LIBTOOL) --mode=install $(INSTALL) lib$(PLUGIN).la \
- $(DESTDIR)/lib$(PLUGIN).la
- @mkdir -p $(METADATADIR)
- @cp $(PLUGIN).xml $(METADATADIR)
-install-schema:
- @xsltproc -o $(PLUGIN).schema $(XSLTDIR)/schemas.xslt $(PLUGIN).xml
- @gconftool-2 --install-schema-file=$(PLUGIN).schema
+#
+# 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: %.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) -R `pkg-config --variable=libdir compiz`/compiz -o $@ $(all-c-objs)
+ @if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e "\r\033[0mlinking : \033[34m$@\033[0m"; \
+ fi
+
clean:
- rm -rf *.lo *.o lib$(PLUGIN).* .libs *~ $(PLUGIN).schema
+ @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); \
+ $(INSTALL) $(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; \
+ $(INSTALL) --mode=u=rw,go=r,a-s $(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; \
+ $(INSTALL) --mode=u=rw,go=r,a-s $(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; \
+ if [ "x$(USER)" = "xroot" ]; then \
+ GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source` \
+ gconftool-2 --makefile-install-rule $(schema-output) > /dev/null; \
+ else \
+ gconftool-2 --install-schema-file=$(schema-output) > /dev/null; \
+ fi; \
+ 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; \
+ FILEDIR="$(DATADIR)/`dirname "$$FILE"`"; \
+ mkdir -p "$$FILEDIR"; \
+ $(INSTALL) --mode=u=rw,go=r,a-s 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; \
+ FILEDIR="$(IMAGEDIR)/`dirname "$$FILE"`"; \
+ mkdir -p "$$FILEDIR"; \
+ $(INSTALL) --mode=u=rw,go=r,a-s 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 "$(schema-output)" -a -e "$(schema-output)" -a 'x$(USER)' = 'xroot' ]; then \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -n -e "\033[0;1;5muninstall \033[0m: \033[0;31m$(schema-output)\033[0m"; \
+ else \
+ $(ECHO) "uninstall : $(schema-output)"; \
+ fi; \
+ GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source` \
+ gconftool-2 --makefile-uninstall-rule $(schema-output) > /dev/null; \
+ if [ '$(color)' != 'no' ]; then \
+ $(ECHO) -e "\r\033[0muninstall : \033[34m$(schema-output)\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/flash.c b/flash.c
deleted file mode 100644
index 741514d..0000000
--- a/flash.c
+++ /dev/null
@@ -1,1008 +0,0 @@
-/**
-*
-* Compiz plugin Flash
-*
-* Copyright : (C) 2007 by Jean-Fran�is Souville & Charles Jeremy
-* E-mail : souville@ecole.ensicaen.fr , charles@ecole.ensicaen.fr
-*
-*
-* 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.
-*
-*/
-
-
-/**
- * FLASH - macro names
- * Flash - struct names
- * flash - function names
- * fd - FlashDisplay variable name
- * fs - FlashScreen variable name
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <X11/Xatom.h>
-#include <X11/extensions/Xrender.h>
-#include <compiz-core.h>
-
-#define OPTION_DISTANCE_MAX 1024
-
-#define FLASH_DISPLAY_OPTION_INITIATE_BUTTON 0
-#define FLASH_DISPLAY_OPTION_INITIATE_KEY 1
-#define FLASH_DISPLAY_OPTION_DISTANCE_MAX 2
-#define FLASH_DISPLAY_OPTION_ECART_MAX 3
-#define FLASH_DISPLAY_OPTION_INTERVAL 4
-#define FLASH_DISPLAY_OPTION_TIME 5
-#define FLASH_DISPLAY_OPTION_COLOR_UP_LEFT 6
-#define FLASH_DISPLAY_OPTION_COLOR_CENTER 7
-#define FLASH_DISPLAY_OPTION_COLOR_DOWN_RIGHT 8
-#define FLASH_DISPLAY_OPTION_NUM 9
-
-#define FLASH_SCREEN_OPTION_WINDOW_TYPE 0
-#define FLASH_SCREEN_OPTION_NUM 1
-
-/*
- * Helpers
- *
- */
-#define GET_FLASH_DISPLAY(d) ((FlashDisplay *) (d)->base.privates[displayPrivateIndex].ptr)
-#define FLASH_DISPLAY(d) FlashDisplay *fd = GET_FLASH_DISPLAY (d)
-#define GET_FLASH_SCREEN(s, fd) ((FlashScreen *) (s)->base.privates[(fd)->screenPrivateIndex].ptr)
-#define FLASH_SCREEN(s) FlashScreen *fs = GET_FLASH_SCREEN (s, GET_FLASH_DISPLAY (s->display))
-#define GET_FLASH_WINDOW(w, fs) ((FlashWindow *) (w)->base.privates[(fs)->windowPrivateIndex].ptr)
-#define FLASH_WINDOW(w) FlashWindow *fw = GET_FLASH_WINDOW (w, GET_FLASH_SCREEN (w->screen, GET_FLASH_DISPLAY (w->screen->display)))
-
-#define NUM_OPTIONS(s) (sizeof ((s)->opt) / sizeof (CompOption))
-
-#define POS_TOP 0
-#define POS_BOTTOM 1
-#define POS_LEFT 2
-#define POS_RIGHT 3
-
-/*
- * pointer to display list
- */
-static int displayPrivateIndex;
-
-static CompMetadata flashMetadata;
-
-/*
- * FlashDisplay structure
- */
-typedef struct _FlashDisplay {
- int screenPrivateIndex;
- CompOption opt[FLASH_DISPLAY_OPTION_NUM];
- HandleEventProc handleEvent;
-} FlashDisplay;
-
-/*
- * FlashScreen structure
- */
-typedef struct _FlashScreen {
-
- int windowPrivateIndex;
- CompOption opt[FLASH_SCREEN_OPTION_NUM];
-
- DonePaintScreenProc donePaintScreen;
- PaintOutputProc paintOutput;
- PreparePaintScreenProc preparePaintScreen;
-
- int pointX, pointY;
- int winX,winY,winW,winH;
-
- double** CoordinateArray;
-
- int tailleTab;
-
- int *remainTime;
-
- int *interval;
-
- int** alea;
-
- int location;
-
- unsigned int WindowMask;
-
- Bool active;
- Bool *lightning;
-
- Bool existWindow;
-
- Bool isAnimated;
- Bool anotherPluginIsUsing;
-
-} FlashScreen;
-
-
-/*
- * flashSetScreenOption
- *
- */
-static Bool
-flashSetScreenOption (CompPlugin *p, CompScreen *s, const char *name, CompOptionValue *value)
-{
- CompOption *o;
- int index;
-
- FLASH_SCREEN (s);
-
- o = compFindOption (fs->opt, NUM_OPTIONS (fs), name, &index);
- if (!o)
- return FALSE;
-
- if (compSetOption (o, value))
- return TRUE;
-
- return FALSE;
-}
-
-/*
- * flashGetScreenOptions
- *
- */
-static CompOption *
-flashGetScreenOptions (CompPlugin *p, CompScreen *s, int *count)
-{
- FLASH_SCREEN (s);
- *count = NUM_OPTIONS (fs);
- return fs->opt;
-}
-
-/*
- * flashInitiate
- *
- */
-static Bool
-flashInitiate (CompDisplay *d, CompAction *action, CompActionState state, CompOption *option, int nOption)
-{
- CompScreen *s;
- int i;
-
- s = findScreenAtDisplay(d, getIntOptionNamed(option, nOption, "root", 0));
- if (s)
- {
- FLASH_SCREEN(s);
- FLASH_DISPLAY(s->display);
- fs->active = !fs->active;
-
- for(i=0 ; i<5 ; i++)
- {
- fs->remainTime[i] = fd->opt[FLASH_DISPLAY_OPTION_TIME].value.i + fs->interval[i];
- fs->lightning[i] = FALSE;
- }
-
- if(!fs->active)
- damageScreen(s);
- }
- return FALSE;
-}
-
-static Bool
-pointerIsInWindow (FlashScreen *fs)
-{
- if(!fs->existWindow)
- return False;
-
- if( (fs->pointX < fs->winX + fs->winW) && (fs->pointX > fs->winX) &&
- (fs->pointY < fs->winY + fs->winH) && (fs->pointY > fs->winY) )
- return True;
-
- return False;
-}
-
-/*
- * getDigression : deplacer la destination
- *
- */
-static int
-getDigression (FlashDisplay *fd, int coord, int min, int max, int *alea)
-{
- int ecart=fd->opt[FLASH_DISPLAY_OPTION_ECART_MAX].value.i;
-
- int interval = max - min;
-
- int tmp=alea[0] % interval;
-
- if(coord-min >= ecart)
- min = coord - ecart;
-
- if(max-coord >= ecart)
- max=coord + ecart;
-
- tmp = tmp * (max - min) / interval;
-
- return (max - tmp) - coord;
-}
-
-/*
- * getCoordTarget
- *
- */
-static void
-getWindowTarget (FlashDisplay *fd, int* distance, int* Tx, int* Ty, int Px, int Py, int Wx, int Wy, int Ww, int Wh, int *alea)
-{
- int distanceMax=fd->opt[FLASH_DISPLAY_OPTION_DISTANCE_MAX].value.i;
-
- if(Px <= Wx) *Tx=Wx;
- else if(Px >= Wx+Ww) *Tx=Wx+Ww;
- else *Tx=Px;
-
- if(Py <= Wy) *Ty=Wy;
- else if(Py >= Wy+Wh) *Ty=Wy+Wh;
- else *Ty=Py;
-
- *distance = sqrt( (Px - *Tx)*(Px - *Tx) + (Py - *Ty)*(Py - *Ty) );
-
- if(*distance > 0)
- if(*Tx == Px)
- *Tx += getDigression(fd,Px,Wx,Wx+Ww, alea) * (*distance) / distanceMax + 1;
- if(*Ty == Py)
- *Ty += getDigression(fd,Py,Wy,Wy+Wh, alea) * (*distance) / distanceMax + 1;
-}
-
-
-
-/*
- * getScreenTarget
- *
- */
-static void
-getScreenTarget (CompScreen *s, int* distance, int* Tx, int* Ty, int Sx, int Sy, int Sw, int Sh, int *alea, int location)
-{
- FLASH_SCREEN(s);
- FLASH_DISPLAY(s->display);
-
- int min=0;
- int max=0;
- int distanceMax=fd->opt[FLASH_DISPLAY_OPTION_DISTANCE_MAX].value.i;
-
- switch(location)
- {
- case POS_TOP:
- *Tx=fs->pointX;
- *Ty=Sy;
- min=Sx;
- max=Sx+Sw;
- if(!fs->existWindow)
- break;
-
- if(fs->pointX < fs->winX && fs->pointY > fs->winY)
- max=fs->winX;
-
- else if(fs->pointX > fs->winX + fs->winW && fs->pointY > fs->winY)
- min=fs->winX+fs->winW;
-
- else if(fs->pointY >= fs->winY + fs->winH)
- *Ty=fs->pointY;
- break;
-
- case POS_BOTTOM:
- *Tx=fs->pointX;
- *Ty=Sy+Sh;
- min=Sx;
- max=Sx+Sw;
- if(!fs->existWindow)
- break;
-
- if(fs->pointX < fs->winX && fs->pointY < fs->winY+fs->winH)
- max=fs->winX;
-
- else if(fs->pointX > fs->winX+fs->winW && fs->pointY < fs->winY+fs->winH)
- min=fs->winX+fs->winW;
-
- else if(fs->pointY <= fs->winY)
- *Ty=fs->pointY;
- break;
-
- case POS_LEFT:
- *Ty=fs->pointY;
- *Tx=Sx;
- min=Sy;
- max=Sy+Sh;
- if(!fs->existWindow)
- break;
-
- if(fs->pointY < fs->winY && fs->pointX > fs->winX)
- max=fs->winY;
-
- else if(fs->pointY > fs->winY+fs->winH && fs->pointX > fs->winX)
- min = fs->winY + fs->winH;
-
- else if(fs->pointX >= fs->winX + fs->winW)
- *Tx=fs->pointX;
- break;
-
- case POS_RIGHT:
- *Ty=fs->pointY;
- *Tx=Sx+Sw;
- min=Sy;
- max=Sy+Sh;
- if(!fs->existWindow)
- break;
-
- if(fs->pointY < fs->winY && fs->pointX < fs->winX+fs->winW)
- max=fs->winY;
-
- else if(fs->pointY > fs->winY+fs->winH && fs->pointX < fs->winX+fs->winW)
- min=fs->winY+fs->winH;
-
- else if(fs->pointX <= fs->winX)
- *Tx=fs->pointX;
- break;
-
- default:
- break;
- }
-
- *distance = sqrt( (fs->pointX - *Tx)*(fs->pointX - *Tx) + (fs->pointY - *Ty)*(fs->pointY - *Ty) );
-
- if(*distance > 0)
- if(*Tx == fs->pointX)
- *Tx += getDigression(fd,fs->pointX,min,max, alea) * (*distance) / distanceMax + 1;
- if(*Ty == fs->pointY)
- *Ty += getDigression(fd,fs->pointY,min,max, alea) * (*distance) / distanceMax + 1;
-}
-
-
-/*
- * getWay : fonction du chemin semi-aleatoire
- *
- */
-static int
-getWay(int xy, int distance, int *alea)
-{
-
- double pi = 4 * atan (1.0);
- int resultat = 0;
- int amplitude = distance * xy / (distance + xy);
- int i;
- int ms = alea[0] % 100;
-
- if(ms <= 50)
- resultat += ms * amplitude * cos( xy * pi / (2*distance));
- else
- resultat += -(ms - 50) * amplitude * cos( xy * pi / (2*distance));
-
- for(i=1;i<10;i++)
- {
- resultat += (alea[i] % 100) * amplitude * cos( pow(2,i) * xy * pi * (alea[i] % 100) / (20 * distance) ) * (distance - xy) / (distance * 5 * (i + 1));
- }
-
- return (resultat / 100);
-}
-
-
-static void
-getCoordinateArray (double** CoordinateArray ,int distance, int Tx, int Ty, int Px, int Py, int* tailleTab, int* alea, int numero)
-{
- int i;
- double Mx,My;
- int ecart;
-
- *tailleTab=distance;
- //courbe demarre au pointeur de la souris
- CoordinateArray[0][0]=0;
- CoordinateArray[0][1]=0;
-
- for(i=1;i<distance;i++)
- {
- Mx=((double)i / (double)distance)*(Tx-Px);
- My=((double)i / (double)distance)*(Ty-Py);
-
- ecart = getWay(i, distance,alea) + numero;
-
- CoordinateArray[i][0] = Mx + (double) ecart * (Ty-Py) / distance;
- CoordinateArray[i][1] = My + (double) ecart * (Tx-Px) / distance;
- }
-}
-
-/*
- * flashPreparePaintOutput
- *
- */
-static void
-flashPreparePaintOutput (CompScreen *s, int msSinceLastPaint)
-{
- FLASH_SCREEN (s);
- FLASH_DISPLAY(s->display);
-
- CompWindow *w;
- Window root, child;
- int winx, winy;
- int i,j;
- unsigned int pmask;
-
-
- if(fs->active)
- {
-
- //Get informations about active window
- w = findWindowAtDisplay(s->display, s->display->activeWindow);
- if(w)
- {
-
- if(matchEval (&fs->opt[FLASH_SCREEN_OPTION_WINDOW_TYPE].value.match, w))
- fs->existWindow=TRUE;
- else
- fs->existWindow=FALSE;
-
- fs->winW=w->width + w->input.left + w->input.right;
- fs->winH=w->height + w->input.top + w->input.bottom;
- fs->winX=w->attrib.x - w->input.left;
- fs->winY=w->attrib.y - w->input.top;
- }
- else
- {
- fs->existWindow=FALSE;
- fs->winW=0;
- fs->winH=0;
- fs->winX=0;
- fs->winY=0;
- fs->isAnimated = FALSE;
- }
-
-
- //test if an other plugin is used at this time.
- if(otherScreenGrabExist(s,0))
- fs->anotherPluginIsUsing = TRUE;
- else
- fs->anotherPluginIsUsing = FALSE;
-
- //get position of pointer
- XQueryPointer(s->display->display, s->root, &root, &child, &(fs->pointX), &(fs->pointY), &winx, &winy, &pmask);
-
- int time = fd->opt[FLASH_DISPLAY_OPTION_TIME].value.i;
-
- for(i = 0 ; i < 5 ; i++)
- {
- fs->remainTime[i] -= msSinceLastPaint;
-
- if(fs->remainTime[i] < 0)
- {
- fs->lightning[i] = FALSE;
- fs->remainTime[i] = fs->interval[i] + time;
-
- srand(fs->alea[i][1] * (fs->pointX+1) * (fs->pointY+1) / (fs->interval[i] + 1) );
- for(j=0;j<10;j++)
- fs->alea[i][j]=(int) rand();
- }
- else
- {
- if( (fs->remainTime[i]) < time )
- fs->lightning[i] = TRUE;
- }
- }
- }
-
- UNWRAP (fs, s, preparePaintScreen);
- (*s->preparePaintScreen) (s, msSinceLastPaint);
- WRAP (fs, s, preparePaintScreen, flashPreparePaintOutput);
-}
-
-/*
- * flashDonePaintScreen
- *
- */
-static void
-flashDonePaintScreen (CompScreen *s)
-{
- FLASH_SCREEN (s);
-
- if(fs->active)
- damageScreen(s);
-
- UNWRAP (fs, s, donePaintScreen);
- (*s->donePaintScreen) (s);
- WRAP (fs, s, donePaintScreen, flashDonePaintScreen);
-}
-
-/*
- * flashPaintOutput
- *
- */
-static Bool
-flashPaintOutput (CompScreen * s, const ScreenPaintAttrib * sAttrib,
- const CompTransform *transform,
- Region region, CompOutput *output, unsigned int mask)
-{
- Bool status;
- FLASH_SCREEN (s);
- FLASH_DISPLAY(s->display);
-
- UNWRAP (fs, s, paintOutput);
- status = (*s->paintOutput) (s, sAttrib, transform ,region, output, mask);
- WRAP (fs, s, paintOutput, flashPaintOutput);
-
- int x1, y1;
- x1 = fs->pointX;
- y1 = fs->pointY;
-
- int x2, y2;
- int distanceToWindow;
- int i,j;
-
- if(!fs->active || pointerIsInWindow(fs) || fs->anotherPluginIsUsing)
- return status;
-
- glPushMatrix(); //sauve la matrice courante
- glLoadIdentity();//remplace la matrice courante par la matrice identite
- prepareXCoords(s, output, -DEFAULT_Z_CAMERA);
-
- glEnable(GL_BLEND);//active le melange des couleurs (glBlendFunc)
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);//permet les effets de transparence
-
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-
- glTranslatef(x1, y1, 0);
-
- glLineWidth(2);
-
- //lightning between pointer and active window
- if(fs->lightning[0])
- {
- getWindowTarget(fd, &distanceToWindow, &x2, &y2, x1, y1, fs->winX, fs->winY, fs->winW, fs->winH, fs->alea[0]);
-
- if(fs->existWindow && distanceToWindow < fd->opt[FLASH_DISPLAY_OPTION_DISTANCE_MAX].value.i && !fs->isAnimated)
- {
- //changement de la frequence d'apparition en fonction de la distance
- fs->interval[0] = (fd->opt[FLASH_DISPLAY_OPTION_INTERVAL].value.i + distanceToWindow) * (fs->alea[0][1]%400) / 200;// * 2 / fd->opt[FLASH_DISPLAY_OPTION_DISTANCE_MAX].value.i;
-
- //affichage du trait du haut ou a gauche
- glBegin(GL_LINE_STRIP);
- glColor4f(
- (float)fd->opt[FLASH_DISPLAY_OPTION_COLOR_UP_LEFT].value.c[0] / 0xffff,
- (float)fd->opt[FLASH_DISPLAY_OPTION_COLOR_UP_LEFT].value.c[1] / 0xffff,
- (float)fd->opt[FLASH_DISPLAY_OPTION_COLOR_UP_LEFT].value.c[2] / 0xffff,
- (float)fd->opt[FLASH_DISPLAY_OPTION_COLOR_UP_LEFT].value.c[3] / 0xffff);
- //remplissage du tableau de coordonnees
- getCoordinateArray(fs->CoordinateArray, distanceToWindow, x2, y2, x1, y1, &(fs->tailleTab), fs->alea[0], -2);
- for(i=0;i<fs->tailleTab;i++)
- glVertex2dv(fs->CoordinateArray[i]);
- glEnd();
-
- //affichage du trait central
- glBegin(GL_LINE_STRIP);
- glColor4f(
- (float)fd->opt[FLASH_DISPLAY_OPTION_COLOR_CENTER].value.c[0] / 0xffff,
- (float)fd->opt[FLASH_DISPLAY_OPTION_COLOR_CENTER].value.c[1] / 0xffff,
- (float)fd->opt[FLASH_DISPLAY_OPTION_COLOR_CENTER].value.c[2] / 0xffff,
- (float)fd->opt[FLASH_DISPLAY_OPTION_COLOR_CENTER].value.c[3] / 0xffff);
- //remplissage du tableau de coordonnees
- getCoordinateArray(fs->CoordinateArray, distanceToWindow, x2, y2, x1, y1, &(fs->tailleTab), fs->alea[0], 0);
- for(i=0;i<fs->tailleTab;i++)
- glVertex2dv(fs->CoordinateArray[i]);
- glEnd();
-
- //affichage du trait du bas ou a droite
- glBegin(GL_LINE_STRIP);
- glColor4f(
- (float)fd->opt[FLASH_DISPLAY_OPTION_COLOR_DOWN_RIGHT].value.c[0] / 0xffff,
- (float)fd->opt[FLASH_DISPLAY_OPTION_COLOR_DOWN_RIGHT].value.c[1] / 0xffff,
- (float)fd->opt[FLASH_DISPLAY_OPTION_COLOR_DOWN_RIGHT].value.c[2] / 0xffff,
- (float)fd->opt[FLASH_DISPLAY_OPTION_COLOR_DOWN_RIGHT].value.c[3] / 0xffff);
- //remplissage du tableau de coordonnees
- getCoordinateArray(fs->CoordinateArray, distanceToWindow, x2, y2, x1, y1, &(fs->tailleTab), fs->alea[0], 2);
- for(i=0;i<fs->tailleTab;i++)
- glVertex2dv(fs->CoordinateArray[i]);
- glEnd();
- }
- }
-
- for(i=1;i<5;i++)
- {
- if(fs->lightning[i])
- {
- getScreenTarget(s, &distanceToWindow, &x2, &y2, s->x, s->y, s->width, s->height, fs->alea[i], i-1);
-
- if(distanceToWindow < fd->opt[FLASH_DISPLAY_OPTION_DISTANCE_MAX].value.i )
- {
- //changement de la frequence d'apparition en fonction de la distance
- fs->interval[i] = fd->opt[FLASH_DISPLAY_OPTION_INTERVAL].value.i + distanceToWindow * (fs->alea[i][1]%600) / 200; // / fd->opt[FLASH_DISPLAY_OPTION_DISTANCE_MAX].value.i;
-
- //affichage du trait du haut ou a gauche
- glBegin(GL_LINE_STRIP);
- glColor4f(
- (float)fd->opt[FLASH_DISPLAY_OPTION_COLOR_UP_LEFT].value.c[0] / 0xffff,
- (float)fd->opt[FLASH_DISPLAY_OPTION_COLOR_UP_LEFT].value.c[1] / 0xffff,
- (float)fd->opt[FLASH_DISPLAY_OPTION_COLOR_UP_LEFT].value.c[2] / 0xffff,
- (float)fd->opt[FLASH_DISPLAY_OPTION_COLOR_UP_LEFT].value.c[3] / 0xffff);
- //remplissage du tableau de coordonnees
- getCoordinateArray(fs->CoordinateArray, distanceToWindow, x2, y2, x1, y1, &(fs->tailleTab), fs->alea[i], -2);
- for(j=0;j<fs->tailleTab;j++)
- glVertex2dv(fs->CoordinateArray[j]);
- glEnd();
-
- //affichage du trait central
- glBegin(GL_LINE_STRIP);
- glColor4f(
- (float)fd->opt[FLASH_DISPLAY_OPTION_COLOR_CENTER].value.c[0] / 0xffff,
- (float)fd->opt[FLASH_DISPLAY_OPTION_COLOR_CENTER].value.c[1] / 0xffff,
- (float)fd->opt[FLASH_DISPLAY_OPTION_COLOR_CENTER].value.c[2] / 0xffff,
- (float)fd->opt[FLASH_DISPLAY_OPTION_COLOR_CENTER].value.c[3] / 0xffff);
- //remplissage du tableau de coordonnees
- getCoordinateArray(fs->CoordinateArray, distanceToWindow, x2, y2, x1, y1, &(fs->tailleTab), fs->alea[i], 0);
- for(j=0;j<fs->tailleTab;j++)
- glVertex2dv(fs->CoordinateArray[j]);
- glEnd();
-
- //affichage du trait du bas ou a droite
- glBegin(GL_LINE_STRIP);
- glColor4f(
- (float)fd->opt[FLASH_DISPLAY_OPTION_COLOR_DOWN_RIGHT].value.c[0] / 0xffff,
- (float)fd->opt[FLASH_DISPLAY_OPTION_COLOR_DOWN_RIGHT].value.c[1] / 0xffff,
- (float)fd->opt[FLASH_DISPLAY_OPTION_COLOR_DOWN_RIGHT].value.c[2] / 0xffff,
- (float)fd->opt[FLASH_DISPLAY_OPTION_COLOR_DOWN_RIGHT].value.c[3] / 0xffff);
- //remplissage du tableau de coordonnees
- getCoordinateArray(fs->CoordinateArray, distanceToWindow, x2, y2, x1, y1, &(fs->tailleTab), fs->alea[i], 2);
- for(j=0;j<fs->tailleTab;j++)
- glVertex2dv(fs->CoordinateArray[j]);
- glEnd();
- }
- }
- }
- glTranslatef(-x1, -y1, 0);
-
- glColor4usv(defaultColor);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- glDisable(GL_BLEND);
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- glPopMatrix();
-
- return status;
-}
-
-
-/*
- * flashSetDisplayOption
- *
- */
-static Bool
-flashSetDisplayOption (CompPlugin *p, CompDisplay *d, const char *name, CompOptionValue *value)
-{
- CompOption *o;
- int index;
-
- FLASH_DISPLAY (d);
-
- o = compFindOption (fd->opt, NUM_OPTIONS (fd), name, &index);
- if (!o)
- return FALSE;
-
- switch (index)
- {
-
- case FLASH_DISPLAY_OPTION_INITIATE_BUTTON:
- case FLASH_DISPLAY_OPTION_INITIATE_KEY:
- if (setDisplayAction (d, o, value))
- return TRUE;
- break;
- case FLASH_DISPLAY_OPTION_DISTANCE_MAX:
- case FLASH_DISPLAY_OPTION_ECART_MAX:
- case FLASH_DISPLAY_OPTION_INTERVAL:
- case FLASH_DISPLAY_OPTION_TIME:
- if (compSetIntOption(o, value))
- return TRUE;
- break;
- case FLASH_DISPLAY_OPTION_COLOR_UP_LEFT:
- case FLASH_DISPLAY_OPTION_COLOR_CENTER:
- case FLASH_DISPLAY_OPTION_COLOR_DOWN_RIGHT:
- if (compSetColorOption(o, value))
- return TRUE;
- break;
- default:
- break;
- }
-
- return FALSE;
-}
-
- /*
- * flashGetDisplayOptions
- *
- */
-static CompOption *
-flashGetDisplayOptions (CompPlugin *p, CompDisplay *d, int *count)
-{
- FLASH_DISPLAY (d);
-
- *count = NUM_OPTIONS (fd);
- return fd->opt;
-}
-
-static const CompMetadataOptionInfo flashDisplayOptionInfo[] = {
- { "initiate_button", "button", 0, flashInitiate, 0 },
- { "initiate_key", "key", 0, flashInitiate, 0 },
- { "distance_max", "int", 0, 0, 0 },
- { "ecart_max", "int", 0, 0, 0 },
- { "interval", "int", 0, 0, 0 },
- { "time", "int", 0, 0, 0 },
- { "flash_color_up_left", "color", 0, 0, 0 },
- { "flash_color_center", "color", 0, 0, 0 },
- { "flash_color_down_right", "color", 0, 0, 0 }
-};
-
-/*
- * flashInitDisplay
- *
- */
-static Bool
-flashInitDisplay (CompPlugin *p, CompDisplay *d)
-{
- FlashDisplay *fd;
-
- fd = malloc (sizeof (FlashDisplay));
- if (!fd)
- return FALSE;
-
- if (!compInitDisplayOptionsFromMetadata (d,
- &flashMetadata,
- flashDisplayOptionInfo,
- fd->opt,
- FLASH_DISPLAY_OPTION_NUM))
- {
- free (fd);
- return FALSE;
- }
-
-
- fd->screenPrivateIndex = allocateScreenPrivateIndex (d);
- if (fd->screenPrivateIndex < 0)
- {
- compFiniDisplayOptions (d, fd->opt, FLASH_DISPLAY_OPTION_NUM);
- free (fd);
- return FALSE;
- }
-
- d->base.privates[displayPrivateIndex].ptr = fd;
-
- return TRUE;
-}
-
-/*
- * flashFiniDisplay
- *
- */
-static void
-flashFiniDisplay (CompPlugin *p, CompDisplay *d)
-{
- FLASH_DISPLAY (d);
-
- freeScreenPrivateIndex (d, fd->screenPrivateIndex);
-
- free (fd);
-}
-
-static const CompMetadataOptionInfo flashScreenOptionInfo[] = {
- { "window_types", "match", 0, 0, 0 }
-};
-
-/*
- * flashInitScreen
- *
- */
-static Bool
-flashInitScreen (CompPlugin *p, CompScreen *s)
-{
- FlashScreen *fs;
- int i,j;
-
- FLASH_DISPLAY (s->display);
-
- fs = malloc (sizeof (FlashScreen));
- if (!fs)
- return FALSE;
-
- if (!compInitScreenOptionsFromMetadata (s,
- &flashMetadata,
- flashScreenOptionInfo,
- fs->opt,
- FLASH_SCREEN_OPTION_NUM))
- {
- free (fs);
- return FALSE;
- }
-
- fs->windowPrivateIndex = allocateWindowPrivateIndex (s);
- if (fs->windowPrivateIndex < 0)
- {
- free (fs);
- return FALSE;
- }
-
- fs->active = FALSE;
-
- fs->lightning = (Bool *) malloc(5 * sizeof(Bool));
- fs->interval = (int *) malloc(5 * sizeof(int));
- fs->remainTime = (int *) malloc(5 * sizeof(int));
-
- fs->alea=(int**)malloc(5 * sizeof(int *));
-
- fs->CoordinateArray= (double **)malloc(OPTION_DISTANCE_MAX * sizeof(double *));
-
- for(i=0; i<OPTION_DISTANCE_MAX; i++)
- fs->CoordinateArray[i]=(double*)malloc(2*sizeof(double));
-
- for(i=0;i<5;i++)
- {
- fs->lightning[i] = FALSE;
-
- fs->alea[i]=(int*)malloc(10 * sizeof(int));
-
- fs->interval[i] = fd->opt[FLASH_DISPLAY_OPTION_INTERVAL].value.i;
- fs->remainTime[i] = fd->opt[FLASH_DISPLAY_OPTION_TIME].value.i + fs->interval[i];
-
- srand(1);
- for(j=0;j<10;j++)
- fs->alea[i][j]=(int) rand();
-
- }
-
- addScreenAction (s, &fd->opt[FLASH_DISPLAY_OPTION_INITIATE_BUTTON].value.action);
- addScreenAction (s, &fd->opt[FLASH_DISPLAY_OPTION_INITIATE_KEY].value.action);
-
- WRAP (fs, s, donePaintScreen, flashDonePaintScreen);
- WRAP (fs, s, paintOutput, flashPaintOutput);
- WRAP (fs, s, preparePaintScreen, flashPreparePaintOutput);
-
- s->base.privates[fd->screenPrivateIndex].ptr = fs;
-
- return TRUE;
-}
-
-/*
- * flashFiniScreen
- *
- */
-static void
-flashFiniScreen (CompPlugin *p, CompScreen *s)
-{
- FLASH_SCREEN (s);
- FLASH_DISPLAY(s->display);
-
- freeWindowPrivateIndex (s, fs->windowPrivateIndex);
-
- UNWRAP (fs, s, donePaintScreen);
- UNWRAP (fs, s, paintOutput);
- UNWRAP (fs, s, preparePaintScreen);
-
- removeScreenAction(s, &fd->opt[FLASH_DISPLAY_OPTION_INITIATE_BUTTON].value.action);
- removeScreenAction(s, &fd->opt[FLASH_DISPLAY_OPTION_INITIATE_KEY].value.action);
-
- compFiniScreenOptions (s, fs->opt, FLASH_SCREEN_OPTION_NUM);
-
- free (fs);
-}
-
-/*
- * flashInit
- *
- */
-static Bool
-flashInit (CompPlugin *p)
-{
- if (!compInitPluginMetadataFromInfo (&flashMetadata,
- p->vTable->name,
- flashDisplayOptionInfo,
- FLASH_DISPLAY_OPTION_NUM,
- flashScreenOptionInfo,
- FLASH_SCREEN_OPTION_NUM))
- return FALSE;
-
- displayPrivateIndex = allocateDisplayPrivateIndex ();
- if (displayPrivateIndex < 0)
- {
- compFiniMetadata (&flashMetadata);
- return FALSE;
- }
-
- compAddMetadataFromFile (&flashMetadata, p->vTable->name);
-
- return TRUE;
-}
-
-/*
- * flashFini
- *
- */
-static void
-flashFini (CompPlugin *p)
-{
- if (displayPrivateIndex >= 0)
- freeDisplayPrivateIndex (displayPrivateIndex);
-
- compFiniMetadata (&flashMetadata);
-}
-
-static CompBool
-flashInitObject (CompPlugin *p,
- CompObject *o)
-{
- static InitPluginObjectProc dispTab[] = {
- (InitPluginObjectProc) 0, /* InitCore */
- (InitPluginObjectProc) flashInitDisplay,
- (InitPluginObjectProc) flashInitScreen
- };
-
- RETURN_DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), TRUE, (p, o));
-}
-
-static void
-flashFiniObject (CompPlugin *p,
- CompObject *o)
-{
- static FiniPluginObjectProc dispTab[] = {
- (FiniPluginObjectProc) 0, /* FiniCore */
- (FiniPluginObjectProc) flashFiniDisplay,
- (FiniPluginObjectProc) flashFiniScreen
- };
-
- DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), (p, o));
-}
-
-static CompOption* flashGetObjectOptions (CompPlugin *plugin,
- CompObject *object, int *count) {
-
- static GetPluginObjectOptionsProc dispTab[] = {
- (GetPluginObjectOptionsProc) 0, // GetCoreOptions
- (GetPluginObjectOptionsProc) flashGetDisplayOptions,
- (GetPluginObjectOptionsProc) flashGetScreenOptions
- };
-
- RETURN_DISPATCH (object, dispTab, ARRAY_SIZE (dispTab),
- (void *) (*count = 0), (plugin, object, count));
-}
-
-static CompBool flashSetObjectOption (CompPlugin *plugin, CompObject *object,
- const char *name, CompOptionValue *value) {
-
- static SetPluginObjectOptionProc dispTab[] = {
- (SetPluginObjectOptionProc) 0, /* SetCoreOption */
- (SetPluginObjectOptionProc) flashSetDisplayOption,
- (SetPluginObjectOptionProc) flashSetScreenOption
- };
-
- RETURN_DISPATCH (object, dispTab, ARRAY_SIZE (dispTab),
- FALSE, (plugin, object, name, value));
-}
-
-static CompMetadata *
-flashGetMetadata (CompPlugin *plugin)
-{
- return &flashMetadata;
-}
-
-/*
- * flashVTable
- *
- */
-CompPluginVTable flashVTable = {
- "flash",
- flashGetMetadata,
- flashInit,
- flashFini,
- flashInitObject,
- flashFiniObject,
- flashGetObjectOptions,
- flashSetObjectOption
-};
-
-/*
- * getCompPluginInfo
- *
- */
-CompPluginVTable *
-getCompPluginInfo20070830 (void)
-{
- return &flashVTable;
-}
diff --git a/flash.cpp b/flash.cpp
new file mode 100644
index 0000000..5f0c88a
--- /dev/null
+++ b/flash.cpp
@@ -0,0 +1,589 @@
+/**
+*
+* Compiz plugin Flash
+*
+* Copyright : (C) 2007 by Jean-Fran�is Souville & Charles Jeremy
+* E-mail : souville@ecole.ensicaen.fr , charles@ecole.ensicaen.fr
+*
+*
+* 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.
+*
+*/
+
+/**
+ * FLASH - macro names
+ * Flash - struct names
+ * flash - function names
+ * fd - FlashDisplay variable name
+ * fs - FlashScreen variable name
+ */
+
+#include "flash.h"
+
+#define OPTION_DISTANCE_MAX 1024
+
+#define POS_TOP 0
+#define POS_BOTTOM 1
+#define POS_LEFT 2
+#define POS_RIGHT 3
+
+COMPIZ_PLUGIN_20081216 (flash, FlashPluginVTable);
+
+/*
+ * flashInitiate
+ *
+ */
+bool
+FlashScreen::flashInitiate (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector options)
+{
+ /* flashInitiate is static, so we need to get vars directly */
+ FLASH_SCREEN (screen);
+ CompositeScreen *coScreen = CompositeScreen::get (screen);
+
+ fs->active = !fs->active;
+
+ /* TODO: Enable / Disable paint bits */
+
+ for(int i=0 ; i<5 ; i++)
+ {
+ fs->remainTime[i] = fs->optionGetTime () + fs->interval[i];
+ fs->lightning[i] = FALSE;
+ }
+
+ if(!fs->active)
+ coScreen->damageScreen();
+ return FALSE;
+}
+
+static bool
+pointerIsInWindow (FlashScreen *fs)
+{
+ if(!fs->existWindow)
+ return false;
+
+ if( (fs->pointX < fs->winX + fs->winW) && (fs->pointX > fs->winX) &&
+ (fs->pointY < fs->winY + fs->winH) && (fs->pointY > fs->winY) )
+ return True;
+
+ return false;
+}
+
+/*
+ * getDigression : deplacer la destination
+ *
+ */
+static int
+getDigression (FlashScreen *fs, int coord, int min, int max, int *alea)
+{
+ int ecart = fs->optionGetEcartMax ();
+
+ int interval = max - min;
+
+ int tmp=alea[0] % interval;
+
+ if(coord-min >= ecart)
+ min = coord - ecart;
+
+ if(max-coord >= ecart)
+ max=coord + ecart;
+
+ tmp = tmp * (max - min) / interval;
+
+ return (max - tmp) - coord;
+}
+
+/*
+ * getCoordTarget
+ *
+ */
+static void
+getWindowTarget (FlashScreen *fs, int* distance, int* Tx, int* Ty, int Px, int Py, int Wx, int Wy, int Ww, int Wh, int *alea)
+{
+ int distanceMax = fs->optionGetDistanceMax ();
+
+ if(Px <= Wx) *Tx=Wx;
+ else if(Px >= Wx+Ww) *Tx=Wx+Ww;
+ else *Tx=Px;
+
+ if(Py <= Wy) *Ty=Wy;
+ else if(Py >= Wy+Wh) *Ty=Wy+Wh;
+ else *Ty=Py;
+
+ *distance = sqrt( (Px - *Tx)*(Px - *Tx) + (Py - *Ty)*(Py - *Ty) );
+
+ if(*distance > 0)
+ if(*Tx == Px)
+ *Tx += getDigression(fs,Px,Wx,Wx+Ww, alea) * (*distance) / distanceMax + 1;
+ if(*Ty == Py)
+ *Ty += getDigression(fs,Py,Wy,Wy+Wh, alea) * (*distance) / distanceMax + 1;
+}
+
+
+
+/*
+ * getScreenTarget
+ *
+ */
+static void
+getScreenTarget (CompScreen *s, int* distance, int* Tx, int* Ty, int Sx, int Sy, int Sw, int Sh, int *alea, int location)
+{
+ FLASH_SCREEN (s);
+
+ int min=0;
+ int max=0;
+ int distanceMax = fs->optionGetDistanceMax ();
+
+ switch(location)
+ {
+ case POS_TOP:
+ *Tx=fs->pointX;
+ *Ty=Sy;
+ min=Sx;
+ max=Sx+Sw;
+ if(!fs->existWindow)
+ break;
+
+ if(fs->pointX < fs->winX && fs->pointY > fs->winY)
+ max=fs->winX;
+
+ else if(fs->pointX > fs->winX + fs->winW && fs->pointY > fs->winY)
+ min=fs->winX+fs->winW;
+
+ else if(fs->pointY >= fs->winY + fs->winH)
+ *Ty=fs->pointY;
+ break;
+
+ case POS_BOTTOM:
+ *Tx=fs->pointX;
+ *Ty=Sy+Sh;
+ min=Sx;
+ max=Sx+Sw;
+ if(!fs->existWindow)
+ break;
+
+ if(fs->pointX < fs->winX && fs->pointY < fs->winY+fs->winH)
+ max=fs->winX;
+
+ else if(fs->pointX > fs->winX+fs->winW && fs->pointY < fs->winY+fs->winH)
+ min=fs->winX+fs->winW;
+
+ else if(fs->pointY <= fs->winY)
+ *Ty=fs->pointY;
+ break;
+
+ case POS_LEFT:
+ *Ty=fs->pointY;
+ *Tx=Sx;
+ min=Sy;
+ max=Sy+Sh;
+ if(!fs->existWindow)
+ break;
+
+ if(fs->pointY < fs->winY && fs->pointX > fs->winX)
+ max=fs->winY;
+
+ else if(fs->pointY > fs->winY+fs->winH && fs->pointX > fs->winX)
+ min = fs->winY + fs->winH;
+
+ else if(fs->pointX >= fs->winX + fs->winW)
+ *Tx=fs->pointX;
+ break;
+
+ case POS_RIGHT:
+ *Ty=fs->pointY;
+ *Tx=Sx+Sw;
+ min=Sy;
+ max=Sy+Sh;
+ if(!fs->existWindow)
+ break;
+
+ if(fs->pointY < fs->winY && fs->pointX < fs->winX+fs->winW)
+ max=fs->winY;
+
+ else if(fs->pointY > fs->winY+fs->winH && fs->pointX < fs->winX+fs->winW)
+ min=fs->winY+fs->winH;
+
+ else if(fs->pointX <= fs->winX)
+ *Tx=fs->pointX;
+ break;
+
+ default:
+ break;
+ }
+
+ *distance = sqrt( (fs->pointX - *Tx)*(fs->pointX - *Tx) + (fs->pointY - *Ty)*(fs->pointY - *Ty) );
+
+ if(*distance > 0)
+ if(*Tx == fs->pointX)
+ *Tx += getDigression(fs,fs->pointX,min,max, alea) * (*distance) / distanceMax + 1;
+ if(*Ty == fs->pointY)
+ *Ty += getDigression(fs,fs->pointY,min,max, alea) * (*distance) / distanceMax + 1;
+}
+
+
+/*
+ * getWay : fonction du chemin semi-aleatoire
+ *
+ */
+static int
+getWay(int xy, int distance, int *alea)
+{
+
+ double pi = 4 * atan (1.0);
+ int resultat = 0;
+ int amplitude = distance * xy / (distance + xy);
+ int i;
+ int ms = alea[0] % 100;
+
+ if(ms <= 50)
+ resultat += ms * amplitude * cos( xy * pi / (2*distance));
+ else
+ resultat += -(ms - 50) * amplitude * cos( xy * pi / (2*distance));
+
+ for(i=1;i<10;i++)
+ {
+ resultat += (alea[i] % 100) * amplitude * cos( pow(2,i) * xy * pi * (alea[i] % 100) / (20 * distance) ) * (distance - xy) / (distance * 5 * (i + 1));
+ }
+
+ return (resultat / 100);
+}
+
+
+static void
+getCoordinateArray (double** CoordinateArray ,int distance, int Tx, int Ty, int Px, int Py, int* tailleTab, int* alea, int numero)
+{
+ int i;
+ double Mx,My;
+ int ecart;
+
+ *tailleTab=distance;
+ //courbe demarre au pointeur de la souris
+ CoordinateArray[0][0]=0;
+ CoordinateArray[0][1]=0;
+
+ for(i=1;i<distance;i++)
+ {
+ Mx=((double)i / (double)distance)*(Tx-Px);
+ My=((double)i / (double)distance)*(Ty-Py);
+
+ ecart = getWay(i, distance,alea) + numero;
+
+ CoordinateArray[i][0] = Mx + (double) ecart * (Ty-Py) / distance;
+ CoordinateArray[i][1] = My + (double) ecart * (Tx-Px) / distance;
+ }
+}
+
+/*
+ * flashPreparePaintOutput
+ *
+ */
+void
+FlashScreen::preparePaint (int msSinceLastPaint)
+{
+
+ CompWindow *w;
+ Window root, child;
+ int winx, winy;
+ int i,j;
+ unsigned int pmask;
+
+
+ if(active)
+ {
+
+ //Get informations about active window
+ w = screen->findWindow (screen->activeWindow ());
+ if(w)
+ {
+
+ if(optionGetWindowTypes ().evaluate (w))
+ existWindow=TRUE;
+ else
+ existWindow=FALSE;
+
+ winW=w->width () + w->input ().left + w->input ().right;
+ winH=w->height () + w->input ().top + w->input ().bottom;
+ winX=w->x () - w->input ().left;
+ winY=w->y () - w->input ().top;
+ }
+ else
+ {
+ existWindow=FALSE;
+ winW=0;
+ winH=0;
+ winX=0;
+ winY=0;
+ isAnimated = FALSE;
+ }
+
+
+ //test if an other plugin is used at this time.
+ if(screen->otherGrabExist (0))
+ anotherPluginIsUsing = TRUE;
+ else
+ anotherPluginIsUsing = FALSE;
+
+ //get position of pointer
+ XQueryPointer(screen->dpy (), screen->root (), &root, &child, &(pointX), &(pointY), &winx, &winy, &pmask);
+
+ int time = optionGetTime ();
+
+ for(i = 0 ; i < 5 ; i++)
+ {
+ remainTime[i] -= msSinceLastPaint;
+
+ if(remainTime[i] < 0)
+ {
+ lightning[i] = FALSE;
+ remainTime[i] = interval[i] + time;
+
+ srand(alea[i][1] * (pointX+1) * (pointY+1) / (interval[i] + 1) );
+ for(j=0;j<10;j++)
+ alea[i][j]=(int) rand();
+ }
+ else
+ {
+ if( (remainTime[i]) < time )
+ lightning[i] = TRUE;
+ }
+ }
+ }
+
+ cScreen->preparePaint (msSinceLastPaint);
+}
+
+/*
+ * flashDonePaintScreen
+ *
+ */
+void
+FlashScreen::donePaint ()
+{
+ if(active)
+ cScreen->damageScreen();
+
+ cScreen->donePaint ();
+}
+
+/*
+ * flashPaintOutput
+ *
+ */
+bool
+FlashScreen::glPaintOutput (const GLScreenPaintAttrib &attrib,
+ const GLMatrix &transform,
+ const CompRegion &region,
+ CompOutput *output,
+ unsigned int mask)
+{
+ bool status;
+
+ gScreen->glPaintOutput (attrib, transform, region, output, mask);
+
+ int x1, y1;
+ x1 = pointX;
+ y1 = pointY;
+
+ int x2, y2;
+ int distanceToWindow;
+ int i,j;
+
+ if(!active || pointerIsInWindow(this) || anotherPluginIsUsing)
+ return status;
+
+ glPushMatrix(); //sauve la matrice courante
+ glLoadIdentity();//remplace la matrice courante par la matrice identite
+ glTranslatef (-0.5f, -0.5f, DEFAULT_Z_CAMERA);
+ glScalef (1.0f / output->width (),
+ -1.0f / output->height (),
+ 1.0f);
+ glTranslatef (-output->x1 (),
+ -output->y2 (),
+ 0.0f);
+
+ glEnable(GL_BLEND);//active le melange des couleurs (glBlendFunc)
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);//permet les effets de transparence
+
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+
+ glTranslatef(x1, y1, 0);
+
+ glLineWidth(2);
+
+ //lightning between pointer and active window
+ if(lightning[0])
+ {
+ getWindowTarget(this, &distanceToWindow, &x2, &y2, x1, y1, winX, winY, winW, winH, alea[0]);
+
+ if(existWindow && distanceToWindow < optionGetDistanceMax () && !isAnimated)
+ {
+ //changement de la frequence d'apparition en fonction de la distance
+ interval[0] = (optionGetInterval () + distanceToWindow) * (alea[0][1]%400) / 200;// * 2 / fd->opt[FLASH_DISPLAY_OPTION_DISTANCE_MAX].value.i;
+
+ //affichage du trait du haut ou a gauche
+ glBegin(GL_LINE_STRIP);
+ glColor4f(
+ optionGetFlashColorUpLeftRed () / 0xffff,
+ optionGetFlashColorUpLeftGreen () / 0xffff,
+ optionGetFlashColorUpLeftBlue () / 0xffff,
+ optionGetFlashColorUpLeftAlpha () / 0xffff);
+ //remplissage du tableau de coordonnees
+ getCoordinateArray(CoordinateArray, distanceToWindow, x2, y2, x1, y1, &(tailleTab), alea[0], -2);
+ for(i=0;i<tailleTab;i++)
+ glVertex2dv(CoordinateArray[i]);
+ glEnd();
+
+ //affichage du trait central
+ glBegin(GL_LINE_STRIP);
+ glColor4f(
+ optionGetFlashColorCenterRed () / 0xffff,
+ optionGetFlashColorCenterGreen () / 0xffff,
+ optionGetFlashColorCenterBlue () / 0xffff,
+ optionGetFlashColorCenterAlpha () / 0xffff);
+ //remplissage du tableau de coordonnees
+ getCoordinateArray(CoordinateArray, distanceToWindow, x2, y2, x1, y1, &(tailleTab), alea[0], 0);
+ for(i=0;i<tailleTab;i++)
+ glVertex2dv(CoordinateArray[i]);
+ glEnd();
+
+ //affichage du trait du bas ou a droite
+ glBegin(GL_LINE_STRIP);
+ glColor4f(
+ optionGetFlashColorDownRightRed () / 0xffff,
+ optionGetFlashColorDownRightGreen () / 0xffff,
+ optionGetFlashColorDownRightBlue () / 0xffff,
+ optionGetFlashColorDownRightAlpha () / 0xffff);
+ //remplissage du tableau de coordonnees
+ getCoordinateArray(CoordinateArray, distanceToWindow, x2, y2, x1, y1, &(tailleTab), alea[0], 2);
+ for(i=0;i<tailleTab;i++)
+ glVertex2dv(CoordinateArray[i]);
+ glEnd();
+ }
+ }
+
+ for(i=1;i<5;i++)
+ {
+ if(lightning[i])
+ {
+ CompPoint p (screen->vp ());
+
+ getScreenTarget(screen, &distanceToWindow, &x2, &y2, p.x (), p.y (), screen->width (), screen->height (), alea[i], i-1);
+
+ if(distanceToWindow < optionGetDistanceMax () )
+ {
+ //changement de la frequence d'apparition en fonction de la distance
+ interval[i] = optionGetInterval () + distanceToWindow * (alea[i][1]%600) / 200; // / fd->opt[FLASH_DISPLAY_OPTION_DISTANCE_MAX].value.i;
+
+ //affichage du trait du haut ou a gauche
+ glBegin(GL_LINE_STRIP);
+ glColor4f(
+ optionGetFlashColorUpLeftRed () / 0xffff,
+ optionGetFlashColorUpLeftGreen () / 0xffff,
+ optionGetFlashColorUpLeftBlue () / 0xffff,
+ optionGetFlashColorUpLeftAlpha () / 0xffff);
+ //remplissage du tableau de coordonnees
+ getCoordinateArray(CoordinateArray, distanceToWindow, x2, y2, x1, y1, &(tailleTab), alea[i], -2);
+ for(j=0;j<tailleTab;j++)
+ glVertex2dv(CoordinateArray[j]);
+ glEnd();
+
+ //affichage du trait central
+ glBegin(GL_LINE_STRIP);
+ glColor4f(
+ optionGetFlashColorCenterRed () / 0xffff,
+ optionGetFlashColorCenterGreen () / 0xffff,
+ optionGetFlashColorCenterBlue () / 0xffff,
+ optionGetFlashColorCenterAlpha () / 0xffff);
+ //remplissage du tableau de coordonnees
+ getCoordinateArray(CoordinateArray, distanceToWindow, x2, y2, x1, y1, &(tailleTab), alea[i], 0);
+ for(j=0;j<tailleTab;j++)
+ glVertex2dv(CoordinateArray[j]);
+ glEnd();
+
+ //affichage du trait du bas ou a droite
+ glBegin(GL_LINE_STRIP);
+ glColor4f(
+ optionGetFlashColorDownRightRed () / 0xffff,
+ optionGetFlashColorDownRightGreen () / 0xffff,
+ optionGetFlashColorDownRightBlue () / 0xffff,
+ optionGetFlashColorDownRightAlpha () / 0xffff);
+ //remplissage du tableau de coordonnees
+ getCoordinateArray(CoordinateArray, distanceToWindow, x2, y2, x1, y1, &(tailleTab), alea[i], 2);
+ for(j=0;j<tailleTab;j++)
+ glVertex2dv(CoordinateArray[j]);
+ glEnd();
+ }
+ }
+ }
+ glTranslatef(-x1, -y1, 0);
+
+ glColor4usv(defaultColor);
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ glDisable(GL_BLEND);
+ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ glPopMatrix();
+
+ return status;
+}
+
+
+FlashScreen::FlashScreen (CompScreen *screen) :
+ PrivateHandler <FlashScreen, CompScreen> (screen),
+ FlashOptions (flashVTable->getMetadata ()),
+ cScreen (CompositeScreen::get (screen)),
+ gScreen (GLScreen::get (screen)),
+ CoordinateArray ((double **) malloc (OPTION_DISTANCE_MAX * sizeof (double *))),
+ remainTime ((int *) malloc (5 * sizeof (int))),
+ interval ((int *) malloc (5 * sizeof (int))),
+ alea ((int **) malloc (5 * sizeof (int *))),
+ active (false),
+ lightning ((bool *) malloc (5 * sizeof (bool)))
+{
+ ScreenInterface::setHandler (screen);
+ CompositeScreenInterface::setHandler (cScreen);
+ GLScreenInterface::setHandler (gScreen);
+
+ for(int i=0; i<OPTION_DISTANCE_MAX; i++)
+ CoordinateArray[i]=(double*)malloc(2*sizeof(double));
+
+ for(int i=0;i<5;i++)
+ {
+ lightning[i] = FALSE;
+
+ alea[i]=(int*) malloc(10 * sizeof(int));
+
+ interval[i] = optionGetInterval ();
+ remainTime[i] = optionGetTime () + interval[i];
+
+ srand(1);
+ for(int j=0;j<10;j++)
+ alea[i][j]=(int) rand();
+
+ }
+
+ optionSetInitiateButtonInitiate (flashInitiate);
+ optionSetInitiateKeyInitiate (flashInitiate);
+
+}
+
+bool
+FlashPluginVTable::init ()
+{
+
+ if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION) ||
+ !CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI) ||
+ !CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI))
+ return false;
+
+ return true;
+}
diff --git a/flash.h b/flash.h
new file mode 100644
index 0000000..4dc8582
--- /dev/null
+++ b/flash.h
@@ -0,0 +1,108 @@
+/**
+*
+* Compiz plugin Flash
+*
+* Copyright : (C) 2007 by Jean-Fran�is Souville & Charles Jeremy
+* E-mail : souville@ecole.ensicaen.fr , charles@ecole.ensicaen.fr
+*
+* Ported to compiz++ by:
+* Sam Spilsbury <smspillaz@gmail.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.
+*
+*/
+
+#include <math.h>
+
+#include <core/core.h>
+#include <core/privatehandler.h>
+
+#include <opengl/opengl.h>
+#include <composite/composite.h>
+
+#include "flash_options.h"
+
+#define POS_TOP 0
+#define POS_BOTTOM 1
+#define POS_LEFT 2
+#define POS_RIGHT 3
+
+class FlashScreen :
+ public PrivateHandler <FlashScreen, CompScreen>,
+ public ScreenInterface,
+ public CompositeScreenInterface,
+ public GLScreenInterface,
+ public FlashOptions
+{
+ public:
+
+ FlashScreen (CompScreen *);
+
+ CompositeScreen *cScreen;
+ GLScreen *gScreen;
+
+ int pointX, pointY;
+ int winX,winY,winW,winH;
+
+ double** CoordinateArray;
+
+ int tailleTab;
+
+ int *remainTime;
+
+ int *interval;
+
+ int** alea;
+
+ int location;
+
+ unsigned int WindowMask;
+
+ bool active;
+ bool *lightning;
+
+ bool existWindow;
+
+ bool isAnimated;
+ bool anotherPluginIsUsing;
+
+ void
+ preparePaint (int ms);
+
+ bool
+ glPaintOutput (const GLScreenPaintAttrib &sAttrib,
+ const GLMatrix &transform,
+ const CompRegion &region,
+ CompOutput *output,
+ unsigned int mask);
+
+ void
+ donePaint ();
+
+ static bool
+ flashInitiate (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector options);
+};
+
+#define FLASH_SCREEN(s) \
+ FlashScreen *fs = FlashScreen::get (s)
+
+class FlashPluginVTable :
+ public CompPlugin::VTableForScreen <FlashScreen>
+{
+ public:
+
+ bool
+ init ();
+
+ PLUGIN_OPTION_HELPER (FlashScreen);
+};
diff --git a/flash.xml b/flash.xml.in
index 9abec47..fd1a95c 100644
--- a/flash.xml
+++ b/flash.xml.in
@@ -1,51 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<compiz>
- <plugin name="flash">
- <short>Lightning Bolts</short>
- <long>Lightning bolts between your cursor and the nearest window</long>
- <display>
+ <plugin name="flash" useBcop="true">
+ <_short>Lightning Bolts</_short>
+ <_long>Lightning bolts between your cursor and the nearest window</_long>
+ <screen>
<option type="key" name="initiate_key">
- <short>Initiate</short>
- <long>Start flash</long>
+ <_short>Initiate</_short>
+ <_long>Start flash</_long>
<default>
<key>&lt;Super&gt;F5</key>
</default>
</option>
<option type="button" name="initiate_button">
- <short>Initiate</short>
- <long>Start flash</long>
+ <_short>Initiate</_short>
+ <_long>Start flash</_long>
</option>
<option type="int" name="distance_max">
- <short>Distance max</short>
- <long>Distance max between pointer and active window.</long>
+ <_short>Distance max</_short>
+ <_long>Distance max between pointer and active window.</_long>
<default>800</default>
<min>50</min>
<max>1024</max>
</option>
<option type="int" name="ecart_max">
- <short>Digression max</short>
- <long>Digression max between pointer's projection and lightning's impact.</long>
+ <_short>Digression max</_short>
+ <_long>Digression max between pointer's projection and lightning's impact.</_long>
<default>800</default>
<min>0</min>
<max>1024</max>
</option>
<option type="int" name="interval">
- <short>Minimum interval between two lightning</short>
- <long>Interval in milliseconde between two lightning</long>
+ <_short>Minimum interval between two lightning</_short>
+ <_long>Interval in milliseconde between two lightning</_long>
<default>200</default>
<min>0</min>
<max>2000</max>
</option>
<option type="int" name="time">
- <short>Time of lightnings</short>
- <long>Time in milliseconds of lightnings</long>
+ <_short>Time of lightnings</_short>
+ <_long>Time in milliseconds of lightnings</_long>
<default>100</default>
<min>50</min>
<max>300</max>
</option>
<option type="color" name="flash_color_up_left">
- <short>Side of lightnings color</short>
- <long></long>
+ <_short>Side of lightnings color</_short>
+ <_long></_long>
<default>
<red>0x3333</red>
<green>0x4444</green>
@@ -54,8 +54,8 @@
</default>
</option>
<option type="color" name="flash_color_center">
- <short>Middle of lightnings color</short>
- <long>Middle of lightnings color</long>
+ <_short>Middle of lightnings color</_short>
+ <_long>Middle of lightnings color</_long>
<default>
<red>0xffff</red>
<green>0xffff</green>
@@ -64,8 +64,8 @@
</default>
</option>
<option type="color" name="flash_color_down_right">
- <short>The other side of lightnings color</short>
- <long>The other side of lightnings color</long>
+ <_short>The other side of lightnings color</_short>
+ <_long>The other side of lightnings color</_long>
<default>
<red>0x3333</red>
<green>0x4444</green>
@@ -73,11 +73,9 @@
<alpha>0x4FFF</alpha>
</default>
</option>
- </display>
- <screen>
<option type="match" name="window_types">
- <short>Window Types</short>
- <long>The window types that lightning bolts will hit</long>
+ <_short>Window Types</_short>
+ <_long>The window types that lightning bolts will hit</_long>
<default>Dialog | Normal</default>
</option>
</screen>
diff --git a/libflash.la b/libflash.la
deleted file mode 100644
index 32089c7..0000000
--- a/libflash.la
+++ /dev/null
@@ -1,35 +0,0 @@
-# libflash.la - a libtool library file
-# Generated by ltmain.sh - GNU libtool 1.5.24 (1.1220.2.455 2007/06/24 02:13:29)
-#
-# Please DO NOT delete this file!
-# It is necessary for linking the library.
-
-# The name that we can dlopen(3).
-dlname='libflash.so.0'
-
-# Names of this library.
-library_names='libflash.so.0.0.0 libflash.so.0 libflash.so'
-
-# The name of the static archive.
-old_library='libflash.a'
-
-# Libraries that this one depends upon.
-dependency_libs=' /usr/lib/libX11-xcb.la /usr/lib/libXcomposite.la /usr/lib/libXdamage.la /usr/lib/libXrandr.la /usr/lib/libXinerama.la /usr/lib/libXext.la /usr/lib/libxslt.la -L/usr/lib /usr/lib/libstartup-notification-1.la /usr/lib/libSM.la /usr/lib/libXfixes.la -lICE /usr/lib/libxml2.la /usr/lib/libcairo.la /usr/lib/libfontconfig.la /usr/lib/libfreetype.la -lexpat /usr/lib/libglitz.la /usr/lib/libpng12.la -lz /usr/lib/libxcb-render-util.la /usr/lib/libxcb-render.la /usr/lib/libXrender.la /usr/lib/libX11.la /usr/lib/libxcb-xlib.la /usr/lib/libxcb.la /usr/lib/libXau.la -ldl -lm'
-
-# Version information for libflash.
-current=0
-age=0
-revision=0
-
-# Is this an already installed library?
-installed=no
-
-# Should we warn about portability when linking against -modules?
-shouldnotlink=no
-
-# Files to dlopen/dlpreopen
-dlopen=''
-dlpreopen=''
-
-# Directory that this library needs to be installed in:
-libdir='/home/Sam/.compiz/plugins'
diff --git a/plugin.info b/plugin.info
new file mode 100644
index 0000000..93ac5a1
--- /dev/null
+++ b/plugin.info
@@ -0,0 +1,2 @@
+PLUGIN = flash
+PKG_DEP = compiz-opengl compiz-composite