summaryrefslogtreecommitdiff
path: root/src/timer.cpp
diff options
context:
space:
mode:
authorDennis Kasprzyk <onestone@compiz-fusion.org>2008-09-15 22:05:41 +0200
committerDennis Kasprzyk <onestone@compiz-fusion.org>2008-09-15 22:05:41 +0200
commitd5acffa9795add9ebc9c6e6920a5e80581584863 (patch)
treea55558b31b3b8b455aa9286cf139b9f6c19df003 /src/timer.cpp
parent8fcba7fa8ec54cac55d4136cfd41a3a8d9ccb192 (diff)
downloadunity-window-decorator-d5acffa9795add9ebc9c6e6920a5e80581584863.tar.gz
unity-window-decorator-d5acffa9795add9ebc9c6e6920a5e80581584863.tar.bz2
Merge CompCore and CompDisplay into CompScreen class.
Diffstat (limited to 'src/timer.cpp')
-rw-r--r--src/timer.cpp107
1 files changed, 107 insertions, 0 deletions
diff --git a/src/timer.cpp b/src/timer.cpp
new file mode 100644
index 0000000..2045220
--- /dev/null
+++ b/src/timer.cpp
@@ -0,0 +1,107 @@
+#include <core/timer.h>
+#include <compscreen.h>
+#include "privatescreen.h"
+
+CompTimer::CompTimer () :
+ mActive (false),
+ mMinTime (0),
+ mMaxTime (0),
+ mMinLeft (0),
+ mMaxLeft (0),
+ mCallBack (NULL)
+{
+}
+
+CompTimer::~CompTimer ()
+{
+ if (mActive)
+ screen->priv->removeTimer (this);
+}
+
+void
+CompTimer::setTimes (unsigned int min, unsigned int max)
+{
+ bool wasActive = mActive;
+ if (mActive)
+ stop ();
+ mMinTime = min;
+ mMaxTime = (min <= max)? max : min;
+
+ if (wasActive)
+ start ();
+}
+
+void
+CompTimer::setCallback (CompTimer::CallBack callback)
+{
+ bool wasActive = mActive;
+ if (mActive)
+ stop ();
+ mCallBack = callback;
+
+ if (wasActive)
+ start ();
+}
+
+void
+CompTimer::start ()
+{
+ stop ();
+ mActive = true;
+ screen->priv->addTimer (this);
+}
+
+void
+CompTimer::start (unsigned int min, unsigned int max)
+{
+ stop ();
+ setTimes (min, max);
+ start ();
+}
+
+void
+CompTimer::start (CompTimer::CallBack callback,
+ unsigned int min, unsigned int max)
+{
+ stop ();
+ setTimes (min, max);
+ setCallback (callback);
+ start ();
+}
+
+void
+CompTimer::stop ()
+{
+ mActive = false;
+ screen->priv->removeTimer (this);
+}
+
+unsigned int
+CompTimer::minTime ()
+{
+ return mMinTime;
+}
+
+unsigned int
+CompTimer::maxTime ()
+{
+ return mMaxTime;
+}
+
+unsigned int
+CompTimer::minLeft ()
+{
+ return (mMinLeft < 0)? 0 : mMinLeft;
+}
+
+unsigned int
+CompTimer::maxLeft ()
+{
+ return (mMaxLeft < 0)? 0 : mMaxLeft;
+}
+
+bool
+CompTimer::active ()
+{
+ return mActive;
+}