diff options
Diffstat (limited to 'SwifTools/Idle')
-rw-r--r-- | SwifTools/Idle/PlatformIdleQuerier.cpp | 4 | ||||
-rw-r--r-- | SwifTools/Idle/WindowsIdleQuerier.cpp | 21 | ||||
-rw-r--r-- | SwifTools/Idle/WindowsIdleQuerier.h | 12 |
3 files changed, 37 insertions, 0 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(); + }; +} |