summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile463
-rw-r--r--cubedbus-types.h2
-rw-r--r--cubedbus.c510
-rw-r--r--cubedbus.h46
-rw-r--r--cubedbus.xml.in25
-rw-r--r--plugin.info2
6 files changed, 1048 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/cubedbus-types.h b/cubedbus-types.h
new file mode 100644
index 0000000..05c728d
--- /dev/null
+++ b/cubedbus-types.h
@@ -0,0 +1,2 @@
+#define CUBEDBUS_COLOUR_OBJECT 1
+#define CUBEDBUS_TEXTURE_OBJECT 2
diff --git a/cubedbus.c b/cubedbus.c
new file mode 100644
index 0000000..c9cb93c
--- /dev/null
+++ b/cubedbus.c
@@ -0,0 +1,510 @@
+
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <signal.h>
+#include <unistd.h>
+#include <math.h>
+
+#include <compiz-core.h>
+#include <compiz-cube.h>
+
+#include "cubedbus_options.h"
+#include "cubedbus.h"
+
+#define PI 3.14159
+
+static int displayPrivateIndex;
+
+static int cubeDisplayPrivateIndex;
+
+typedef struct _CubedbusDisplay
+{
+ int screenPrivateIndex;
+
+}
+CubedbusDisplay;
+
+typedef struct _CubedbusScreen
+{
+ DonePaintScreenProc donePaintScreen;
+ PreparePaintScreenProc preparePaintScreen;
+
+ CubeClearTargetOutputProc clearTargetOutput;
+ CubePaintInsideProc paintInside;
+
+ Bool damage;
+
+ CubedbusObject *head;
+
+}
+CubedbusScreen;
+
+#define GET_CUBEDBUS_DISPLAY(d) \
+ ((CubedbusDisplay *) (d)->base.privates[displayPrivateIndex].ptr)
+#define CUBEDBUS_DISPLAY(d) \
+ CubedbusDisplay *gd = GET_CUBEDBUS_DISPLAY(d); /* Macros to get the gd pointer to CubedbusDisplay struct */
+
+#define GET_CUBEDBUS_SCREEN(s, gd) \
+ ((CubedbusScreen *) (s)->base.privates[(gd)->screenPrivateIndex].ptr)
+#define CUBEDBUS_SCREEN(s) \
+ CubedbusScreen *gs = GET_CUBEDBUS_SCREEN(s, GET_CUBEDBUS_DISPLAY(s->display)) /* Macros to get the gs pointer to CubedbusScreen struct */
+
+
+static Bool
+cubedbusAddObject (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
+{
+ //get gs pointer
+ CompScreen *s;
+ Window xid;
+ xid = getIntOptionNamed (option, nOption, "root", 0);
+ s = findScreenAtDisplay (d, xid);
+ CUBEDBUS_SCREEN(s);
+
+ compLogMessage (NULL, "cubedbus", CompLogLevelWarn, "Adding Object");
+
+ GLint err;
+ while((err=glGetError())){
+ compLogMessage (NULL, "cubedbus", CompLogLevelError, "before %d",err);}
+
+
+ CubedbusObject *objptr;
+ objptr=gs->head;
+
+ if (gs->head == NULL)
+ {
+ gs->head = malloc (sizeof(CubedbusObject));
+ if(gs->head == NULL) return FALSE;
+ objptr=gs->head;
+ objptr->prev = NULL;
+ }
+ else
+ {
+ while(1)
+ {
+ if(objptr->next == NULL )
+ {
+ objptr->next = malloc (sizeof(CubedbusObject));
+ if(objptr->next == NULL) return FALSE;
+ objptr->next->prev=objptr;
+ objptr=objptr->next; /* objptr now points to newly created object */
+ }
+ else objptr=objptr->next;
+ }
+ }
+
+ /* have now created CubedbusObject */
+
+ objptr->next=NULL;
+ objptr->type=getIntOptionNamed (option,nOption, "type", 0);
+ if(objptr->type == 0) return FALSE;
+ objptr->name=getStringOptionNamed (option,nOption,"name", "");
+ if(strcmp(objptr->name,"") == 0) return FALSE;
+
+ switch (objptr->type)
+ {
+ case CUBEDBUS_COLOUR_OBJECT:
+ {
+ compLogMessage (NULL, "cubedbus", CompLogLevelWarn, "Adding ColourObject");
+
+ objptr->func=&cubedbusDrawColourObject;
+ objptr->data= malloc( sizeof(CubedbusColourObject) );
+ if(objptr->data == NULL) return FALSE;
+
+ CubedbusColourObject *colourData=objptr->data;
+
+ colourData->rotate[0]=getFloatOptionNamed (option,nOption, "rotateAngle", 0.0);
+ colourData->rotate[1]=getFloatOptionNamed (option,nOption, "rotateX", 1.0);
+ colourData->rotate[2]=getFloatOptionNamed (option,nOption, "rotateY", 0.0);
+ colourData->rotate[3]=getFloatOptionNamed (option,nOption, "rotateZ", 0.0);
+ colourData->translate[0]=getFloatOptionNamed (option,nOption, "translateX", 0.0);
+ colourData->translate[1]=getFloatOptionNamed (option,nOption, "translateY", 0.0);
+ colourData->translate[2]=getFloatOptionNamed (option,nOption, "translateZ", 0.0);
+ colourData->scale[0]=getFloatOptionNamed (option,nOption, "scaleX", 1.0);
+ colourData->scale[1]=getFloatOptionNamed (option,nOption, "scaleY", 1.0);
+ colourData->scale[2]=getFloatOptionNamed (option,nOption, "scaleZ", 1.0);
+ colourData->order=getBoolOptionNamed (option, nOption, "order", TRUE);
+
+ compLogMessage (NULL, "cubedbus", CompLogLevelWarn, "translate %f", colourData->translate[0]);
+
+ /* Code to make dList */
+
+ colourData->dList=glGenLists (1);
+ glNewList (colourData->dList, GL_COMPILE);
+
+
+ int i;
+ float r,g,b,a;
+ float x,y,z;
+ char string[4];
+
+ glBegin(GL_POLYGON);
+
+ for(i=0;i</*num*/3;i++)
+ {
+ sprintf(string,"r%d",i);
+ r=getFloatOptionNamed (option, nOption, string, 1.0 );
+ sprintf(string,"g%d",i);
+ g=getFloatOptionNamed (option, nOption, string, 0.0 );
+ sprintf(string,"b%d",i);
+ b=getFloatOptionNamed (option, nOption, string, 0.0 );
+ sprintf(string,"a%d",i);
+ a=getFloatOptionNamed (option, nOption, string, 1.0 );
+ sprintf(string,"x%d",i);
+ x=getFloatOptionNamed (option, nOption, string, 0.0);
+ sprintf(string,"y%d",i);
+ y=getFloatOptionNamed (option, nOption, string, 0.0);
+ sprintf(string,"z%d",i);
+ z=getFloatOptionNamed (option, nOption, string, 0.0 );
+
+
+ glColor4f(r,g,b,a);
+ glVertex3f( x, y, z);
+ }
+ glEnd();
+
+ glEndList();
+
+
+ return TRUE;
+ break;
+ }
+ case CUBEDBUS_TEXTURE_OBJECT:
+ {
+ return TRUE;
+ break;
+ }
+ }
+
+ return FALSE;
+}
+
+/* Drawing functions */
+
+static bool
+cubedbusDrawColourObject (CubedbusObject *obj)
+{
+ glShadeModel (GL_SMOOTH);
+
+ CubedbusColourObject *data=obj->data;
+
+ if(data->order) glTranslatef (data->translate[0], data->translate[1], data->translate[2]);
+ glRotatef ( data->rotate[0], data->rotate[1], data->rotate[2], data->rotate[3]);
+ if(!(data->order)) glTranslatef (data->translate[0], data->translate[1], data->translate[2]);
+
+ glScalef( data->scale[0],data->scale[1], data->scale[2]); /* Rotate, translate and scale */
+
+
+
+ glCallList(data->dList);
+
+
+
+
+ return TRUE;
+}
+
+static bool
+cubedbusDrawTextureObject (CubedbusObject *obj)
+{
+ return TRUE;
+}
+
+/* Standard plugin 'stuff' */
+
+static void
+cubedbusClearTargetOutput (CompScreen *s, /* Doesn't do anything except glClear(GL_DEPTH_BUFFER_BIT)? - cube must change it? */
+ float xRotate,
+ float vRotate)
+{
+ CUBEDBUS_SCREEN (s);
+ CUBE_SCREEN (s);
+
+ UNWRAP (gs, cs, clearTargetOutput);
+ (*cs->clearTargetOutput) (s, xRotate, vRotate);
+ WRAP (gs, cs, clearTargetOutput, cubedbusClearTargetOutput);
+
+ glClear (GL_DEPTH_BUFFER_BIT);
+}
+
+static void /* draws the cubedbus, then calls the cube function */
+cubedbusPaintInside (CompScreen *s,
+ const ScreenPaintAttrib *sAttrib,
+ const CompTransform *transform,
+ CompOutput *output,
+ int size)
+{
+ CUBEDBUS_SCREEN (s);
+ CUBE_SCREEN (s);
+
+ Bool enabled;
+
+ ScreenPaintAttrib sA = *sAttrib;
+
+ sA.yRotate += (360.0f / size) * (cs->xRotations - (s->x * cs->nOutput)); /*?*/
+
+ CompTransform mT = *transform;
+
+ (*s->applyScreenTransform) (s, &sA, output, &mT);
+
+ glPushMatrix();
+ glLoadMatrixf (mT.m);
+ glTranslatef (cs->outputXOffset, -cs->outputYOffset, 0.0f); /* OpenGL stuff to set correct transformation due to cube rotation? */
+ glScalef (cs->outputXScale, cs->outputYScale, 1.0f);
+
+ glPushAttrib (GL_COLOR_BUFFER_BIT | GL_TEXTURE_BIT);
+
+ enabled = glIsEnabled (GL_CULL_FACE);
+
+ glDisable(GL_CULL_FACE);
+
+
+ glPushMatrix();
+
+ glDisable (GL_LIGHTING);
+ glDisable (GL_COLOR_MATERIAL);
+ glEnable (GL_DEPTH_TEST);
+
+/*********************************************/
+
+ CubedbusObject *obj=gs->head;
+
+ while(true)
+ {
+ if(obj == NULL) break; /* pull out of loop if finished drawing all objects */
+
+ glPushMatrix();
+
+ if(!( (obj->func) (obj) )) compLogMessage(NULL, "cubedbus", CompLogLevelWarn, "error calling function") ; /* Call function */
+
+ glPopMatrix();
+
+ obj = obj->next;
+ }
+
+/**********************************************/
+
+ glPopMatrix();
+
+ glEnable (GL_COLOR_MATERIAL);
+
+ if (s->lighting)
+ glEnable (GL_LIGHTING);
+
+ glDisable (GL_DEPTH_TEST);
+ glDisable (GL_BLEND);
+
+ if (enabled) glEnable (GL_CULL_FACE);
+ else glDisable (GL_CULL_FACE); /* resets settings to original */
+
+ glPopMatrix();
+ glPopAttrib();
+
+ gs->damage = TRUE;
+
+ UNWRAP (gs, cs, paintInside);
+ (*cs->paintInside) (s, sAttrib, transform, output, size);
+ WRAP (gs, cs, paintInside, cubedbusPaintInside);
+}
+
+static void
+cubedbusPreparePaintScreen (CompScreen *s,
+ int ms)
+{
+ CUBEDBUS_SCREEN (s);
+
+ /* check for messages */
+
+ UNWRAP (gs, s, preparePaintScreen);
+ (*s->preparePaintScreen) (s, ms);
+ WRAP (gs, s, preparePaintScreen, cubedbusPreparePaintScreen);
+}
+
+static void /* Calls damageScreen ? */
+cubedbusDonePaintScreen (CompScreen * s)
+{
+ CUBEDBUS_SCREEN (s);
+
+ if (gs->damage)
+ {
+ damageScreen (s);
+ gs->damage = FALSE;
+ }
+
+ UNWRAP (gs, s, donePaintScreen);
+ (*s->donePaintScreen) (s);
+ WRAP (gs, s, donePaintScreen, cubedbusDonePaintScreen);
+}
+
+/* Inits display */
+
+static Bool
+cubedbusInitDisplay (CompPlugin *p,
+ CompDisplay *d)
+{
+ CubedbusDisplay *gd;
+
+ if (!checkPluginABI ("core", CORE_ABIVERSION) ||
+ !checkPluginABI ("cube", CUBE_ABIVERSION))
+ return FALSE;
+
+ if (!getPluginDisplayIndex (d, "cube", &cubeDisplayPrivateIndex))
+ return FALSE;
+
+ gd = malloc (sizeof (CubedbusDisplay)); /* creates data struct - remainder is error checking */
+
+ if (!gd)
+ return FALSE;
+
+ gd->screenPrivateIndex = allocateScreenPrivateIndex (d);
+
+ if (gd->screenPrivateIndex < 0)
+ {
+ free (gd);
+ return FALSE;
+ }
+
+ d->base.privates[displayPrivateIndex].ptr = gd; /* allows use of CUBEDBUS_DISPLAY macro */
+
+ cubedbusSetAddInitiate (d, cubedbusAddObject);
+
+
+ return TRUE;
+}
+
+static void
+cubedbusFiniDisplay (CompPlugin *p,
+ CompDisplay *d)
+{
+ CUBEDBUS_DISPLAY (d);
+
+ freeScreenPrivateIndex (d, gd->screenPrivateIndex);
+ free (gd);
+}
+
+
+/* Function which is run when screen is initialized */
+
+static Bool
+cubedbusInitScreen (CompPlugin *p,
+ CompScreen *s)
+{
+ CubedbusScreen *gs;
+
+ CUBEDBUS_DISPLAY (s->display); /* sets gd pointer used below */
+
+ CUBE_SCREEN (s);
+
+ gs = malloc (sizeof (CubedbusScreen) ); /* creates gearScreen struct */
+
+ if (!gs)
+ return FALSE;
+
+ s->base.privates[gd->screenPrivateIndex].ptr = gs; /* For the CUBEDBUS_SCREEN macro to work */
+
+ gs->head= NULL;
+
+
+ WRAP (gs, s, donePaintScreen, cubedbusDonePaintScreen); /*Functions version of ... is called instead of cores (which then also calls core function) */
+ WRAP (gs, s, preparePaintScreen, cubedbusPreparePaintScreen);
+ WRAP (gs, cs, clearTargetOutput, cubedbusClearTargetOutput);
+ WRAP (gs, cs, paintInside, cubedbusPaintInside);
+
+ return TRUE;
+
+}
+
+/* Fuction is run when screen is uninitialized */
+
+static void
+cubedbusFiniScreen (CompPlugin *p,
+ CompScreen *s)
+{
+ CUBEDBUS_SCREEN (s); /*Sets the pointers cs gs */
+ CUBE_SCREEN (s);
+
+
+
+
+ UNWRAP (gs, s, donePaintScreen); /* gs is pointer to structure GearScreen, s is pointer to structure screen? - these functions are core functions*/
+ UNWRAP (gs, s, preparePaintScreen);
+
+ UNWRAP (gs, cs, clearTargetOutput); /* ... cs is pointer to structure CubeScreen? - these two functions are part of the Cube plugin*/
+ UNWRAP (gs, cs, paintInside);
+
+
+
+ free (gs);
+}
+
+/* Load and Unload plugin */
+
+static Bool
+cubedbusInit (CompPlugin * p)
+{
+ displayPrivateIndex = allocateDisplayPrivateIndex();
+
+ if (displayPrivateIndex < 0)
+ return FALSE;
+
+ return TRUE;
+}
+
+static void
+cubedbusFini (CompPlugin * p)
+{
+ if (displayPrivateIndex >= 0)
+ freeDisplayPrivateIndex (displayPrivateIndex);
+}
+
+/* Init Object - lists functions for Core, Display and Screen */
+
+static CompBool
+cubedbusInitObject (CompPlugin *p,
+ CompObject *o)
+{
+ static InitPluginObjectProc dispTab[] = {
+ (InitPluginObjectProc) 0, /* InitCore */
+ (InitPluginObjectProc) cubedbusInitDisplay,
+ (InitPluginObjectProc) cubedbusInitScreen
+ };
+
+ RETURN_DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), TRUE, (p, o));
+}
+
+static void
+cubedbusFiniObject (CompPlugin *p,
+ CompObject *o)
+{
+ static FiniPluginObjectProc dispTab[] = {
+ (FiniPluginObjectProc) 0, /* FiniCore */
+ (FiniPluginObjectProc) cubedbusFiniDisplay,
+ (FiniPluginObjectProc) cubedbusFiniScreen
+ };
+
+ DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), (p, o));
+}
+
+/* VTable */
+
+CompPluginVTable cubedbusVTable = {
+ "cubedbus",
+ 0, /* (?) */
+ cubedbusInit,
+ cubedbusFini,
+ cubedbusInitObject,
+ cubedbusFiniObject,
+ 0, /* Get(?) Object Options */
+ 0 /* Set(?) Object Options */
+};
+
+CompPluginVTable *
+getCompPluginInfo (void)
+{
+ return &cubedbusVTable;
+}
diff --git a/cubedbus.h b/cubedbus.h
new file mode 100644
index 0000000..8fa9adf
--- /dev/null
+++ b/cubedbus.h
@@ -0,0 +1,46 @@
+#include <stdbool.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "cubedbus-types.h"
+
+#include <compiz-core.h>
+
+typedef struct _CubedbusObject CubedbusObject;
+typedef struct _CubedbusColourObject CubedbusColourObject;
+typedef struct _CubedbusTextureObject CubedbusTextureObject;
+
+static bool cubedbusDrawColourObject (CubedbusObject *obj);
+static bool cubedbusDrawTextureObject (CubedbusObject *obj);
+
+
+/* Struct containing pointer to data struct and pointer to function to draw */
+
+struct _CubedbusObject
+{
+ int type;
+ char *name;
+
+ bool (*func) (CubedbusObject *obj);
+ void *data;
+
+ CubedbusObject *next;
+ CubedbusObject *prev;
+};
+
+
+/* Structs for data for each type */
+
+struct _CubedbusColourObject
+{
+GLuint dList;
+bool order;
+float rotate[4], translate[3], scale[3];
+};
+
+struct _CubedbusTextureObject
+{
+GLuint dList;
+};
+
diff --git a/cubedbus.xml.in b/cubedbus.xml.in
new file mode 100644
index 0000000..72fe638
--- /dev/null
+++ b/cubedbus.xml.in
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<compiz>
+ <plugin name="cubedbus" useBcop="true">
+ <_short>Draw inside cube using D-Bus</_short>
+ <_long>Allows other applications to draw inside cube using D-Bus</_long>
+ <category>Utility</category>
+ <deps>
+ <relation type="after">
+ <plugin>cube</plugin>
+ <plugin>dbus</plugin>
+ </relation>
+ <requirement>
+ <plugin>cube</plugin>
+ <plugin>dbus</plugin>
+ </requirement>
+ </deps>
+
+ <display>
+ <option name="add" type="action">
+ <_short>Add an object</_short>
+ <_long>Add an object to draw in cube</_long>
+ </option>
+ </display>
+ </plugin>
+</compiz>
diff --git a/plugin.info b/plugin.info
new file mode 100644
index 0000000..1e19d81
--- /dev/null
+++ b/plugin.info
@@ -0,0 +1,2 @@
+PLUGIN = cubedbus
+PKG_DEP = compiz-cube