summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <smspillaz@gmail.com>2009-02-02 14:53:03 +0100
committerDanny Baumann <dannybaumann@web.de>2009-02-02 14:53:03 +0100
commit9a4c126616e6d5ba4cbdd4d854d102ce0af7de4d (patch)
tree52b82ff0719101ed22071e61a4b458b82f72c090
parent0730e4edc38e065156b0184af7ef0140523e7125 (diff)
downloadextrawm-9a4c126616e6d5ba4cbdd4d854d102ce0af7de4d.tar.gz
extrawm-9a4c126616e6d5ba4cbdd4d854d102ce0af7de4d.tar.bz2
Initial C++ port.
-rw-r--r--CMakeLists.txt2
-rw-r--r--Makefile36
-rw-r--r--extrawm.c466
-rw-r--r--extrawm.cpp277
-rw-r--r--extrawm.h117
-rw-r--r--extrawm.xml.in4
-rw-r--r--plugin.info1
7 files changed, 403 insertions, 500 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4d2230f..76309a0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,3 +1,3 @@
include (CompizFusion)
-compiz_fusion_plugin (extrawm)
+compiz_fusion_plugin (extrawm PLUGINDEPS composite)
diff --git a/Makefile b/Makefile
index d9a07cf..fb9d387 100644
--- a/Makefile
+++ b/Makefile
@@ -89,14 +89,14 @@ 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)
+CFLAGS = -g -Wall -Wpointer-arith -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_HEADERS = compiz.h core/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\""; \
@@ -105,7 +105,6 @@ is-bcop-target := $(shell if [ -e $(PLUGIN).xml.in ]; then cat $(PLUGIN).xml.in
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 )
@@ -119,17 +118,14 @@ 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 %.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
@@ -280,28 +276,6 @@ $(BUILDDIR)/compiz-%.pc: compiz-%.pc.in
# 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"; \
@@ -319,7 +293,7 @@ $(BUILDDIR)/%.lo: %.cxx $(h-files)
else \
$(ECHO) "compiling $< -> $@"; \
fi
- @$(LIBTOOL) --quiet --mode=compile $(CPP) $(CFLAGS) $(DEFINES) -I$(BUILDDIR) -c -o $@ $<
+ @$(LIBTOOL) --mode=compile $(CPP) $(CFLAGS) $(DEFINES) -I$(BUILDDIR) -c -o $@ $<
@if [ '$(color)' != 'no' ]; then \
$(ECHO) -e "\r\033[0mcompiling : \033[34m$< -> $@\033[0m"; \
fi
@@ -336,7 +310,7 @@ $(BUILDDIR)/lib$(PLUGIN).la: $(all-c-objs)
else \
$(ECHO) "linking : $@"; \
fi
- @$(LIBTOOL) --quiet --mode=link $(CC) $(LDFLAGS) -rpath $(DESTDIR) -o $@ $(all-c-objs)
+ @$(LIBTOOL) --quiet --mode=link $(CC) $(LDFLAGS) -rpath $(DESTDIR) -o $@ $(all-c-objs) -R `pkg-config --variable=libdir compiz`/compiz
@if [ '$(color)' != 'no' ]; then \
$(ECHO) -e "\r\033[0mlinking : \033[34m$@\033[0m"; \
fi
diff --git a/extrawm.c b/extrawm.c
deleted file mode 100644
index 8d4c721..0000000
--- a/extrawm.c
+++ /dev/null
@@ -1,466 +0,0 @@
-/*
- * 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 <X11/Xatom.h>
-
-#include <compiz-core.h>
-#include "extrawm_options.h"
-
-static int ExtraWMDisplayPrivateIndex;
-
-typedef struct _DemandsAttentionWindow {
- CompWindow *w;
- struct _DemandsAttentionWindow *next;
-} DemandsAttentionWindow;
-
-typedef struct _ExtraWMDisplay {
- int screenPrivateIndex;
-
- HandleEventProc handleEvent;
-} ExtraWMDisplay;
-
-typedef struct _ExtraWMScreen {
- WindowStateChangeNotifyProc windowStateChangeNotify;
-
- DemandsAttentionWindow *attentionWindows;
-} ExtraWMScreen;
-
-#define EXTRAWM_DISPLAY(d) PLUGIN_DISPLAY(d, ExtraWM, e)
-#define EXTRAWM_SCREEN(s) PLUGIN_SCREEN(s, ExtraWM, e)
-
-static void
-addAttentionWindow (CompWindow *w)
-{
- DemandsAttentionWindow *dw;
-
- EXTRAWM_SCREEN (w->screen);
-
- /* check if the window is already there */
- for (dw = es->attentionWindows; dw; dw = dw->next)
- if (dw->w == w)
- return;
-
- dw = malloc (sizeof (DemandsAttentionWindow));
- if (!dw)
- return;
-
- dw->w = w;
- dw->next = es->attentionWindows;
- es->attentionWindows = dw;
-}
-
-static void
-removeAttentionWindow (CompWindow *w)
-{
- DemandsAttentionWindow *dw, *ldw;
-
- EXTRAWM_SCREEN (w->screen);
-
- for (dw = es->attentionWindows, ldw = NULL; dw; dw = dw->next)
- {
- if (w == dw->w)
- {
- if (ldw)
- ldw->next = dw->next;
- else
- es->attentionWindows = dw->next;
-
- free (dw);
- break;
- }
-
- ldw = dw;
- }
-}
-
-static void
-updateAttentionWindow (CompWindow *w)
-{
- XWMHints *hints;
- Bool urgent = FALSE;
-
- hints = XGetWMHints (w->screen->display->display, w->id);
- if (hints)
- {
- if (hints->flags & XUrgencyHint)
- urgent = TRUE;
-
- XFree (hints);
- }
-
- if (urgent || (w->state & CompWindowStateDemandsAttentionMask))
- addAttentionWindow (w);
- else
- removeAttentionWindow (w);
-}
-
-static Bool
-activateDemandsAttention (CompDisplay *d,
- CompAction *action,
- CompActionState state,
- CompOption *option,
- int nOption)
-{
- Window xid;
- CompScreen *s;
-
- xid = getIntOptionNamed (option, nOption, "root", None);
- s = findScreenAtDisplay (d, xid);
-
- if (s)
- {
- EXTRAWM_SCREEN (s);
-
- if (es->attentionWindows)
- {
- CompWindow *w = es->attentionWindows->w;
-
- removeAttentionWindow (w);
- (*w->screen->activateWindow) (w);
- }
- }
-
- return FALSE;
-}
-
-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);
- 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 void
-extraWMHandleEvent (CompDisplay *d,
- XEvent *event)
-{
- EXTRAWM_DISPLAY (d);
-
- UNWRAP (ed, d, handleEvent);
- (*d->handleEvent) (d, event);
- WRAP (ed, d, handleEvent, extraWMHandleEvent);
-
- switch (event->type) {
- case PropertyNotify:
- if (event->xproperty.atom == XA_WM_HINTS)
- {
- CompWindow *w;
-
- w = findWindowAtDisplay (d, event->xproperty.window);
- if (w)
- updateAttentionWindow (w);
- }
- break;
- default:
- break;
- }
-}
-
-static void
-extraWMWindowStateChangeNotify (CompWindow *w,
- unsigned int lastState)
-{
- CompScreen *s = w->screen;
-
- EXTRAWM_SCREEN (s);
-
- UNWRAP (es, s, windowStateChangeNotify);
- (*s->windowStateChangeNotify) (w, lastState);
- WRAP (es, s, windowStateChangeNotify, extraWMWindowStateChangeNotify);
-
- if ((w->state ^ lastState) & CompWindowStateDemandsAttentionMask)
- updateAttentionWindow (w);
-}
-
-static Bool
-extraWMInit (CompPlugin *p)
-{
- ExtraWMDisplayPrivateIndex = allocateDisplayPrivateIndex ();
- if (ExtraWMDisplayPrivateIndex < 0)
- return FALSE;
-
- return TRUE;
-}
-
-static void
-extraWMFini (CompPlugin *p)
-{
- freeDisplayPrivateIndex (ExtraWMDisplayPrivateIndex);
-}
-
-static Bool
-extraWMInitDisplay (CompPlugin *p,
- CompDisplay *d)
-{
- ExtraWMDisplay *ed;
-
- if (!checkPluginABI ("core", CORE_ABIVERSION))
- return FALSE;
-
- ed = malloc (sizeof (ExtraWMDisplay));
- if (!ed)
- return FALSE;
-
- ed->screenPrivateIndex = allocateScreenPrivateIndex (d);
- if (ed->screenPrivateIndex < 0)
- {
- free (ed);
- return FALSE;
- }
-
- extrawmSetToggleRedirectKeyInitiate (d, toggleRedirect);
- extrawmSetToggleAlwaysOnTopKeyInitiate (d, toggleAlwaysOnTop);
- extrawmSetToggleStickyKeyInitiate (d, toggleSticky);
- extrawmSetToggleFullscreenKeyInitiate (d, toggleFullscreen);
- extrawmSetActivateInitiate (d, activateWin);
- extrawmSetActivateDemandsAttentionKeyInitiate (d, activateDemandsAttention);
-
- WRAP (ed, d, handleEvent, extraWMHandleEvent);
-
- d->base.privates[ExtraWMDisplayPrivateIndex].ptr = ed;
-
- return TRUE;
-}
-
-static void
-extraWMFiniDisplay (CompPlugin *p,
- CompDisplay *d)
-{
- EXTRAWM_DISPLAY (d);
-
- freeScreenPrivateIndex (d, ed->screenPrivateIndex);
-
- UNWRAP (ed, d, handleEvent);
-
- free (ed);
-}
-
-static Bool
-extraWMInitScreen (CompPlugin *p,
- CompScreen *s)
-{
- ExtraWMScreen *es;
-
- EXTRAWM_DISPLAY (s->display);
-
- es = malloc (sizeof (ExtraWMScreen));
- if (!es)
- return FALSE;
-
- es->attentionWindows = NULL;
-
- WRAP (es, s, windowStateChangeNotify, extraWMWindowStateChangeNotify);
-
- s->base.privates[ed->screenPrivateIndex].ptr = es;
-
- return TRUE;
-}
-
-static void
-extraWMFiniScreen (CompPlugin *p,
- CompScreen *s)
-{
- EXTRAWM_SCREEN (s);
-
- UNWRAP (es, s, windowStateChangeNotify);
-
- while (es->attentionWindows)
- removeAttentionWindow (es->attentionWindows->w);
-
- free (es);
-}
-
-static void
-extraWMFiniWindow (CompPlugin *p,
- CompWindow *w)
-{
- removeAttentionWindow (w);
-}
-
-static CompBool
-extraWMInitObject (CompPlugin *p,
- CompObject *o)
-{
- static InitPluginObjectProc dispTab[] = {
- (InitPluginObjectProc) 0, /* InitCore */
- (InitPluginObjectProc) extraWMInitDisplay,
- (InitPluginObjectProc) extraWMInitScreen
- };
-
- RETURN_DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), TRUE, (p, o));
-}
-
-static void
-extraWMFiniObject (CompPlugin *p,
- CompObject *o)
-{
- static InitPluginObjectProc dispTab[] = {
- (InitPluginObjectProc) 0, /* InitCore */
- (InitPluginObjectProc) extraWMFiniDisplay,
- (InitPluginObjectProc) extraWMFiniScreen,
- (InitPluginObjectProc) extraWMFiniWindow
- };
-
- DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), (p, o));
-}
-
-CompPluginVTable extraWMVTable = {
- "extrawm",
- 0,
- extraWMInit,
- extraWMFini,
- extraWMInitObject,
- extraWMFiniObject,
- 0,
- 0
-};
-
-CompPluginVTable*
-getCompPluginInfo (void)
-{
- return &extraWMVTable;
-}
diff --git a/extrawm.cpp b/extrawm.cpp
new file mode 100644
index 0000000..e002d5b
--- /dev/null
+++ b/extrawm.cpp
@@ -0,0 +1,277 @@
+/*
+ * Compiz extra WM actions plugins
+ * extrawm.cpp
+ *
+ * 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 "extrawm.h"
+
+COMPIZ_PLUGIN_20081216 (extrawm, ExtraWMPluginVTable);
+
+void
+ExtraWMScreen::addAttentionWindow (CompWindow *w)
+{
+ std::list <CompWindow *>::iterator it;
+
+ /* check if the window is already there */
+ for (it = attentionWindows.begin (); it != attentionWindows.end (); it++)
+ {
+ CompWindow *window = *it;
+ if (window == w)
+ return;
+ }
+
+ attentionWindows.push_back (w);
+}
+
+void
+ExtraWMScreen::removeAttentionWindow (CompWindow *w)
+{
+ attentionWindows.remove (w);
+}
+
+void
+ExtraWMScreen::updateAttentionWindow (CompWindow *w)
+{
+ XWMHints *hints;
+ Bool urgent = FALSE;
+
+ hints = XGetWMHints (screen->dpy (), w->id ());
+ if (hints)
+ {
+ if (hints->flags & XUrgencyHint)
+ urgent = TRUE;
+
+ XFree (hints);
+ }
+
+ if (urgent || (w->state () & CompWindowStateDemandsAttentionMask))
+ addAttentionWindow (w);
+ else
+ removeAttentionWindow (w);
+}
+
+bool
+ExtraWMScreen::activateDemandsAttention (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options)
+{
+ EXTRAWM_SCREEN (screen);
+
+ if (!es->attentionWindows.empty ())
+ {
+ CompWindow *w = es->attentionWindows.front (); // first member
+
+ es->removeAttentionWindow (w);
+ w->activate ();
+ }
+
+ return false;
+}
+
+bool
+ExtraWMScreen::activateWin (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options)
+{
+ CompWindow *w;
+ Window xid;
+
+ xid = CompOption::getIntOptionNamed (options, "window");
+ w = screen->findWindow (xid);
+ if (w)
+ screen->sendWindowActivationRequest (w->id ());
+
+ return TRUE;
+}
+
+void
+ExtraWMScreen::fullscreenWindow (CompWindow *w,
+ unsigned int state)
+{
+ unsigned int newState = w->state ();
+
+ if (w->overrideRedirect ())
+ return;
+
+ /* It would be a bug, to put a shaded window to fullscreen. */
+ if (w->shaded ())
+ return;
+
+ state = w->constrainWindowState (state, w->actions ());
+ state &= CompWindowStateFullscreenMask;
+
+ if (state == (w->state () & CompWindowStateFullscreenMask))
+ return;
+
+ newState &= ~CompWindowStateFullscreenMask;
+ newState |= state;
+
+ w->changeState (newState);
+ w->updateAttributes (CompStackingUpdateModeNormal);
+}
+
+bool
+ExtraWMScreen::toggleFullscreen (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options)
+{
+ CompWindow *w;
+ Window xid;
+
+ EXTRAWM_SCREEN (screen);
+
+ xid = CompOption::getIntOptionNamed (options, "window");
+
+ w = screen->findWindow (xid);
+ if (w && (w->actions () & CompWindowActionFullscreenMask))
+ es->fullscreenWindow (w, w->state () ^ CompWindowStateFullscreenMask);
+
+ return TRUE;
+}
+
+bool
+ExtraWMScreen::toggleRedirect (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options)
+{
+ CompWindow *w;
+ Window xid;
+
+ xid = CompOption::getIntOptionNamed (options, "window");
+ w = screen->findTopLevelWindow (xid);
+ if (w)
+ {
+ if (CompositeWindow::get (w)->redirected ())
+ CompositeWindow::get (w)->unredirect ();
+ else
+ CompositeWindow::get (w)->redirect ();
+ }
+
+ return TRUE;
+}
+
+bool
+ExtraWMScreen::toggleAlwaysOnTop (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options)
+{
+ CompWindow *w;
+ Window xid;
+
+ xid = CompOption::getIntOptionNamed (options, "window");
+ w = screen->findTopLevelWindow (xid);
+ if (w)
+ {
+ unsigned int newState;
+ newState = w->state () ^ CompWindowStateAboveMask;
+ w->changeState (newState);
+ w->updateAttributes (CompStackingUpdateModeNormal);
+ }
+
+ return TRUE;
+}
+
+/* From here */
+
+bool
+ExtraWMScreen::toggleSticky (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options)
+{
+ CompWindow *w;
+ Window xid;
+
+ xid = CompOption::getIntOptionNamed (options, "window");
+ w = screen->findTopLevelWindow (xid);
+ if (w && (w->actions () & CompWindowActionStickMask))
+ {
+ unsigned int newState;
+ newState = w->state () ^ CompWindowStateStickyMask;
+ w->changeState (newState);
+ }
+
+ return TRUE;
+}
+
+void
+ExtraWMScreen::handleEvent (XEvent *event)
+{
+
+ screen->handleEvent (event);
+
+ switch (event->type) {
+ case PropertyNotify:
+ if (event->xproperty.atom == XA_WM_HINTS)
+ {
+ CompWindow *w;
+
+ w = screen->findWindow (event->xproperty.window);
+ if (w)
+ updateAttentionWindow (w);
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void
+ExtraWMWindow::stateChangeNotify (unsigned int lastState)
+{
+ EXTRAWM_SCREEN (screen);
+
+ window->stateChangeNotify (lastState);
+
+ if ((window->state () ^ lastState) & CompWindowStateDemandsAttentionMask)
+ es->updateAttentionWindow (window);
+}
+
+ExtraWMScreen::ExtraWMScreen (CompScreen *screen) :
+ PrivateHandler <ExtraWMScreen, CompScreen> (screen),
+ ExtrawmOptions (extrawmVTable->getMetadata ())
+{
+
+ ScreenInterface::setHandler (screen);
+
+ optionSetToggleRedirectKeyInitiate (toggleRedirect);
+ optionSetToggleAlwaysOnTopKeyInitiate (toggleAlwaysOnTop);
+ optionSetToggleStickyKeyInitiate (toggleSticky);
+ optionSetToggleFullscreenKeyInitiate (toggleFullscreen);
+ optionSetActivateInitiate (activateWin);
+ optionSetActivateDemandsAttentionKeyInitiate (activateDemandsAttention);
+
+}
+
+ExtraWMWindow::ExtraWMWindow (CompWindow *window) :
+ PrivateHandler <ExtraWMWindow, CompWindow> (window),
+ window (window)
+{
+ WindowInterface::setHandler (window);
+}
+
+bool
+ExtraWMPluginVTable::init ()
+{
+ if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION) ||
+ !CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI))
+ return false;
+
+ return true;
+}
diff --git a/extrawm.h b/extrawm.h
new file mode 100644
index 0000000..b382843
--- /dev/null
+++ b/extrawm.h
@@ -0,0 +1,117 @@
+/*
+ * extrawm.h
+ * 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 <X11/Xatom.h>
+
+#include <core/core.h>
+#include <core/privatehandler.h>
+
+#include <composite/composite.h>
+
+#include "extrawm_options.h"
+
+class ExtraWMScreen :
+ public PrivateHandler <ExtraWMScreen, CompScreen>,
+ public ExtrawmOptions,
+ public ScreenInterface
+{
+ public:
+
+ std::list <CompWindow *> attentionWindows;
+
+ ExtraWMScreen (CompScreen *);
+
+ void
+ handleEvent (XEvent *);
+
+ void
+ addAttentionWindow (CompWindow *w);
+
+ void
+ removeAttentionWindow (CompWindow *w);
+
+ void
+ updateAttentionWindow (CompWindow *w);
+
+ void
+ fullscreenWindow (CompWindow *w,
+ unsigned int state);
+
+ static bool
+ activateDemandsAttention (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
+
+ static bool
+ activateWin (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
+
+ static bool
+ toggleFullscreen (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
+
+ static bool
+ toggleRedirect (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
+
+ static bool
+ toggleAlwaysOnTop (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
+
+ static bool
+ toggleSticky (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
+};
+
+class ExtraWMWindow :
+ public PrivateHandler <ExtraWMWindow, CompWindow>,
+ public WindowInterface
+{
+ public:
+
+ ExtraWMWindow (CompWindow *);
+
+ CompWindow *window;
+
+ void
+ stateChangeNotify (unsigned int);
+};
+
+#define EXTRAWM_SCREEN(s) \
+ ExtraWMScreen *es = ExtraWMScreen::get (s);
+
+#define EXTRAWM_WINDOW(w) \
+ ExtraWMWindow *ew = ExtraWMWindow::get (w);
+
+class ExtraWMPluginVTable :
+ public CompPlugin::VTableForScreenAndWindow <ExtraWMScreen, ExtraWMWindow>
+{
+ public:
+
+ bool init ();
+
+ PLUGIN_OPTION_HELPER (ExtraWMScreen);
+};
diff --git a/extrawm.xml.in b/extrawm.xml.in
index 7b7397e..5ff9faa 100644
--- a/extrawm.xml.in
+++ b/extrawm.xml.in
@@ -4,7 +4,7 @@
<_short>Extra WM Actions</_short>
<_long>Provides less commonly used WM actions</_long>
<category>Window Management</category>
- <display>
+ <options>
<option name="activate" type="action">
<_short>Activate Window</_short>
<_long>Activate a given window</_long>
@@ -29,6 +29,6 @@
<_short>Activate Demanding Attention Window</_short>
<_long>Activate next window which has the "demands attention" flag set.</_long>
</option>
- </display>
+ </options>
</plugin>
</compiz>
diff --git a/plugin.info b/plugin.info
index ce07360..c790540 100644
--- a/plugin.info
+++ b/plugin.info
@@ -1 +1,2 @@
PLUGIN = extrawm
+PKG_DEP= compiz-composite