summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'SwifTools/Idle/WindowsIdleQuerier.cpp')
-rw-r--r--SwifTools/Idle/WindowsIdleQuerier.cpp21
1 files changed, 21 insertions, 0 deletions
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;
+ }
+}
+
+}