diff options
author | Dennis Kasprzyk <onestone@opencompositing.org> | 2008-01-18 16:07:32 +0100 |
---|---|---|
committer | Dennis kasprzyk <onestone@opencompositing.org> | 2008-01-18 16:07:32 +0100 |
commit | 0e6e36eb55621e894db12cd907fa6527db56e736 (patch) | |
tree | ad5dfe111bed9e102555978ab10e996244fb8635 | |
parent | 26ccdb5aefdcf42df0a6413d71f048070194325c (diff) | |
download | mousepoll-0e6e36eb55621e894db12cd907fa6527db56e736.tar.gz mousepoll-0e6e36eb55621e894db12cd907fa6527db56e736.tar.bz2 |
Initial commit.
-rw-r--r-- | Makefile | 467 | ||||
-rw-r--r-- | compiz-mousepoll.h | 51 | ||||
-rw-r--r-- | compiz-mousepoll.pc.in | 12 | ||||
-rw-r--r-- | dummy | 0 | ||||
-rw-r--r-- | mousepoll.c | 483 | ||||
-rw-r--r-- | mousepoll.xml.in | 22 | ||||
-rw-r--r-- | plugin.info | 1 |
7 files changed, 1036 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..cc68853 --- /dev/null +++ b/Makefile @@ -0,0 +1,467 @@ +## +# +# 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 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 += $(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; \ + 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 "$(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/compiz-mousepoll.h b/compiz-mousepoll.h new file mode 100644 index 0000000..cf1b64b --- /dev/null +++ b/compiz-mousepoll.h @@ -0,0 +1,51 @@ +/* + * + * Compiz mouse position polling plugin + * + * Copyright : (C) 2008 by Dennis Kasprzyk + * E-mail : onestone@opencompositing.org + * + * + * 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. + * + */ + +#ifndef _COMPIZ_MOUSEPOLL_H +#define _COMPIZ_MOUSEPOLL_H + +#define MOUSEPOLL_ABIVERSION 20080116 + +typedef int PositionPollingHandle; + +typedef void (*PositionUpdateProc) (CompScreen *s, + int x, + int y); + +typedef PositionPollingHandle +(*AddPositionPollingProc) (CompScreen *s, + PositionUpdateProc update); + +typedef void +(*RemovePositionPollingProc) (CompScreen *s, + PositionPollingHandle id); + +typedef void +(*GetCurrentPositionProc) (CompScreen *s, + int *x, + int *y); + +typedef struct _MousePollFunc { + AddPositionPollingProc addPositionPolling; + RemovePositionPollingProc removePositionPolling; + GetCurrentPositionProc getCurrentPosition; +} MousePollFunc; + +#endif diff --git a/compiz-mousepoll.pc.in b/compiz-mousepoll.pc.in new file mode 100644 index 0000000..341681b --- /dev/null +++ b/compiz-mousepoll.pc.in @@ -0,0 +1,12 @@ +prefix=@prefix@ +exec_prefix=@prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: compiz-mousepoll +Description: Mousepoll plugin for compiz +Version: @VERSION@ + +Requires: +Libs: +Cflags: @COMPIZ_CFLAGS@ diff --git a/mousepoll.c b/mousepoll.c new file mode 100644 index 0000000..04df5eb --- /dev/null +++ b/mousepoll.c @@ -0,0 +1,483 @@ +/* + * + * Compiz mouse position polling plugin + * + * mousepoll.c + * + * Copyright : (C) 2008 by Dennis Kasprzyk + * E-mail : onestone@opencompositing.org + * + * + * 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 <compiz-core.h> + +#include "compiz-mousepoll.h" + +static CompMetadata mousepollMetadata; + +static int displayPrivateIndex; +static int functionsPrivateIndex; + +typedef struct _MousepollClient MousepollClient; + +struct _MousepollClient { + MousepollClient *next; + MousepollClient *prev; + + PositionPollingHandle id; + PositionUpdateProc update; +}; + +typedef enum _MousepollDisplayOptions +{ + MP_DISPLAY_OPTION_ABI, + MP_DISPLAY_OPTION_INDEX, + MP_DISPLAY_OPTION_MOUSE_POLL_INTERVAL, + MP_DISPLAY_OPTION_NUM +} MousepollDisplayOptions; + +typedef struct _MousepollDisplay { + int screenPrivateIndex; + + CompOption opt[MP_DISPLAY_OPTION_NUM]; +} MousepollDisplay; + +typedef struct _MousepollScreen { + + MousepollClient *clients; + PositionPollingHandle freeId; + + CompTimeoutHandle updateHandle; + int posX; + int posY; + +} MousepollScreen; + + +#define GET_MOUSEPOLL_DISPLAY(d) \ + ((MousepollDisplay *) (d)->base.privates[displayPrivateIndex].ptr) + +#define MOUSEPOLL_DISPLAY(d) \ + MousepollDisplay *md = GET_MOUSEPOLL_DISPLAY (d) + +#define GET_MOUSEPOLL_SCREEN(s, md) \ + ((MousepollScreen *) (s)->base.privates[(md)->screenPrivateIndex].ptr) + +#define MOUSEPOLL_SCREEN(s) \ + MousepollScreen *ms = GET_MOUSEPOLL_SCREEN (s, GET_MOUSEPOLL_DISPLAY (s->display)) + +#define NUM_OPTIONS(s) (sizeof ((s)->opt) / sizeof (CompOption)) + +static Bool +getMousePosition (CompScreen *s) +{ + Window root_return; + Window child_return; + int rootX, rootY; + int winX, winY; + unsigned int maskReturn; + Bool status; + + MOUSEPOLL_SCREEN (s); + + status = XQueryPointer (s->display->display, s->root, + &root_return, &child_return, + &rootX, &rootY, &winX, &winY, &maskReturn); + + if (!status || rootX > s->width || rootY > s->height || + s->root != root_return) + return FALSE; + + if ((rootX != ms->posX || rootY != ms->posY)) + { + ms->posX = rootX; + ms->posY = rootY; + return TRUE; + } + return FALSE; +} + +static Bool +updatePosition (void *c) +{ + CompScreen *s = (CompScreen *)c; + MousepollClient *mc; + + MOUSEPOLL_SCREEN (s); + + if (!ms->clients) + return FALSE; + + if (getMousePosition (s)) + { + for (mc = ms->clients; mc; mc = mc->next) + if (mc->update) + (*mc->update) (s, ms->posX, ms->posY); + } + + return TRUE; +} + +static PositionPollingHandle +mousepollAddPositionPolling (CompScreen *s, + PositionUpdateProc update) +{ + MOUSEPOLL_SCREEN (s); + MOUSEPOLL_DISPLAY (s->display); + + Bool start = FALSE; + + MousepollClient *mc = malloc (sizeof (MousepollClient)); + + if (!mc) + return -1; + + if (!ms->clients) + start = TRUE; + + mc->update = update; + mc->id = ms->freeId; + ms->freeId++; + + mc->prev = NULL; + mc->next = ms->clients; + + if (ms->clients) + ms->clients->prev = mc; + + ms->clients = mc; + + if (start) + { + getMousePosition (s); + ms->updateHandle = + compAddTimeout ( + md->opt[MP_DISPLAY_OPTION_MOUSE_POLL_INTERVAL].value.i, + updatePosition, s); + } + + return mc->id; +} + +static void +mousepollRemovePositionPolling (CompScreen *s, + PositionPollingHandle id) +{ + MOUSEPOLL_SCREEN (s); + + MousepollClient *mc = ms->clients; + + if (ms->clients && ms->clients->id == id) + { + ms->clients = ms->clients->next; + if (ms->clients) + ms->clients->prev = NULL; + + free (mc); + return; + } + + for (mc = ms->clients; mc; mc = mc->next) + if (mc->id == id) + { + if (mc->next) + mc->next->prev = mc->prev; + if (mc->prev) + mc->prev->next = mc->next; + free (mc); + return; + } + + if (!ms->clients && ms->updateHandle) + { + compRemoveTimeout (ms->updateHandle); + ms->updateHandle = 0; + } +} + +static void +mousepollGetCurrentPosition (CompScreen *s, + int *x, + int *y) +{ + MOUSEPOLL_SCREEN (s); + + if (!ms->clients) + getMousePosition (s); + + if (x) + *x = ms->posX; + if (y) + *y = ms->posY; +} + +static const CompMetadataOptionInfo mousepollDisplayOptionInfo[] = { + { "abi", "int", 0, 0, 0 }, + { "index", "int", 0, 0, 0 }, + { "mouse_poll_interval", "int", "<min>1</min><max>500</max><default>10</default>", 0, 0 } +}; + +static CompOption * +mousepollGetDisplayOptions (CompPlugin *plugin, + CompDisplay *display, + int *count) +{ + MOUSEPOLL_DISPLAY (display); + *count = NUM_OPTIONS (md); + return md->opt; +} + +static Bool +mousepollSetDisplayOption (CompPlugin *plugin, + CompDisplay *display, + const char *name, + CompOptionValue *value) +{ + CompOption *o; + CompScreen *s; + MousepollScreen *ms; + int index; + Bool status = FALSE; + MOUSEPOLL_DISPLAY (display); + o = compFindOption (md->opt, NUM_OPTIONS (md), name, &index); + if (!o) + return FALSE; + + switch (index) { + case MP_DISPLAY_OPTION_ABI: + case MP_DISPLAY_OPTION_INDEX: + break; + case MP_DISPLAY_OPTION_MOUSE_POLL_INTERVAL: + status = compSetDisplayOption (display, o, value); + for (s = display->screens; s; s = s->next) + { + ms = GET_MOUSEPOLL_SCREEN (s, md); + if (ms->updateHandle) + { + compRemoveTimeout (ms->updateHandle); + ms->updateHandle = + compAddTimeout ( + md->opt[MP_DISPLAY_OPTION_MOUSE_POLL_INTERVAL].value.i, + updatePosition, s); + } + } + return status; + break; + default: + return compSetDisplayOption (display, o, value); + } + + return FALSE; +} + +static MousePollFunc mousepollFunctions = +{ + .addPositionPolling = mousepollAddPositionPolling, + .removePositionPolling = mousepollRemovePositionPolling, + .getCurrentPosition = mousepollGetCurrentPosition, +}; + +static Bool +mousepollInitDisplay (CompPlugin *p, + CompDisplay *d) +{ + MousepollDisplay *md; + + if (!checkPluginABI ("core", CORE_ABIVERSION)) + return FALSE; + + md = malloc (sizeof (MousepollDisplay)); + if (!md) + return FALSE; + if (!compInitDisplayOptionsFromMetadata (d, + &mousepollMetadata, + mousepollDisplayOptionInfo, + md->opt, + MP_DISPLAY_OPTION_NUM)) + { + free (md); + return FALSE; + } + + md->screenPrivateIndex = allocateScreenPrivateIndex (d); + if (md->screenPrivateIndex < 0) + { + compFiniDisplayOptions (d, md->opt, MP_DISPLAY_OPTION_NUM); + free (md); + return FALSE; + } + + md->opt[MP_DISPLAY_OPTION_ABI].value.i = MOUSEPOLL_ABIVERSION; + md->opt[MP_DISPLAY_OPTION_INDEX].value.i = functionsPrivateIndex; + + d->base.privates[displayPrivateIndex].ptr = md; + d->base.privates[functionsPrivateIndex].ptr = &mousepollFunctions; + return TRUE; +} + +static void +mousepollFiniDisplay (CompPlugin *p, + CompDisplay *d) +{ + MOUSEPOLL_DISPLAY (d); + + compFiniDisplayOptions (d, md->opt, MP_DISPLAY_OPTION_NUM); + free (md); +} + +static Bool +mousepollInitScreen (CompPlugin *p, + CompScreen *s) +{ + MousepollScreen *ms; + + MOUSEPOLL_DISPLAY (s->display); + + ms = malloc (sizeof (MousepollScreen)); + if (!ms) + return FALSE; + + ms->posX = 0; + ms->posY = 0; + + ms->clients = NULL; + ms->freeId = 1; + + s->base.privates[md->screenPrivateIndex].ptr = ms; + return TRUE; +} + +static void +mousepollFiniScreen (CompPlugin *p, + CompScreen *s) +{ + MOUSEPOLL_SCREEN (s); + + free (ms); +} + +static CompBool +mousepollInitObject (CompPlugin *p, + CompObject *o) +{ + static InitPluginObjectProc dispTab[] = { + (InitPluginObjectProc) 0, /* InitCore */ + (InitPluginObjectProc) mousepollInitDisplay, + (InitPluginObjectProc) mousepollInitScreen + }; + + RETURN_DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), TRUE, (p, o)); +} + +static void +mousepollFiniObject (CompPlugin *p, + CompObject *o) +{ + static FiniPluginObjectProc dispTab[] = { + (FiniPluginObjectProc) 0, /* FiniCore */ + (FiniPluginObjectProc) mousepollFiniDisplay, + (FiniPluginObjectProc) mousepollFiniScreen + }; + + DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), (p, o)); +} + +static Bool +mousepollInit (CompPlugin *p) +{ + if (!compInitPluginMetadataFromInfo (&mousepollMetadata, + p->vTable->name, + mousepollDisplayOptionInfo, + MP_DISPLAY_OPTION_NUM, + NULL, 0)) + return FALSE; + + displayPrivateIndex = allocateDisplayPrivateIndex (); + if (displayPrivateIndex < 0) + { + compFiniMetadata (&mousepollMetadata); + return FALSE; + } + + functionsPrivateIndex = allocateDisplayPrivateIndex (); + if (functionsPrivateIndex < 0) + { + freeDisplayPrivateIndex (displayPrivateIndex); + compFiniMetadata (&mousepollMetadata); + return FALSE; + } + + compAddMetadataFromFile (&mousepollMetadata, p->vTable->name); + return TRUE; +} + +static CompOption * +mousepollGetObjectOptions (CompPlugin *plugin, + CompObject *object, + int *count) +{ + static GetPluginObjectOptionsProc dispTab[] = { + (GetPluginObjectOptionsProc) 0, /* GetCoreOptions */ + (GetPluginObjectOptionsProc) mousepollGetDisplayOptions + }; + + RETURN_DISPATCH (object, dispTab, ARRAY_SIZE (dispTab), + (void *) (*count = 0), (plugin, object, count)); +} + +static CompBool +mousepollSetObjectOption (CompPlugin *plugin, + CompObject *object, + const char *name, + CompOptionValue *value) +{ + static SetPluginObjectOptionProc dispTab[] = { + (SetPluginObjectOptionProc) 0, /* SetCoreOption */ + (SetPluginObjectOptionProc) mousepollSetDisplayOption + }; + + RETURN_DISPATCH (object, dispTab, ARRAY_SIZE (dispTab), FALSE, + (plugin, object, name, value)); +} + +static void +mousepollFini (CompPlugin *p) +{ + freeDisplayPrivateIndex (displayPrivateIndex); + freeDisplayPrivateIndex (functionsPrivateIndex); + compFiniMetadata (&mousepollMetadata); +} + +static CompMetadata * +mousepollGetMetadata (CompPlugin *plugin) +{ + return &mousepollMetadata; +} + +CompPluginVTable mousepollVTable = { + "mousepoll", + mousepollGetMetadata, + mousepollInit, + mousepollFini, + mousepollInitObject, + mousepollFiniObject, + mousepollGetObjectOptions, + mousepollSetObjectOption +}; + +CompPluginVTable * +getCompPluginInfo20070830 (void) +{ + return &mousepollVTable; +} diff --git a/mousepoll.xml.in b/mousepoll.xml.in new file mode 100644 index 0000000..cb67917 --- /dev/null +++ b/mousepoll.xml.in @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<compiz> + <plugin name="mousepoll"> + <_short>Mouse position polling</_short> + <_long>Updates the mouse pointer position from the xserver</_long> + <category>Utility</category> + <display> + <option name="abi" type="int" read_only="true"/> + <option name="index" type="int" read_only="true"/> + <group> + <_short>Misc</_short> + <option type="int" name="mouse_poll_interval"> + <_short>Mouse Poll Interval</_short> + <_long>How often to poll the mouse position, in miliseconds. Reduce this to reduce choppy behavior.</_long> + <default>10</default> + <min>1</min> + <max>500</max> + </option> + </group> + </display> + </plugin> +</compiz> diff --git a/plugin.info b/plugin.info new file mode 100644 index 0000000..d23fcce --- /dev/null +++ b/plugin.info @@ -0,0 +1 @@ +PLUGIN = mousepoll |