summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <smspillaz@gmail.com>2009-09-04 17:09:05 +0800
committerSam Spilsbury <smspillaz@gmail.com>2009-09-04 17:09:05 +0800
commite708d5a740f9f803b57ba7d3c1a66955b40b7459 (patch)
tree85808241aba6240d6e60cc9cbb6a1b664bf87dfb
parent46960f12a9d213e5f0e841557e2ed2f7ea18cc79 (diff)
downloadworkarounds-e708d5a740f9f803b57ba7d3c1a66955b40b7459.tar.gz
workarounds-e708d5a740f9f803b57ba7d3c1a66955b40b7459.tar.bz2
C++ port
-rw-r--r--CMakeLists.txt6
-rw-r--r--Makefile533
-rw-r--r--plugin.info2
-rw-r--r--src/workarounds.cpp691
-rw-r--r--src/workarounds.h159
-rw-r--r--workarounds.c855
-rw-r--r--workarounds.xml.in19
7 files changed, 867 insertions, 1398 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3ed7405..041e31b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,3 +1,5 @@
-include (CompizFusion)
+find_package (Compiz REQUIRED)
-compiz_fusion_plugin (workarounds)
+include (CompizPlugin)
+
+compiz_plugin (workarounds PLUGINDEPS composite opengl)
diff --git a/Makefile b/Makefile
deleted file mode 100644
index d9a07cf..0000000
--- a/Makefile
+++ /dev/null
@@ -1,533 +0,0 @@
-##
-#
-# 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); \
- $(INSTALL) $(BUILDDIR)/$(PLUGIN).xml $(XMLDIR)/$(PLUGIN).xml; \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0minstall : \033[34m$(XMLDIR)/$(PLUGIN).xml\033[0m"; \
- fi; \
- fi
- @if [ -n "$(hdr-install-target)" ]; then \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5minstall \033[0m: \033[0;31m$(CINCDIR)/compiz/$(hdr-install-target)\033[0m"; \
- else \
- $(ECHO) "install : $(CINCDIR)/compiz/$(hdr-install-target)"; \
- fi; \
- $(INSTALL) --mode=u=rw,go=r,a-s $(hdr-install-target) $(CINCDIR)/compiz/$(hdr-install-target); \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0minstall : \033[34m$(CINCDIR)/compiz/$(hdr-install-target)\033[0m"; \
- fi; \
- fi
- @if [ -n "$(pkg-target)" ]; then \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5minstall \033[0m: \033[0;31m$(PKGDIR)/compiz-$(PLUGIN).pc\033[0m"; \
- else \
- $(ECHO) "install : $(PKGDIR)/compiz-$(PLUGIN).pc"; \
- fi; \
- $(INSTALL) --mode=u=rw,go=r,a-s $(pkg-target) $(PKGDIR)/compiz-$(PLUGIN).pc; \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0minstall : \033[34m$(PKGDIR)/compiz-$(PLUGIN).pc\033[0m"; \
- fi; \
- fi
- @if [ -n "$(schema-output)" -a -e "$(schema-output)" ]; then \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5minstall \033[0m: \033[0;31m$(schema-output)\033[0m"; \
- else \
- $(ECHO) "install : $(schema-output)"; \
- fi; \
- if [ "x$(USER)" = "xroot" ]; then \
- GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source` \
- gconftool-2 --makefile-install-rule $(schema-output) > /dev/null; \
- else \
- gconftool-2 --install-schema-file=$(schema-output) > /dev/null; \
- fi; \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0minstall : \033[34m$(schema-output)\033[0m"; \
- fi; \
- fi
- @if [ -n "$(data-files)" ]; then \
- mkdir -p $(DATADIR); \
- for FILE in $(data-files); do \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5minstall \033[0m: \033[0;31m$(DATADIR)/$$FILE\033[0m"; \
- else \
- $(ECHO) "install : $(DATADIR)/$$FILE"; \
- fi; \
- FILEDIR="$(DATADIR)/`dirname "$$FILE"`"; \
- mkdir -p "$$FILEDIR"; \
- $(INSTALL) --mode=u=rw,go=r,a-s data/$$FILE $(DATADIR)/$$FILE; \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0minstall : \033[34m$(DATADIR)/$$FILE\033[0m"; \
- fi; \
- done \
- fi
- @if [ -n "$(image-files)" ]; then \
- mkdir -p $(IMAGEDIR); \
- for FILE in $(image-files); do \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5minstall \033[0m: \033[0;31m$(IMAGEDIR)/$$FILE\033[0m"; \
- else \
- $(ECHO) "install : $(IMAGEDIR)/$$FILE"; \
- fi; \
- FILEDIR="$(IMAGEDIR)/`dirname "$$FILE"`"; \
- mkdir -p "$$FILEDIR"; \
- $(INSTALL) --mode=u=rw,go=r,a-s images/$$FILE $(IMAGEDIR)/$$FILE; \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0minstall : \033[34m$(IMAGEDIR)/$$FILE\033[0m"; \
- fi; \
- done \
- fi
-
-uninstall:
- @if [ -e $(DESTDIR)/lib$(PLUGIN).so ]; then \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5muninstall \033[0m: \033[0;31m$(DESTDIR)/lib$(PLUGIN).so\033[0m"; \
- else \
- $(ECHO) "uninstall : $(DESTDIR)/lib$(PLUGIN).so"; \
- fi; \
- rm -f $(DESTDIR)/lib$(PLUGIN).so; \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0muninstall : \033[34m$(DESTDIR)/lib$(PLUGIN).so\033[0m"; \
- fi; \
- fi
- @if [ -e $(XMLDIR)/$(PLUGIN).xml ]; then \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5muninstall \033[0m: \033[0;31m$(XMLDIR)/$(PLUGIN).xml\033[0m"; \
- else \
- $(ECHO) "uninstall : $(XMLDIR)/$(PLUGIN).xml"; \
- fi; \
- rm -f $(XMLDIR)/$(PLUGIN).xml; \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0muninstall : \033[34m$(XMLDIR)/$(PLUGIN).xml\033[0m"; \
- fi; \
- fi
- @if [ -n "$(hdr-install-target)" -a -e $(CINCDIR)/compiz/$(hdr-install-target) ]; then \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5muninstall \033[0m: \033[0;31m$(CINCDIR)/compiz/$(hdr-install-target)\033[0m"; \
- else \
- $(ECHO) "uninstall : $(CINCDIR)/compiz/$(hdr-install-target)"; \
- fi; \
- rm -f $(CINCDIR)/compiz/$(hdr-install-target); \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0muninstall : \033[34m$(CINCDIR)/compiz/$(hdr-install-target)\033[0m"; \
- fi; \
- fi
- @if [ -n "$(pkg-target)" -a -e $(PKGDIR)/compiz-$(PLUGIN).pc ]; then \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5muninstall \033[0m: \033[0;31m$(PKGDIR)/compiz-$(PLUGIN).pc\033[0m"; \
- else \
- $(ECHO) "uninstall : $(PKGDIR)/compiz-$(PLUGIN).pc"; \
- fi; \
- rm -f $(PKGDIR)/compiz-$(PLUGIN).pc; \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0muninstall : \033[34m$(PKGDIR)/compiz-$(PLUGIN).pc\033[0m"; \
- fi; \
- fi
- @if [ -n "$(schema-output)" -a -e "$(schema-output)" -a 'x$(USER)' = 'xroot' ]; then \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5muninstall \033[0m: \033[0;31m$(schema-output)\033[0m"; \
- else \
- $(ECHO) "uninstall : $(schema-output)"; \
- fi; \
- GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source` \
- gconftool-2 --makefile-uninstall-rule $(schema-output) > /dev/null; \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0muninstall : \033[34m$(schema-output)\033[0m"; \
- fi; \
- fi
- @if [ -n "$(data-files)" ]; then \
- for FILE in $(data-files); do \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5muninstall \033[0m: \033[0;31m$(DATADIR)/$$FILE\033[0m"; \
- else \
- $(ECHO) "uninstall : $(DATADIR)/$$FILE"; \
- fi; \
- rm -f $(DATADIR)/$$FILE; \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0muninstall : \033[34m$(DATADIR)/$$FILE\033[0m"; \
- fi; \
- done \
- fi
- @if [ -n "$(image-files)" ]; then \
- for FILE in $(image-files); do \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -n -e "\033[0;1;5muninstall \033[0m: \033[0;31m$(IMAGEDIR)/$$FILE\033[0m"; \
- else \
- $(ECHO) "uninstall : $(IMAGEDIR)/$$FILE"; \
- fi; \
- rm -f $(IMAGEDIR)/$$FILE; \
- if [ '$(color)' != 'no' ]; then \
- $(ECHO) -e "\r\033[0muninstall : \033[34m$(IMAGEDIR)/$$FILE\033[0m"; \
- fi; \
- done \
- fi
diff --git a/plugin.info b/plugin.info
deleted file mode 100644
index ada615e..0000000
--- a/plugin.info
+++ /dev/null
@@ -1,2 +0,0 @@
-PLUGIN = workarounds
-CFLAGS_ADD = -I./build
diff --git a/src/workarounds.cpp b/src/workarounds.cpp
new file mode 100644
index 0000000..eb336ff
--- /dev/null
+++ b/src/workarounds.cpp
@@ -0,0 +1,691 @@
+/*
+ * Copyright (C) 2007 Andrew Riedi <andrewriedi@gmail.com>
+ *
+ * Sticky window handling and OpenGL fixes:
+ * Copyright (c) 2007 Dennis Kasprzyk <onestone@opencompositing.org>
+ *
+ * Ported to Compiz 0.9:
+ * Copyright (c) 2008 Sam Spilsbury <smspillaz@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * This plug-in for Metacity-like workarounds.
+ */
+
+#include "workarounds.h"
+
+bool haveOpenGL;
+
+COMPIZ_PLUGIN_20090315 (workarounds, WorkaroundsPluginVTable);
+
+void
+WorkaroundsScreen::checkFunctions (bool checkWindow, bool checkScreen)
+{
+ if (haveOpenGL && optionGetForceGlxSync () && checkScreen)
+ {
+ gScreen->glPaintOutputSetEnabled (this, true);
+ }
+ else if (haveOpenGL && checkScreen)
+ {
+ gScreen->glPaintOutputSetEnabled (this, false);
+ }
+
+ if ((optionGetLegacyFullscreen () ||
+ optionGetFirefoxMenuFix () ||
+ optionGetOooMenuFix () ||
+ optionGetNotificationDaemonFix () ||
+ optionGetJavaFix () ||
+ optionGetQtFix () ||
+ optionGetConvertUrgency () ) && checkScreen)
+ {
+ screen->handleEventSetEnabled (this, true);
+ }
+ else if (checkScreen)
+ {
+ screen->handleEventSetEnabled (this, false);
+ }
+
+ if (optionGetLegacyFullscreen () && checkWindow)
+ {
+ foreach (CompWindow *w, screen->windows ())
+ {
+ WORKAROUNDS_WINDOW (w);
+
+ ww->window->getAllowedActionsSetEnabled (ww, true);
+ ww->window->resizeNotifySetEnabled (ww, true);
+ }
+ }
+ else if (checkWindow)
+ {
+ foreach (CompWindow *w, screen->windows ())
+ {
+ WORKAROUNDS_WINDOW (w);
+
+ ww->window->getAllowedActionsSetEnabled (ww, false);
+ ww->window->resizeNotifySetEnabled (ww, false);
+ }
+ }
+}
+
+
+void
+WorkaroundsScreen::addToFullscreenList (CompWindow *w)
+{
+ mfwList.push_back (w->id ());
+}
+
+void
+WorkaroundsScreen::removeFromFullscreenList (CompWindow *w)
+{
+ mfwList.remove (w->id ());
+}
+
+static void
+workaroundsProgramEnvParameter4f (GLenum target,
+ GLuint index,
+ GLfloat x,
+ GLfloat y,
+ GLfloat z,
+ GLfloat w)
+{
+ WorkaroundsScreen *ws;
+ GLdouble data[4];
+
+ ws = WorkaroundsScreen::get (screen);
+
+ data[0] = x;
+ data[1] = y;
+ data[2] = z;
+ data[3] = w;
+
+ (*ws->programEnvParameter4dv) (target, index, data);
+}
+
+void
+WorkaroundsScreen::updateParameterFix ()
+{
+ if (!GL::programEnvParameter4f || !programEnvParameter4dv)
+ return;
+ if (optionGetAiglxFragmentFix ())
+ GL::programEnvParameter4f = workaroundsProgramEnvParameter4f;
+ else
+ GL::programEnvParameter4f = origProgramEnvParameter4f;
+}
+
+bool
+WorkaroundsScreen::glPaintOutput (const GLScreenPaintAttrib &attrib,
+ const GLMatrix &transform,
+ const CompRegion &region,
+ CompOutput *output,
+ unsigned int mask)
+{
+ if (optionGetForceGlxSync ())
+ glXWaitX ();
+
+ return gScreen->glPaintOutput (attrib, transform, region, output, mask);
+}
+
+CompString
+WorkaroundsWindow::getRoleAtom ()
+{
+ Atom type;
+ unsigned long nItems;
+ unsigned long bytesAfter;
+ unsigned char *str = NULL;
+ int format, result;
+ CompString retval;
+
+ WORKAROUNDS_SCREEN (screen);
+
+ result = XGetWindowProperty (screen->dpy (), window->id (), ws->roleAtom,
+ 0, LONG_MAX, FALSE, XA_STRING,
+ &type, &format, &nItems, &bytesAfter,
+ (unsigned char **) &str);
+
+ if (result != Success)
+ return NULL;
+
+ if (type != XA_STRING)
+ {
+ XFree (str);
+ return NULL;
+ }
+
+ retval = CompString ((const char *) str);
+
+ return retval;
+}
+
+void
+WorkaroundsWindow::removeSticky ()
+{
+ if (window->state () & CompWindowStateStickyMask && madeSticky)
+ window->changeState (window->state () & ~CompWindowStateStickyMask);
+ madeSticky = FALSE;
+}
+
+void
+WorkaroundsWindow::updateSticky ()
+{
+ Bool makeSticky = FALSE;
+
+ WORKAROUNDS_SCREEN (screen);
+
+ if (ws->optionGetStickyAlldesktops () && window->desktop () == 0xffffffff &&
+ ws->optionGetAlldesktopStickyMatch ().evaluate (window))
+ makeSticky = TRUE;
+
+ if (makeSticky)
+ {
+ if (!(window->state () & CompWindowStateStickyMask))
+ {
+ madeSticky = TRUE;
+ window->changeState (
+ window->state () | CompWindowStateStickyMask);
+ }
+ }
+ else
+ removeSticky ();
+}
+
+void
+WorkaroundsWindow::updateUrgencyState ()
+{
+ Bool urgent;
+ XWMHints *xwmh;
+
+ xwmh = XGetWMHints (screen->dpy (), window->id ());
+
+ if (!xwmh)
+ {
+ XFree (xwmh);
+ return;
+ }
+
+ urgent = (xwmh->flags & XUrgencyHint);
+
+ XFree (xwmh);
+
+ if (urgent)
+ {
+ madeDemandAttention = TRUE;
+ window->changeState (window->state () |
+ CompWindowStateDemandsAttentionMask);
+ }
+ else if (madeDemandAttention)
+ {
+ madeDemandAttention = FALSE;
+ window->changeState (window->state () &
+ ~CompWindowStateDemandsAttentionMask);
+ }
+}
+
+void
+WorkaroundsWindow::getAllowedActions (unsigned int &setActions,
+ unsigned int &clearActions)
+{
+
+ window->getAllowedActions (setActions, clearActions);
+
+ if (isFullscreen)
+ setActions |= CompWindowActionFullscreenMask;
+}
+
+void
+WorkaroundsWindow::fixupFullscreen ()
+{
+ Bool isFullSize;
+ int output;
+ BoxPtr box;
+
+ WORKAROUNDS_SCREEN (screen);
+
+ if (!ws->optionGetLegacyFullscreen ())
+ return;
+
+ if (window->wmType () & CompWindowTypeDesktopMask)
+ {
+ /* desktop windows are implicitly fullscreen */
+ isFullSize = FALSE;
+ }
+ else
+ {
+ /* get output region for window */
+ output = screen->outputDeviceForGeometry (window->geometry ());
+ box = &screen->outputDevs ().at (output).region ()->extents;
+
+ /* does the size match the output rectangle? */
+ isFullSize = (window->serverX () == box->x1) &&
+ (window->serverY () == box->y1) &&
+ (window->serverWidth () == (box->x2 - box->x1)) &&
+ (window->serverHeight () == (box->y2 - box->y1));
+
+ /* if not, check if it matches the whole screen */
+ if (!isFullSize)
+ {
+ if ((window->serverX () == 0) && (window->serverY () == 0) &&
+ (window->serverWidth () == screen->width ()) &&
+ (window->serverHeight () == screen->height ()))
+ {
+ isFullSize = TRUE;
+ }
+ }
+ }
+
+ isFullscreen = isFullSize;
+ if (isFullSize && !(window->state () & CompWindowStateFullscreenMask))
+ {
+ unsigned int state = window->state () &
+ ~CompWindowStateFullscreenMask;
+
+ if (isFullSize)
+ state |= CompWindowStateFullscreenMask;
+ madeFullscreen = isFullSize;
+
+ if (state != window->state ())
+ {
+ window->changeState (state);
+ window->updateAttributes (CompStackingUpdateModeNormal);
+
+ /* keep track of windows that we interact with */
+ ws->addToFullscreenList (window);
+ }
+ }
+ else if (!isFullSize && !ws->mfwList.empty () &&
+ (window->state () & CompWindowStateFullscreenMask))
+ {
+ /* did we set the flag? */
+
+ foreach (Window mfw, ws->mfwList)
+ {
+ if (mfw == window->id ())
+ {
+ unsigned int state = window->state () &
+ ~CompWindowStateFullscreenMask;
+
+ if (isFullSize)
+ state |= CompWindowStateFullscreenMask;
+
+ madeFullscreen = isFullSize;
+
+ if (state != window->state ())
+ {
+ window->changeState (state);
+ window->updateAttributes (CompStackingUpdateModeNormal);
+ }
+
+ ws->removeFromFullscreenList (window);
+ break;
+ }
+ }
+ }
+}
+
+void
+WorkaroundsWindow::updateFixedWindow (unsigned int newWmType)
+{
+ if (newWmType != window->wmType ())
+ {
+ adjustedWinType = TRUE;
+
+ window->recalcType ();
+ window->recalcActions ();
+
+ screen->matchPropertyChanged (window);
+ }
+}
+
+unsigned int
+WorkaroundsWindow::getFixedWindowType ()
+{
+ unsigned int newWmType;
+ XClassHint classHint;
+ CompString resName;
+
+ WORKAROUNDS_SCREEN (screen);
+
+ newWmType = window->type (); // ???
+
+ if (!XGetClassHint (screen->dpy (), window->id (), &classHint) != Success)
+ return newWmType;
+
+ if (classHint.res_name)
+ {
+ resName = CompString (classHint.res_name);
+ XFree (classHint.res_name);
+ }
+
+ /* FIXME: Is this the best way to detect a notification type window? */
+ if (ws->optionGetNotificationDaemonFix ())
+ {
+ if (newWmType == CompWindowTypeNormalMask &&
+ window->overrideRedirect () && !resName.empty () &&
+ resName.compare("notification-daemon") == 0)
+ {
+ newWmType = CompWindowTypeNotificationMask;
+ updateFixedWindow (newWmType);
+ return newWmType;
+ }
+ }
+
+ if (ws->optionGetFirefoxMenuFix ())
+ {
+ if (newWmType == CompWindowTypeNormalMask &&
+ window->overrideRedirect () && !resName.empty ())
+ {
+ if ((resName.compare ( "gecko") == 0) ||
+ (resName.compare ( "popup") == 0))
+ {
+ newWmType = CompWindowTypeDropdownMenuMask;
+ updateFixedWindow (newWmType);
+ return newWmType;
+ }
+ }
+ }
+
+ if (ws->optionGetOooMenuFix ())
+ {
+ if (newWmType == CompWindowTypeNormalMask &&
+ window->overrideRedirect () && !resName.empty ())
+ {
+ if (resName.compare ( "VCLSalFrame") == 0)
+ {
+ newWmType = CompWindowTypeDropdownMenuMask;
+ updateFixedWindow (newWmType);
+ return newWmType;
+ }
+ }
+ }
+ /* FIXME: Basic hack to get Java windows working correctly. */
+ if (ws->optionGetJavaFix () && !resName.empty ())
+ {
+ if ((resName.compare ( "sun-awt-X11-XMenuWindow") == 0) ||
+ (resName.compare ( "sun-awt-X11-XWindowPeer") == 0))
+ {
+ newWmType = CompWindowTypeDropdownMenuMask;
+ updateFixedWindow (newWmType);
+ return newWmType;
+ }
+ else if (resName.compare ( "sun-awt-X11-XDialogPeer") == 0)
+ {
+ newWmType = CompWindowTypeDialogMask;
+ updateFixedWindow (newWmType);
+ return newWmType;
+ }
+ else if (resName.compare ( "sun-awt-X11-XFramePeer") == 0)
+ {
+ newWmType = CompWindowTypeNormalMask;
+ updateFixedWindow (newWmType);
+ return newWmType;
+ }
+ }
+
+ if (ws->optionGetQtFix ())
+ {
+ CompString windowRole;
+
+ /* fix tooltips */
+ windowRole = getRoleAtom ();
+ if (!windowRole.empty ())
+ {
+ if ((windowRole.compare ("toolTipTip") == 0) ||
+ (windowRole.compare ("qtooltip_label") == 0))
+ {
+ newWmType = CompWindowTypeTooltipMask;
+ updateFixedWindow (newWmType);
+ return newWmType;
+ }
+ }
+
+ /* fix Qt transients - FIXME: is there a better way to detect them? */
+ if (resName.empty () && window->overrideRedirect () &&
+ (window->windowClass () == InputOutput) &&
+ (newWmType == CompWindowTypeUnknownMask))
+ {
+ newWmType = CompWindowTypeDropdownMenuMask;
+ updateFixedWindow (newWmType);
+ return newWmType;
+ }
+ }
+
+ return newWmType;
+}
+
+void
+WorkaroundsScreen::optionChanged (CompOption *opt,
+ WorkaroundsOptions::Options num)
+{
+ checkFunctions (true, true);
+
+ foreach (CompWindow *w, screen->windows ())
+ WorkaroundsWindow::get (w)->updateSticky ();
+
+ if (haveOpenGL)
+ {
+ updateParameterFix ();
+
+ if (optionGetFglrxXglFix ())
+ GL::copySubBuffer = NULL;
+ else
+ GL::copySubBuffer = origCopySubBuffer;
+ }
+}
+
+void
+WorkaroundsScreen::handleEvent (XEvent *event)
+{
+ CompWindow *w;
+
+ switch (event->type) {
+ case ConfigureRequest:
+ w = screen->findWindow (event->xconfigurerequest.window);
+ if (w)
+ {
+ WORKAROUNDS_WINDOW (w);
+
+ if (ww->madeFullscreen)
+ w->changeState (w->state () &= ~CompWindowStateFullscreenMask);
+ }
+ break;
+ case MapRequest:
+ w = screen->findWindow (event->xmaprequest.window);
+ if (w)
+ {
+ WORKAROUNDS_WINDOW (w);
+ ww->updateSticky ();
+ w->wmType () = ww->getFixedWindowType ();
+ ww->fixupFullscreen ();
+ }
+ break;
+ case MapNotify:
+ w = screen->findWindow (event->xmap.window);
+ if (w && w->overrideRedirect ())
+ {
+ WORKAROUNDS_WINDOW (w);
+ w->wmType () = ww->getFixedWindowType ();
+ }
+ break;
+ case DestroyNotify:
+ w = screen->findWindow (event->xdestroywindow.window);
+ if (w)
+ removeFromFullscreenList (w);
+ break;
+ }
+
+ screen->handleEvent (event);
+
+ switch (event->type) {
+ case ConfigureRequest:
+ w = screen->findWindow (event->xconfigurerequest.window);
+ if (w)
+ {
+ WORKAROUNDS_WINDOW (w);
+
+ if (ww->madeFullscreen)
+ w->state () |= CompWindowStateFullscreenMask;
+ }
+ break;
+ case ClientMessage:
+ if (event->xclient.message_type == Atoms::winDesktop)
+ {
+ w = screen->findWindow (event->xclient.window);
+ if (w)
+ {
+ WORKAROUNDS_WINDOW (w);
+ ww->updateSticky ();
+ }
+ }
+ break;
+ case PropertyNotify:
+ if ((event->xproperty.atom == XA_WM_CLASS) ||
+ (event->xproperty.atom == Atoms::winType))
+ {
+ w = screen->findWindow (event->xproperty.window);
+ if (w)
+ {
+ WORKAROUNDS_WINDOW (w);
+ w->wmType () = ww->getFixedWindowType ();
+ }
+ }
+ else if (event->xproperty.atom == XA_WM_HINTS)
+ {
+ if (optionGetConvertUrgency ())
+ {
+ w = screen->findWindow (event->xproperty.window);
+ if (w)
+ {
+ WORKAROUNDS_WINDOW (w);
+ ww->updateUrgencyState ();
+ }
+ }
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void
+WorkaroundsWindow::resizeNotify (int dx, int dy,
+ int dwidth, int dheight)
+{
+ if (window->isViewable ())
+ fixupFullscreen ();
+
+ window->resizeNotify (dx, dy, dwidth, dheight);
+}
+
+WorkaroundsScreen::WorkaroundsScreen (CompScreen *screen) :
+ PluginClassHandler <WorkaroundsScreen, CompScreen> (screen),
+ cScreen (CompositeScreen::get (screen)),
+ gScreen (GLScreen::get (screen)),
+ roleAtom (XInternAtom (screen->dpy (), "WM_WINDOW_ROLE", 0))
+{
+ ScreenInterface::setHandler (screen, false);
+ if (haveOpenGL)
+ GLScreenInterface::setHandler (gScreen, false);
+
+ optionSetStickyAlldesktopsNotify (boost::bind (
+ &WorkaroundsScreen::optionChanged, this,
+ _1, _2));
+ optionSetAlldesktopStickyMatchNotify (boost::bind (
+ &WorkaroundsScreen::optionChanged, this,
+ _1, _2));
+
+ optionSetAiglxFragmentFixNotify (boost::bind (
+ &WorkaroundsScreen::optionChanged, this,
+ _1, _2));
+
+ optionSetFglrxXglFixNotify (boost::bind (
+ &WorkaroundsScreen::optionChanged, this,
+ _1, _2));
+
+ if (haveOpenGL)
+ {
+ origProgramEnvParameter4f = GL::programEnvParameter4f;
+ programEnvParameter4dv = (GLProgramParameter4dvProc)
+ gScreen->getProcAddress ("glProgramEnvParameter4dvARB");
+ origCopySubBuffer = GL::copySubBuffer;
+
+ updateParameterFix ();
+ }
+
+ if (optionGetFglrxXglFix () && haveOpenGL)
+ GL::copySubBuffer = NULL;
+
+ checkFunctions (false, true);
+}
+
+WorkaroundsScreen::~WorkaroundsScreen ()
+{
+ if (haveOpenGL)
+ GL::copySubBuffer = origCopySubBuffer;
+}
+
+WorkaroundsWindow::WorkaroundsWindow (CompWindow *window) :
+ PluginClassHandler <WorkaroundsWindow, CompWindow> (window),
+ window (window),
+ cWindow (CompositeWindow::get (window)),
+ gWindow (GLWindow::get (window)),
+ adjustedWinType (false),
+ madeSticky (false),
+ madeFullscreen (false),
+ isFullscreen (false),
+ madeDemandAttention (false)
+{
+ WindowInterface::setHandler (window, false);
+
+ WORKAROUNDS_SCREEN (screen);
+
+ if (ws->optionGetLegacyFullscreen ())
+ {
+ window->getAllowedActionsSetEnabled (this, false);
+ window->resizeNotifySetEnabled (this, false);
+ }
+}
+
+
+WorkaroundsWindow::~WorkaroundsWindow ()
+{
+ if (!window->destroyed ())
+ {
+ if (adjustedWinType)
+ {
+ window->wmType () = window->type ();
+ window->recalcType ();
+ window->recalcActions ();
+ }
+
+ if (window->state () & CompWindowStateStickyMask && madeSticky)
+ {
+ window->state () &= ~CompWindowStateStickyMask;
+ }
+ }
+}
+
+bool
+WorkaroundsPluginVTable::init ()
+{
+ if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION))
+ return false;
+
+ if ((CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI)) &&
+ (CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI)))
+ haveOpenGL = true;
+ else
+ haveOpenGL = false;
+
+ return true;
+}
diff --git a/src/workarounds.h b/src/workarounds.h
new file mode 100644
index 0000000..ff821cc
--- /dev/null
+++ b/src/workarounds.h
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2007 Andrew Riedi <andrewriedi@gmail.com>
+ *
+ * Sticky window handling and OpenGL fixes:
+ * Copyright (c) 2007 Dennis Kasprzyk <onestone@opencompositing.org>
+ *
+ * Ported to Compiz 0.9:
+ * Copyright (c) 2008 Sam Spilsbury <smspillaz@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * This plug-in for Metacity-like workarounds.
+ */
+
+#include <string.h>
+#include <limits.h>
+
+#include <core/core.h>
+#include <composite/composite.h>
+#include <opengl/opengl.h>
+#include <core/atoms.h>
+#include <X11/Xatom.h>
+
+#include "workarounds_options.h"
+
+extern bool haveOpenGL;
+
+typedef void (*GLProgramParameter4dvProc) (GLenum target,
+ GLuint index,
+ const GLdouble *data);
+
+class WorkaroundsScreen :
+ public PluginClassHandler <WorkaroundsScreen, CompScreen>,
+ public ScreenInterface,
+ public GLScreenInterface,
+ public WorkaroundsOptions
+{
+ public:
+
+ WorkaroundsScreen (CompScreen *);
+ ~WorkaroundsScreen ();
+
+ CompositeScreen *cScreen;
+ GLScreen *gScreen;
+
+ Atom roleAtom;
+ std::list <Window> mfwList;
+
+ GL::GLProgramParameter4fProc origProgramEnvParameter4f;
+ GLProgramParameter4dvProc programEnvParameter4dv;
+
+ GL::GLXCopySubBufferProc origCopySubBuffer;
+
+ void
+ handleEvent (XEvent *);
+
+ bool
+ glPaintOutput (const GLScreenPaintAttrib &,
+ const GLMatrix &,
+ const CompRegion &,
+ CompOutput *,
+ unsigned int );
+
+ void
+ addToFullscreenList (CompWindow *w);
+
+ void
+ removeFromFullscreenList (CompWindow *w);
+
+ void
+ updateParameterFix ();
+
+ void
+ optionChanged (CompOption *opt,
+ WorkaroundsOptions::Options num);
+
+ void
+ checkFunctions (bool window, bool screen);
+
+
+
+
+};
+
+#define WORKAROUNDS_SCREEN(s) \
+ WorkaroundsScreen *ws = WorkaroundsScreen::get (s)
+
+class WorkaroundsWindow :
+ public PluginClassHandler <WorkaroundsWindow, CompWindow>,
+ public WindowInterface
+{
+ public:
+
+ WorkaroundsWindow (CompWindow *);
+ ~WorkaroundsWindow ();
+
+ CompWindow *window;
+ CompositeWindow *cWindow;
+ GLWindow *gWindow;
+
+ bool adjustedWinType;
+ bool madeSticky;
+ bool madeFullscreen;
+ bool isFullscreen;
+ bool madeDemandAttention;
+
+ void
+ resizeNotify (int, int, int, int);
+
+ void
+ getAllowedActions (unsigned int &,
+ unsigned int &);
+
+ void
+ removeSticky ();
+
+ CompString
+ getRoleAtom ();
+
+ void
+ updateSticky ();
+
+ void
+ updateUrgencyState ();
+
+ void
+ fixupFullscreen ();
+
+ void
+ updateFixedWindow (unsigned int newWmType);
+
+ unsigned int
+ getFixedWindowType ();
+
+};
+
+#define WORKAROUNDS_WINDOW(w) \
+ WorkaroundsWindow *ww = WorkaroundsWindow::get (w)
+
+class WorkaroundsPluginVTable :
+ public CompPlugin::VTableForScreenAndWindow <WorkaroundsScreen,
+ WorkaroundsWindow>
+{
+ public:
+
+ bool init ();
+};
diff --git a/workarounds.c b/workarounds.c
deleted file mode 100644
index f987fa0..0000000
--- a/workarounds.c
+++ /dev/null
@@ -1,855 +0,0 @@
-/*
- * Copyright (C) 2007 Andrew Riedi <andrewriedi@gmail.com>
- *
- * Sticky window handling by Dennis Kasprzyk <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.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * This plug-in for Metacity-like workarounds.
- */
-
-#include <string.h>
-#include <limits.h>
-
-#include <compiz-core.h>
-#include <X11/Xatom.h>
-#include "workarounds_options.h"
-
-static int displayPrivateIndex;
-
-typedef struct _WorkaroundsManagedFsWindow {
- Window id;
- struct _WorkaroundsManagedFsWindow *next;
-} WorkaroundsManagedFsWindow;
-
-typedef struct _WorkaroundsDisplay {
- int screenPrivateIndex;
-
- HandleEventProc handleEvent;
-
- Atom roleAtom;
- WorkaroundsManagedFsWindow *mfwList;
-} WorkaroundsDisplay;
-
-typedef void (*GLProgramParameter4dvProc) (GLenum target,
- GLuint index,
- const GLdouble *data);
-
-typedef struct _WorkaroundsScreen {
- int windowPrivateIndex;
-
- WindowResizeNotifyProc windowResizeNotify;
- GetAllowedActionsForWindowProc getAllowedActionsForWindow;
- PaintScreenProc paintScreen;
-
- GLProgramParameter4fProc origProgramEnvParameter4f;
- GLProgramParameter4dvProc programEnvParameter4dv;
-
- GLXCopySubBufferProc origCopySubBuffer;
-} WorkaroundsScreen;
-
-CompScreen *currentScreen = NULL;
-
-typedef struct _WorkaroundsWindow {
- Bool adjustedWinType;
- Bool madeSticky;
- Bool madeFullscreen;
- Bool isFullscreen;
- Bool madeDemandAttention;
-} WorkaroundsWindow;
-
-#define GET_WORKAROUNDS_DISPLAY(d) \
- ((WorkaroundsDisplay *) (d)->base.privates[displayPrivateIndex].ptr)
-
-#define WORKAROUNDS_DISPLAY(d) \
- WorkaroundsDisplay *wd = GET_WORKAROUNDS_DISPLAY (d)
-
-#define GET_WORKAROUNDS_SCREEN(s, wd) \
- ((WorkaroundsScreen *) (s)->base.privates[(wd)->screenPrivateIndex].ptr)
-
-#define WORKAROUNDS_SCREEN(s) \
- WorkaroundsScreen *ws = GET_WORKAROUNDS_SCREEN (s, \
- GET_WORKAROUNDS_DISPLAY (s->display))
-
-#define GET_WORKAROUNDS_WINDOW(w, ns) \
- ((WorkaroundsWindow *) (w)->base.privates[(ns)->windowPrivateIndex].ptr)
-#define WORKAROUNDS_WINDOW(w) \
- WorkaroundsWindow *ww = GET_WORKAROUNDS_WINDOW (w, \
- GET_WORKAROUNDS_SCREEN (w->screen, \
- GET_WORKAROUNDS_DISPLAY (w->screen->display)))
-
-static void
-workaroundsAddToFullscreenList (CompWindow *w)
-{
- WorkaroundsManagedFsWindow *mfw, *nmfw;
-
- WORKAROUNDS_DISPLAY (w->screen->display);
-
- nmfw = malloc (sizeof (WorkaroundsManagedFsWindow));
- if (!nmfw)
- return;
-
- nmfw->id = w->id;
- nmfw->next = NULL;
-
- if (!wd->mfwList)
- wd->mfwList = nmfw;
- else
- {
- for (mfw = wd->mfwList; mfw->next; mfw = mfw->next)
- if (mfw->id == w->id)
- {
- free (nmfw);
- return;
- }
-
- mfw->next = nmfw;
- }
-}
-
-static void
-workaroundsRemoveFromFullscreenList (CompWindow *w)
-{
- WorkaroundsManagedFsWindow *mfw;
- WorkaroundsManagedFsWindow *temp;
-
- WORKAROUNDS_DISPLAY (w->screen->display);
-
- if (!wd->mfwList)
- return;
-
- if (wd->mfwList->id == w->id)
- {
- mfw = wd->mfwList;
- wd->mfwList = wd->mfwList->next;
- free (mfw);
- return;
- }
-
- for (mfw = wd->mfwList; mfw->next; mfw = mfw->next)
- {
- if (mfw->next->id == w->id)
- {
- temp = mfw->next;
- mfw->next = mfw->next->next;
- free (temp);
- break;
- }
- }
-}
-
-static void
-workaroundsProgramEnvParameter4f (GLenum target,
- GLuint index,
- GLfloat x,
- GLfloat y,
- GLfloat z,
- GLfloat w)
-{
- WorkaroundsScreen *ws;
- GLdouble data[4];
-
- if (!currentScreen)
- return;
-
- ws = GET_WORKAROUNDS_SCREEN (currentScreen, GET_WORKAROUNDS_DISPLAY (
- currentScreen->display));
-
- data[0] = x;
- data[1] = y;
- data[2] = z;
- data[3] = w;
-
- (*ws->programEnvParameter4dv) (target, index, data);
-}
-
-static void
-workaroundsUpdateParameterFix (CompScreen *s)
-{
- WORKAROUNDS_SCREEN (s);
-
- if (!s->programEnvParameter4f || !ws->programEnvParameter4dv)
- return;
- if (workaroundsGetAiglxFragmentFix (s->display))
- s->programEnvParameter4f = workaroundsProgramEnvParameter4f;
- else
- s->programEnvParameter4f = ws->origProgramEnvParameter4f;
-}
-
-static void
-workaroundsPaintScreen (CompScreen *s,
- CompOutput *outputs,
- int numOutputs,
- unsigned int mask)
-{
- WORKAROUNDS_SCREEN (s);
-
- currentScreen = s;
-
- if (workaroundsGetForceGlxSync (s->display))
- glXWaitX ();
-
- UNWRAP (ws, s, paintScreen);
- (*s->paintScreen) (s, outputs, numOutputs, mask);
- WRAP (ws, s, paintScreen, workaroundsPaintScreen);
-}
-
-static char *
-workaroundsGetWindowRoleAtom (CompWindow *w)
-{
- CompDisplay *d = w->screen->display;
- Atom type;
- unsigned long nItems;
- unsigned long bytesAfter;
- unsigned char *str = NULL;
- int format, result;
- char *retval;
-
- WORKAROUNDS_DISPLAY (d);
-
- result = XGetWindowProperty (d->display, w->id, wd->roleAtom,
- 0, LONG_MAX, FALSE, XA_STRING,
- &type, &format, &nItems, &bytesAfter,
- (unsigned char **) &str);
-
- if (result != Success)
- return NULL;
-
- if (type != XA_STRING)
- {
- XFree (str);
- return NULL;
- }
-
- retval = strdup ((char *) str);
-
- XFree (str);
-
- return retval;
-}
-
-static void
-workaroundsRemoveSticky (CompWindow *w)
-{
- WORKAROUNDS_WINDOW (w);
-
- if (w->state & CompWindowStateStickyMask && ww->madeSticky)
- changeWindowState (w, w->state & ~CompWindowStateStickyMask);
- ww->madeSticky = FALSE;
-}
-
-static void
-workaroundsUpdateSticky (CompWindow *w)
-{
- WORKAROUNDS_WINDOW (w);
-
- CompDisplay *d = w->screen->display;
- Bool makeSticky = FALSE;
-
- if (workaroundsGetStickyAlldesktops (d) && w->desktop == 0xffffffff &&
- matchEval (workaroundsGetAlldesktopStickyMatch (d), w))
- makeSticky = TRUE;
-
- if (makeSticky)
- {
- if (!(w->state & CompWindowStateStickyMask))
- {
- ww->madeSticky = TRUE;
- changeWindowState (w, w->state | CompWindowStateStickyMask);
- }
- }
- else
- workaroundsRemoveSticky (w);
-}
-
-static void
-updateUrgencyState (CompWindow *w)
-{
- Bool urgent;
-
- WORKAROUNDS_WINDOW (w);
-
- urgent = (w->hints && (w->hints->flags & XUrgencyHint));
-
- if (urgent)
- {
- ww->madeDemandAttention = TRUE;
- changeWindowState (w, w->state | CompWindowStateDemandsAttentionMask);
- }
- else if (ww->madeDemandAttention)
- {
- ww->madeDemandAttention = FALSE;
- changeWindowState (w, w->state & ~CompWindowStateDemandsAttentionMask);
- }
-}
-
-static void
-workaroundsGetAllowedActionsForWindow (CompWindow *w,
- unsigned int *setActions,
- unsigned int *clearActions)
-{
- CompScreen *s = w->screen;
-
- WORKAROUNDS_SCREEN (s);
- WORKAROUNDS_WINDOW (w);
-
- UNWRAP (ws, s, getAllowedActionsForWindow);
- (*s->getAllowedActionsForWindow) (w, setActions, clearActions);
- WRAP (ws, s, getAllowedActionsForWindow,
- workaroundsGetAllowedActionsForWindow);
-
- if (ww->isFullscreen)
- *setActions |= CompWindowActionFullscreenMask;
-}
-
-static void
-workaroundsFixupFullscreen (CompWindow *w)
-{
- Bool isFullSize;
- int output;
- BoxPtr box;
-
- WORKAROUNDS_WINDOW (w);
- WORKAROUNDS_DISPLAY (w->screen->display);
-
- if (!workaroundsGetLegacyFullscreen (w->screen->display))
- return;
-
- if (w->wmType & CompWindowTypeDesktopMask)
- {
- /* desktop windows are implicitly fullscreen */
- isFullSize = FALSE;
- }
- else
- {
- /* get output region for window */
- output = outputDeviceForWindow (w);
- box = &w->screen->outputDev[output].region.extents;
-
- /* does the size match the output rectangle? */
- isFullSize = (w->serverX == box->x1) && (w->serverY == box->y1) &&
- (w->serverWidth == (box->x2 - box->x1)) &&
- (w->serverHeight == (box->y2 - box->y1));
-
- /* if not, check if it matches the whole screen */
- if (!isFullSize)
- {
- if ((w->serverX == 0) && (w->serverY == 0) &&
- (w->serverWidth == w->screen->width) &&
- (w->serverHeight == w->screen->height))
- {
- isFullSize = TRUE;
- }
- }
- }
-
- ww->isFullscreen = isFullSize;
- if (isFullSize && !(w->state & CompWindowStateFullscreenMask))
- {
- unsigned int state = w->state & ~CompWindowStateFullscreenMask;
-
- if (isFullSize)
- state |= CompWindowStateFullscreenMask;
- ww->madeFullscreen = isFullSize;
-
- if (state != w->state)
- {
- changeWindowState (w, state);
- updateWindowAttributes (w, CompStackingUpdateModeNormal);
-
- /* keep track of windows that we interact with */
- workaroundsAddToFullscreenList (w);
- }
- }
- else if (!isFullSize && wd->mfwList &&
- (w->state & CompWindowStateFullscreenMask))
- {
- /* did we set the flag? */
- WorkaroundsManagedFsWindow *mfw;
-
- for (mfw = wd->mfwList; mfw->next; mfw = mfw->next)
- {
- if (mfw->id == w->id)
- {
- unsigned int state = w->state & ~CompWindowStateFullscreenMask;
-
- if (isFullSize)
- state |= CompWindowStateFullscreenMask;
-
- ww->madeFullscreen = isFullSize;
-
- if (state != w->state)
- {
- changeWindowState (w, state);
- updateWindowAttributes (w, CompStackingUpdateModeNormal);
- }
-
- workaroundsRemoveFromFullscreenList (w);
- break;
- }
- }
- }
-}
-
-static void
-workaroundsDoFixes (CompWindow *w)
-{
- CompDisplay *d = w->screen->display;
- unsigned int newWmType;
-
- newWmType = getWindowType (d, w->id);
-
- /* FIXME: Is this the best way to detect a notification type window? */
- if (workaroundsGetNotificationDaemonFix (d))
- {
- if (newWmType == CompWindowTypeNormalMask &&
- w->attrib.override_redirect && w->resName &&
- strcmp (w->resName, "notification-daemon") == 0)
- {
- newWmType = CompWindowTypeNotificationMask;
- goto AppliedFix;
- }
- }
-
- if (workaroundsGetFirefoxMenuFix (d))
- {
- if (newWmType == CompWindowTypeNormalMask &&
- w->attrib.override_redirect && w->resName)
- {
- if ((strcasecmp (w->resName, "gecko") == 0) ||
- (strcasecmp (w->resName, "popup") == 0))
- {
- newWmType = CompWindowTypeDropdownMenuMask;
- goto AppliedFix;
- }
- }
- }
-
- if (workaroundsGetOooMenuFix (d))
- {
- if (newWmType == CompWindowTypeNormalMask &&
- w->attrib.override_redirect && w->resName)
- {
- if (strcasecmp (w->resName, "VCLSalFrame") == 0)
- {
- newWmType = CompWindowTypeDropdownMenuMask;
- goto AppliedFix;
- }
- }
- }
- /* FIXME: Basic hack to get Java windows working correctly. */
- if (workaroundsGetJavaFix (d) && w->resName)
- {
- if ((strcmp (w->resName, "sun-awt-X11-XMenuWindow") == 0) ||
- (strcmp (w->resName, "sun-awt-X11-XWindowPeer") == 0))
- {
- newWmType = CompWindowTypeDropdownMenuMask;
- goto AppliedFix;
- }
- else if (strcmp (w->resName, "sun-awt-X11-XDialogPeer") == 0)
- {
- newWmType = CompWindowTypeDialogMask;
- goto AppliedFix;
- }
- else if (strcmp (w->resName, "sun-awt-X11-XFramePeer") == 0)
- {
- newWmType = CompWindowTypeNormalMask;
- goto AppliedFix;
- }
- }
-
- if (workaroundsGetQtFix (d))
- {
- char *windowRole;
-
- /* fix tooltips */
- windowRole = workaroundsGetWindowRoleAtom (w);
- if (windowRole)
- {
- if ((strcmp (windowRole, "toolTipTip") == 0) ||
- (strcmp (windowRole, "qtooltip_label") == 0))
- {
- free (windowRole);
- newWmType = CompWindowTypeTooltipMask;
- goto AppliedFix;
- }
- else
- {
- free (windowRole);
- }
- }
-
- /* fix Qt transients - FIXME: is there a better way to detect them? */
- if (!w->resName && w->attrib.override_redirect &&
- (w->attrib.class == InputOutput) &&
- (newWmType == CompWindowTypeUnknownMask))
- {
- newWmType = CompWindowTypeDropdownMenuMask;
- goto AppliedFix;
- }
- }
-
-AppliedFix:
- if (newWmType != w->wmType)
- {
- WORKAROUNDS_WINDOW (w);
-
- ww->adjustedWinType = TRUE;
- w->wmType = newWmType;
-
- recalcWindowType (w);
- recalcWindowActions (w);
-
- (*d->matchPropertyChanged) (d, w);
- }
-}
-
-static void
-workaroundsDisplayOptionChanged (CompDisplay *d,
- CompOption *opt,
- WorkaroundsDisplayOptions num)
-{
- CompScreen *s;
- CompWindow *w;
-
- WorkaroundsScreen *ws;
-
- for (s = d->screens; s; s = s->next)
- {
- ws = GET_WORKAROUNDS_SCREEN (s, GET_WORKAROUNDS_DISPLAY (d));
- for (w = s->windows; w; w = w->next)
- workaroundsUpdateSticky (w);
- workaroundsUpdateParameterFix (s);
- if (workaroundsGetFglrxXglFix (d))
- s->copySubBuffer = NULL;
- else
- s->copySubBuffer = ws->origCopySubBuffer;
- }
-}
-
-static void
-workaroundsHandleEvent (CompDisplay *d,
- XEvent *event)
-{
- CompWindow *w;
-
- WORKAROUNDS_DISPLAY (d);
-
- switch (event->type) {
- case ConfigureRequest:
- w = findWindowAtDisplay (d, event->xconfigurerequest.window);
- if (w)
- {
- WORKAROUNDS_WINDOW (w);
-
- if (ww->madeFullscreen)
- w->state &= ~CompWindowStateFullscreenMask;
- }
- break;
- case MapRequest:
- w = findWindowAtDisplay (d, event->xmaprequest.window);
- if (w)
- {
- workaroundsUpdateSticky (w);
- workaroundsDoFixes (w);
- workaroundsFixupFullscreen (w);
- }
- break;
- case MapNotify:
- w = findWindowAtDisplay (d, event->xmap.window);
- if (w && w->attrib.override_redirect)
- {
- workaroundsDoFixes (w);
- workaroundsFixupFullscreen (w);
- }
- break;
- case DestroyNotify:
- w = findWindowAtDisplay (d, event->xdestroywindow.window);
- if (w)
- workaroundsRemoveFromFullscreenList (w);
- break;
- }
-
- UNWRAP (wd, d, handleEvent);
- (*d->handleEvent) (d, event);
- WRAP (wd, d, handleEvent, workaroundsHandleEvent);
-
- switch (event->type) {
- case ConfigureRequest:
- w = findWindowAtDisplay (d, event->xconfigurerequest.window);
- if (w)
- {
- WORKAROUNDS_WINDOW (w);
-
- if (ww->madeFullscreen)
- w->state |= CompWindowStateFullscreenMask;
- }
- break;
- case ClientMessage:
- if (event->xclient.message_type == d->winDesktopAtom)
- {
- w = findWindowAtDisplay (d, event->xclient.window);
- if (w)
- workaroundsUpdateSticky (w);
- }
- break;
- case PropertyNotify:
- if ((event->xproperty.atom == XA_WM_CLASS) ||
- (event->xproperty.atom == d->winTypeAtom))
- {
- w = findWindowAtDisplay (d, event->xproperty.window);
- if (w)
- workaroundsDoFixes (w);
- }
- else if (event->xproperty.atom == XA_WM_HINTS)
- {
- if (workaroundsGetConvertUrgency (d))
- {
- w = findWindowAtDisplay (d, event->xproperty.window);
- if (w)
- updateUrgencyState (w);
- }
- }
- break;
- default:
- break;
- }
-}
-
-static void
-workaroundsWindowResizeNotify (CompWindow *w, int dx, int dy,
- int dwidth, int dheight)
-{
- WORKAROUNDS_SCREEN (w->screen);
-
- if (w->attrib.map_state == IsViewable)
- workaroundsFixupFullscreen (w);
-
- UNWRAP (ws, w->screen, windowResizeNotify);
- (*w->screen->windowResizeNotify) (w, dx, dy, dwidth, dheight);
- WRAP (ws, w->screen, windowResizeNotify, workaroundsWindowResizeNotify);
-}
-
-static Bool
-workaroundsInitDisplay (CompPlugin *plugin, CompDisplay *d)
-{
- WorkaroundsDisplay *wd;
-
- if (!checkPluginABI ("core", CORE_ABIVERSION))
- return FALSE;
-
- wd = malloc (sizeof (WorkaroundsDisplay));
- if (!wd)
- return FALSE;
-
- wd->screenPrivateIndex = allocateScreenPrivateIndex (d);
- if (wd->screenPrivateIndex < 0)
- {
- free (wd);
- return FALSE;
- }
-
- wd->roleAtom = XInternAtom (d->display, "WM_WINDOW_ROLE", 0);
- wd->mfwList = NULL;
-
- workaroundsSetStickyAlldesktopsNotify (d, workaroundsDisplayOptionChanged);
- workaroundsSetAlldesktopStickyMatchNotify (d,
- workaroundsDisplayOptionChanged);
- workaroundsSetAiglxFragmentFixNotify (d, workaroundsDisplayOptionChanged);
- workaroundsSetFglrxXglFixNotify (d, workaroundsDisplayOptionChanged);
-
-
- d->base.privates[displayPrivateIndex].ptr = wd;
-
- WRAP (wd, d, handleEvent, workaroundsHandleEvent);
-
- return TRUE;
-}
-
-static void
-workaroundsFiniDisplay (CompPlugin *plugin, CompDisplay *d)
-{
- WORKAROUNDS_DISPLAY (d);
-
- freeScreenPrivateIndex (d, wd->screenPrivateIndex);
-
- UNWRAP (wd, d, handleEvent);
-
- free (wd);
-}
-
-static Bool
-workaroundsInitScreen (CompPlugin *plugin, CompScreen *s)
-{
- WorkaroundsScreen *ws;
-
- WORKAROUNDS_DISPLAY (s->display);
-
- ws = malloc (sizeof (WorkaroundsScreen));
- if (!ws)
- return FALSE;
-
- ws->windowPrivateIndex = allocateWindowPrivateIndex (s);
- if (ws->windowPrivateIndex < 0)
- {
- free (ws);
- return FALSE;
- }
-
- ws->programEnvParameter4dv = (GLProgramParameter4dvProc)
- (*s->getProcAddress) ((GLubyte *) "glProgramEnvParameter4dvARB");
- ws->origProgramEnvParameter4f = s->programEnvParameter4f;
-
- ws->origCopySubBuffer = s->copySubBuffer;
-
- WRAP (ws, s, windowResizeNotify, workaroundsWindowResizeNotify);
- WRAP (ws, s, getAllowedActionsForWindow,
- workaroundsGetAllowedActionsForWindow);
-
- WRAP (ws, s, paintScreen, workaroundsPaintScreen);
-
- s->base.privates[wd->screenPrivateIndex].ptr = ws;
-
- workaroundsUpdateParameterFix (s);
-
- if (workaroundsGetFglrxXglFix (s->display))
- s->copySubBuffer = NULL;
-
- return TRUE;
-}
-
-static void
-workaroundsFiniScreen (CompPlugin *plugin, CompScreen *s)
-{
- WORKAROUNDS_SCREEN (s);
-
- freeWindowPrivateIndex (s, ws->windowPrivateIndex);
-
- UNWRAP (ws, s, windowResizeNotify);
- UNWRAP (ws, s, getAllowedActionsForWindow);
-
- UNWRAP (ws, s, paintScreen);
-
- s->copySubBuffer = ws->origCopySubBuffer;
-
- free (ws);
-}
-
-static Bool
-workaroundsInitWindow (CompPlugin *plugin, CompWindow *w)
-{
- WorkaroundsWindow *ww;
-
- WORKAROUNDS_SCREEN (w->screen);
-
- ww = malloc (sizeof (WorkaroundsWindow));
- if (!ww)
- return FALSE;
-
- ww->madeSticky = FALSE;
- ww->adjustedWinType = FALSE;
- ww->isFullscreen = FALSE;
- ww->madeFullscreen = FALSE;
- ww->madeDemandAttention = FALSE;
-
- w->base.privates[ws->windowPrivateIndex].ptr = ww;
-
- return TRUE;
-}
-
-static void
-workaroundsFiniWindow (CompPlugin *plugin, CompWindow *w)
-{
- WORKAROUNDS_WINDOW (w);
-
- if (!w->destroyed)
- {
- if (ww->adjustedWinType)
- {
- w->wmType = getWindowType (w->screen->display, w->id);
- recalcWindowType (w);
- recalcWindowActions (w);
- }
-
- if (w->state & CompWindowStateStickyMask && ww->madeSticky)
- setWindowState (w->screen->display,
- w->state & ~CompWindowStateStickyMask, w->id);
- }
-
- free (ww);
-}
-
-static CompBool
-workaroundsInitObject (CompPlugin *p,
- CompObject *o)
-{
- static InitPluginObjectProc dispTab[] = {
- (InitPluginObjectProc) 0, /* InitCore */
- (InitPluginObjectProc) workaroundsInitDisplay,
- (InitPluginObjectProc) workaroundsInitScreen,
- (InitPluginObjectProc) workaroundsInitWindow
- };
-
- RETURN_DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), TRUE, (p, o));
-}
-
-static void
-workaroundsFiniObject (CompPlugin *p,
- CompObject *o)
-{
- static FiniPluginObjectProc dispTab[] = {
- (FiniPluginObjectProc) 0, /* FiniCore */
- (FiniPluginObjectProc) workaroundsFiniDisplay,
- (FiniPluginObjectProc) workaroundsFiniScreen,
- (FiniPluginObjectProc) workaroundsFiniWindow
- };
-
- DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), (p, o));
-}
-
-static Bool
-workaroundsInit (CompPlugin *plugin)
-{
- displayPrivateIndex = allocateDisplayPrivateIndex ();
- if (displayPrivateIndex < 0)
- return FALSE;
-
- return TRUE;
-}
-
-static void
-workaroundsFini (CompPlugin *plugin)
-{
- freeDisplayPrivateIndex (displayPrivateIndex);
-}
-
-CompPluginVTable workaroundsVTable =
-{
- "workarounds",
- 0,
- workaroundsInit,
- workaroundsFini,
- workaroundsInitObject,
- workaroundsFiniObject,
- 0,
- 0
-};
-
-CompPluginVTable *
-getCompPluginInfo (void)
-{
- return &workaroundsVTable;
-}
-
diff --git a/workarounds.xml.in b/workarounds.xml.in
index 1648e88..332959f 100644
--- a/workarounds.xml.in
+++ b/workarounds.xml.in
@@ -3,11 +3,20 @@
<!-- workarounds metadata -->
<plugin name="workarounds" useBcop="true">
<category>Utility</category>
- <deps>
- </deps>
<_short>Workarounds</_short>
<_long>Metacity-like workarounds.</_long>
- <display>
+ <deps>
+ <relation type="after">
+ <plugin>composite</plugin>
+ <plugin>opengl</plugin>
+ </relation>
+ <requirement>
+ <plugin>composite</plugin>
+ <plugin>opengl</plugin>
+ </requirement>
+
+ </deps>
+ <options>
<option type="bool" name="legacy_fullscreen">
<_short>Legacy Fullscreen Support</_short>
<_long>Make Wine and legacy applications fullscreen properly.</_long>
@@ -71,8 +80,6 @@
<default>any</default>
</option>
</subgroup>
- </display>
- <screen>
- </screen>
+ </options>
</plugin>
</compiz>