summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrcxdude <rcxdude@gmail.com>2008-04-23 20:29:15 +0100
committerrcxdude <rcxdude@gmail.com>2008-04-23 20:29:15 +0100
commitc8b24531724760da1e79a5b5f86bf807a79263b8 (patch)
treec4fdfcd5521e9828456d57e8df17c375235a1223
parentace15aa66adaffc9d09543a4c65420d320531727 (diff)
downloaddodge-c8b24531724760da1e79a5b5f86bf807a79263b8.tar.gz
dodge-c8b24531724760da1e79a5b5f86bf807a79263b8.tar.bz2
initial commit
-rw-r--r--CMakeLists.txt3
-rw-r--r--Makefile533
-rw-r--r--dodge.c622
-rw-r--r--dodge.xml.in83
-rw-r--r--dummy0
-rw-r--r--plugin.info3
6 files changed, 1244 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..c8685d6
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,3 @@
+include (CompizFusion)
+
+compiz_fusion_plugin(dodge PLUGINDEPS mousepoll)
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..ccaa8d4
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,533 @@
+##
+#
+# 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)
+ 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
+
+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 )
+
+COMPIZ_HEADERS = compiz.h compiz-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-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 compiz-$(PLUGIN).h ]; then $(ECHO) "compiz-$(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 += $(foreach file,$(COMPIZ_HEADERS) $(CHK_HEADERS),$(shell $(ECHO) -n "$(COMPIZ_INC)$(file)"))
+
+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)
+
+# 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)
+
+#
+# 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; \
+ 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"; \
+ 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; \
+ FILEDIR="$(IMAGEDIR)/`dirname "$$FILE"`"; \
+ mkdir -p "$$FILEDIR"; \
+ 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 "$(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/dodge.c b/dodge.c
new file mode 100644
index 0000000..2f790d4
--- /dev/null
+++ b/dodge.c
@@ -0,0 +1,622 @@
+/**
+ *
+ * dodge.c
+ *
+ * Copyright (c) 2007 Douglas Young <rcxdude@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.
+ *
+ **/
+
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <compiz-core.h>
+#include <compiz-mousepoll.h>
+#include <math.h>
+
+#include "dodge_options.h"
+
+
+
+static int displayPrivateIndex;
+
+typedef struct _DodgeDisplay
+{
+ int screenPrivateIndex;
+
+ MousePollFunc *mpFunc;
+ Atom resizeNotifyAtom;
+} DodgeDisplay;
+
+#define NORTH 0
+#define SOUTH 1
+#define EAST 2
+#define WEST 3
+
+typedef struct _DodgeWindow
+{
+ float vx; /* velocity */
+ float vy;
+
+ int ox; /* original position */
+ int oy;
+
+ int pos; /* North South East West */
+
+ Bool isdodge;
+} DodgeWindow;
+
+typedef struct _DodgeScreen
+{
+ PaintOutputProc paintOutput;
+ PreparePaintScreenProc preparePaintScreen;
+ PositionPollingHandle pollHandle;
+
+ int windowPrivateIndex;
+ CompWindow *window;
+
+ int px;
+ int py;
+
+ int ox;
+ int oy; /* the previous viewport position */
+
+ int model;
+ int padding;
+ float springk;
+ float friction;
+ Bool active;
+ Bool exiting;
+
+} DodgeScreen;
+
+
+#define GET_DODGE_DISPLAY(d) \
+ ((DodgeDisplay *) (d)->base.privates[displayPrivateIndex].ptr)
+
+#define DODGE_DISPLAY(d) \
+ DodgeDisplay *dd = GET_DODGE_DISPLAY (d)
+
+#define GET_DODGE_SCREEN(s, dd) \
+ ((DodgeScreen *) (s)->base.privates[(dd)->screenPrivateIndex].ptr)
+
+#define DODGE_SCREEN(s) \
+ DodgeScreen *ds = GET_DODGE_SCREEN (s, \
+ GET_DODGE_DISPLAY (s->display))
+
+#define GET_DODGE_WINDOW(w, ds) \
+ ((DodgeWindow *) (w)->base.privates[(ds)->windowPrivateIndex].ptr)
+
+#define DODGE_WINDOW(w) \
+ DodgeWindow *dw = GET_DODGE_WINDOW (w, \
+ GET_DODGE_SCREEN (w->screen, \
+ GET_DODGE_DISPLAY (w->screen->display)))
+static float
+noneg (float x)
+{
+ if (x<0)
+ return 0;
+ return x;
+}
+
+static void
+positionUpdate (CompScreen *s, int x, int y)
+{
+ DODGE_SCREEN (s);
+ ds->px = x;
+ ds->py = y;
+}
+
+#define PI 3.1415926
+#define FRICTION (0.005f * ds->friction)
+#define SPRING_K (0.00005f * ds->springk)
+#define PADDING (ds->padding)
+
+#define WIN_X(w) ((w)->attrib.x - (w)->input.left)
+#define WIN_Y(w) ((w)->attrib.y - (w)->input.top)
+#define WIN_W(w) ((w)->width + (w)->input.left + (w)->input.right)
+#define WIN_H(w) ((w)->height + (w)->input.top + (w)->input.bottom)
+
+#define WIN_CX(w) (WIN_X(w) + WIN_W(w)/2)
+#define WIN_CY(w) (WIN_Y(w) + WIN_H(w)/2)
+
+static int
+dodgestep (CompWindow *w, int ms, int away)
+{
+ DODGE_WINDOW (w);
+ DODGE_SCREEN (w->screen);
+ int dx; /* x distance from pointer */
+ int dy; /* y distance from pointer */
+ float dp; /* actual distance from pointer */
+ switch (ds->model)
+ {
+ case ModelSimpleAvoid:
+ /* increase velocity away from the pointer */
+ dx = WIN_CX(w) - ds->px;
+ dy = WIN_CY(w) - ds->py;
+
+ dp = sqrt(dx*dx + dy*dy);
+ if(WIN_W(w)/2 + PADDING - abs(dx) >
+ WIN_H(w)/2 + PADDING - abs(dy))
+ {
+ dw->vx += noneg(WIN_H(w)/2 + PADDING - abs(dy))
+ * SPRING_K * dx/(abs(dx) + abs(dy)) * ms;
+ dw->vy += noneg(WIN_H(w)/2 + PADDING - abs(dy))
+ * SPRING_K * dy/(abs(dx) + abs(dy)) * ms;
+ } else {
+ dw->vx += noneg(WIN_W(w)/2 + PADDING - abs(dx))
+ * SPRING_K * dx/(abs(dx) + abs(dy)) * ms;
+ dw->vy += noneg(WIN_W(w)/2 + PADDING - abs(dx))
+ * SPRING_K * dy/(abs(dx) + abs(dy)) * ms;
+ }
+ break;
+ case ModelReturnToPosition:
+ if ((ds->px > dw->ox - WIN_W(w)/2 - PADDING &&
+ ds->py > dw->oy - WIN_H(w)/2 - PADDING &&
+ ds->px < dw->ox + WIN_W(w)/2 + PADDING &&
+ ds->py < dw->oy + WIN_H(w)/2 + PADDING) &&
+ !ds->exiting && away)
+ {
+ /* increase velocity away from / toward the pointer */
+ dx = WIN_CX(w) - ds->px;
+ dy = WIN_CY(w) - ds->py;
+
+ dp = sqrt(dx*dx + dy*dy);
+ if(WIN_W(w)/2 + PADDING - abs(dx) >
+ WIN_H(w)/2 + PADDING - abs(dy))
+ {
+ dw->vx += (WIN_H(w)/2 + PADDING - abs(dy))
+ * SPRING_K * dx/(abs(dx) + abs(dy)) * ms;
+ dw->vy += (WIN_H(w)/2 + PADDING - abs(dy))
+ * SPRING_K * dy/(abs(dx) + abs(dy)) * ms;
+ } else {
+ dw->vx += (WIN_W(w)/2 + PADDING - abs(dx))
+ * SPRING_K * dx/(abs(dx) + abs(dy)) * ms;
+ dw->vy += (WIN_W(w)/2 + PADDING - abs(dx))
+ * SPRING_K * dy/(abs(dx) + abs(dy)) * ms;
+ }
+ } else {
+ /* increase velocity towards the original position */
+ dx = WIN_CX(w) - dw->ox;
+ dy = WIN_CY(w) - dw->oy;
+
+ dp = sqrt(dx*dx + dy*dy);
+ if (dx || dy)
+ {
+ dw->vx -= dp * SPRING_K * dx/(abs(dx) + abs(dy)) * ms;
+ dw->vy -= dp * SPRING_K * dy/(abs(dx) + abs(dy)) * ms;
+ }
+ }
+ break;
+ case ModelOffScreen:
+ if ((ds->px > dw->ox - WIN_W(w)/2 - PADDING &&
+ ds->py > dw->oy - WIN_H(w)/2 - PADDING &&
+ ds->px < dw->ox + WIN_W(w)/2 + PADDING &&
+ ds->py < dw->oy + WIN_H(w)/2 + PADDING) &&
+ !ds->exiting && away)
+ {
+ switch (dw->pos)
+ {
+ case NORTH:
+ dx = 0;
+ dy = WIN_Y(w) + WIN_H(w);
+ break;
+ case SOUTH:
+ dx = 0;
+ dy = WIN_Y(w) - w->screen->height;
+ break;
+ case EAST:
+ dx = WIN_X(w) + WIN_W(w);
+ dy = 0;
+ break;
+ case WEST:
+ dx = WIN_X(w) - w->screen->width;
+ dy = 0;
+ break;
+ }
+
+ dw->vx -= dx * SPRING_K * ms;
+ dw->vy -= dy * SPRING_K * ms;
+ } else {
+ dx = WIN_CX(w) - dw->ox;
+ dy = WIN_CY(w) - dw->oy;
+
+ dp = sqrt(dx*dx + dy*dy);
+ if (dx || dy)
+ {
+ dw->vx -= dp * SPRING_K * dx/(abs(dx) + abs(dy)) * ms * 0.5;
+ dw->vy -= dp * SPRING_K * dy/(abs(dx) + abs(dy)) * ms * 0.5;
+ }
+ }
+ break;
+
+ }
+ /* apply friction */
+ dw->vx -= FRICTION * dw->vx * ms;
+ dw->vy -= FRICTION * dw->vy * ms;
+
+ /* stop the window going offscreen with the simple model */
+ if (((WIN_X(w) + WIN_W(w) > w->screen->width && dw->vx > 0) ||
+ (WIN_X(w) < 0 && dw->vx < 0)) &&
+ ds->model == ModelSimpleAvoid)
+ dw->vx = 0;
+ if (((WIN_Y(w) + WIN_H(w) > w->screen->height && dw->vy > 0) ||
+ (WIN_Y(w) < 0 && dw->vy < 0)) &&
+ ds->model == ModelSimpleAvoid)
+ dw->vy = 0;
+ /* stop excessive velocity */
+ if (dw->vx > w->screen->width || dw->vx < 0 - w->screen->width ||
+ dw->vy > w->screen->height || dw->vx < 0 - w->screen->height)
+ dw->vx = dw->vy = 0;
+
+ /* if there's enough velocity, move the window */
+ if (fabs(dw->vx)*ms >= 1 || fabs(dw->vy)*ms >= 1)
+ {
+ moveWindow (w,dw->vx*ms,dw->vy*ms,TRUE,TRUE);
+ syncWindowPosition (w);
+ return 1;
+ }
+ /*if(abs(WIN_CX(w) - dw->ox) < 1 &&
+ abs(WIN_CY(w) - dw->oy) < 1)
+ {
+ moveWindowToViewportPosition(w,(dw->ox - WIN_W(w)/2),
+ (dw->oy - WIN_H(w)/2),1);
+ printf("returning 0\n");
+ return 0;
+ }*/
+ return 0;
+
+}
+
+static void
+dodgeMarkDodgeWindows (CompScreen *s)
+{
+ DODGE_SCREEN (s);
+ CompWindow *w;
+ for (w = s->windows; w; w = w->next)
+ {
+ DODGE_WINDOW (w);
+ if(matchEval(dodgeGetWindowTypes (s->display),w) &&
+ !(w->invisible || w->destroyed || w->hidden || w->minimized))
+ {
+ if (dw)
+ {
+ dw->isdodge = TRUE;
+ dw->vx = 0;
+ dw->vy = 0;
+ dw->ox = WIN_CX(w);
+ dw->oy = WIN_CY(w);
+ if (ds->model == ModelOffScreen)
+ {
+ if (WIN_CX(w) > WIN_CY(w) &&
+ WIN_CX(w) * w->screen->height +
+ WIN_CY(w) * w->screen->width >
+ (w->screen->width * w->screen->height))
+ dw->pos = WEST;
+ if (WIN_CX(w) < WIN_CY(w) &&
+ WIN_CX(w) * w->screen->height +
+ WIN_CY(w) * w->screen->width >
+ (w->screen->width * w->screen->height))
+ dw->pos = SOUTH;
+ if (WIN_CX(w) > WIN_CY(w) &&
+ WIN_CX(w) * w->screen->height +
+ WIN_CY(w) * w->screen->width <
+ (w->screen->width * w->screen->height))
+ dw->pos = NORTH;
+ if (WIN_CX(w) < WIN_CY(w) &&
+ WIN_CX(w) * w->screen->height +
+ WIN_CY(w) * w->screen->width <
+ (w->screen->width * w->screen->height))
+ dw->pos = EAST;
+ }
+ }
+ }
+ else
+ {
+ if (dw->isdodge)
+ {
+ dw->isdodge = FALSE;
+ dw->ox = 0;
+ dw->oy = 0;
+ }
+ }
+ }
+}
+static void
+dodgePreparePaintScreen (CompScreen *s,
+ int ms)
+{
+ DODGE_SCREEN (s);
+ CompWindow *w;
+ int count = 0; /* number of windows moved */
+ /* if another plugin has grabbed the screen we don't want to interfere
+ * except for expo or rotate cube, in which case windows return to their original
+ * positions */
+ if (otherScreenGrabExist(s,"dodge","expo","rotate",0))
+ {
+ UNWRAP (ds, s, preparePaintScreen);
+ (*s->preparePaintScreen) (s, ms);
+ WRAP (ds, s, preparePaintScreen, dodgePreparePaintScreen);
+ return;
+ }
+
+ /* update original positions to prevent windows springing to new viewport */
+ if ((ds->ox != s->x || ds->oy != s->y) &&
+ ds->active)
+ {
+ for (w = s->windows; w; w = w->next)
+ {
+ DODGE_WINDOW (w);
+ if (dw->isdodge && !(w->state & CompWindowStateStickyMask))
+ {
+ dw->ox -= (s->x - ds->ox) * s->width;
+ dw->oy -= (s->y - ds->oy) * s->height;
+ }
+ }
+ ds->ox = s->x;
+ ds->oy = s->y;
+ }
+
+ if (ds->active)
+ {
+ for (w = s->windows; w; w = w->next)
+ {
+ DODGE_WINDOW (w);
+ if (dw->isdodge)
+ count += dodgestep(w,ms,!otherScreenGrabExist(s,"dodge",0));
+ }
+ }
+ if (ds->exiting && !count)
+ {
+ ds->active = FALSE;
+ ds->exiting = FALSE;
+ }
+
+ UNWRAP (ds, s, preparePaintScreen);
+ (*s->preparePaintScreen) (s, ms);
+ WRAP (ds, s, preparePaintScreen, dodgePreparePaintScreen);
+}
+
+static Bool
+dodgeToggle (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
+{
+ CompScreen *s;
+ Window xid;
+ xid = getIntOptionNamed (option, nOption, "root", 0);
+ s = findScreenAtDisplay (d, xid);
+ if (s)
+ {
+ DODGE_SCREEN(s);
+ if (ds->active)
+ ds->exiting = TRUE;
+ else
+ {
+ ds->model = dodgeGetModel (d);
+ ds->springk = dodgeGetSpringK (d);
+ ds->friction = dodgeGetFriction (d);
+ ds->padding = dodgeGetPadding (d);
+ ds->ox = s->x;
+ ds->oy = s->y;
+ dodgeMarkDodgeWindows (s);
+ ds->active = TRUE;
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+static Bool
+dodgePaintOutput (CompScreen *s,
+ const ScreenPaintAttrib *sAttrib,
+ const CompTransform *transform,
+ Region region,
+ CompOutput *output,
+ unsigned int mask)
+{
+ Bool status;
+
+ DODGE_SCREEN (s);
+ if (ds->active)
+ {
+ /* damage a small area around the mouse to prevent jerkiness */
+ REGION r;
+
+ r.rects = &r.extents;
+ r.numRects = r.size = 1;
+ r.extents.x1 = ds->px - PADDING;
+ r.extents.x2 = ds->px + PADDING;
+ r.extents.y1 = ds->py - PADDING;
+ r.extents.y2 = ds->py + PADDING;
+
+ damageScreenRegion(s,&r);
+ }
+
+
+ UNWRAP (ds, s, paintOutput);
+ status = (*s->paintOutput) (s, sAttrib, transform, region, output, mask);
+ WRAP (ds, s, paintOutput, dodgePaintOutput);
+
+ return status;
+}
+
+
+static Bool
+dodgeInitDisplay (CompPlugin *p,
+ CompDisplay *d)
+{
+ DodgeDisplay *dd;
+ int mousepollindex;
+ if (!checkPluginABI ("core", CORE_ABIVERSION))
+ return FALSE;
+
+ dd = malloc (sizeof (DodgeDisplay));
+ if (!dd)
+ return FALSE;
+
+ if (!getPluginDisplayIndex (d, "mousepoll", &mousepollindex))
+ return FALSE;
+
+ dd->screenPrivateIndex = allocateScreenPrivateIndex (d);
+ if (dd->screenPrivateIndex < 0)
+ {
+ free (dd);
+ return FALSE;
+ }
+
+ d->base.privates[displayPrivateIndex].ptr = dd;
+ dodgeSetDodgeToggleKeyInitiate (d, dodgeToggle);
+ dodgeSetDodgeToggleButtonInitiate (d, dodgeToggle);
+
+ dd->mpFunc = d->base.privates[mousepollindex].ptr;
+ return TRUE;
+}
+
+static void
+dodgeFiniDisplay (CompPlugin *p,
+ CompDisplay *d)
+{
+ DODGE_DISPLAY (d);
+ freeScreenPrivateIndex (d, dd->screenPrivateIndex);
+ free (dd);
+}
+
+static Bool
+dodgeInitScreen (CompPlugin *p,
+ CompScreen *s)
+{
+ DodgeScreen * ds;
+
+ DODGE_DISPLAY (s->display);
+
+ ds = malloc (sizeof (DodgeScreen));
+ if (!ds)
+ return FALSE;
+
+ ds->active = FALSE;
+ ds->exiting = FALSE;
+
+ WRAP (ds, s, preparePaintScreen, dodgePreparePaintScreen);
+ WRAP (ds, s, paintOutput, dodgePaintOutput);
+ ds->windowPrivateIndex = allocateWindowPrivateIndex (s);
+ s->base.privates[dd->screenPrivateIndex].ptr = ds;
+
+ (*dd->mpFunc->getCurrentPosition) (s, &ds->px, &ds->py);
+ ds->pollHandle = (*dd->mpFunc->addPositionPolling) (s, positionUpdate);
+ return TRUE;
+}
+
+static void
+dodgeFiniScreen (CompPlugin *p,
+ CompScreen *s)
+{
+ DODGE_SCREEN (s);
+ DODGE_DISPLAY (s->display);
+ UNWRAP (ds, s, preparePaintScreen);
+ UNWRAP (ds, s, paintOutput);
+ (*dd->mpFunc->removePositionPolling) (s, ds->pollHandle);
+ free (ds);
+}
+
+static Bool
+dodgeInitWindow (CompPlugin *p,
+ CompWindow *w)
+{
+ DodgeWindow *dw;
+
+ DODGE_SCREEN (w->screen);
+
+ dw = malloc (sizeof (DodgeWindow));
+ if (!dw)
+ return FALSE;
+ dw->vx = 0;
+ dw->vy = 0;
+ dw->isdodge = FALSE;
+ w->base.privates[ds->windowPrivateIndex].ptr = dw;
+
+ return TRUE;
+}
+
+static void
+dodgeFiniWindow (CompPlugin *p,
+ CompWindow *w)
+{
+ DODGE_WINDOW (w);
+ free (dw);
+}
+
+static CompBool
+dodgeInitObject (CompPlugin *p,
+ CompObject *o)
+{
+ static InitPluginObjectProc dispTab[] = {
+ (InitPluginObjectProc) 0, /* InitCore */
+ (InitPluginObjectProc) dodgeInitDisplay,
+ (InitPluginObjectProc) dodgeInitScreen,
+ (InitPluginObjectProc) dodgeInitWindow
+ };
+
+ RETURN_DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), TRUE, (p, o));
+}
+
+static void
+dodgeFiniObject (CompPlugin *p,
+ CompObject *o)
+{
+ static FiniPluginObjectProc dispTab[] = {
+ (FiniPluginObjectProc) 0, /* FiniCore */
+ (FiniPluginObjectProc) dodgeFiniDisplay,
+ (FiniPluginObjectProc) dodgeFiniScreen,
+ (FiniPluginObjectProc) dodgeFiniWindow
+ };
+
+ DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), (p, o));
+}
+
+static Bool
+dodgeInit (CompPlugin *p)
+{
+ displayPrivateIndex = allocateDisplayPrivateIndex ();
+ if (displayPrivateIndex < 0)
+ return FALSE;
+
+ return TRUE;
+}
+
+static void
+dodgeFini (CompPlugin *p)
+{
+ freeDisplayPrivateIndex(displayPrivateIndex);
+}
+
+static CompPluginVTable dodgeVTable = {
+ "dodge",
+ 0,
+ dodgeInit,
+ dodgeFini,
+ dodgeInitObject,
+ dodgeFiniObject,
+ 0,
+ 0
+};
+
+CompPluginVTable*
+getCompPluginInfo (void)
+{
+ return &dodgeVTable;
+}
diff --git a/dodge.xml.in b/dodge.xml.in
new file mode 100644
index 0000000..b6ad2ea
--- /dev/null
+++ b/dodge.xml.in
@@ -0,0 +1,83 @@
+<?xml version="1.0"?>
+<compiz>
+ <plugin name="dodge" useBcop="true">
+ <_short>Dodge</_short>
+ <_long>Makes windows stay out of your way</_long>
+ <category>Extras</category>
+ <deps>
+ <relation type="after">
+ <plugin>cube</plugin>
+ <plugin>wall</plugin>
+ <plugin>regex</plugin>
+ <plugin>mousepoll</plugin>
+ <plugin>expo</plugin>
+ </relation>
+ <requirement>
+ <plugin>mousepoll</plugin>
+ <plugin>regex</plugin>
+ </requirement>
+ </deps>
+ <display>
+ <group>
+ <option name="dodge_toggle_key" type="key">
+ <_short>Toggle Dodging</_short>
+ <_long>Toggle Dodging</_long>
+ <default>none</default>
+ </option>
+ <option name="dodge_toggle_button" type="button">
+ <_short>Toggle Dodging</_short>
+ <_long>Toggle Dodging</_long>
+ <default>none</default>
+ </option>
+ <option name="window_types" type="match">
+ <_short>Window Types</_short>
+ <_long>Windows which should dodge</_long>
+ <default>state=above &amp; type=normal</default>
+ </option>
+ <option name="model" type="int">
+ <_short>Dodge Model</_short>
+ <_long>What model Dodge should use when dodging</_long>
+ <default>1</default>
+ <min>0</min>
+ <max>2</max>
+ <desc>
+ <value>0</value>
+ <_name>Simple Avoid</_name>
+ </desc>
+ <desc>
+ <value>1</value>
+ <_name>Return to position</_name>
+ </desc>
+ <desc>
+ <value>2</value>
+ <_name>Off Screen</_name>
+ </desc>
+ </option>
+ <option name="spring_k" type="float">
+ <_short>Spring K</_short>
+ <_long>Spring Stiffness</_long>
+ <default>8</default>
+ <min>1</min>
+ <max>10</max>
+ <precision>0.01</precision>
+ </option>
+ <option name="friction" type="float">
+ <_short>Friction</_short>
+ <_long>Friction</_long>
+ <default>3</default>
+ <min>1</min>
+ <max>10</max>
+ <precision>0.01</precision>
+ </option>
+ <option name="padding" type="int">
+ <_short>Padding</_short>
+ <_long>Padding around windows</_long>
+ <default>20</default>
+ <min>0</min>
+ <max>100</max>
+ </option>
+ </group>
+ </display>
+ </plugin>
+</compiz>
+
diff --git a/dummy b/dummy
deleted file mode 100644
index e69de29..0000000
--- a/dummy
+++ /dev/null
diff --git a/plugin.info b/plugin.info
new file mode 100644
index 0000000..7063311
--- /dev/null
+++ b/plugin.info
@@ -0,0 +1,3 @@
+PLUGIN=dodge
+PKG_DEP = compiz-mousepoll
+CHK_HEADERS = compiz-mousepoll.h