summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <sam.spilsbury@canonical.com>2011-07-17 04:25:12 +0800
committerSam Spilsbury <sam.spilsbury@canonical.com>2011-07-17 04:25:12 +0800
commit6494f382b89ef77c370930c05a0cbf9431f8fd57 (patch)
tree0064b0ef041bba4c21b8a3b4f008024d81c6ea01
parent18f325cc1cf0fba0666e9f5a58d098e23469e11d (diff)
downloadlocker-6494f382b89ef77c370930c05a0cbf9431f8fd57.tar.gz
locker-6494f382b89ef77c370930c05a0cbf9431f8fd57.tar.bz2
Export locker plugin interface
-rw-r--r--CMakeLists.txt.user105
-rw-r--r--compiz-locker.pc.in13
-rw-r--r--include/locker/locker.h117
-rw-r--r--include/locker/locker.h~112
-rw-r--r--src/locker.cpp14
-rw-r--r--src/locker.h~ (renamed from src/locker.h)20
-rw-r--r--src/private.h204
7 files changed, 461 insertions, 124 deletions
diff --git a/CMakeLists.txt.user b/CMakeLists.txt.user
deleted file mode 100644
index 396fcbe..0000000
--- a/CMakeLists.txt.user
+++ /dev/null
@@ -1,105 +0,0 @@
-<!DOCTYPE QtCreatorProject>
-<qtcreator>
- <data>
- <variable>ProjectExplorer.Project.ActiveTarget</variable>
- <value type="int">0</value>
- </data>
- <data>
- <variable>ProjectExplorer.Project.EditorSettings</variable>
- <valuemap type="QVariantMap">
- <value key="EditorConfiguration.Codec" type="QByteArray">Default</value>
- </valuemap>
- </data>
- <data>
- <variable>ProjectExplorer.Project.Target.0</variable>
- <valuemap type="QVariantMap">
- <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Desktop</value>
- <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
- <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">CMakeProjectManager.DefaultCMakeTarget</value>
- <value key="ProjectExplorer.Target.ActiveBuildConfiguration" type="int">0</value>
- <value key="ProjectExplorer.Target.ActiveDeployConfiguration" type="int">0</value>
- <value key="ProjectExplorer.Target.ActiveRunConfiguration" type="int">0</value>
- <valuemap key="ProjectExplorer.Target.BuildConfiguration.0" type="QVariantMap">
- <value key="CMakeProjectManager.CMakeBuildConfiguration.BuildDirectory" type="QString">/media/d1dddb1a-729f-40ef-9725-dc2a9ad56031/smspillaz/Source/Compiz/dev/dev/plugins/locker/build</value>
- <value key="CMakeProjectManager.CMakeBuildConfiguration.MsvcVersion" type="QString"></value>
- <valuemap key="ProjectExplorer.BuildConfiguration.BuildStepList.0" type="QVariantMap">
- <valuemap key="ProjectExplorer.BuildStepList.Step.0" type="QVariantMap">
- <valuelist key="CMakeProjectManager.MakeStep.AdditionalArguments" type="QVariantList"/>
- <valuelist key="CMakeProjectManager.MakeStep.BuildTargets" type="QVariantList"/>
- <value key="CMakeProjectManager.MakeStep.Clean" type="bool">false</value>
- <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Make</value>
- <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
- <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">CMakeProjectManager.MakeStep</value>
- </valuemap>
- <value key="ProjectExplorer.BuildStepList.StepsCount" type="int">1</value>
- <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Build</value>
- <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
- <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">ProjectExplorer.BuildSteps.Build</value>
- </valuemap>
- <valuemap key="ProjectExplorer.BuildConfiguration.BuildStepList.1" type="QVariantMap">
- <valuemap key="ProjectExplorer.BuildStepList.Step.0" type="QVariantMap">
- <valuelist key="CMakeProjectManager.MakeStep.AdditionalArguments" type="QVariantList">
- <value type="QString">clean</value>
- </valuelist>
- <valuelist key="CMakeProjectManager.MakeStep.BuildTargets" type="QVariantList"/>
- <value key="CMakeProjectManager.MakeStep.Clean" type="bool">true</value>
- <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Make</value>
- <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
- <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">CMakeProjectManager.MakeStep</value>
- </valuemap>
- <value key="ProjectExplorer.BuildStepList.StepsCount" type="int">1</value>
- <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Clean</value>
- <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
- <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">ProjectExplorer.BuildSteps.Clean</value>
- </valuemap>
- <value key="ProjectExplorer.BuildConfiguration.BuildStepListCount" type="int">2</value>
- <value key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment" type="bool">false</value>
- <valuelist key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges" type="QVariantList"/>
- <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">all</value>
- <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
- <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">CMakeProjectManager.CMakeBuildConfiguration</value>
- </valuemap>
- <value key="ProjectExplorer.Target.BuildConfigurationCount" type="int">1</value>
- <valuemap key="ProjectExplorer.Target.DeployConfiguration.0" type="QVariantMap">
- <valuemap key="ProjectExplorer.BuildConfiguration.BuildStepList.0" type="QVariantMap">
- <value key="ProjectExplorer.BuildStepList.StepsCount" type="int">0</value>
- <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Deploy</value>
- <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
- <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">ProjectExplorer.BuildSteps.Deploy</value>
- </valuemap>
- <value key="ProjectExplorer.BuildConfiguration.BuildStepListCount" type="int">1</value>
- <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">No deployment</value>
- <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
- <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">ProjectExplorer.DefaultDeployConfiguration</value>
- </valuemap>
- <value key="ProjectExplorer.Target.DeployConfigurationCount" type="int">1</value>
- <valuemap key="ProjectExplorer.Target.RunConfiguration.0" type="QVariantMap">
- <valuelist key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments" type="QVariantList"/>
- <value key="ProjectExplorer.CustomExecutableRunConfiguration.BaseEnvironmentBase" type="int">2</value>
- <value key="ProjectExplorer.CustomExecutableRunConfiguration.Executable" type="QString"></value>
- <value key="ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal" type="bool">false</value>
- <valuelist key="ProjectExplorer.CustomExecutableRunConfiguration.UserEnvironmentChanges" type="QVariantList"/>
- <value key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory" type="QString">$BUILDDIR</value>
- <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Custom Executable</value>
- <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
- <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">ProjectExplorer.CustomExecutableRunConfiguration</value>
- <value key="RunConfiguration.QmlDebugServerPort" type="uint">3768</value>
- <value key="RunConfiguration.UseCppDebugger" type="bool">true</value>
- <value key="RunConfiguration.UseQmlDebugger" type="bool">false</value>
- </valuemap>
- <value key="ProjectExplorer.Target.RunConfigurationCount" type="int">1</value>
- </valuemap>
- </data>
- <data>
- <variable>ProjectExplorer.Project.TargetCount</variable>
- <value type="int">1</value>
- </data>
- <data>
- <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
- <value type="QString">{0e0fa3aa-91f0-40d8-b828-710ac6928cb7}</value>
- </data>
- <data>
- <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
- <value type="int">8</value>
- </data>
-</qtcreator>
diff --git a/compiz-locker.pc.in b/compiz-locker.pc.in
new file mode 100644
index 0000000..8c4e22c
--- /dev/null
+++ b/compiz-locker.pc.in
@@ -0,0 +1,13 @@
+prefix=@prefix@
+exec_prefix=@prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: compiz-locker
+Description: Locker plugin for compiz
+Version: @VERSION@
+
+Requires: compiz xscrnsaver
+Libs: -L${libdir}/compiz -llocker
+Cflags: @COMPIZ_CFLAGS@ -I${includedir}/compiz
+
diff --git a/include/locker/locker.h b/include/locker/locker.h
new file mode 100644
index 0000000..68c42fd
--- /dev/null
+++ b/include/locker/locker.h
@@ -0,0 +1,117 @@
+/*
+ * Compiz locker plugin
+ *
+ * locker.h
+ *
+ * Copyright (c) 2010 Canonical Ltd.
+ *
+ * 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 3
+ * 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.
+ *
+ */
+
+#ifndef _COMPIZ_LOCKER_H
+#define _COMPIZ_LOCKER_H
+
+#include <core/core.h>
+#include <composite/composite.h>
+#include <opengl/opengl.h>
+
+#define COMPIZ_LOCKER_ABI 1
+
+class LockerLockWindow :
+ public CompRect
+{
+public:
+
+ LockerLockWindow () {}
+ virtual ~LockerLockWindow () {};
+
+ virtual void hide () = 0;
+ virtual void show () = 0;
+ virtual bool visible () = 0;
+ virtual void paint (const GLMatrix &transform) = 0;
+ virtual bool needsGrab () = 0;
+ virtual bool handleKeyPress (XKeyEvent *xk) { return false; };
+ virtual bool handleButtonPress (XButtonEvent *xb) { return false; };
+ virtual bool handleKeyRelease (XKeyEvent *xk) { return false; };
+ virtual bool handleButtonRelease (XButtonEvent *xb) { return false; };
+ virtual bool handleMotion (XMotionEvent *xm) { return false; };
+
+ virtual CompRegion & damage () = 0;
+
+ static void
+ SetDefault (LockerLockWindow *);
+
+ static LockerLockWindow *
+ Default ();
+};
+
+class LockerLockBackground :
+ public CompRect
+{
+public:
+
+ LockerLockBackground () {}
+ virtual ~LockerLockBackground () {};
+
+ virtual void hide () = 0;
+ virtual void show () = 0;
+ virtual bool visible () = 0;
+ virtual void paint (const GLMatrix &transform) = 0;
+ virtual CompRegion & damage () = 0;
+
+ static void
+ SetDefault (LockerLockBackground *);
+
+ static LockerLockBackground *
+ Default ();
+};
+
+class LockTrigger
+{
+public:
+ LockTrigger () {}
+ virtual ~LockTrigger () {}
+
+ virtual void unlocked () = 0;
+
+ static LockTrigger *
+ Default ();
+
+ static void
+ SetDefault (LockTrigger *);
+};
+
+class Lockable
+{
+public:
+
+ Lockable () {}
+ virtual ~Lockable () {}
+
+ virtual bool lock () = 0;
+ virtual bool unlock () = 0;
+ virtual bool wake () = 0;
+
+ static void
+ SetDefault (Lockable *);
+
+ static Lockable *
+ Default ();
+
+protected:
+
+ LockerLockWindow *mLockerWindow;
+ LockerLockBackground *mLockerBackground;
+ LockTrigger *mTrigger;
+};
+
+#endif
diff --git a/include/locker/locker.h~ b/include/locker/locker.h~
new file mode 100644
index 0000000..bd63e1f
--- /dev/null
+++ b/include/locker/locker.h~
@@ -0,0 +1,112 @@
+/*
+ * Compiz locker plugin
+ *
+ * locker.cpp
+ *
+ * Copyright (c) 2010 Canonical Ltd.
+ *
+ * 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 3
+ * 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 <composite/composite.h>
+#include <opengl/opengl.h>
+
+#include "locker_options.h"
+
+class LockerLockWindow :
+ public CompRect
+{
+public:
+
+ LockerLockWindow () {}
+ virtual ~LockerLockWindow () {};
+
+ virtual void hide () = 0;
+ virtual void show () = 0;
+ virtual bool visible () = 0;
+ virtual void paint (const GLMatrix &transform) = 0;
+ virtual bool needsGrab () = 0;
+ virtual bool handleKeyPress (XKeyEvent *xk) { return false; };
+ virtual bool handleButtonPress (XButtonEvent *xb) { return false; };
+ virtual bool handleKeyRelease (XKeyEvent *xk) { return false; };
+ virtual bool handleButtonRelease (XButtonEvent *xb) { return false; };
+ virtual bool handleMotion (XMotionEvent *xm) { return false; };
+
+ virtual CompRegion & damage () = 0;
+
+ static void
+ SetDefault (LockerLockWindow *);
+
+ static LockerLockWindow *
+ Default ();
+};
+
+class LockerLockBackground :
+ public CompRect
+{
+public:
+
+ LockerLockBackground () {}
+ virtual ~LockerLockBackground () {};
+
+ virtual void hide () = 0;
+ virtual void show () = 0;
+ virtual bool visible () = 0;
+ virtual void paint (const GLMatrix &transform) = 0;
+ virtual CompRegion & damage () = 0;
+
+ static void
+ SetDefault (LockerLockBackground *);
+
+ static LockerLockBackground *
+ Default ();
+};
+
+class LockTrigger
+{
+public:
+ LockTrigger () {}
+ virtual ~LockTrigger () {}
+
+ virtual void unlocked () = 0;
+
+ static LockTrigger *
+ Default ();
+
+ static void
+ SetDefault (LockTrigger *);
+};
+
+class Lockable
+{
+public:
+
+ Lockable () {}
+ virtual ~Lockable () {}
+
+ virtual bool lock () = 0;
+ virtual bool unlock () = 0;
+ virtual bool wake () = 0;
+
+ static void
+ SetDefault (Lockable *);
+
+ static Lockable *
+ Default ();
+
+protected:
+
+ LockerLockWindow *mLockerWindow;
+ LockerLockBackground *mLockerBackground;
+ LockTrigger *mTrigger;
+};
diff --git a/src/locker.cpp b/src/locker.cpp
index d2578bf..8702540 100644
--- a/src/locker.cpp
+++ b/src/locker.cpp
@@ -17,7 +17,7 @@
*
*/
-#include "locker.h"
+#include "private.h"
#include <cmath>
#include <limits.h>
@@ -661,7 +661,7 @@ TimerTrigger::TimerTrigger (unsigned int timeout) :
}
LockerScreen::LockerScreen (CompScreen *s) :
- PluginClassHandler <LockerScreen, CompScreen> (s),
+ PluginClassHandler <LockerScreen, CompScreen, COMPIZ_LOCKER_ABI> (s),
cScreen (CompositeScreen::get (screen)),
gScreen (GLScreen::get (screen)),
mAnimationProgress (0.0f),
@@ -723,6 +723,16 @@ LockerPluginVTable::init ()
!CompPlugin::checkPluginABI ("opengl", COMPIZ_OPENGL_ABI))
return false;
+ CompPrivate p;
+ p.uval = COMPIZ_LOCKER_ABI;
+ screen->storeValue ("locker_ABI", p);
+
return true;
}
+
+void
+LockerPluginVTable::fini ()
+{
+ screen->eraseValue ("locker_ABI");
+}
diff --git a/src/locker.h b/src/locker.h~
index 806d16a..2be02fa 100644
--- a/src/locker.h
+++ b/src/locker.h~
@@ -1,20 +1,6 @@
-/*
- * Compiz locker plugin
- *
- * locker.cpp
- *
- * Copyright (c) 2010 Canonical Ltd.
- *
- * 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 3
- * 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.
- *
+/* Compiz locker plugin
+ * Copyright (c) Canonical Ltd
+ * GPLv3
*/
#include <core/core.h>
diff --git a/src/private.h b/src/private.h
new file mode 100644
index 0000000..e1e365c
--- /dev/null
+++ b/src/private.h
@@ -0,0 +1,204 @@
+/*
+ * Compiz locker plugin
+ *
+ * locker.cpp
+ *
+ * Copyright (c) 2010 Canonical Ltd.
+ *
+ * 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 3
+ * 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 <composite/composite.h>
+#include <opengl/opengl.h>
+#include <locker/locker.h>
+
+#include "locker_options.h"
+
+#include <X11/extensions/scrnsaver.h>
+
+class SimpleLockerWindow :
+ public LockerLockWindow
+{
+public:
+ void hide ();
+ void show ();
+ bool visible ();
+ void paint (const GLMatrix &transform);
+ bool needsGrab () { return true; }
+
+ bool handleKeyPress (XKeyEvent *xk);
+ bool handleKeyRelease (XKeyEvent *xk);
+ bool handleButtonPress (XButtonEvent *xb);
+ bool handleButtonRelease (XButtonEvent *xb);
+ bool handleMotion (XMotionEvent *xm);
+
+ CompRegion & damage ();
+
+private:
+ bool mShowing;
+ CompRegion mDamage;
+};
+
+class SimpleLockerBackground :
+ public LockerLockBackground
+{
+public:
+ void hide ();
+ void show ();
+ bool visible ();
+ void paint (const GLMatrix &transform);
+
+ CompRegion & damage ();
+
+private:
+ bool mShowing;
+ CompRegion mDamage;
+};
+
+class XScreenSaverTrigger :
+ public LockTrigger
+{
+public:
+
+ XScreenSaverTrigger (Display *, Window root, unsigned int timeout);
+ ~XScreenSaverTrigger ();
+
+ bool usable ();
+ void processEvent (XEvent *);
+ void unlocked ();
+
+private:
+
+ Display *dpy;
+ Window root;
+
+ int timeout;
+ int interval;
+ int preferBlanking;
+ int allowExposures;
+
+ int eventBase;
+ int eventBit;
+};
+
+/* Not exactly reliable */
+class TimerTrigger :
+ public LockTrigger
+{
+public:
+
+ TimerTrigger (unsigned int timeout);
+
+ void processEvent (XEvent *);
+ bool check ();
+ void unlocked ();
+
+private:
+
+ CompTimer mTimer;
+ unsigned int mTimeout;
+ bool mLocked;
+};
+
+class LockerScreen :
+ public PluginClassHandler <LockerScreen, CompScreen, COMPIZ_LOCKER_ABI>,
+ public ScreenInterface,
+ public CompositeScreenInterface,
+ public GLScreenInterface,
+ public Lockable,
+ public LockerOptions
+{
+public:
+
+ LockerScreen (CompScreen *);
+ ~LockerScreen ();
+
+ CompositeScreen *cScreen;
+ GLScreen *gScreen;
+
+ typedef enum
+ {
+ AnimationStateIdle = 0,
+ AnimationStateLocking = 1,
+ AnimationStateUnlocking = 2,
+ AnimationStateLocked = 3
+ } AnimationState;
+
+public:
+
+ void preparePaint (int);
+ bool glPaintOutput (const GLScreenPaintAttrib &attrib,
+ const GLMatrix &transform,
+ const CompRegion &region,
+ CompOutput *output,
+ unsigned int mask);
+ void donePaint ();
+
+ bool lock ();
+ bool unlock ();
+ bool wake ();
+
+ void handleEvent (XEvent *);
+
+private:
+
+ /* Normalized */
+ float mAnimationProgress;
+ CompWindowList mAnimatedWindows;
+ AnimationState mAnimationState;
+
+ CompTimer mWaitTimer;
+
+ CompScreen::GrabHandle mGrabIndex;
+};
+
+class LockerWindow :
+ public PluginClassHandler <LockerWindow, CompWindow>,
+ public WindowInterface,
+ public CompositeWindowInterface,
+ public GLWindowInterface
+{
+public:
+
+ LockerWindow (CompWindow *);
+
+ CompWindow *window;
+ CompositeWindow *cWindow;
+ GLWindow *gWindow;
+
+public:
+
+ bool glPaint (const GLWindowPaintAttrib &attrib,
+ const GLMatrix &transform,
+ const CompRegion &region,
+ unsigned int mask);
+
+ bool isLockerWindow ();
+ bool isAnimatedWindow ();
+
+ void setAnimationProgress (float animProgress) { mAnimationProgress = animProgress; };
+
+private:
+
+ /* Normalized */
+ float mAnimationProgress;
+};
+
+class LockerPluginVTable :
+ public CompPlugin::VTableForScreenAndWindow <LockerScreen, LockerWindow>
+{
+public:
+
+ bool init ();
+ void fini ();
+};