diff options
Diffstat (limited to 'SwifTools')
-rw-r--r-- | SwifTools/Idle/PlatformIdleQuerier.cpp | 4 | ||||
-rw-r--r-- | SwifTools/Idle/WindowsIdleQuerier.cpp | 21 | ||||
-rw-r--r-- | SwifTools/Idle/WindowsIdleQuerier.h | 12 | ||||
-rw-r--r-- | SwifTools/SConscript | 2 |
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"] : |