summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <Sam@XPS-SUSE.site>2009-01-14 20:48:53 +0900
committerSam Spilsbury <Sam@XPS-SUSE.site>2009-01-14 20:48:53 +0900
commit1a553104cbeb3b6981f74a89dc60634d510a36db (patch)
tree839e8561b8296e393724a819081207efdd213337
parent6f3b8a0ccecc510a4b919eda76d3496d56bb9ee9 (diff)
downloadexample-1a553104cbeb3b6981f74a89dc60634d510a36db.tar.gz
example-1a553104cbeb3b6981f74a89dc60634d510a36db.tar.bz2
Fix all the build errors and link errors. Plugin works now
-rw-r--r--CMakeLists.txt2
-rw-r--r--example.cpp122
-rw-r--r--example.h60
-rw-r--r--example.xml.in29
-rw-r--r--plugin.info2
5 files changed, 133 insertions, 82 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2b96e5c..da867a5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,3 +1,3 @@
include (CompizFusion)
-compiz_fusion_plugin (example)
+compiz_fusion_plugin (example PLUGINDEPS composite opengl)
diff --git a/example.cpp b/example.cpp
index b778367..d3b08fe 100644
--- a/example.cpp
+++ b/example.cpp
@@ -20,6 +20,11 @@
#include "example.h"
+/* You must also call this. This creates a proper vTable for a plugin name in the
+ * first argument (it's a macro, so you don't need a string). */
+
+COMPIZ_PLUGIN_20081216 (example, ExamplePluginVTable);
+
/* This is the function that is called before the screen is 're-painted'. It is used for animation
* and such because it gives you a time difference between when the last time the screen was repainted
* and the current time of the execution of the functions in milliseconds). It's part of the composite
@@ -30,11 +35,11 @@ void
ExampleScreen::preparePaint (int ms)
{
/* compLogMessage is a framework for reporting messages to the terminal via compiz */
- compLogMessage (CompLogLevelInfo, "preparePaint Called\n");
+ compLogMessage ("example", CompLogLevelInfo, "preparePaint Called\n");
/* At the end of every function, you must call BaseClass->functionName (args) in order to pass on
* the call chain */
- ret = cScreen->preparePaint (ms);
+ cScreen->preparePaint (ms);
}
/* This is the guts of the paint function. You can transform the way the entire output is painted
@@ -42,17 +47,17 @@ ExampleScreen::preparePaint (int ms)
* the screen, see opengl/opengl.h on how you can change it */
bool
-ExampleScreen::glPaintOutput (const GLScreenPaintAttrib &sAttrib, // Some basic attribs on how the screen should be painted
- const GLMatrix &sTransform, // Screen transformation matrix
+ExampleScreen::glPaintOutput (const GLScreenPaintAttrib &attrib, // Some basic attribs on how the screen should be painted
+ const GLMatrix &transform, // Screen transformation matrix
const CompRegion &region, // Region of screen being painted
CompOutput *output, // Output properties. Use this to the get output width and height for the output being painted
unsigned int mask /* Some other paint properties, see opengl.h */)
{
bool ret;
- compLogMessage (CompLogLevelInfo, "glPaintOutput Called\n");
+ compLogMessage ("example", CompLogLevelInfo, "glPaintOutput Called\n");
/* glPaintOutput is part of the opengl plugin, so we need the GLScreen base class. */
- ret = gScreen->glPaintOutput (attrib, sTransform, region, output, mask);
+ ret = gScreen->glPaintOutput (attrib, transform, region, output, mask);
return ret;
}
@@ -60,20 +65,17 @@ ExampleScreen::glPaintOutput (const GLScreenPaintAttrib &sAttrib, // Some basic
/* This is called when the output is transformed by a matrix. Basically the same, but core has
* done a few things for us like clip planes etc */
-bool
-ExampleScreen::glPaintTransformedOutput (const GLScreenPaintAttrib &sAttrib, // Some basic attribs on how the screen should be painted
- const GLMatrix &sTransform, // Screen transformation matrix
+void
+ExampleScreen::glPaintTransformedOutput (const GLScreenPaintAttrib &attrib, // Some basic attribs on how the screen should be painted
+ const GLMatrix &transform, // Screen transformation matrix
const CompRegion &region, // Region of screen being painted
CompOutput *output, // Output properties. Use this to the get output width and height for the output being painted
unsigned int mask /* Some other paint properties, see opengl.h */)
{
- bool ret;
- compLogMessage (CompLogLevelInfo, "glPaintOutput Called\n");
+ compLogMessage ("example", CompLogLevelInfo, "glPaintOutput Called\n");
/* glPaintOutput is part of the opengl plugin, so we need the GLScreen base class. */
- ret = gScreen->glPaintOutput (attrib, sTransform, region, output, mask);
-
- return ret;
+ gScreen->glPaintOutput (attrib, transform, region, output, mask);
}
/* This is called after screen painting is finished. It gives you a chance to do any cleanup and or
@@ -84,9 +86,9 @@ ExampleScreen::glPaintTransformedOutput (const GLScreenPaintAttrib &sAttrib, //
void
ExampleScreen::donePaint ()
{
- compLogMessage (CompLogLevelInfo, "donePaint Called\n");
+ compLogMessage ("example", CompLogLevelInfo, "donePaint Called\n");
- cScreen->donePaint ()
+ cScreen->donePaint ();
}
/* This is our event handler. It directly hooks into the screen's X Event handler and allows us to handle
@@ -96,7 +98,7 @@ ExampleScreen::donePaint ()
void
ExampleScreen::handleEvent (XEvent *event)
{
- compLogMessage (CompLogLevelInfo, "handleEventCalled\n");
+ compLogMessage ("example", CompLogLevelInfo, "handleEventCalled\n");
/* Switch event->type to see what kind of even we received */
@@ -107,7 +109,7 @@ ExampleScreen::handleEvent (XEvent *event)
fprintf (stderr, " * - Button Pressed Event!\n");
break;
/* Read event->xbutton for properties on this */
- case ButtonPress:
+ case ButtonRelease:
fprintf (stderr, " * - Button Released Event!\n");
break;
/* Read event->xmotion for properties on this */
@@ -154,7 +156,7 @@ ExampleWindow::glPaint (const GLWindowPaintAttrib &attrib, // Brightness, Satura
unsigned int mask) // Other flags. See opengl.h
{
bool ret;
- compLogMessage (CompLogLevelInfo, "glPaint called!\n");
+ compLogMessage ("example", CompLogLevelInfo, "glPaint called!\n");
ret = gWindow->glPaint (attrib, transform, region, mask);
@@ -166,11 +168,11 @@ ExampleWindow::glPaint (const GLWindowPaintAttrib &attrib, // Brightness, Satura
*/
bool
-ExampleWindow::damageRect (bool intial, // initial damage?
- CompRect &rect) // The actual rect. Modifyable.
+ExampleWindow::damageRect (bool initial, // initial damage?
+ const CompRect &rect) // The actual rect. Modifyable.
{
bool ret;
- compLogMessage (CompLogLevelInfo, "damageRect called!\n");
+ compLogMessage ("example", CompLogLevelInfo, "damageRect called!\n");
ret = cWindow->damageRect (initial, rect);
@@ -183,7 +185,7 @@ bool
ExampleWindow::focus ()
{
bool ret;
- compLogMessage (CompLogLevelInfo, "focus called!\n");
+ compLogMessage ("example", CompLogLevelInfo, "focus called!\n");
ret = window->focus ();
@@ -195,7 +197,7 @@ ExampleWindow::focus ()
void
ExampleWindow::activate ()
{
- compLogMessage (CompLogLevelInfo, "activate called!\n");
+ compLogMessage ("example", CompLogLevelInfo, "activate called!\n");
window->activate ();
}
@@ -207,7 +209,7 @@ bool
ExampleWindow::place (CompPoint &point)
{
bool ret;
- compLogMessage (CompLogLevelInfo, "place called!\n");
+ compLogMessage ("example", CompLogLevelInfo, "place called!\n");
ret = window->place (point);
return ret;
@@ -220,12 +222,11 @@ ExampleWindow::place (CompPoint &point)
void
ExampleWindow::moveNotify (int dx,
int dy,
- unsigned int state,
- unsigned int mask)
+ bool immediate)
{
- compLogMessage (CompLogLevelInfo, "moveNotify called!\n");
+ compLogMessage ("example", CompLogLevelInfo, "moveNotify called!\n");
- window->moveNotify (dx, dy, state, mask);
+ window->moveNotify (dx, dy, immediate);
}
/* This is called whenever the window is resized. It tells you how much the window has been resized */
@@ -236,9 +237,9 @@ ExampleWindow::resizeNotify (int dx,
int dwidth,
int dheight)
{
- compLogMessage (CompLogLevelInfo, "resizeNotify called!\n");
+ compLogMessage ("example", CompLogLevelInfo, "resizeNotify called!\n");
- window->moveNotify (dx, dy, dwidth, dheight);
+ window->resizeNotify (dx, dy, dwidth, dheight);
}
/* This is called when another plugin deems a window to be 'grabbed'. You can't actually 'grab' a
@@ -250,7 +251,7 @@ ExampleWindow::grabNotify (int x,
unsigned int state,
unsigned int mask)
{
- compLogMessage (CompLogLevelInfo, "grabNotify called!\n");
+ compLogMessage ("example", CompLogLevelInfo, "grabNotify called!\n");
window->grabNotify (x, y, state, mask);
}
@@ -260,7 +261,7 @@ ExampleWindow::grabNotify (int x,
void
ExampleWindow::ungrabNotify ()
{
- compLogMessage (CompLogLevelInfo, "ungrabNotify called!\n");
+ compLogMessage ("example", CompLogLevelInfo, "ungrabNotify called!\n");
window->ungrabNotify ();
}
@@ -270,7 +271,7 @@ ExampleWindow::ungrabNotify ()
void
ExampleWindow::windowNotify (CompWindowNotify n)
{
- compLogMessage (CompLogLevelInfo, "windowNotify called!\n");
+ compLogMessage ("example", CompLogLevelInfo, "windowNotify called!\n");
window->windowNotify (n);
}
@@ -284,7 +285,7 @@ ExampleScreen::exampleInitiate (CompAction *action,
CompAction::State state,
CompOption::Vector &options)
{
- compLogMessage (CompLogLevelInfo, "exampleInitaite called!\n");
+ compLogMessage ("example", CompLogLevelInfo, "exampleInitaite called!\n");
return false;
}
@@ -292,11 +293,11 @@ ExampleScreen::exampleInitiate (CompAction *action,
/* Some actions are initiated until the key is let go of, at which point they are terminated */
bool
-PrivateScaleScreen::specialInitiate (CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
+ExampleScreen::specialInitiate (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options)
{
- compLogMessage (CompLogLevelInfo, "specialInitiate called!\n");
+ compLogMessage ("example", CompLogLevelInfo, "specialInitiate called!\n");
/* You have to set the state to StateTerm* once you've finished with the action */
@@ -316,7 +317,7 @@ ExampleScreen::specialTerminate (CompAction *action,
CompAction::State state,
CompOption::Vector &options)
{
- compLogMessage (CompLogLevelInfo, "specialTerminate called!\n");
+ compLogMessage ("example", CompLogLevelInfo, "specialTerminate called!\n");
/* It's always good practice to remove that state too */
@@ -335,7 +336,7 @@ ExampleScreen::customInitiate (CompAction *action,
CompOption::Vector options,
int theMeaningOfLife)
{
- compLogMessage (CompLogLevelInfo, "customInitiate called! The meaning of life is %i\n", theMeaningOfLife);
+ compLogMessage ("example", CompLogLevelInfo, "customInitiate called! The meaning of life is %i\n", theMeaningOfLife);
return false;
}
@@ -353,18 +354,17 @@ ExampleScreen::ExampleScreen (CompScreen *screen) :// The constructor takes a Co
screen (screen),
cScreen (CompositeScreen::get (screen)),
gScreen (GLScreen::get (screen)),
- foo (42),
- foobar ("foobar")
+ foo (42)
{
- compLogMessage (CompLogLevelInfo, "ExampleScreen constructor called!");
- ScreenInterface::setHandler (screen) // Sets the screen function hook handler
- CompositeScreenInterface::setHandler (screen) // Ditto for cScreen
- GLScreenInterface::setHandler (screen) // Ditto for gScreen
-
- optionGetExampleInitiate (exampleInitiate); // Initiate handler for 'example' action
- optionGetSpecialInitiate (specialInitiate); // Initiate handler for 'special' action
- optionGetSpecialTerminate (specialTerminate); // Terminate handler for 'special' action
- optionGetCustomInitiate (boost::bind (customInitiate, _1, _2, _3, 42)); // Initiate handler for 'special' action. Note how boost::bind is used to create a new function with more args? Neat eh?
+ compLogMessage ("example", CompLogLevelInfo, "ExampleScreen constructor called!");
+ ScreenInterface::setHandler (screen); // Sets the screen function hook handler
+ CompositeScreenInterface::setHandler (cScreen); // Ditto for cScreen
+ GLScreenInterface::setHandler (gScreen); // Ditto for gScreen
+
+ optionSetExampleInitiate (exampleInitiate); // Initiate handler for 'example' action
+ optionSetSpecialInitiate (specialInitiate); // Initiate handler for 'special' action
+ optionSetSpecialTerminate (specialTerminate); // Terminate handler for 'custorm' action
+ optionSetCustomInitiate (boost::bind (customInitiate, _1, _2, _3, 42)); // Initiate handler for 'special' action. Note how boost::bind is used to create a new function with more args? Neat eh?
}
/* This is the destructor. It is called when the class is destroyed. If you allocated any
@@ -373,24 +373,24 @@ ExampleScreen::ExampleScreen (CompScreen *screen) :// The constructor takes a Co
ExampleScreen::~ExampleScreen ()
{
- compLogMessage (CompLogLevelInfo, "ExampleScreen destructor called!\n");
+ compLogMessage ("example", CompLogLevelInfo, "ExampleScreen destructor called!\n");
}
ExampleWindow::ExampleWindow (CompWindow *window) :
PrivateHandler <ExampleWindow, CompWindow> (window), // Initiate our PrivateHandler class template
window (window),
cWindow (CompositeWindow::get (window)),
- gWindow (CompositeWindow::get (window))
+ gWindow (GLWindow::get (window))
{
- compLogMessage (CompLogLevelInfo, "ExampleWindow constructor called!");
- WindowInterface::setHandler (window) // Sets the window function hook handler
- CompositeWindowInterface::setHandler (window) // Ditto for cWindow
- GLWindowInterface::setHandler (window) // Ditto for gWindow
+ compLogMessage ("example", CompLogLevelInfo, "ExampleWindow constructor called!");
+ WindowInterface::setHandler (window); // Sets the window function hook handler
+ CompositeWindowInterface::setHandler (cWindow); // Ditto for cWindow
+ GLWindowInterface::setHandler (gWindow); // Ditto for gWindow
}
ExampleWindow::~ExampleWindow ()
{
- compLogMessage (CompLogLevelInfo, "ExampleWindow destructor called!\n");
+ compLogMessage ("example", CompLogLevelInfo, "ExampleWindow destructor called!\n");
}
/* This is the very first function compiz calls. It kicks off plugin initialization */
@@ -405,9 +405,9 @@ ExamplePluginVTable::init ()
if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION))
return false;
- if (!CompPlugin::checkPluginABI ("composite", COMPOSITE_ABIVERSION))
+ if (!CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI))
return false;
- if (!CompPlugin::checkPluginABI ("opengl", OPENGL_ABIVERSION))
+ if (!CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI))
return false;
return true;
diff --git a/example.h b/example.h
index 80fc90a..c49e2bb 100644
--- a/example.h
+++ b/example.h
@@ -54,7 +54,7 @@ class ExampleScreen :
/* Same goes for screen functions in the composite plugin */
public CompositeScreenInterface,
/* And opengl plugin */
- public GLScreenInterface
+ public GLScreenInterface,
/* 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
@@ -74,13 +74,13 @@ class ExampleScreen :
* class is created. Notice how it is the same name as the class name. It has to be that way.
*/
- ExampleScreen::ExampleScreen (CompScreen *s);
+ 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 ();
+ ~ExampleScreen ();
/* We store CompositeScreen, GLScreen, and CompScreen to avoid unecessary calls to ::get */
CompScreen *screen;
@@ -89,7 +89,6 @@ class ExampleScreen :
/* 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',
@@ -118,7 +117,7 @@ class ExampleScreen :
/* This is called when the output is transformed by a matrix. Basically the same, but core has
* done a few things for us like clip planes etc */
- bool
+ void
glPaintTransformedOutput (const GLScreenPaintAttrib &,
const GLMatrix &, const CompRegion &,
CompOutput *, unsigned int);
@@ -138,14 +137,41 @@ class ExampleScreen :
void
handleEvent (XEvent *);
+
+ /* Actions, these are called on keypresses, buttonpress, edges etc by compiz */
+
+ static bool
+ exampleInitiate (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
+
+ /* Initiate / Terminate action pair */
+
+ static bool
+ specialInitiate (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
+
+ static bool
+ specialTerminate (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
+
+ /* Actions with additional args through boost::bind */
+
+ static bool
+ customInitiate (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector options,
+ int theMeaningOfLife);
};
-class ExampleWindow
+class ExampleWindow :
/* Same for Example Screen, inherit interfaces, private handlers, options */
public WindowInterface,
public CompositeWindowInterface,
public GLWindowInterface,
- public PrivateHandler <ExampleWindow, CompWindow>,
+ public PrivateHandler <ExampleWindow, CompWindow>
{
public:
@@ -156,9 +182,9 @@ class ExampleWindow
~ExampleWindow ();
/* We store CompositeWindow, GLWindow, and CompWindow to avoid unecessary calls to ::get */
- CompScreen *window;
- CompositeScreen *cWindow;
- GLScreen *gWindow;
+ CompWindow *window;
+ CompositeWindow *cWindow;
+ GLWindow *gWindow;
/* This gets called whenever the window needs to be repainted. WindowPaintAttrib gives you some
* attributes like brightness/saturation etc to play around with. GLMatrix is the window's
@@ -167,7 +193,7 @@ class ExampleWindow
bool
glPaint (const GLWindowPaintAttrib &, const GLMatrix &,
- const CompRegion &, unsigned int)
+ const CompRegion &, unsigned int);
/* This get's called whenever a window's rect is damaged. You can do stuff here or you can adjust the damage
* rectangle so that the window will update properly. Part of the CompositeWindowInterface.
@@ -211,6 +237,7 @@ class ExampleWindow
/* This is called when another misc notification arises, such as Map/Unmap etc */
void
windowNotify (CompWindowNotify);
+
};
/* Most plugins set up macros to access their Screen and Window classes based on a CompScreen * or CompWindow * */
@@ -224,10 +251,10 @@ ExampleWindow *ew = ExampleWindow::get (window);
/* Your vTable class is some basic info about the plugin that core uses.
*/
-class LPPluginVTable :
+class ExamplePluginVTable :
/* Inheriting CompPlugin::VTableForScreenAndWindow <ScreenClass, WindowClass>
* automatically does most of the vTable setup for you */
- public CompPlugin::VTableForScreenAndWindow<LPScreen, LPWindow>
+ public CompPlugin::VTableForScreenAndWindow<ExampleScreen, ExampleWindow>
{
public:
@@ -239,10 +266,5 @@ class LPPluginVTable :
/* This implements ::getOption and ::setOption in your screen class for you. Yay */
- PLUGIN_OPTION_HELPER (LPScreen);
+ PLUGIN_OPTION_HELPER (ExampleScreen);
};
-
-/* You must also call this. This creates a proper vTable for a plugin name in the
- * first argument (it's a macro, so you don't need a string). */
-
-COMPIZ_PLUGIN_20081216 (lazypointer, LPPluginVTable);
diff --git a/example.xml.in b/example.xml.in
index e69de29..2b75615 100644
--- a/example.xml.in
+++ b/example.xml.in
@@ -0,0 +1,29 @@
+<compiz>
+ <plugin name="example" useBcop="true">
+ <_short>Example plugin</_short>
+ <_long>Developers are awesome</_long>
+ <relation type="after">
+ <plugin>composite</plugin>
+ <plugin>opengl</plugin>
+ </relation>
+ <requirement>
+ <plugin>composite</plugin>
+ <plugin>opengl</plugin>
+ </requirement>
+ <screen>
+ <option type="key" name="example">
+ <_short>Example Action</_short>
+ <_long>Example action. See what comes out of a terminal? Familiar with the code yet?</_long>
+ </option>
+ <option type="key" name="special">
+ <_short>Special Action</_short>
+ <_long>Special action. See how it works</_long>
+ </option>
+ <option type="key" name="custom">
+ <_short>Custom Action</_short>
+ <_long>Custom action. Where did that 42 come from? Isn't boost::bind awesome!</_long>
+ </option>
+ </screen>
+ </plugin>
+</compiz>
+
diff --git a/plugin.info b/plugin.info
index 0cf43ca..c488208 100644
--- a/plugin.info
+++ b/plugin.info
@@ -2,7 +2,7 @@
# Plugin name
PLUGIN = example
# Any pkg-config packages this plugin depends on?
-#PKG_DEP = compiz
+PKG_DEP = compiz-composite compiz-opengl
# Any flags that should be passed to the linker?
#LD_FLAGS =
# Any flags that should be passed to the compiler?