summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2010-11-19 15:22:57 +0100
committerDanny Baumann <dannybaumann@web.de>2010-11-19 15:22:57 +0100
commitf49c5e9605b2c9d8a67bec1ab357bcceee8433e8 (patch)
treefab84043e72269a784155c9355fb92e4727bd203
parent24ff9c249790737bf363f19bbbd99d893cf8ab82 (diff)
downloaddodge-compiz-0.8.tar.gz
dodge-compiz-0.8.tar.bz2
Revert "C++ port of the dodge plugin"compiz-0.8
This reverts commit 24ff9c249790737bf363f19bbbd99d893cf8ab82.
-rw-r--r--CMakeLists.txt6
-rw-r--r--Makefile533
-rw-r--r--dodge.c777
-rw-r--r--dodge.xml.in8
-rw-r--r--plugin.info3
-rw-r--r--src/dodge.cpp494
-rw-r--r--src/dodge.h144
7 files changed, 1317 insertions, 648 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5c9f550..c8685d6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,3 @@
-find_package (Compiz REQUIRED)
+include (CompizFusion)
-include (CompizPlugin)
-
-compiz_plugin (dodge PLUGINDEPS composite opengl mousepoll)
+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..b5bce5e
--- /dev/null
+++ b/dodge.c
@@ -0,0 +1,777 @@
+/**
+ *
+ * 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;
+ float x; /* position as float */
+ float y;
+
+ int ox; /* original position */
+ int oy;
+
+ int pos; /* North South East West */
+
+ Bool selected;
+ Bool isdodge;
+} DodgeWindow;
+
+typedef struct _DodgeScreen
+{
+ PaintOutputProc paintOutput;
+ PreparePaintScreenProc preparePaintScreen;
+ WindowStateChangeNotifyProc windowStateChangeNotify;
+ WindowMoveNotifyProc windowMoveNotify;
+ WindowResizeNotifyProc windowResizeNotify;
+ DonePaintScreenProc donePaintScreen;
+
+ PositionPollingHandle pollHandle;
+
+ int windowPrivateIndex;
+ CompWindow *window;
+
+ int px;
+ int py;
+
+ int model;
+ int padding;
+ float springk;
+ float friction;
+ Bool active;
+ Bool exiting;
+ Bool movelock;
+ Bool moreAdjust;
+
+} 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)))
+
+#define POSITIVE(x) ((x)>0?(x):0)
+
+
+#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)
+{
+ if (!w) return 0;
+ 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 += POSITIVE(WIN_H(w)/2 + PADDING - abs(dy))
+ * SPRING_K * dx/(abs(dx) + abs(dy)) * ms;
+ dw->vy += POSITIVE(WIN_H(w)/2 + PADDING - abs(dy))
+ * SPRING_K * dy/(abs(dx) + abs(dy)) * ms;
+ } else {
+ dw->vx += POSITIVE(WIN_W(w)/2 + PADDING - abs(dx))
+ * SPRING_K * dx/(abs(dx) + abs(dy)) * ms;
+ dw->vy += POSITIVE(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;
+
+ dw->x += dw->vx * ms;
+ dw->y += dw->vy * ms;
+ /* if there's enough differenc, move the window */
+ if (fabs(dw->x - WIN_X(w)) >= 1 || fabs(dw->y - WIN_Y(w)) >= 1)
+ {
+ moveWindow (w,(int) dw->x - WIN_X(w),
+ (int) dw->y - WIN_Y(w),TRUE,TRUE);
+ syncWindowPosition (w);
+ ds->moreAdjust = TRUE;
+ }
+ if ((dy || dx) && !ds->model == ModelSimpleAvoid)
+ {
+ ds->moreAdjust = TRUE;
+ }
+ return 0;
+
+}
+
+
+static void
+dodgePreparePaintScreen (CompScreen *s,
+ int ms)
+{
+ DODGE_SCREEN (s);
+ CompWindow *w;
+ /* 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;
+ }
+
+ if (ds->active)
+ {
+ ds->movelock = TRUE;
+ ds->moreAdjust = FALSE;
+ for (w = s->windows; w; w = w->next)
+ {
+ DODGE_WINDOW (w);
+ if (dw->isdodge)
+ dodgestep(w,ms,!otherScreenGrabExist(s,"dodge",0)
+ && (w->screen->display->activeWindow != w->id
+ || dodgeGetDodgeActive (s->display)));
+ }
+ ds->movelock = FALSE;
+ }
+ if (ds->exiting && !ds->moreAdjust)
+ {
+ ds->active = FALSE;
+ ds->exiting = FALSE;
+ ds->moreAdjust = FALSE;
+ }
+
+ UNWRAP (ds, s, preparePaintScreen);
+ (*s->preparePaintScreen) (s, ms);
+ WRAP (ds, s, preparePaintScreen, dodgePreparePaintScreen);
+}
+
+static void
+dodgeDonePaintScreen (CompScreen *s)
+{
+ DODGE_SCREEN(s);
+ if (ds->active && ds->moreAdjust)
+ {
+ CompWindow *w;
+ for (w = s->windows; w; w = w->next)
+ {
+ DODGE_WINDOW(w);
+ if (dw->isdodge)
+ addWindowDamage(w);
+ }
+ }
+ UNWRAP (ds, s, donePaintScreen);
+ (*s->donePaintScreen) (s);
+ WRAP (ds, s, donePaintScreen, dodgeDonePaintScreen);
+}
+
+static void
+dodgeUpdateDodgeWindow (CompWindow *w)
+{
+ DODGE_WINDOW (w);
+ DODGE_SCREEN (w->screen);
+ if((matchEval(dodgeGetWindowTypes (w->screen->display),w) || dw->selected) &&
+ !(w->invisible || w->destroyed || w->hidden || w->minimized))
+ {
+ if (dw)
+ {
+ dw->isdodge = TRUE;
+ dw->vx = 0;
+ dw->vy = 0;
+ dw->x = (float) WIN_X(w);
+ dw->y = (float) WIN_Y(w);
+ /* don't change original position if dodge is active */
+ if (!ds->active || !(dw->ox || dw->oy))
+ {
+ dw->ox = WIN_CX(w);
+ dw->oy = WIN_CY(w);
+ }
+ 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 Bool
+dodgeSelect (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
+{
+ Window xid;
+ CompWindow *w;
+
+ xid = getIntOptionNamed (option, nOption, "window", 0);
+ w = findWindowAtDisplay (d, xid);
+ DODGE_WINDOW(w);
+ DODGE_SCREEN(w->screen);
+ dw->selected = !dw->selected;
+ if (ds->active)
+ dodgeUpdateDodgeWindow (w);
+
+ return TRUE;
+}
+
+static Bool
+dodgeToggle (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
+{
+ CompScreen *s;
+ for (s = d->screens; s; s = s->next)
+ {
+ 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);
+ CompWindow *w;
+ for (w = s->windows; w; w = w->next)
+ {
+ dodgeUpdateDodgeWindow (w);
+ }
+ ds->active = TRUE;
+ }
+ }
+ }
+ return TRUE;
+}
+
+static void
+dodgeWindowMoveNotify (CompWindow *w,
+ int dx,
+ int dy,
+ Bool immediate)
+{
+ DODGE_WINDOW (w);
+ DODGE_SCREEN (w->screen);
+
+ if (!ds->movelock && ds->active)
+ {
+ dw->ox += dx;
+ dw->oy += dy;
+ }
+ UNWRAP (ds, w->screen, windowMoveNotify);
+ (*w->screen->windowMoveNotify) (w, dx, dy, immediate);
+ WRAP (ds, w->screen, windowMoveNotify, dodgeWindowMoveNotify);
+}
+
+static void
+dodgeWindowResizeNotify (CompWindow *w,
+ int dx,
+ int dy,
+ int dwidth,
+ int dheight)
+{
+ DODGE_WINDOW (w);
+ DODGE_SCREEN (w->screen);
+
+ if (!ds->movelock && ds->active)
+ {
+ dw->ox += dx;
+ dw->oy += dy;
+ }
+ UNWRAP (ds, w->screen, windowResizeNotify);
+ (*w->screen->windowResizeNotify) (w, dx, dy, dwidth, dheight);
+ WRAP (ds, w->screen, windowResizeNotify, dodgeWindowResizeNotify);
+}
+
+static void
+positionUpdate (CompScreen *s, int x, int y)
+{
+ DODGE_SCREEN (s);
+ ds->px = x;
+ ds->py = y;
+ 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);
+ }
+
+}
+
+static void
+dodgeStateChange (CompWindow *w,
+ unsigned int last)
+{
+ DODGE_SCREEN (w->screen);
+ if(ds->active)
+ dodgeUpdateDodgeWindow (w);
+ UNWRAP (ds, w->screen, windowStateChangeNotify);
+ (*w->screen->windowStateChangeNotify) (w,last);
+ WRAP (ds, w->screen, windowStateChangeNotify, dodgeStateChange);
+
+}
+
+static void
+dodgeModelChange (CompDisplay *d,
+ CompOption *opt,
+ DodgeDisplayOptions num)
+{
+ CompScreen *s;
+ for (s = d->screens; s; s = s->next)
+ {
+ DODGE_SCREEN (s);
+ ds->model = dodgeGetModel (d);
+ }
+}
+
+static void
+dodgeFrictionChange (CompDisplay *d,
+ CompOption *opt,
+ DodgeDisplayOptions num)
+{
+ CompScreen *s;
+ for (s = d->screens; s; s = s->next)
+ {
+ DODGE_SCREEN (s);
+ ds->friction = dodgeGetFriction (d);
+ }
+}
+
+static void
+dodgePaddingChange (CompDisplay *d,
+ CompOption *opt,
+ DodgeDisplayOptions num)
+{
+ CompScreen *s;
+ for (s = d->screens; s; s = s->next)
+ {
+ DODGE_SCREEN (s);
+ ds->padding = dodgeGetPadding (d);
+ }
+}
+
+static void
+dodgeKChange (CompDisplay *d,
+ CompOption *opt,
+ DodgeDisplayOptions num)
+{
+ CompScreen *s;
+ for (s = d->screens; s; s = s->next)
+ {
+ DODGE_SCREEN (s);
+ ds->springk = dodgeGetSpringK (d);
+ }
+}
+
+static void
+dodgeTypeChange (CompDisplay *d,
+ CompOption *opt,
+ DodgeDisplayOptions num)
+{
+ CompScreen *s;
+ for (s = d->screens; s; s = s->next)
+ {
+ CompWindow *w;
+ for (w = s->windows; w; w = w->next)
+ {
+ dodgeUpdateDodgeWindow (w);
+ }
+ }
+}
+
+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);
+ dodgeSetDodgeToggleEdgeInitiate (d, dodgeToggle);
+ dodgeSetDodgeSelectKeyInitiate (d, dodgeSelect);
+
+ dodgeSetModelNotify (d, dodgeModelChange);
+ dodgeSetFrictionNotify (d, dodgeFrictionChange);
+ dodgeSetPaddingNotify (d, dodgePaddingChange);
+ dodgeSetSpringKNotify (d, dodgeKChange);
+ dodgeSetWindowTypesNotify (d, dodgeTypeChange);
+
+ 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;
+ ds->moreAdjust = FALSE;
+
+ WRAP (ds, s, preparePaintScreen, dodgePreparePaintScreen);
+ WRAP (ds, s, windowStateChangeNotify, dodgeStateChange);
+ WRAP (ds, s, windowMoveNotify, dodgeWindowMoveNotify);
+ WRAP (ds, s, windowResizeNotify, dodgeWindowResizeNotify);
+ WRAP (ds, s, donePaintScreen, dodgeDonePaintScreen);
+
+ 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, windowStateChangeNotify);
+ UNWRAP (ds, s, windowMoveNotify);
+ UNWRAP (ds, s, windowResizeNotify);
+ UNWRAP (ds, s, donePaintScreen);
+
+ (*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;
+ dw->selected = FALSE;
+ w->base.privates[ds->windowPrivateIndex].ptr = dw;
+ if (ds->active)
+ dodgeUpdateDodgeWindow (w);
+
+ 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
index 4ebbc16..c79f3d9 100644
--- a/dodge.xml.in
+++ b/dodge.xml.in
@@ -10,18 +10,14 @@
<plugin>wall</plugin>
<plugin>regex</plugin>
<plugin>mousepoll</plugin>
- <plugin>composite</plugin>
- <plugin>opengl</plugin>
<plugin>expo</plugin>
</relation>
<requirement>
<plugin>mousepoll</plugin>
<plugin>regex</plugin>
- <plugin>composite</plugin>
- <plugin>opengl</plugin>
</requirement>
</deps>
- <options>
+ <display>
<group>
<option name="dodge_toggle_key" type="key">
<_short>Toggle Dodging</_short>
@@ -96,7 +92,7 @@
<max>100</max>
</option>
</group>
- </options>
+ </display>
</plugin>
</compiz>
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
diff --git a/src/dodge.cpp b/src/dodge.cpp
deleted file mode 100644
index 63ffcfa..0000000
--- a/src/dodge.cpp
+++ /dev/null
@@ -1,494 +0,0 @@
-/**
- *
- * 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.
- *
- **/
-
-#include "dodge.h"
-
-#define POSITIVE(x) ((x)>0?(x):0)
-
-
-#define PI 3.1415926
-#define FRICTION_W (0.005f * ds->mFriction)
-#define SPRING_K_W (0.00005f * ds->mSpringk)
-#define PADDING_W (ds->mPadding)
-#define FRICTION (0.005f * mFriction)
-#define SPRING_K (0.00005f * mSpringk)
-#define PADDING (mPadding)
-
-#define WIN_X(w) ((w)->x () - (w)->input ().left)
-#define WIN_Y(w) ((w)->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)
-
-COMPIZ_PLUGIN_20090315 (dodge, DodgePluginVTable);
-
-
-int
-DodgeWindow::step (int ms,
- int away)
-{
- if (!window)
- return 0;
-
- DODGE_SCREEN (screen);
- int dx; /* x distance from pointer */
- int dy; /* y distance from pointer */
- float dp; /* actual distance from pointer */
- switch (ds->mModel)
- {
- case DodgeOptions::ModelSimpleAvoid:
- /* increase velocity away from the pointer */
- dx = WIN_CX(window) - ds->mPx;
- dy = WIN_CY(window) - ds->mPy;
-
- dp = sqrt(dx*dx + dy*dy);
- if(WIN_W(window)/2 + PADDING_W - abs(dx) >
- WIN_H(window)/2 + PADDING_W - abs(dy))
- {
- mVx += POSITIVE(WIN_H(window)/2 + PADDING_W - abs(dy))
- * SPRING_K_W * dx/(abs(dx) + abs(dy)) * ms;
- mVy += POSITIVE(WIN_H(window)/2 + PADDING_W - abs(dy))
- * SPRING_K_W * dy/(abs(dx) + abs(dy)) * ms;
- } else {
- mVx += POSITIVE(WIN_W(window)/2 + PADDING_W - abs(dx))
- * SPRING_K_W * dx/(abs(dx) + abs(dy)) * ms;
- mVy += POSITIVE(WIN_W(window)/2 + PADDING_W - abs(dx))
- * SPRING_K_W * dy/(abs(dx) + abs(dy)) * ms;
- }
- break;
- case DodgeOptions::ModelReturnToPosition:
- if ((ds->mPx > mOx - WIN_W(window)/2 - PADDING_W &&
- ds->mPy > mOy - WIN_H(window)/2 - PADDING_W &&
- ds->mPx < mOx + WIN_W(window)/2 + PADDING_W &&
- ds->mPy < mOy + WIN_H(window)/2 + PADDING_W) &&
- !ds->mExiting && away)
- {
- /* increase velocity away from / toward the pointer */
- dx = WIN_CX(window) - ds->mPx;
- dy = WIN_CY(window) - ds->mPy;
-
- dp = sqrt(dx*dx + dy*dy);
- if(WIN_W(window)/2 + PADDING_W - abs(dx) >
- WIN_H(window)/2 + PADDING_W - abs(dy))
- {
- mVx += (WIN_H(window)/2 + PADDING_W - abs(dy))
- * SPRING_K_W * dx/(abs(dx) + abs(dy)) * ms;
- mVy += (WIN_H(window)/2 + PADDING_W - abs(dy))
- * SPRING_K_W * dy/(abs(dx) + abs(dy)) * ms;
- } else {
- mVx += (WIN_W(window)/2 + PADDING_W - abs(dx))
- * SPRING_K_W * dx/(abs(dx) + abs(dy)) * ms;
- mVy += (WIN_W(window)/2 + PADDING_W - abs(dx))
- * SPRING_K_W * dy/(abs(dx) + abs(dy)) * ms;
- }
- } else {
- /* increase velocity towards the original position */
- dx = WIN_CX(window) - mOx;
- dy = WIN_CY(window) - mOy;
-
- dp = sqrt(dx*dx + dy*dy);
- if (dx || dy)
- {
- mVx -= dp * SPRING_K_W * dx/(abs(dx) + abs(dy)) * ms;
- mVy -= dp * SPRING_K_W * dy/(abs(dx) + abs(dy)) * ms;
- }
- }
- break;
- case DodgeOptions::ModelOffScreen:
- if ((ds->mPx > mOx - WIN_W(window)/2 - PADDING_W &&
- ds->mPy > mOy - WIN_H(window)/2 - PADDING_W &&
- ds->mPx < mOx + WIN_W(window)/2 + PADDING_W &&
- ds->mPy < mOy + WIN_H(window)/2 + PADDING_W) &&
- !ds->mExiting && away)
- {
- switch (mPos)
- {
- case NORTH:
- dx = 0;
- dy = WIN_Y(window) + WIN_H(window);
- break;
- case SOUTH:
- dx = 0;
- dy = WIN_Y(window) - screen->height ();
- break;
- case EAST:
- dx = WIN_X(window) + WIN_W(window);
- dy = 0;
- break;
- case WEST:
- dx = WIN_X(window) - screen->width ();
- dy = 0;
- break;
- }
-
- mVx -= dx * SPRING_K_W * ms;
- mVy -= dy * SPRING_K_W * ms;
- } else {
- dx = WIN_CX(window) - mOx;
- dy = WIN_CY(window) - mOy;
-
- dp = sqrt(dx*dx + dy*dy);
- if (dx || dy)
- {
- mVx -= dp * SPRING_K_W * dx/(abs(dx) + abs(dy)) * ms * 0.5;
- mVy -= dp * SPRING_K_W * dy/(abs(dx) + abs(dy)) * ms * 0.5;
- }
- }
- break;
-
- }
-
- /* apply friction */
- mVx -= FRICTION_W * mVx * ms;
- mVy -= FRICTION_W * mVy * ms;
-
- /* stop the window going offscreen with the simple model */
- if (((WIN_X(window) + WIN_W(window) > screen->width () && mVx > 0) ||
- (WIN_X(window) < 0 && mVx < 0)) &&
- ds->mModel == DodgeOptions::ModelSimpleAvoid)
- mVx = 0;
- if (((WIN_Y(window) + WIN_H(window) > screen->height () && mVy > 0) ||
- (WIN_Y(window) < 0 && mVy < 0)) &&
- ds->mModel == DodgeOptions::ModelSimpleAvoid)
- mVy = 0;
- /* stop excessive velocity */
- if (mVx > screen->width () || mVx < 0 - screen->width () ||
- mVy > screen->height () || mVx < 0 - screen->height ())
- mVx = mVy = 0;
-
- mX += mVx * ms;
- mY += mVy * ms;
- /* if there's enough differenc, move the window */
- if (fabs(mX - WIN_X(window)) >= 1 || fabs(mY - WIN_Y(window)) >= 1)
- {
- window->move ((int) mX - WIN_X(window),
- (int) mY - WIN_Y(window),true);
- window->syncPosition ();
- ds->mMoreAdjust = TRUE;
- }
- if ((dy || dx) && !ds->mModel == DodgeOptions::ModelSimpleAvoid)
- {
- ds->mMoreAdjust = TRUE;
- }
- return 0;
-
-}
-
-
-void
-DodgeScreen::preparePaint (int ms)
-{
- /* 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 (screen->otherGrabExist ("dodge","expo","rotate",0))
- {
- cScreen->preparePaint (ms);
- return;
- }
-
- if (mActive)
- {
- mMoveLock = TRUE;
- mMoreAdjust = FALSE;
- foreach (CompWindow *w, screen->windows ())
- {
- DODGE_WINDOW (w);
- if (dw->mIsDodge)
- dw->step (ms,!screen->otherGrabExist ("dodge",0)
- && (screen->activeWindow () != w->id ()
- || optionGetDodgeActive ()));
- }
- mMoveLock = FALSE;
- }
- if (mExiting && !mMoreAdjust)
- {
- mActive = FALSE;
- mExiting = FALSE;
- mMoreAdjust = FALSE;
- }
-
- cScreen->preparePaint (ms);
-}
-
-void
-DodgeScreen::donePaint ()
-{
- if (mActive && mMoreAdjust)
- {
- foreach (CompWindow *w, screen->windows ())
- {
- DODGE_WINDOW(w);
- if (dw->mIsDodge)
- dw->cWindow->addDamage ();
- }
- }
- cScreen->donePaint ();
-}
-
-void
-DodgeWindow::update ()
-{
- DODGE_SCREEN (screen);
- if ((ds->optionGetWindowTypes ().evaluate (window) || mSelected) &&
- !(window->invisible () || window->destroyed () || window->minimized ()))
- {
- mIsDodge = TRUE;
- mVx = 0;
- mVy = 0;
- mX = (float) WIN_X(window);
- mY = (float) WIN_Y(window);
- /* don't change original position if dodge is active */
- if (!ds->mActive || !(mOx || mOy))
- {
- mOx = WIN_CX(window);
- mOy = WIN_CY(window);
- }
- if (WIN_CX(window) > WIN_CY(window) &&
- WIN_CX(window) * screen->height () +
- WIN_CY(window) * screen->width () >
- (screen->width () * screen->height ()))
- mPos = WEST;
- if (WIN_CX(window) < WIN_CY(window) &&
- WIN_CX(window) * screen->height () +
- WIN_CY(window) * screen->width () >
- (screen->width () * screen->height ()))
- mPos = SOUTH;
- if (WIN_CX(window) > WIN_CY(window) &&
- WIN_CX(window) * screen->height () +
- WIN_CY(window) * screen->width () <
- (screen->width () * screen->height ()))
- mPos = NORTH;
- if (WIN_CX(window) < WIN_CY(window) &&
- WIN_CX(window) * screen->height () +
- WIN_CY(window) * screen->width () <
- (screen->width () * screen->height ()))
- mPos = EAST;
-
- }
- else
- {
- if (mIsDodge)
- {
- mIsDodge = FALSE;
- mOx = 0;
- mOy = 0;
- }
- }
-
-}
-
-bool
-DodgeScreen::select (CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
-{
- Window xid;
- CompWindow *w;
-
- xid = CompOption::getIntOptionNamed (options, "window", 0);
- w = screen->findWindow (xid);
- DODGE_WINDOW(w);
- dw->mSelected = !dw->mSelected;
- if (mActive)
- dw->update ();
-
- return TRUE;
-}
-
-bool
-DodgeScreen::toggle (CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
-{
- if (mActive)
- {
- mPoller.stop ();
- mExiting = TRUE;
- }
- else
- {
- mPoller.start ();
- mModel = optionGetModel ();
- mSpringk = optionGetSpringK ();
- mFriction = optionGetFriction ();
- mPadding = optionGetPadding ();
- foreach (CompWindow *w, screen->windows ())
- {
- DodgeWindow::get (w)->update ();
- }
- mActive = TRUE;
- }
- return TRUE;
-}
-
-void
-DodgeWindow::moveNotify (int dx, int dy, bool immediate)
-{
- DODGE_SCREEN (screen);
-
- if (!ds->mMoveLock && ds->mActive)
- {
- mOx += dx;
- mOy += dy;
- }
-
- window->moveNotify (dx, dy, immediate);;
-}
-
-void
-DodgeWindow::resizeNotify (int dx,
- int dy,
- int dwidth,
- int dheight)
-{
- DODGE_SCREEN (screen);
-
- if (!ds->mMoveLock && ds->mActive)
- {
- mOx += dx;
- mOy += dy;
- }
-
- window->resizeNotify (dx, dy, dwidth, dheight);
-}
-
-void
-DodgeScreen::positionUpdate (const CompPoint &p)
-{
- int x = p.x ();
- int y = p.y ();
-
- mPx = x;
- mPy = y;
- if (mActive)
- {
- /* damage a small area around the mouse to prevent jerkiness */
- CompRegion r (mPx - PADDING,
- mPy - PADDING,
- PADDING * 2,
- PADDING * 2);
-
- cScreen->damageRegion (r);
- }
-
-}
-
-void
-DodgeWindow::stateChangeNotify (unsigned int last)
-{
- DODGE_SCREEN (screen);
-
- if (ds->mActive)
- update ();
-
- window->stateChangeNotify (last);
-}
-
-void
-DodgeScreen::optionChanged (CompOption *option,
- DodgeOptions::Options num)
-{
- switch (num)
- {
- case DodgeOptions::Model:
- mModel = optionGetModel ();
- case DodgeOptions::Friction:
- mFriction = optionGetFriction ();
- case DodgeOptions::Padding:
- mPadding = optionGetPadding ();
- case DodgeOptions::SpringK:
- mSpringk = optionGetSpringK ();
- case DodgeOptions::WindowTypes:
- foreach (CompWindow *w, screen->windows ())
- DodgeWindow::get (w)->update ();
- default:
- break;
- }
-}
-
-DodgeScreen::DodgeScreen (CompScreen *screen) :
- PluginClassHandler <DodgeScreen, CompScreen> (screen),
- cScreen (CompositeScreen::get (screen)),
- gScreen (GLScreen::get (screen)),
- mWindow (NULL),
- mPx (0),
- mPy (0),
- mModel (0),
- mPadding (0),
- mSpringk (0.0f),
- mFriction (0.0f),
- mExiting (false),
- mMoveLock (false),
- mMoreAdjust (false),
- mActive (false)
-{
- CompositeScreenInterface::setHandler (cScreen);
-
- optionSetDodgeToggleKeyInitiate (boost::bind (&DodgeScreen::toggle, this, _1, _2, _3));
- optionSetDodgeToggleButtonInitiate (boost::bind (&DodgeScreen::toggle, this, _1, _2, _3));
- optionSetDodgeToggleEdgeInitiate (boost::bind (&DodgeScreen::toggle, this, _1, _2, _3));
- optionSetDodgeSelectKeyInitiate (boost::bind (&DodgeScreen::select, this, _1, _2, _3));
-
- optionSetModelNotify (boost::bind (&DodgeScreen::optionChanged, this, _1, _2));
- optionSetFrictionNotify (boost::bind (&DodgeScreen::optionChanged, this, _1, _2));
- optionSetPaddingNotify (boost::bind (&DodgeScreen::optionChanged, this, _1, _2));
- optionSetSpringKNotify (boost::bind (&DodgeScreen::optionChanged, this, _1, _2));
- optionSetWindowTypesNotify (boost::bind (&DodgeScreen::optionChanged, this, _1, _2));
-
- mPoller.setCallback (boost::bind (&DodgeScreen::positionUpdate, this, _1));
- CompPoint p = mPoller.getPosition ();
-
- mPx = p.x ();
- mPy = p.y ();
-}
-
-DodgeScreen::~DodgeScreen ()
-{
- mPoller.stop ();
-}
-
-DodgeWindow::DodgeWindow (CompWindow *w) :
- PluginClassHandler <DodgeWindow, CompWindow> (w),
- window (w),
- cWindow (CompositeWindow::get (w)),
- gWindow (GLWindow::get (w)),
- mVx (0),
- mVy (0),
- mSelected (false),
- mIsDodge (false)
-{
- WindowInterface::setHandler (window);
-
- if (DodgeScreen::get (screen)->mActive)
- update ();
-}
-
-bool
-DodgePluginVTable::init ()
-{
- if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION) ||
- !CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI) ||
- !CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI) ||
- !CompPlugin::checkPluginABI ("mousepoll", COMPIZ_MOUSEPOLL_ABI))
- return false;
-
- return true;
-}
diff --git a/src/dodge.h b/src/dodge.h
deleted file mode 100644
index 4d4d6c6..0000000
--- a/src/dodge.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/**
- *
- * dodge.h
- *
- * 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.
- *
- **/
-
-#include <core/core.h>
-#include <composite/composite.h>
-#include <opengl/opengl.h>
-#include <mousepoll/mousepoll.h>
-
-#include <cmath>
-
-#include "dodge_options.h"
-
-#define NORTH 0
-#define SOUTH 1
-#define EAST 2
-#define WEST 3
-
-class DodgeWindow :
- public PluginClassHandler <DodgeWindow, CompWindow>,
- public WindowInterface
-{
- public:
-
- DodgeWindow (CompWindow *);
-
- public:
-
- CompWindow *window;
- CompositeWindow *cWindow;
- GLWindow *gWindow;
-
- float mVx;
- float mVy;
- float mX;
- float mY;
- float mOx;
- float mOy;
- int mPos;
- bool mSelected;
- bool mIsDodge;
-
- void
- resizeNotify (int, int, int, int);
-
- void
- moveNotify (int, int, bool);
-
- void
- stateChangeNotify (unsigned int);
-
- int
- step (int, int);
-
- void
- update ();
-
-
-
-};
-
-class DodgeScreen :
- public PluginClassHandler <DodgeScreen, CompScreen>,
- public CompositeScreenInterface,
- public DodgeOptions
-{
- public:
-
- DodgeScreen (CompScreen *);
- ~DodgeScreen ();
-
- public:
-
- CompositeScreen *cScreen;
- GLScreen *gScreen;
-
- MousePoller mPoller;
-
- CompWindow *mWindow;
-
- int mPx;
- int mPy;
- int mModel;
- int mPadding;
- float mSpringk;
- float mFriction;
- bool mExiting;
- bool mMoveLock;
- bool mMoreAdjust;
- bool mActive;
-
- void
- preparePaint (int);
-
- void
- donePaint ();
-
- bool
- select (CompAction *action,
- CompAction::State state,
- CompOption::Vector &options);
-
- bool
- toggle (CompAction *action,
- CompAction::State state,
- CompOption::Vector &options);
-
- void
- positionUpdate (const CompPoint &p);
-
- void
- optionChanged (CompOption *option,
- DodgeOptions::Options num);
-
-
-};
-
-#define DODGE_SCREEN(s) \
- DodgeScreen *ds = DodgeScreen::get (s);
-
-#define DODGE_WINDOW(w) \
- DodgeWindow *dw = DodgeWindow::get (w);
-
-class DodgePluginVTable :
- public CompPlugin::VTableForScreenAndWindow <DodgeScreen, DodgeWindow>
-{
- public:
-
- bool init ();
-};