summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Kasprzyk <onestone@beryl-project.org>2007-05-17 12:53:41 +0200
committerDennis Kasprzyk <onestone@beryl-project.org>2007-05-17 12:53:41 +0200
commit52dd013414d47b201811ef0478b592241e5f1cd0 (patch)
tree9c6d176faff5b0678748e2592866c9c651c78dca
parent20660501f5e1f77c0e700044cda6e5e23a7fdd20 (diff)
downloadextrawm-52dd013414d47b201811ef0478b592241e5f1cd0.tar.gz
extrawm-52dd013414d47b201811ef0478b592241e5f1cd0.tar.bz2
initial commit
-rw-r--r--Makefile218
-rw-r--r--extrawm.c221
-rw-r--r--extrawm.xml48
3 files changed, 487 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..94a6dd3
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,218 @@
+##
+#
+# Compiz plugin Makefile
+#
+# Copyright : (C) 2006 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.
+#
+##
+
+## configuration
+
+#enter plugin name here
+PLUGIN = extrawm
+
+#enter dependencies here
+PKG_DEP =
+
+## end of configuration
+
+#enter beryl or compiz here
+TARGET = compiz
+
+ifeq ($(BUILD_GLOBAL),true)
+ DESTDIR = $(shell pkg-config --variable=libdir compiz)/compiz
+ XMLDIR = $(shell pkg-config --variable=prefix compiz)/share/compiz
+else
+ DESTDIR = $(HOME)/.$(TARGET)/plugins
+ XMLDIR = $(HOME)/.$(TARGET)/metadata
+endif
+
+BUILDDIR = build
+
+CC = gcc
+LIBTOOL = libtool
+INSTALL = install
+
+BCOP = `pkg-config --variable=bin bcop`
+
+CFLAGS = -g -Wall `pkg-config --cflags $(PKG_DEP) $(TARGET) `
+LDFLAGS = `pkg-config --libs $(PKG_DEP) $(TARGET) `
+
+is-bcop-target := $(shell if [ -e $(PLUGIN).xml ]; then cat $(PLUGIN).xml | grep "useBcop=\"true\"";fi )
+
+bcop-target := $(shell if [ -n "$(is-bcop-target)" ]; then echo $(PLUGIN).xml; fi )
+bcop-target-src := $(shell if [ -n "$(is-bcop-target)" ]; then echo $(PLUGIN)_options.c; fi )
+bcop-target-hdr := $(shell if [ -n "$(is-bcop-target)" ]; then echo $(PLUGIN)_options.h; fi )
+
+gen-schemas := $(shell if [ -e $(PLUGIN).xml ] && [ -n `pkg-config --variable=xsltdir compiz-gconf` ]; then echo true; fi )
+schema-target := $(shell if [ -n "$(gen-schemas)" ]; then echo $(PLUGIN).xml; fi )
+schema-output := $(shell if [ -n "$(gen-schemas)" ]; then echo compiz-$(PLUGIN).schema; fi )
+
+# find all the object files (including those from .moc.cpp files)
+
+c-objs := $(patsubst %.c,%.lo,$(shell find -name '*.c' 2> /dev/null | grep -v "$(BUILDDIR)/" | sed -e 's/^.\///'))
+c-objs := $(filter-out $(bcop-target-src:.c=.lo),$(c-objs))
+c-objs += $(bcop-target-src:.c=.lo)
+
+# system include path parameter, -isystem doesn't work on old gcc's
+inc-path-param = $(shell if [ -z "`gcc --version | head -n 1 | grep ' 3'`" ]; then echo "-isystem"; else echo "-I"; fi)
+
+# default color settings
+color := $(shell if [ $$TERM = "dumb" ]; then echo "no"; else echo "yes"; fi)
+
+#
+# Do it.
+#
+
+.PHONY: $(BUILDDIR) build-dir bcop-build schema-creation c-build-objs c-link-plugin
+
+all: $(BUILDDIR) build-dir bcop-build schema-creation c-build-objs c-link-plugin
+
+bcop-build: $(bcop-target-hdr) $(bcop-target-src)
+
+schema-creation: $(schema-output)
+
+c-build-objs: $(addprefix $(BUILDDIR)/,$(cxx-objs))
+
+c-link-plugin: $(BUILDDIR)/lib$(PLUGIN).la
+
+#
+# Create build directory
+#
+
+$(BUILDDIR) :
+ @mkdir -p $(BUILDDIR)
+
+$(DESTDIR) :
+ @mkdir -p $(DESTDIR)
+
+#
+# BCOP'ing
+
+%_options.h: %.xml
+ @if [ '$(color)' != 'no' ]; then \
+ echo -e -n "\033[0;1;5mbcop'ing \033[0;1;37m: \033[0;32m$< \033[0;1;37m-> \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
+
+%_options.c: %.xml
+ @if [ '$(color)' != 'no' ]; then \
+ echo -e -n "\033[0;1;5mbcop'ing \033[0;1;37m: \033[0;32m$< \033[0;1;37m-> \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
+
+compiz-%.schema: %.xml
+ @if [ '$(color)' != 'no' ]; then \
+ echo -e -n "\033[0;1;5mschema \033[0;1;37m: \033[0;32m$< \033[0;1;37m-> \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
+
+
+
+#
+# Compiling
+#
+
+$(BUILDDIR)/%.lo: %.c
+ @if [ '$(color)' != 'no' ]; then \
+ echo -n -e "\033[0;1;5mcompiling \033[0;1;37m: \033[0;32m$< \033[0;1;37m-> \033[0;31m$@\033[0m"; \
+ else \
+ echo "compiling $< -> $@"; \
+ fi
+ @$(LIBTOOL) --quiet --mode=compile $(CC) $(CFLAGS) -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: $(addprefix $(BUILDDIR)/,$(c-objs))
+ @if [ '$(color)' != 'no' ]; then \
+ echo -e -n "\033[0;1;5mlinking -> \033[0;31m$@\033[0m"; \
+ else \
+ echo "linking -> $@"; \
+ fi
+ @$(LIBTOOL) --quiet --mode=link $(CC) $(LDFLAGS) -rpath $(DESTDIR) -o $@ $(addprefix $(BUILDDIR)/,$(c-objs))
+ @if [ '$(color)' != 'no' ]; then \
+ echo -e "\r\033[0mlinking -> \033[34m$@\033[0m"; \
+ fi
+
+
+clean:
+ rm -rf $(BUILDDIR)
+ rm -f $(bcop-target-src)
+ rm -f $(bcop-target-hdr)
+ rm -f $(schema-output)
+
+install: $(DESTDIR) all
+ @if [ '$(color)' != 'no' ]; then \
+ echo -n -e "\033[0;1;5minstall \033[0;1;37m: \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 $(PLUGIN).xml ]; then \
+ if [ '$(color)' != 'no' ]; then \
+ echo -n -e "\033[0;1;5minstall \033[0;1;37m: \033[0;31m$(XMLDIR)/$(PLUGIN).xml\033[0m"; \
+ else \
+ echo "install : $(XMLDIR)/$(PLUGIN).xml"; \
+ fi; \
+ mkdir -p $(XMLDIR); \
+ cp $(PLUGIN).xml $(XMLDIR)/$(PLUGIN).xml; \
+ if [ '$(color)' != 'no' ]; then \
+ echo -e "\r\033[0minstall : \033[34m$(XMLDIR)/$(PLUGIN).xml\033[0m"; \
+ fi; \
+ fi
+ @if [ -e $(schema-output) ]; then \
+ if [ '$(color)' != 'no' ]; then \
+ echo -n -e "\033[0;1;5minstall \033[0;1;37m: \033[0;31m$(schema-output)\033[0m"; \
+ else \
+ echo "install : $(schema-output)"; \
+ fi; \
+ gconftool-2 --install-schema-file=$(schema-output) > /dev/null; \
+ if [ '$(color)' != 'no' ]; then \
+ echo -e "\r\033[0minstall : \033[34m$(schema-output)\033[0m"; \
+ fi; \
+ fi
+
+
+
+
diff --git a/extrawm.c b/extrawm.c
new file mode 100644
index 0000000..b021743
--- /dev/null
+++ b/extrawm.c
@@ -0,0 +1,221 @@
+/*
+ * extrawm.c
+ * Compiz extra WM actions plugins
+ * Copyright: (C) 2007 Danny Baumann <maniac@beryl-project.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <compiz.h>
+#include "extrawm_options.h"
+
+
+static Bool
+activateWin (CompDisplay * d,
+ CompAction * action,
+ CompActionState state,
+ CompOption * option,
+ int nOption)
+{
+ CompWindow *w;
+ Window xid;
+
+ xid = getIntOptionNamed(option, nOption, "window", 0);
+
+ w = findWindowAtDisplay(d, xid);
+ if (w)
+ sendWindowActivationRequest(w->screen, w->id);
+
+ return TRUE;
+}
+
+static void
+fullscreenWindow (CompWindow * w,
+ int state)
+{
+ unsigned int newState = w->state;
+
+ if (w->attrib.override_redirect)
+ return;
+
+ /* It would be a bug, to put a shaded window to fullscreen. */
+ if (w->shaded)
+ return;
+
+ state = constrainWindowState(state, w->actions);
+ state &= CompWindowStateFullscreenMask;
+
+ if (state == (w->state & CompWindowStateFullscreenMask))
+ return;
+
+ newState &= ~CompWindowStateFullscreenMask;
+ newState |= state;
+
+ changeWindowState(w, newState);
+ recalcWindowType(w);
+ recalcWindowActions(w);
+ updateWindowAttributes(w, CompStackingUpdateModeNormal);
+}
+
+static Bool
+toggleFullscreen (CompDisplay * d,
+ CompAction * action,
+ CompActionState state,
+ CompOption * option,
+ int nOption)
+{
+ CompWindow *w;
+ Window xid;
+
+ xid = getIntOptionNamed(option, nOption, "window", 0);
+
+ w = findTopLevelWindowAtDisplay(d, xid);
+ if (w && (w->actions & CompWindowActionFullscreenMask))
+ fullscreenWindow(w, w->state ^ CompWindowStateFullscreenMask);
+
+ return TRUE;
+}
+
+static Bool
+toggleRedirect (CompDisplay * d,
+ CompAction * action,
+ CompActionState state,
+ CompOption * option,
+ int nOption)
+{
+ CompWindow *w;
+ Window xid;
+
+ xid = getIntOptionNamed(option, nOption, "window", 0);
+
+ w = findTopLevelWindowAtDisplay(d, xid);
+ if (w)
+ {
+ if (w->redirected)
+ unredirectWindow(w);
+ else
+ redirectWindow(w);
+ }
+
+ return TRUE;
+}
+
+static Bool
+toggleAlwaysOnTop (CompDisplay * d,
+ CompAction * action,
+ CompActionState state,
+ CompOption * option,
+ int nOption)
+{
+ CompWindow *w;
+ Window xid;
+
+ xid = getIntOptionNamed(option, nOption, "window", 0);
+
+ w = findTopLevelWindowAtDisplay(d, xid);
+ if (w)
+ {
+ unsigned int newState;
+ newState = w->state ^ CompWindowStateAboveMask;
+ changeWindowState (w, newState);
+ updateWindowAttributes (w, CompStackingUpdateModeNormal);
+ }
+
+ return TRUE;
+}
+
+static Bool
+toggleSticky (CompDisplay * d,
+ CompAction * action,
+ CompActionState state,
+ CompOption * option,
+ int nOption)
+{
+ CompWindow *w;
+ Window xid;
+
+ xid = getIntOptionNamed(option, nOption, "window", 0);
+
+ w = findTopLevelWindowAtDisplay(d, xid);
+ if (w && (w->actions & CompWindowActionStickMask))
+ {
+ unsigned int newState;
+ newState = w->state ^ CompWindowStateStickyMask;
+ changeWindowState(w, newState);
+ }
+
+ return TRUE;
+}
+
+static Bool
+extraWMInit(CompPlugin * p)
+{
+ return TRUE;
+}
+
+static void
+extraWMFini(CompPlugin * p)
+{
+}
+
+static Bool
+extraWMInitDisplay (CompPlugin *p,
+ CompDisplay *d)
+{
+ extrawmSetToggleRedirectInitiate (d, toggleRedirect);
+ extrawmSetToggleAlwaysOnTopInitiate (d, toggleAlwaysOnTop);
+ extrawmSetToggleStickyInitiate (d, toggleSticky);
+ extrawmSetToggleFullscreenInitiate (d, toggleFullscreen);
+ extrawmSetActivateInitiate (d, activateWin);
+
+ return TRUE;
+}
+
+static int extraWMGetVersion (CompPlugin * p,
+ int version)
+{
+ return ABIVERSION;
+}
+
+CompPluginVTable extraWMVTable = {
+ "extrawm",
+ extraWMGetVersion,
+ 0,
+ extraWMInit,
+ extraWMFini,
+ extraWMInitDisplay,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0
+};
+
+CompPluginVTable *getCompPluginInfo(void)
+{
+ return &extraWMVTable;
+}
diff --git a/extrawm.xml b/extrawm.xml
new file mode 100644
index 0000000..37e1b21
--- /dev/null
+++ b/extrawm.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0"?>
+<compiz>
+ <plugin name="extrawm" useBcop="true">
+ <short>Extra WM Actions</short>
+ <long>Provides less commonly used WM actions</long>
+ <category>Window Management</category>
+ <display>
+ <option name="activate" type="action">
+ <short>Activate Window</short>
+ <long>Activate a given window</long>
+ <allowed/>
+ <default/>
+ </option>
+ <option name="toggle_redirect" type="action">
+ <short>Toggle Redirect</short>
+ <long>Toggle window redirect</long>
+ <allowed key="true"/>
+ <default>
+ <key/>
+ </default>
+ </option>
+ <option name="toggle_fullscreen" type="action">
+ <short>Toggle Fullscreen</short>
+ <long>Toggle window fullscreen</long>
+ <allowed key="true"/>
+ <default>
+ <key/>
+ </default>
+ </option>
+ <option name="toggle_always_on_top" type="action">
+ <short>Toggle Always-On-Top</short>
+ <long>Toggle always on top for the active window</long>
+ <allowed key="true"/>
+ <default>
+ <key/>
+ </default>
+ </option>
+ <option name="toggle_sticky" type="action">
+ <short>Toggle Sticky</short>
+ <long>Toggle window stickyness</long>
+ <allowed key="true"/>
+ <default>
+ <key/>
+ </default>
+ </option>
+ </display>
+ </plugin>
+</compiz>