summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <Sam@XPS-SUSE.site>2009-01-14 01:14:14 +0900
committerSam Spilsbury <Sam@XPS-SUSE.site>2009-01-14 01:14:14 +0900
commitcc87500cc4f770fd344390b802224705a09bee4d (patch)
treeb55054416cacdc063dfd4022c845a3c9eb7892eb
parent8538d7c5a94fe880ff36feee3e750d9ab984600c (diff)
downloadexample-cc87500cc4f770fd344390b802224705a09bee4d.tar.gz
example-cc87500cc4f770fd344390b802224705a09bee4d.tar.bz2
Added a basic looking commented screen class
-rw-r--r--example.cpp0
-rw-r--r--example.h97
-rw-r--r--example.xml.in0
3 files changed, 97 insertions, 0 deletions
diff --git a/example.cpp b/example.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/example.cpp
diff --git a/example.h b/example.h
new file mode 100644
index 0000000..e2db2a8
--- /dev/null
+++ b/example.h
@@ -0,0 +1,97 @@
+/* Compiz example plugin
+ * example.c
+ *
+ * Copyright (c) 2008 Sam Spilsbury <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.
+ *
+ * Your own copyright notice would go above. You are free to choose whatever
+ * licence you want, just take note that some compiz code is GPL and you will
+ * not be able to re-use it if you want to use a different licence.
+ */
+
+/* The include path is set to /PREFIX/include/compiz in the Makefile, so you
+ * don't need to worry about not being able to find compiz headers */
+
+#include <core/core.h>
+
+/* You need to include this in order to get access to the CompPrivate templates */
+
+#include <core/privatehandler.h>
+
+/* Compositing is no longer built in by-default, so you need to include the interface
+ * of the composite plugin. You also need to do the same with opengl.h if you plan to
+ * use opengl functions
+ */
+
+#include <composite/composite.h>
+
+/* This is your base screen class. This class definition can be considered the top most
+ * as there is no multi-screen or multi-display support in compiz++, only one compiz
+ * instance per screen.
+ */
+
+class ExampleScreen :
+ /* You should inherit the ScreenInterface class if you want to dynamically hook
+ * screen-level core functions. */
+ public ScreenInterface,
+ /* Same goes for screen functions in the composite plugin */
+ public CompositeScreenInterface,
+ /* This sets up a privates handler, where you can access an instance of your class for
+ * every CompScreen object (same goes for ExampleWindow and CompWindow). It adds the
+ * member function ::get, which will allow you get an instance of this class from a
+ * CompScreen * object. Oh, and the memory management is done for you now ^_^
+ */
+ public PrivateHandler <ExampleScreen, CompScreen>,
+ /* And finally, because we are using BCOP to generate our options, it creates a class
+ * with a bunch of getters and setters that are added to out class when we inherit it. Yay.
+ */
+ public ExampleOptions
+{
+
+ public:
+
+ /* Lets get into buisness. This is the constructor, it replaces the initScreen, initEtc
+ * things that used to be in compiz and is called automatically when an instance of this
+ * class is created. Notice how it is the same name as the class name. It has to be that way.
+ */
+
+ ExampleScreen::ExampleScreen (CompScreen *s);
+
+ /* This is the destructor. It is called when the class is destroyed. If you allocated any
+ * memory or need to do some cleanup, here is where you do it. Note the tilde (~)?
+ */
+
+ ExampleScreen::~ExampleScreen ();
+
+ /* We store CompositeScreen and CompScreen to avoid unecessary calls to ::get */
+ CompScreen *screen;
+ CompositeScreen *cScreen;
+
+ /* And some member variables */
+ int foo;
+ char *foobar;
+
+ /* Now. Because we imported ScreenInterface and CompositeScreenInterface, we get all the
+ * core functions in there for free. Here's the twist. Those functions are stored as 'virtual',
+ * so they can be overridden. That is what we do here. So instead of a core function being called,
+ * our own is
+ */
+
+ bool
+ preparePaint (int)
+
+ bool
+ donePaint ();
+
+ bool
+ handleEvent (XEvent *);
+};
diff --git a/example.xml.in b/example.xml.in
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/example.xml.in