summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <smspillaz@gmail.com>2009-01-28 09:04:02 +0100
committerDanny Baumann <dannybaumann@web.de>2009-01-28 09:04:02 +0100
commitc881acac90cf792b08d4b587663415f60ec1a174 (patch)
tree09629cd6caa77c1bc7eee6faadb1baf5d1b0ef45
parent3921fdaeda0e13ede64b85424efc193873706809 (diff)
downloadfadedesktop-c881acac90cf792b08d4b587663415f60ec1a174.tar.gz
fadedesktop-c881acac90cf792b08d4b587663415f60ec1a174.tar.bz2
Initial C++ port.
-rw-r--r--CMakeLists.txt2
-rw-r--r--Makefile36
-rw-r--r--fadedesktop.c474
-rw-r--r--fadedesktop.cpp261
-rw-r--r--fadedesktop.h101
-rw-r--r--plugin.info1
6 files changed, 369 insertions, 506 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fd0ea61..b42a2da 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,3 +1,3 @@
include (CompizFusion)
-compiz_fusion_plugin (fadedesktop)
+compiz_fusion_plugin (fadedesktop PLUGINDEPS opengl 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/fadedesktop.c b/fadedesktop.c
deleted file mode 100644
index 3336f74..0000000
--- a/fadedesktop.c
+++ /dev/null
@@ -1,474 +0,0 @@
-/**
- *
- * Compiz fade to desktop plugin
- *
- * fadedesktop.c
- *
- * Copyright (c) 2006 Robert Carr <racarr@beryl-project.org>
- * 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.
- *
- **/
-
-#include <stdlib.h>
-#include <string.h>
-#include <compiz-core.h>
-#include "fadedesktop_options.h"
-
-#include <math.h>
-
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-#include <X11/Xproto.h>
-
-typedef enum
-{
- FD_STATE_OFF = 0,
- FD_STATE_OUT,
- FD_STATE_ON,
- FD_STATE_IN
-} FadeDesktopState;
-
-typedef struct _FadeDesktopDisplay
-{
- int screenPrivateIndex;
-} FadeDesktopDisplay;
-
-typedef struct _FadeDesktopScreen
-{
- int windowPrivateIndex;
-
- PreparePaintScreenProc preparePaintScreen;
- DonePaintScreenProc donePaintScreen;
- PaintWindowProc paintWindow;
- EnterShowDesktopModeProc enterShowDesktopMode;
- LeaveShowDesktopModeProc leaveShowDesktopMode;
-
- FadeDesktopState state;
- int fadeTime;
-} FadeDesktopScreen;
-
-typedef struct _FadeDesktopWindow
-{
- Bool fading;
- Bool isHidden;
-
- GLushort opacity;
-} FadeDesktopWindow;
-
-#define GET_FADEDESKTOP_DISPLAY(d) \
- ((FadeDesktopDisplay *) (d)->base.privates[displayPrivateIndex].ptr)
-
-#define FD_DISPLAY(d) \
- FadeDesktopDisplay *fd = GET_FADEDESKTOP_DISPLAY (d)
-
-#define GET_FADEDESKTOP_SCREEN(s, fd) \
- ((FadeDesktopScreen *) (s)->base.privates[(fd)->screenPrivateIndex].ptr)
-
-#define FD_SCREEN(s) \
- FadeDesktopScreen *fs = GET_FADEDESKTOP_SCREEN (s, GET_FADEDESKTOP_DISPLAY (s->display))
-
-#define GET_FADEDESKTOP_WINDOW(w, fs) \
- ((FadeDesktopWindow *) (w)->base.privates[(fs)->windowPrivateIndex].ptr)
-
-#define FD_WINDOW(w) \
- FadeDesktopWindow *fw = GET_FADEDESKTOP_WINDOW(w, \
- GET_FADEDESKTOP_SCREEN (w->screen, GET_FADEDESKTOP_DISPLAY (w->screen->display)))
-
-
-static int displayPrivateIndex;
-
-
-static void
-fadeDesktopActivateEvent (CompScreen *s,
- Bool activating)
-{
- CompOption o[2];
-
- o[0].type = CompOptionTypeInt;
- o[0].name = "root";
- o[0].value.i = s->root;
-
- o[1].type = CompOptionTypeBool;
- o[1].name = "active";
- o[1].value.b = activating;
-
- (*s->display->handleCompizEvent)
- (s->display, "fadedesktop", "activate", o, 2);
-}
-
-static Bool isFDWin(CompWindow *w)
-{
- if (w->attrib.override_redirect)
- return FALSE;
-
- if (w->grabbed)
- return FALSE;
-
- if (!w->managed)
- return FALSE;
-
- if (w->wmType & (CompWindowTypeDesktopMask |
- CompWindowTypeDockMask))
- return FALSE;
-
- if (w->state & CompWindowStateSkipPagerMask)
- return FALSE;
-
- if (!matchEval(fadedesktopGetWindowMatch(w->screen), w))
- return FALSE;
-
- return TRUE;
-}
-
-static void
-fadeDesktopPreparePaintScreen(CompScreen *s, int msSinceLastPaint)
-{
- FD_SCREEN(s);
- Bool doFade;
-
- fs->fadeTime -= msSinceLastPaint;
- if (fs->fadeTime < 0)
- fs->fadeTime = 0;
-
- if ((fs->state == FD_STATE_OUT) || (fs->state == FD_STATE_IN))
- {
- CompWindow *w;
- for (w = s->windows; w; w = w->next)
- {
- FD_WINDOW(w);
-
- if (fs->state == FD_STATE_OUT)
- doFade = fw->fading && w->inShowDesktopMode;
- else
- doFade = fw->fading && !w->inShowDesktopMode;
-
- if (doFade)
- {
- fw->opacity = w->paint.opacity *
- (float)((fs->state == FD_STATE_OUT) ? fs->fadeTime :
- fadedesktopGetFadetime(s) - fs->fadeTime) /
- (float)fadedesktopGetFadetime(s);
- }
- }
- }
-
- UNWRAP (fs, s, preparePaintScreen);
- (*s->preparePaintScreen) (s, msSinceLastPaint);
- WRAP (fs, s, preparePaintScreen, fadeDesktopPreparePaintScreen);
-}
-
-static void fadeDesktopDonePaintScreen(CompScreen *s)
-{
- FD_SCREEN(s);
-
- if ((fs->state == FD_STATE_OUT) || (fs->state == FD_STATE_IN))
- {
- if (fs->fadeTime <= 0)
- {
- CompWindow *w;
- Bool isStillSD = FALSE;
-
- for (w = s->windows; w; w = w->next)
- {
- FD_WINDOW(w);
- if (fw->fading)
- {
- if (fs->state == FD_STATE_OUT)
- {
- hideWindow(w);
- fw->isHidden = TRUE;
- }
- fw->fading = FALSE;
- }
- if (w->inShowDesktopMode)
- isStillSD = TRUE;
- }
-
- if ((fs->state == FD_STATE_OUT) || isStillSD)
- fs->state = FD_STATE_ON;
- else
- fs->state = FD_STATE_OFF;
- fadeDesktopActivateEvent (s, FALSE);
- }
- else
- damageScreen(s);
- }
-
- UNWRAP (fs, s, donePaintScreen);
- (*s->donePaintScreen)(s);
- WRAP (fs, s, donePaintScreen, fadeDesktopDonePaintScreen);
-}
-
-static Bool fadeDesktopPaintWindow (CompWindow *w,
- const WindowPaintAttrib *attrib,
- const CompTransform *transform,
- Region region,
- unsigned int mask)
-{
- Bool status;
- CompScreen *s = w->screen;
- FD_WINDOW(w);
- FD_SCREEN(s);
-
- if (fw->fading || fw->isHidden)
- {
- WindowPaintAttrib wAttrib = *attrib;
- wAttrib.opacity = fw->opacity;
-
- UNWRAP (fs, s, paintWindow);
- status = (*s->paintWindow) (w, &wAttrib, transform, region, mask);
- WRAP (fs, s, paintWindow, fadeDesktopPaintWindow);
- }
- else
- {
- UNWRAP (fs, s, paintWindow);
- status = (*s->paintWindow) (w, attrib, transform, region, mask);
- WRAP (fs, s, paintWindow, fadeDesktopPaintWindow);
- }
-
- return status;
-}
-
-static void fadeDesktopEnterShowDesktopMode(CompScreen *s)
-{
- FD_SCREEN(s);
- CompWindow *w;
-
- if ((fs->state == FD_STATE_OFF) || (fs->state == FD_STATE_IN))
- {
- if (fs->state == FD_STATE_OFF)
- fadeDesktopActivateEvent (s, TRUE);
-
- fs->state = FD_STATE_OUT;
- fs->fadeTime = fadedesktopGetFadetime(s) - fs->fadeTime;
-
- for (w = s->windows; w; w = w->next)
- {
- if (isFDWin(w))
- {
- FD_WINDOW(w);
-
- fw->fading = TRUE;
- w->inShowDesktopMode = TRUE;
- fw->opacity = w->paint.opacity;
- }
- }
-
- damageScreen(s);
- }
-
- UNWRAP(fs, s, enterShowDesktopMode);
- (*s->enterShowDesktopMode)(s);
- WRAP(fs, s, enterShowDesktopMode, fadeDesktopEnterShowDesktopMode);
-}
-
-static void fadeDesktopLeaveShowDesktopMode(CompScreen *s, CompWindow *w)
-{
- FD_SCREEN(s);
-
- if (fs->state != FD_STATE_OFF)
- {
- CompWindow *cw;
-
- if (fs->state != FD_STATE_IN)
- {
- if (fs->state == FD_STATE_ON)
- fadeDesktopActivateEvent (s, TRUE);
-
- fs->state = FD_STATE_IN;
- fs->fadeTime = fadedesktopGetFadetime(s) - fs->fadeTime;
- }
-
- for (cw = s->windows; cw; cw = cw->next)
- {
- if (w && (w->id != cw->id))
- continue;
-
- FD_WINDOW(cw);
- if (fw->isHidden)
- {
- cw->inShowDesktopMode = FALSE;
- showWindow(cw);
- fw->isHidden = FALSE;
- fw->fading = TRUE;
- }
- else if (fw->fading)
- {
- cw->inShowDesktopMode = FALSE;
- }
- }
-
- damageScreen(s);
- }
-
- UNWRAP (fs, s, leaveShowDesktopMode);
- (*s->leaveShowDesktopMode)(s, w);
- WRAP (fs, s, leaveShowDesktopMode, fadeDesktopLeaveShowDesktopMode);
-}
-
-static Bool fadeDesktopInit(CompPlugin *p)
-{
- displayPrivateIndex = allocateDisplayPrivateIndex();
- if (displayPrivateIndex < 0)
- return FALSE;
-
- return TRUE;
-}
-
-
-static void fadeDesktopFini(CompPlugin *p)
-{
- if (displayPrivateIndex >= 0)
- freeDisplayPrivateIndex(displayPrivateIndex);
-}
-
-static Bool fadeDesktopInitDisplay(CompPlugin *p, CompDisplay *d)
-{
- FadeDesktopDisplay *fd;
- if (!checkPluginABI ("core", CORE_ABIVERSION))
- return FALSE;
- fd = malloc(sizeof(FadeDesktopDisplay));
- if (!fd)
- return FALSE;
- fd->screenPrivateIndex = allocateScreenPrivateIndex(d);
- if (fd->screenPrivateIndex < 0)
- {
- free(fd);
- return FALSE;
- }
-
- d->base.privates[displayPrivateIndex].ptr = fd;
- return TRUE;
-}
-
-static void fadeDesktopFiniDisplay(CompPlugin *p, CompDisplay *d)
-{
- FD_DISPLAY(d);
- freeScreenPrivateIndex(d, fd->screenPrivateIndex);
- free(fd);
-}
-
-static Bool fadeDesktopInitScreen(CompPlugin *p, CompScreen *s)
-{
- FadeDesktopScreen *fs;
- FD_DISPLAY(s->display);
-
- fs = malloc(sizeof(FadeDesktopScreen));
- if (!fs)
- return FALSE;
-
- fs->windowPrivateIndex = allocateWindowPrivateIndex(s);
- if (fs->windowPrivateIndex < 0)
- {
- free(fs);
- return FALSE;
- }
-
- fs->state = FD_STATE_OFF;
- fs->fadeTime = 0;
-
- WRAP(fs, s, paintWindow, fadeDesktopPaintWindow);
- WRAP(fs, s, preparePaintScreen, fadeDesktopPreparePaintScreen);
- WRAP(fs, s, donePaintScreen, fadeDesktopDonePaintScreen);
- WRAP(fs, s, enterShowDesktopMode, fadeDesktopEnterShowDesktopMode);
- WRAP(fs, s, leaveShowDesktopMode, fadeDesktopLeaveShowDesktopMode);
-
- s->base.privates[fd->screenPrivateIndex].ptr = fs;
-
- return TRUE;
-
-}
-
-static void fadeDesktopFiniScreen(CompPlugin *p, CompScreen *s)
-{
- FD_SCREEN(s);
-
- UNWRAP(fs, s, paintWindow);
- UNWRAP(fs, s, preparePaintScreen);
- UNWRAP(fs, s, donePaintScreen);
- UNWRAP(fs, s, enterShowDesktopMode);
- UNWRAP(fs, s, leaveShowDesktopMode);
-
- freeWindowPrivateIndex(s, fs->windowPrivateIndex);
-
- free (fs);
-}
-
-static Bool fadeDesktopInitWindow(CompPlugin *p, CompWindow *w)
-{
- FadeDesktopWindow *fw;
- FD_SCREEN(w->screen);
-
- fw = malloc(sizeof(FadeDesktopWindow));
- if (!fw)
- return FALSE;
-
- fw->isHidden = FALSE;
- fw->fading = FALSE;
-
- w->base.privates[fs->windowPrivateIndex].ptr = fw;
-
- return TRUE;
-
-}
-
-static void fadeDesktopFiniWindow(CompPlugin *p, CompWindow *w)
-{
- FD_WINDOW(w);
-
- free (fw);
-}
-
-static CompBool
-fadeDesktopInitObject (CompPlugin *p,
- CompObject *o)
-{
- static InitPluginObjectProc dispTab[] = {
- (InitPluginObjectProc) 0, /* InitCore */
- (InitPluginObjectProc) fadeDesktopInitDisplay,
- (InitPluginObjectProc) fadeDesktopInitScreen,
- (InitPluginObjectProc) fadeDesktopInitWindow
- };
-
- RETURN_DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), TRUE, (p, o));
-}
-
-static void
-fadeDesktopFiniObject (CompPlugin *p,
- CompObject *o)
-{
- static FiniPluginObjectProc dispTab[] = {
- (FiniPluginObjectProc) 0, /* FiniCore */
- (FiniPluginObjectProc) fadeDesktopFiniDisplay,
- (FiniPluginObjectProc) fadeDesktopFiniScreen,
- (FiniPluginObjectProc) fadeDesktopFiniWindow
- };
-
- DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), (p, o));
-}
-
-static CompPluginVTable fadeDesktopVTable = {
- "fadedesktop",
- 0,
- fadeDesktopInit,
- fadeDesktopFini,
- fadeDesktopInitObject,
- fadeDesktopFiniObject,
- NULL,
- NULL
-};
-
-CompPluginVTable * getCompPluginInfo(void)
-{
- return &fadeDesktopVTable;
-}
diff --git a/fadedesktop.cpp b/fadedesktop.cpp
new file mode 100644
index 0000000..647e529
--- /dev/null
+++ b/fadedesktop.cpp
@@ -0,0 +1,261 @@
+/**
+ *
+ * Compiz fade to desktop plugin
+ *
+ * fadedesktop.cpp
+ *
+ * Copyright (c) 2006 Robert Carr <racarr@beryl-project.org>
+ * 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.
+ *
+ **/
+
+#include "fadedesktop.h"
+
+COMPIZ_PLUGIN_20081216 (fadedesktop, FadedesktopPluginVTable);
+
+static void
+fadeDesktopActivateEvent (bool activating)
+{
+ CompOption::Vector o;
+
+ o.push_back (CompOption ("root", CompOption::TypeInt));
+ o.push_back (CompOption ("active", CompOption::TypeBool));
+
+ o[0].value (). set ((int) screen->root ());
+ o[1].value (). set ((bool) activating);
+}
+
+static bool
+isFDWin (CompWindow *w)
+{
+ CompMatch match (FadedesktopScreen::get (screen)->optionGetWindowMatch ());
+ if (w->overrideRedirect ())
+ return false;
+
+ if (w->grabbed ())
+ return false;
+
+ if (!w->managed ())
+ return false;
+
+ if (w->wmType () & (CompWindowTypeDesktopMask |
+ CompWindowTypeDockMask))
+ return false;
+
+ if (w->state () & CompWindowStateSkipPagerMask)
+ return false;
+
+ if (!match.evaluate (w))
+ return false;
+
+ return true;
+}
+
+void
+FadedesktopScreen::preparePaint (int msSinceLastPaint)
+{
+ bool doFade;
+
+ fadeTime -= msSinceLastPaint;
+ if (fadeTime < 0)
+ fadeTime = 0;
+
+ if ((state == FD_STATE_OUT) || (state == FD_STATE_IN))
+ {
+ foreach (CompWindow *w, screen->windows ())
+ {
+ FD_WINDOW (w);
+
+ if (state == FD_STATE_OUT)
+ doFade = fw->fading && w->inShowDesktopMode ();
+ else
+ doFade = fw->fading && !w->inShowDesktopMode ();
+
+ if (doFade)
+ {
+ fw->opacity = fw->cWindow->opacity () *
+ (float)((state == FD_STATE_OUT) ? fadeTime :
+ optionGetFadetime () - fadeTime) /
+ (float)optionGetFadetime();
+ }
+ }
+ }
+
+ cScreen->preparePaint (msSinceLastPaint);
+}
+
+void
+FadedesktopScreen::donePaint ()
+{
+ if ((state == FD_STATE_OUT) || (state == FD_STATE_IN))
+ {
+ if (fadeTime <= 0)
+ {
+ bool isStillSD = false;
+
+ foreach (CompWindow *w, screen->windows ())
+ {
+ FD_WINDOW (w);
+
+ if (fw->fading)
+ {
+ if (state == FD_STATE_OUT)
+ {
+ w->hide ();
+ fw->isHidden = true;
+ }
+ fw->fading = false;
+ }
+ if (w->inShowDesktopMode ())
+ isStillSD = true;
+ }
+
+ if ((state == FD_STATE_OUT) || isStillSD)
+ state = FD_STATE_ON;
+ else
+ state = FD_STATE_OFF;
+ fadeDesktopActivateEvent (false);
+ }
+ else
+ cScreen->damageScreen ();
+ }
+
+ cScreen->donePaint ();
+}
+
+bool
+FadedesktopWindow::glPaint (const GLWindowPaintAttrib &attrib,
+ const GLMatrix &transform,
+ const CompRegion &region,
+ unsigned int mask)
+{
+ bool status;
+
+ if (fading || isHidden)
+ {
+ GLWindowPaintAttrib wAttrib = attrib;
+ wAttrib.opacity = opacity;
+
+ status = gWindow->glPaint (wAttrib, transform, region, mask);
+ }
+ else
+ status = gWindow->glPaint (attrib, transform, region, mask);
+
+ return status;
+}
+
+void
+FadedesktopScreen::enterShowDesktopMode ()
+{
+ if ((state == FD_STATE_OFF) || (state == FD_STATE_IN))
+ {
+ if (state == FD_STATE_OFF)
+ fadeDesktopActivateEvent (true);
+
+ state = FD_STATE_OUT;
+ fadeTime = optionGetFadetime() - fadeTime;
+
+ foreach (CompWindow *w, screen->windows ())
+ {
+ if (isFDWin(w))
+ {
+ FD_WINDOW(w);
+
+ fw->fading = true;
+ w->setShowDesktopMode (true);
+ fw->opacity = fw->cWindow->opacity ();
+ }
+ }
+
+ cScreen->damageScreen ();
+ }
+
+ screen->enterShowDesktopMode ();
+}
+
+void
+FadedesktopScreen::leaveShowDesktopMode (CompWindow *w)
+{
+ if (state != FD_STATE_OFF)
+ {
+ if (state != FD_STATE_IN)
+ {
+ if (state == FD_STATE_ON)
+ fadeDesktopActivateEvent (true);
+
+ state = FD_STATE_IN;
+ fadeTime = optionGetFadetime() - fadeTime;
+ }
+
+ foreach (CompWindow *cw, screen->windows ())
+ {
+ if (w && (w->id () != cw->id ()))
+ continue;
+
+ FD_WINDOW(cw);
+
+ if (fw->isHidden)
+ {
+ cw->setShowDesktopMode (false);
+ cw->show ();
+ fw->isHidden = false;
+ fw->fading = false;
+ }
+ else if (fw->fading)
+ {
+ cw->setShowDesktopMode (false);
+ }
+ }
+
+ cScreen->damageScreen ();
+ }
+
+ screen->leaveShowDesktopMode (w);
+}
+
+FadedesktopScreen::FadedesktopScreen (CompScreen *screen) :
+ PrivateHandler <FadedesktopScreen, CompScreen> (screen),
+ FadedesktopOptions (fadedesktopVTable->getMetadata ()),
+ cScreen (CompositeScreen::get (screen)),
+ gScreen (GLScreen::get (screen)),
+ state (FD_STATE_OFF),
+ fadeTime (0)
+{
+ ScreenInterface::setHandler (screen);
+ CompositeScreenInterface::setHandler (cScreen);
+ GLScreenInterface::setHandler (gScreen);
+}
+
+FadedesktopWindow::FadedesktopWindow (CompWindow *window) :
+ PrivateHandler <FadedesktopWindow, CompWindow> (window),
+ window (window),
+ cWindow (CompositeWindow::get (window)),
+ gWindow (GLWindow::get (window)),
+ fading (false),
+ isHidden (false),
+ opacity (OPAQUE)
+{
+ WindowInterface::setHandler (window);
+ GLWindowInterface::setHandler (gWindow);
+}
+
+bool
+FadedesktopPluginVTable::init ()
+{
+ if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION) ||
+ !CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI) ||
+ !CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI))
+ return false;
+
+ return true;
+}
diff --git a/fadedesktop.h b/fadedesktop.h
new file mode 100644
index 0000000..9c5a899
--- /dev/null
+++ b/fadedesktop.h
@@ -0,0 +1,101 @@
+/**
+ *
+ * Compiz fade to desktop plugin
+ *
+ * fadedesktop.c
+ *
+ * Copyright (c) 2006 Robert Carr <racarr@beryl-project.org>
+ * 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.
+ *
+ **/
+
+#include <core/core.h>
+#include <core/privatehandler.h>
+
+#include <composite/composite.h>
+#include <opengl/opengl.h>
+
+#include "fadedesktop_options.h"
+
+class FadedesktopScreen :
+ public PrivateHandler <FadedesktopScreen, CompScreen>,
+ public ScreenInterface,
+ public CompositeScreenInterface,
+ public GLScreenInterface,
+ public FadedesktopOptions
+{
+ public:
+
+ typedef enum
+ {
+ FD_STATE_OFF = 0,
+ FD_STATE_OUT,
+ FD_STATE_ON,
+ FD_STATE_IN
+ } FadeDesktopState;
+ public:
+
+ FadedesktopScreen (CompScreen *);
+
+ void preparePaint (int);
+ void donePaint ();
+
+ void enterShowDesktopMode ();
+ void leaveShowDesktopMode (CompWindow *w);
+
+ CompositeScreen *cScreen;
+ GLScreen *gScreen;
+
+ FadeDesktopState state;
+ int fadeTime;
+};
+
+class FadedesktopWindow :
+ public PrivateHandler <FadedesktopWindow, CompWindow>,
+ public WindowInterface,
+ public GLWindowInterface
+{
+ public:
+
+ FadedesktopWindow (CompWindow *);
+
+ bool glPaint (const GLWindowPaintAttrib &,
+ const GLMatrix &,
+ const CompRegion &,
+ unsigned int);
+
+ CompWindow *window;
+ CompositeWindow *cWindow;
+ GLWindow *gWindow;
+
+ bool fading;
+ bool isHidden;
+
+ GLushort opacity;
+};
+
+#define FD_SCREEN(s) \
+ FadedesktopScreen *fs = FadedesktopScreen::get (s);
+
+#define FD_WINDOW(w) \
+ FadedesktopWindow *fw = FadedesktopWindow::get (w);
+
+class FadedesktopPluginVTable :
+ public CompPlugin::VTableForScreenAndWindow <FadedesktopScreen, FadedesktopWindow>
+{
+ public:
+
+ bool init ();
+
+ PLUGIN_OPTION_HELPER (FadedesktopScreen);
+};
diff --git a/plugin.info b/plugin.info
index 1717286..9cc2208 100644
--- a/plugin.info
+++ b/plugin.info
@@ -1 +1,2 @@
PLUGIN = fadedesktop
+PKG_DEP = compiz-composite compiz-opengl