summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <SmSpillaz@gmail.com>2010-05-11 20:05:10 +0800
committerSam Spilsbury <SmSpillaz@gmail.com>2010-05-11 20:05:10 +0800
commit26251afa579977cf7a8cf5a61c19e0fc6de9b7a2 (patch)
treea97d6f2f9c98b217127996e8be1f45bb34310844
parent7a6ed881564ec949e37bb5a8cd60cb1760cca732 (diff)
parentc15d19b46ae0124d71221afc67342f7a755581ca (diff)
downloadstatic-26251afa579977cf7a8cf5a61c19e0fc6de9b7a2.tar.gz
static-26251afa579977cf7a8cf5a61c19e0fc6de9b7a2.tar.bz2
Merge branch 'master' of ../static_old
-rw-r--r--CMakeLists.txt5
-rw-r--r--src/static.cpp187
-rw-r--r--src/static.h125
-rw-r--r--static.xml.in34
4 files changed, 351 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..96f9f98
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,5 @@
+find_package (Compiz REQUIRED)
+
+include (CompizPlugin)
+
+compiz_plugin (static PLUGINDEPS composite opengl)
diff --git a/src/static.cpp b/src/static.cpp
new file mode 100644
index 0000000..aa088b4
--- /dev/null
+++ b/src/static.cpp
@@ -0,0 +1,187 @@
+/*
+ * Compiz Static Windows plugin
+ *
+ * static.c
+ *
+ * Copyright : (C) 2008 by Mark Thomas
+ * E-mail : markbt@efaref.net
+ *
+ *
+ * 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 "static.h"
+
+COMPIZ_PLUGIN_20090315 (static, StaticPluginVTable);
+
+bool
+StaticWindow::isStatic ()
+{
+ return StaticScreen::get (screen)->optionGetWindowMatch ().evaluate (window);
+}
+
+void
+StaticScreen::preparePaint (int msSinceLastPaint)
+{
+ /* Initially we are painting all windows.
+ * This may change if we switch to transformed mode.
+ */
+ mStaticMode = STATIC_ALL;
+
+ cScreen->preparePaint (msSinceLastPaint);
+}
+
+void
+StaticScreen::glPaintTransformedOutput (const GLScreenPaintAttrib &attrib,
+ const GLMatrix &transform,
+ const CompRegion &region,
+ CompOutput *output,
+ unsigned int mask)
+{
+ /* We are now painting in transformed mode.
+ * Start painting only normal windows.
+ */
+ mStaticMode = STATIC_NORMAL;
+
+ gScreen->glPaintTransformedOutput (attrib, transform, region, output, mask);
+}
+
+void
+StaticScreen::glApplyTransform (const GLScreenPaintAttrib &attrib,
+ CompOutput *output,
+ GLMatrix *transform)
+{
+ if (mStaticMode == STATIC_STATIC)
+ {
+ //int oldNumber = gScreen->glApplyTransformGetCurrentIndex ();
+ //gScreen->glApplyTransformSetCurrentIndex (MAXSHORT);
+ gScreen->glApplyTransform (attrib, output, transform);
+ //gScreen->glApplyTransformSetCurrentIndex (oldNumber);
+ }
+ else
+ {
+ gScreen->glApplyTransform (attrib, output, transform);
+ }
+}
+
+bool
+StaticScreen::glPaintOutput (const GLScreenPaintAttrib &attrib,
+ const GLMatrix &transform,
+ const CompRegion &region,
+ CompOutput *output,
+ unsigned int mask)
+{
+ bool status;
+
+ status = gScreen->glPaintOutput (attrib, transform, region, output, mask);
+
+ if (mStaticMode == STATIC_NORMAL)
+ {
+ GLMatrix sTransform (transform);
+
+ sTransform.toScreenSpace (output, -DEFAULT_Z_CAMERA);
+
+ /* We switched to Transformed mode somewhere along the line.
+ * Now paint the dock windows untransformed by bypassing
+ * the virtual table.
+ */
+ //mask &= ~PAINT_SCREEN_CLEAR_MASK;
+
+ mStaticMode = STATIC_STATIC;
+
+ foreach (CompWindow *w, screen->windows ())
+ {
+ STATIC_WINDOW (w);
+
+ if (!sw->isStatic ())
+ continue;
+
+ if (!output->contains (w->inputRect ()))
+ continue;
+
+ GLMatrix wMatrix;
+ GLFragment::Attrib fragment (sw->gWindow->paintAttrib ());
+
+ wMatrix.toScreenSpace (&screen->currentOutputDev (), -DEFAULT_Z_CAMERA);
+ mask |= PAINT_WINDOW_TRANSFORMED_MASK;
+
+ int oldIndex = sw->gWindow->glAddGeometryGetCurrentIndex ();
+ glPushMatrix ();
+ glLoadMatrixf (wMatrix.getMatrix ());
+ sw->gWindow->glAddGeometrySetCurrentIndex (MAXSHORT);
+ status = sw->gWindow->glDraw (wMatrix, fragment, infiniteRegion, mask);
+ sw->gWindow->glAddGeometrySetCurrentIndex (oldIndex);
+ glPopMatrix ();
+
+ mStaticMode = STATIC_NORMAL;
+ }
+ }
+
+ return status;
+}
+
+
+bool
+StaticWindow::glPaint (const GLWindowPaintAttrib &attrib,
+ const GLMatrix &transform,
+ const CompRegion &region,
+ unsigned int mask)
+{
+ bool status = TRUE;
+ STATIC_SCREEN (screen);
+
+ if (ss->mStaticMode == STATIC_STATIC && isStatic ())
+ mask |= PAINT_WINDOW_NO_CORE_INSTANCE_MASK;
+
+ status = gWindow->glPaint (attrib, transform, region, mask);
+
+ return status;
+}
+
+
+StaticScreen::StaticScreen (CompScreen *screen) :
+ PluginClassHandler <StaticScreen, CompScreen> (screen),
+ cScreen (CompositeScreen::get (screen)),
+ gScreen (GLScreen::get (screen)),
+ mStaticMode (STATIC_ALL)
+{
+ CompositeScreenInterface::setHandler (cScreen);
+ GLScreenInterface::setHandler (gScreen);
+}
+
+StaticScreen::~StaticScreen ()
+{
+}
+
+StaticWindow::StaticWindow (CompWindow *window) :
+ PluginClassHandler <StaticWindow, CompWindow> (window),
+ window (window),
+ cWindow (CompositeWindow::get (window)),
+ gWindow (GLWindow::get (window))
+{
+ GLWindowInterface::setHandler (gWindow);
+}
+
+StaticWindow::~StaticWindow ()
+{
+}
+
+bool
+StaticPluginVTable::init ()
+{
+ if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION) ||
+ !CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI) ||
+ !CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI))
+ return false;
+ else
+ return true;
+}
diff --git a/src/static.h b/src/static.h
new file mode 100644
index 0000000..d17c02b
--- /dev/null
+++ b/src/static.h
@@ -0,0 +1,125 @@
+/*
+ * Compiz Static Windows plugin
+ *
+ * static.h
+ *
+ * Copyright : (C) 2008 by Mark Thomas
+ * E-mail : markbt@efaref.net
+ *
+ *
+ * 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/pluginclasshandler.h>
+#include <opengl/opengl.h>
+#include <composite/composite.h>
+
+#include "static_options.h"
+
+typedef enum _StaticMode
+{
+ STATIC_ALL,
+ STATIC_NORMAL,
+ STATIC_STATIC
+}
+StaticMode;
+
+class StaticScreen :
+ public PluginClassHandler <StaticScreen, CompScreen>,
+ public GLScreenInterface,
+ public CompositeScreenInterface,
+ public StaticOptions
+{
+ public:
+
+ StaticScreen (CompScreen *);
+ ~StaticScreen ();
+
+ public:
+
+ CompositeScreen *cScreen;
+ GLScreen *gScreen;
+
+ public:
+
+ bool
+ glPaintOutput (const GLScreenPaintAttrib &,
+ const GLMatrix &,
+ const CompRegion &,
+ CompOutput *,
+ unsigned int );
+
+ void
+ glApplyTransform (const GLScreenPaintAttrib &,
+ CompOutput *,
+ GLMatrix *);
+
+ void
+ glPaintTransformedOutput (const GLScreenPaintAttrib &,
+ const GLMatrix &,
+ const CompRegion &,
+ CompOutput *,
+ unsigned int );
+
+ void
+ preparePaint (int);
+
+ public:
+
+ StaticMode mStaticMode;
+ bool mPaintingStatic;
+};
+
+#define STATIC_SCREEN(s) \
+ StaticScreen *ss = StaticScreen::get (s);
+
+class StaticWindow :
+ public PluginClassHandler <StaticWindow, CompWindow>,
+ public GLWindowInterface
+{
+ public:
+
+ StaticWindow (CompWindow *);
+ ~StaticWindow ();
+
+ public:
+
+ CompWindow *window;
+ CompositeWindow *cWindow;
+ GLWindow *gWindow;
+
+ public:
+
+ bool
+ glPaint (const GLWindowPaintAttrib &,
+ const GLMatrix &,
+ const CompRegion &,
+ unsigned int );
+
+ public:
+
+ bool
+ isStatic ();
+
+};
+
+#define STATIC_WINDOW(w) \
+ StaticWindow *sw = StaticWindow::get (w)
+
+class StaticPluginVTable :
+ public CompPlugin::VTableForScreenAndWindow <StaticScreen, StaticWindow>
+{
+ public:
+
+ bool init ();
+};
diff --git a/static.xml.in b/static.xml.in
new file mode 100644
index 0000000..5c58a7a
--- /dev/null
+++ b/static.xml.in
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<compiz>
+ <plugin name="static" useBcop="true">
+ <_short>Static Windows</_short>
+ <_long>Keep windows such as dock or panels static</_long>
+ <category>Desktop</category>
+ <deps>
+ <requirement>
+ <plugin>composite</plugin>
+ <plugin>opengl</plugin>
+ </requirement>
+ <relation type="after">
+ <plugin>composite</plugin>
+ <plugin>opengl</plugin>
+ <plugin>3d</plugin>
+ <plugin>expo</plugin>
+ <plugin>zoom</plugin>
+ <plugin>ezoom</plugin>
+ </relation>
+ <relation type="before">
+ </relation>
+ </deps>
+ <options>
+ <group>
+ <_short>General</_short>
+ <option name="window_match" type="match">
+ <_short>Window Match</_short>
+ <_long>Windows that should be kept static during transformations.</_long>
+ <default>Dock</default>
+ </option>
+ </group>
+ </options>
+ </plugin>
+</compiz>