summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-11-24 19:24:36 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-11-24 19:24:36 (GMT)
commitadc92c14ef621d8106796e63f499ec88eb3fe28e (patch)
tree5928678592b9ba049d99782f74a89dc8ebbb2832 /SwifTools
parent70de00c6cb3ecf5feccf5c2590595400cf501e57 (diff)
downloadswift-contrib-adc92c14ef621d8106796e63f499ec88eb3fe28e.zip
swift-contrib-adc92c14ef621d8106796e63f499ec88eb3fe28e.tar.bz2
Added Windows idle querier.
Diffstat (limited to 'SwifTools')
-rw-r--r--SwifTools/Idle/PlatformIdleQuerier.cpp4
-rw-r--r--SwifTools/Idle/WindowsIdleQuerier.cpp21
-rw-r--r--SwifTools/Idle/WindowsIdleQuerier.h12
-rw-r--r--SwifTools/SConscript2
4 files changed, 38 insertions, 1 deletions
diff --git a/SwifTools/Idle/PlatformIdleQuerier.cpp b/SwifTools/Idle/PlatformIdleQuerier.cpp
index 80a5da3..fb206b7 100644
--- a/SwifTools/Idle/PlatformIdleQuerier.cpp
+++ b/SwifTools/Idle/PlatformIdleQuerier.cpp
@@ -3,6 +3,8 @@
#if defined(SWIFTEN_PLATFORM_MACOSX)
#include "SwifTools/Idle/MacOSXIdleQuerier.h"
+#elif defined(SWIFTEN_PLATFORM_WINDOWS)
+#include "SwifTools/Idle/WindowsIdleQuerier.h"
#elif defined(HAVE_XSS)
#include "SwifTools/Idle/XSSIdleQuerier.h"
#else
@@ -17,6 +19,8 @@ namespace Swift {
PlatformIdleQuerier::PlatformIdleQuerier() : querier(NULL) {
#if defined(SWIFTEN_PLATFORM_MACOSX)
querier = new MacOSXIdleQuerier();
+#elif defined(SWIFTEN_PLATFORM_WINDOWS)
+ querier = new WindowsIdleQuerier();
#elif defined(HAVE_XSS)
querier = new XSSIdleQuerier();
#else
diff --git a/SwifTools/Idle/WindowsIdleQuerier.cpp b/SwifTools/Idle/WindowsIdleQuerier.cpp
new file mode 100644
index 0000000..11b1e75
--- /dev/null
+++ b/SwifTools/Idle/WindowsIdleQuerier.cpp
@@ -0,0 +1,21 @@
+#include "SwifTools/Idle/WindowsIdleQuerier.h"
+
+#include <windows.h>
+
+namespace Swift {
+
+WindowsIdleQuerier::WindowsIdleQuerier() {
+}
+
+int WindowsIdleQuerier::getIdleTimeSeconds() {
+ LASTINPUTINFO info;
+ info.cbSize = sizeof(info);
+ if (GetLastInputInfo(&info)) {
+ return (GetTickCount() - info.dwTime) / 1000;
+ }
+ else {
+ return 0;
+ }
+}
+
+}
diff --git a/SwifTools/Idle/WindowsIdleQuerier.h b/SwifTools/Idle/WindowsIdleQuerier.h
new file mode 100644
index 0000000..0786cbe
--- /dev/null
+++ b/SwifTools/Idle/WindowsIdleQuerier.h
@@ -0,0 +1,12 @@
+#pragma once
+
+#include "SwifTools/Idle/IdleQuerier.h"
+
+namespace Swift {
+ class WindowsIdleQuerier : public IdleQuerier {
+ public:
+ WindowsIdleQuerier();
+
+ virtual int getIdleTimeSeconds();
+ };
+}
diff --git a/SwifTools/SConscript b/SwifTools/SConscript
index a92e0dc..2ae4e4e 100644
--- a/SwifTools/SConscript
+++ b/SwifTools/SConscript
@@ -17,7 +17,7 @@ sources = [
]
if myenv["PLATFORM"] == "win32" :
- pass
+ sources += ["Idle/WindowsIdleQuerier.cpp"]
elif myenv["PLATFORM"] == "darwin" :
sources += ["Idle/MacOSXIdleQuerier.cpp"]
elif myenv["HAVE_XSS"] :