summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <smspillaz@gmail.com>2010-02-05 00:56:21 +0800
committerSam Spilsbury <smspillaz@gmail.com>2010-02-05 00:56:21 +0800
commit9698dc9e7ed6b522440f963c0c30899231b99bb4 (patch)
tree1e37e57d847c579ebd51256900dfadc92c7360df
parenta5c375bb7fc58a4b076f74961b31aeac4ac1b176 (diff)
parent84b91b75fbcd55cd193ab7bba480b1296f35d6a3 (diff)
downloadtitleinfo-9698dc9e7ed6b522440f963c0c30899231b99bb4.tar.gz
titleinfo-9698dc9e7ed6b522440f963c0c30899231b99bb4.tar.bz2
Merge branch 'compiz++' of ../titleinfo
Conflicts: titleinfo.c titleinfo.xml.in
-rw-r--r--CMakeLists.txt6
-rw-r--r--Makefile533
-rw-r--r--plugin.info2
-rw-r--r--src/titleinfo.cpp305
-rw-r--r--src/titleinfo.h115
-rw-r--r--titleinfo.c491
-rw-r--r--titleinfo.xml.in4
7 files changed, 426 insertions, 1030 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c58aad0..52128f6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,3 +1,5 @@
-include (CompizFusion)
+find_package (Compiz REQUIRED)
-compiz_fusion_plugin (titleinfo)
+include (CompizPlugin)
+
+compiz_plugin (titleinfo)
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 35af994..0000000
--- a/plugin.info
+++ /dev/null
@@ -1,2 +0,0 @@
-PLUGIN = titleinfo
-
diff --git a/src/titleinfo.cpp b/src/titleinfo.cpp
new file mode 100644
index 0000000..78ecbb2
--- /dev/null
+++ b/src/titleinfo.cpp
@@ -0,0 +1,305 @@
+/*
+ *
+ * Compiz title bar information extension plugin
+ *
+ * titleinfo.cpp
+ *
+ * Copyright : (C) 2009 by Danny Baumann
+ * E-mail : maniac@compiz.org
+ *
+ * Ported to Compiz 0.9 by:
+ * Copyright : (C) 2009 Sam Spilsbury
+ * E-mail : 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.
+ *
+ */
+
+#include "titleinfo.h"
+
+
+COMPIZ_PLUGIN_20090315 (titleinfo, TitleinfoPluginVTable);
+
+void
+TitleinfoWindow::updateVisibleName ()
+{
+ CompString text, f_machine;
+ CompString root, f_title;
+
+ TITLEINFO_SCREEN (screen);
+
+ fprintf (stderr, "title is %s\n", title.c_str ());
+
+ f_title = title.size () ? title : "";
+
+ if (ts->optionGetShowRoot () && owner == 0)
+ root = "ROOT: ";
+
+ if (ts->optionGetShowRemoteMachine () && remoteMachine.size ())
+ {
+ char hostname[256];
+
+ if (gethostname (hostname, 256) || strcmp (hostname, remoteMachine.c_str ()))
+ f_machine = remoteMachine;
+ }
+
+ if (f_machine.size ())
+ text = root + f_title + "(@" + f_machine + ")";
+ else if (root.size ())
+ text = root + f_title;
+
+ if (text.size ())
+ {
+ XChangeProperty (screen->dpy (), window->id (), ts->visibleNameAtom,
+ Atoms::utf8String, 8, PropModeReplace,
+ (unsigned char *) text.c_str (), text.size ());
+ text.clear ();
+ }
+ else
+ {
+ XDeleteProperty (screen->dpy (), window->id (), ts->visibleNameAtom);
+ }
+}
+
+void
+TitleinfoWindow::updatePid ()
+{
+ int pid = -1;
+ Atom type;
+ int result, format;
+ unsigned long nItems, bytesAfter;
+ unsigned char *propVal;
+
+ TITLEINFO_SCREEN (screen);
+
+ owner = -1;
+
+ result = XGetWindowProperty (screen->dpy (), window->id (), ts->wmPidAtom,
+ 0L, 1L, False, XA_CARDINAL, &type,
+ &format, &nItems, &bytesAfter, &propVal);
+
+ if (result == Success && propVal)
+ {
+ if (nItems)
+ {
+ unsigned long value;
+
+ memcpy (&value, propVal, sizeof (unsigned long));
+ pid = value;
+ }
+
+ XFree (propVal);
+ }
+
+ if (pid >= 0)
+ {
+ char path[512];
+ struct stat fileStat;
+
+ snprintf (path, 512, "/proc/%d", pid);
+ if (!lstat (path, &fileStat))
+ owner = fileStat.st_uid;
+ }
+
+ if (ts->optionGetShowRoot ())
+ updateVisibleName ();
+}
+
+CompString
+TitleinfoScreen::getUtf8Property (Window id,
+ Atom atom)
+{
+ Atom type;
+ int result, format;
+ unsigned long nItems, bytesAfter;
+ char *val, *retval_c;
+ CompString retval;
+
+ result = XGetWindowProperty (screen->dpy (), id, atom, 0L, 65536, False,
+ Atoms::utf8String, &type, &format, &nItems,
+ &bytesAfter, (unsigned char **) &val);
+
+ if (result != Success)
+ return retval;
+
+ if (type == Atoms::utf8String && format == 8 && val && nItems > 0)
+ {
+ retval_c = (char *) malloc (sizeof (char) * (nItems + 1));
+ if (retval_c)
+ {
+ strncpy (retval_c, val, nItems);
+ retval_c[nItems] = 0;
+ }
+ }
+
+ if (retval_c)
+ retval = CompString (retval_c);
+
+ if (val)
+ XFree (val);
+
+ return retval;
+}
+
+CompString
+TitleinfoScreen::getTextProperty (Window id,
+ Atom atom)
+{
+ XTextProperty text;
+ char *retval_c = NULL;
+ CompString retval;
+
+ text.nitems = 0;
+ if (XGetTextProperty (screen->dpy (), id, &text, atom))
+ {
+ if (text.value)
+ {
+ retval_c = (char *) malloc (sizeof (char) * (text.nitems + 1));
+ if (retval_c)
+ {
+ strncpy (retval_c, (char *) text.value, text.nitems);
+ retval_c[text.nitems] = 0;
+ }
+
+ XFree (text.value);
+ }
+ }
+
+ if (retval_c)
+ retval = CompString (retval_c);
+
+ return retval;
+}
+
+void
+TitleinfoWindow::updateTitle ()
+{
+ CompString f_title;
+
+ TITLEINFO_SCREEN (screen);
+
+ f_title = ts->getUtf8Property (window->id (), Atoms::wmName);
+
+ if (f_title.empty ())
+ title = ts->getTextProperty (window->id (), XA_WM_NAME);\
+
+ title = f_title;
+ updateVisibleName ();
+}
+
+
+void
+TitleinfoWindow::updateMachine ()
+{
+ TITLEINFO_SCREEN (screen);
+
+ if (remoteMachine.size ())
+ remoteMachine.clear ();
+
+ remoteMachine = ts->getTextProperty (window->id (),
+ XA_WM_CLIENT_MACHINE);
+
+ if (ts->optionGetShowRemoteMachine ())
+ updateVisibleName ();
+}
+/*
+static unsigned int
+titleinfoAddSupportedAtoms (CompScreen *s,
+ Atom *atoms,
+ unsigned int size)
+{
+ unsigned int count;
+
+ TITLEINFO_DISPLAY (s->display);
+ TITLEINFO_SCREEN (s);
+
+ UNWRAP (ts, s, addSupportedAtoms);
+ count = (*s->addSupportedAtoms) (s, atoms, size);
+ WRAP (ts, s, addSupportedAtoms, titleinfoAddSupportedAtoms);
+
+ if ((size - count) >= 2)
+ {
+ atoms[count++] = td->visibleNameAtom;
+ atoms[count++] = td->wmPidAtom;
+ }
+
+ return count;
+}
+*/
+
+void
+TitleinfoScreen::handleEvent (XEvent *event)
+{
+
+ screen->handleEvent (event);
+
+ if (event->type == PropertyNotify)
+ {
+ CompWindow *w;
+
+ if (event->xproperty.atom == XA_WM_CLIENT_MACHINE)
+ {
+ w = screen->findWindow (event->xproperty.window);
+ if (w)
+ {
+ TITLEINFO_WINDOW (w);
+ tw->updateMachine ();
+ }
+ }
+ else if (event->xproperty.atom == wmPidAtom)
+ {
+ w = screen->findWindow (event->xproperty.window);
+ if (w)
+ {
+ TITLEINFO_WINDOW (w);
+ tw->updatePid ();
+ }
+ }
+ else if (event->xproperty.atom == Atoms::wmName ||
+ event->xproperty.atom == XA_WM_NAME)
+ {
+ w = screen->findWindow (event->xproperty.window);
+ if (w)
+ {
+ TITLEINFO_WINDOW (w);
+ tw->updateTitle ();
+ }
+ }
+ }
+}
+
+TitleinfoScreen::TitleinfoScreen (CompScreen *screen) :
+ PluginClassHandler <TitleinfoScreen, CompScreen> (screen),
+ visibleNameAtom (XInternAtom (screen->dpy (), "_NET_WM_VISIBLE_NAME", 0)),
+ wmPidAtom (XInternAtom (screen->dpy (), "_NET_WM_PID", 0))
+{
+ ScreenInterface::setHandler (screen);
+};
+
+TitleinfoWindow::TitleinfoWindow (CompWindow *window) :
+ PluginClassHandler <TitleinfoWindow, CompWindow> (window),
+ window (window),
+ owner (-1)
+{
+ updateTitle ();
+ updateMachine ();
+ updatePid ();
+ updateVisibleName ();
+}
+
+bool
+TitleinfoPluginVTable::init ()
+{
+ if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION))
+ return false;
+
+ return true;
+};
diff --git a/src/titleinfo.h b/src/titleinfo.h
new file mode 100644
index 0000000..cc6f0de
--- /dev/null
+++ b/src/titleinfo.h
@@ -0,0 +1,115 @@
+/*
+ *
+ * Compiz title bar information extension plugin
+ *
+ * titleinfo.h
+ *
+ * Copyright : (C) 2009 by Danny Baumann
+ * E-mail : maniac@compiz.org
+ *
+ * Ported to Compiz 0.9 by:
+ * Copyright : (C) 2009 Sam Spilsbury
+ * E-mail : 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.
+ *
+ */
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+#include <cmath>
+#include <unistd.h>
+#include <cstring>
+#include <X11/Xatom.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <core/core.h>
+#include <core/pluginclasshandler.h>
+#include <core/atoms.h>
+
+#include "titleinfo_options.h"
+
+class TitleinfoScreen :
+ public PluginClassHandler <TitleinfoScreen, CompScreen>,
+ public ScreenInterface,
+ public TitleinfoOptions
+{
+ public:
+
+ TitleinfoScreen (CompScreen *);
+
+ Atom visibleNameAtom;
+ Atom wmPidAtom;
+
+ void
+ handleEvent (XEvent *);
+
+ /* FIXME:
+ * Need something like this in core to be wrappable
+ unsigned int
+ addSupportedAtoms (Atom *atoms,
+ unsigned int size);
+ */
+
+ CompString
+ getUtf8Property (Window id,
+ Atom atom);
+
+ CompString
+ getTextProperty (Window id,
+ Atom atom);
+
+
+};
+
+#define TITLEINFO_SCREEN(s) \
+ TitleinfoScreen *ts = TitleinfoScreen::get (screen)
+
+class TitleinfoWindow :
+ public PluginClassHandler <TitleinfoWindow, CompWindow>
+{
+ public:
+ TitleinfoWindow (CompWindow *);
+
+ CompWindow *window;
+
+ CompString title;
+ CompString remoteMachine;
+ int owner;
+
+ void
+ updateMachine ();
+
+ void
+ updateTitle ();
+
+ void
+ updatePid ();
+
+ void
+ updateVisibleName ();
+
+
+};
+
+#define TITLEINFO_WINDOW(w) \
+ TitleinfoWindow *tw = TitleinfoWindow::get (w);
+
+class TitleinfoPluginVTable :
+ public CompPlugin::VTableForScreenAndWindow <TitleinfoScreen, TitleinfoWindow>
+{
+ public:
+
+ bool init ();
+};
diff --git a/titleinfo.c b/titleinfo.c
deleted file mode 100644
index df627ae..0000000
--- a/titleinfo.c
+++ /dev/null
@@ -1,491 +0,0 @@
-/*
- *
- * Compiz title bar information extension plugin
- *
- * titleinfo.c
- *
- * Copyright : (C) 2009 by Danny Baumann
- * E-mail : maniac@compiz.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.
- *
- */
-
-#define _GNU_SOURCE
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <unistd.h>
-#include <string.h>
-#include <X11/Xatom.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <compiz-core.h>
-#include "titleinfo_options.h"
-
-static int TitleinfoDisplayPrivateIndex;
-
-typedef struct _TitleinfoDisplay {
- int screenPrivateIndex;
-
- Atom visibleNameAtom;
- Atom wmPidAtom;
-
- HandleEventProc handleEvent;
-} TitleinfoDisplay;
-
-typedef struct _TitleinfoScreen {
- int windowPrivateIndex;
-
- AddSupportedAtomsProc addSupportedAtoms;
-} TitleinfoScreen;
-
-typedef struct _TitleinfoWindow {
- char *title;
- char *remoteMachine;
- int owner;
-} TitleinfoWindow;
-
-#define TITLEINFO_DISPLAY(display) PLUGIN_DISPLAY(display, Titleinfo, t)
-#define TITLEINFO_SCREEN(screen) PLUGIN_SCREEN(screen, Titleinfo, t)
-#define TITLEINFO_WINDOW(window) PLUGIN_WINDOW(window, Titleinfo, t)
-
-static void
-titleinfoUpdateVisibleName (CompWindow *w)
-{
- CompDisplay *d = w->screen->display;
- char *text = NULL, *machine = NULL;
- const char *root = "", *title;
-
- TITLEINFO_DISPLAY (d);
- TITLEINFO_WINDOW (w);
-
- title = tw->title ? tw->title : "";
-
- if (titleinfoGetShowRoot (w->screen) && tw->owner == 0)
- root = "ROOT: ";
-
- if (titleinfoGetShowRemoteMachine (w->screen) && tw->remoteMachine)
- {
- char hostname[256];
-
- if (gethostname (hostname, 256) || strcmp (hostname, tw->remoteMachine))
- machine = tw->remoteMachine;
- }
-
- if (machine)
- asprintf (&text, "%s%s (@%s)", root, title, machine);
- else if (root[0])
- asprintf (&text, "%s%s", root, title);
-
- if (text)
- {
- XChangeProperty (d->display, w->id, td->visibleNameAtom,
- d->utf8StringAtom, 8, PropModeReplace,
- (unsigned char *) text, strlen (text));
- free (text);
- }
- else
- {
- XDeleteProperty (d->display, w->id, td->visibleNameAtom);
- }
-}
-
-static void
-titleinfoUpdatePid (CompWindow *w)
-{
- CompDisplay *d = w->screen->display;
- int pid = -1;
- Atom type;
- int result, format;
- unsigned long nItems, bytesAfter;
- unsigned char *propVal;
-
- TITLEINFO_DISPLAY (d);
- TITLEINFO_WINDOW (w);
-
- tw->owner = -1;
-
- result = XGetWindowProperty (d->display, w->id, td->wmPidAtom,
- 0L, 1L, False, XA_CARDINAL, &type,
- &format, &nItems, &bytesAfter, &propVal);
-
- if (result == Success && propVal)
- {
- if (nItems)
- {
- unsigned long value;
-
- memcpy (&value, propVal, sizeof (unsigned long));
- pid = value;
- }
-
- XFree (propVal);
- }
-
- if (pid >= 0)
- {
- char path[512];
- struct stat fileStat;
-
- snprintf (path, 512, "/proc/%d", pid);
- if (!lstat (path, &fileStat))
- tw->owner = fileStat.st_uid;
- }
-
- if (titleinfoGetShowRoot (w->screen))
- titleinfoUpdateVisibleName (w);
-}
-
-static char *
-titleinfoGetUtf8Property (CompDisplay *d,
- Window id,
- Atom atom)
-{
- Atom type;
- int result, format;
- unsigned long nItems, bytesAfter;
- char *val, *retval = NULL;
-
- result = XGetWindowProperty (d->display, id, atom, 0L, 65536, False,
- d->utf8StringAtom, &type, &format, &nItems,
- &bytesAfter, (unsigned char **) &val);
-
- if (result != Success)
- return NULL;
-
- if (type == d->utf8StringAtom && format == 8 && val && nItems > 0)
- {
- retval = malloc (sizeof (char) * (nItems + 1));
- if (retval)
- {
- strncpy (retval, val, nItems);
- retval[nItems] = 0;
- }
- }
-
- if (val)
- XFree (val);
-
- return retval;
-}
-
-static char *
-titleinfoGetTextProperty (CompDisplay *d,
- Window id,
- Atom atom)
-{
- XTextProperty text;
- char *retval = NULL;
-
- text.nitems = 0;
- if (XGetTextProperty (d->display, id, &text, atom))
- {
- if (text.value)
- {
- retval = malloc (sizeof (char) * (text.nitems + 1));
- if (retval)
- {
- strncpy (retval, (char *) text.value, text.nitems);
- retval[text.nitems] = 0;
- }
-
- XFree (text.value);
- }
- }
-
- return retval;
-}
-
-static void
-titleinfoUpdateTitle (CompWindow *w)
-{
- CompDisplay *d = w->screen->display;
- char *title;
-
- TITLEINFO_WINDOW (w);
-
- title = titleinfoGetUtf8Property (d, w->id, d->wmNameAtom);
-
- if (!title)
- title = titleinfoGetTextProperty (d, w->id, XA_WM_NAME);
-
- if (tw->title)
- free (tw->title);
-
- tw->title = title;
- titleinfoUpdateVisibleName (w);
-}
-
-
-static void
-titleinfoUpdateMachine (CompWindow *w)
-{
- TITLEINFO_WINDOW (w);
-
- if (tw->remoteMachine)
- free (tw->remoteMachine);
-
- tw->remoteMachine = titleinfoGetTextProperty (w->screen->display, w->id,
- XA_WM_CLIENT_MACHINE);
-
- if (titleinfoGetShowRemoteMachine (w->screen))
- titleinfoUpdateVisibleName (w);
-}
-
-static unsigned int
-titleinfoAddSupportedAtoms (CompScreen *s,
- Atom *atoms,
- unsigned int size)
-{
- unsigned int count;
-
- TITLEINFO_DISPLAY (s->display);
- TITLEINFO_SCREEN (s);
-
- UNWRAP (ts, s, addSupportedAtoms);
- count = (*s->addSupportedAtoms) (s, atoms, size);
- WRAP (ts, s, addSupportedAtoms, titleinfoAddSupportedAtoms);
-
- if ((size - count) >= 2)
- {
- atoms[count++] = td->visibleNameAtom;
- atoms[count++] = td->wmPidAtom;
- }
-
- return count;
-}
-
-static void
-titleinfoHandleEvent (CompDisplay *d,
- XEvent *event)
-{
- TITLEINFO_DISPLAY (d);
-
- UNWRAP (td, d, handleEvent);
- (*d->handleEvent) (d, event);
- WRAP (td, d, handleEvent, titleinfoHandleEvent);
-
- if (event->type == PropertyNotify)
- {
- CompWindow *w;
-
- if (event->xproperty.atom == XA_WM_CLIENT_MACHINE)
- {
- w = findWindowAtDisplay (d, event->xproperty.window);
- if (w)
- titleinfoUpdateMachine (w);
- }
- else if (event->xproperty.atom == td->wmPidAtom)
- {
- w = findWindowAtDisplay (d, event->xproperty.window);
- if (w)
- titleinfoUpdatePid (w);
- }
- else if (event->xproperty.atom == d->wmNameAtom ||
- event->xproperty.atom == XA_WM_NAME)
- {
- w = findWindowAtDisplay (d, event->xproperty.window);
- if (w)
- titleinfoUpdateTitle (w);
- }
- }
-}
-
-static Bool
-titleinfoInitDisplay (CompPlugin *p,
- CompDisplay *d)
-{
- TitleinfoDisplay *td;
-
- if (!checkPluginABI ("core", CORE_ABIVERSION))
- return FALSE;
-
- td = malloc (sizeof (TitleinfoDisplay));
- if (!td)
- return FALSE;
-
- td->screenPrivateIndex = allocateScreenPrivateIndex (d);
- if (td->screenPrivateIndex < 0)
- {
- free (td);
- return FALSE;
- }
-
- td->visibleNameAtom = XInternAtom (d->display, "_NET_WM_VISIBLE_NAME", 0);
- td->wmPidAtom = XInternAtom (d->display, "_NET_WM_PID", 0);
-
- WRAP (td, d, handleEvent, titleinfoHandleEvent);
-
- d->base.privates[TitleinfoDisplayPrivateIndex].ptr = td;
-
- return TRUE;
-}
-
-static void
-titleinfoFiniDisplay (CompPlugin *p,
- CompDisplay *d)
-{
- TITLEINFO_DISPLAY (d);
-
- freeScreenPrivateIndex (d, td->screenPrivateIndex);
-
- UNWRAP (td, d, handleEvent);
-
- free (td);
-}
-
-static Bool
-titleinfoInitScreen (CompPlugin *p,
- CompScreen *s)
-{
- TitleinfoScreen *ts;
-
- TITLEINFO_DISPLAY (s->display);
-
- ts = malloc (sizeof (TitleinfoScreen));
- if (!ts)
- return FALSE;
-
- ts->windowPrivateIndex = allocateWindowPrivateIndex (s);
- if (ts->windowPrivateIndex < 0)
- {
- free (ts);
- return FALSE;
- }
-
- s->base.privates[td->screenPrivateIndex].ptr = ts;
-
- WRAP (ts, s, addSupportedAtoms, titleinfoAddSupportedAtoms);
-
- return TRUE;
-}
-
-static void
-titleinfoFiniScreen (CompPlugin *p,
- CompScreen *s)
-{
- TITLEINFO_SCREEN (s);
-
- UNWRAP (ts, s, addSupportedAtoms);
-
- freeWindowPrivateIndex (s, ts->windowPrivateIndex);
-
- free (ts);
-}
-
-static Bool
-titleinfoInitWindow (CompPlugin *p,
- CompWindow *w)
-{
- TitleinfoWindow *tw;
-
- TITLEINFO_SCREEN (w->screen);
-
- tw = malloc (sizeof (TitleinfoWindow));
- if (!tw)
- return FALSE;
-
- tw->remoteMachine = NULL;
- tw->title = NULL;
- tw->owner = -1;
-
- w->base.privates[ts->windowPrivateIndex].ptr = tw;
-
- titleinfoUpdateTitle (w);
- titleinfoUpdateMachine (w);
- titleinfoUpdatePid (w);
- titleinfoUpdateVisibleName (w);
-
- return TRUE;
-}
-
-static void
-titleinfoFiniWindow (CompPlugin *p,
- CompWindow *w)
-{
- TITLEINFO_WINDOW (w);
-
- if (tw->title)
- free (tw->title);
-
- if (tw->remoteMachine)
- free (tw->remoteMachine);
-
- tw->remoteMachine = NULL;
- titleinfoUpdateVisibleName (w);
-
- free (tw);
-}
-
-static CompBool
-titleinfoInitObject (CompPlugin *p,
- CompObject *o)
-{
- static InitPluginObjectProc dispTab[] = {
- (InitPluginObjectProc) 0, /* InitCore */
- (InitPluginObjectProc) titleinfoInitDisplay,
- (InitPluginObjectProc) titleinfoInitScreen,
- (InitPluginObjectProc) titleinfoInitWindow
- };
-
- RETURN_DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), TRUE, (p, o));
-}
-
-static void
-titleinfoFiniObject (CompPlugin *p,
- CompObject *o)
-{
- static FiniPluginObjectProc dispTab[] = {
- (FiniPluginObjectProc) 0, /* FiniCore */
- (FiniPluginObjectProc) titleinfoFiniDisplay,
- (FiniPluginObjectProc) titleinfoFiniScreen,
- (FiniPluginObjectProc) titleinfoFiniWindow
- };
-
- DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), (p, o));
-}
-
-static Bool
-titleinfoInit (CompPlugin *p)
-{
- TitleinfoDisplayPrivateIndex = allocateDisplayPrivateIndex ();
- if (TitleinfoDisplayPrivateIndex < 0)
- return FALSE;
-
- return TRUE;
-}
-
-static void
-titleinfoFini (CompPlugin *p)
-{
- freeDisplayPrivateIndex (TitleinfoDisplayPrivateIndex);
-}
-
-CompPluginVTable titleinfoVTable = {
- "titleinfo",
- 0,
- titleinfoInit,
- titleinfoFini,
- titleinfoInitObject,
- titleinfoFiniObject,
- 0,
- 0
-};
-
-CompPluginVTable *
-getCompPluginInfo (void)
-{
- return &titleinfoVTable;
-}
-
diff --git a/titleinfo.xml.in b/titleinfo.xml.in
index cc050ce..b0816a4 100644
--- a/titleinfo.xml.in
+++ b/titleinfo.xml.in
@@ -4,7 +4,7 @@
<_short>Title Bar Info</_short>
<_long>Shows additional information in the window title bar</_long>
<category>Utility</category>
- <screen>
+ <options>
<option name="show_remote_machine" type="bool">
<_short>Show Remote Machine Name</_short>
<_long>Show name of remote machine if a certain application is executed remotely.</_long>
@@ -15,6 +15,6 @@
<_long>Show marker if you're logged in as root.</_long>
<default>true</default>
</option>
- </screen>
+ </options>
</plugin>
</compiz>