summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'SwifTools/Idle')
-rw-r--r--SwifTools/Idle/ActualIdleDetector.cpp16
-rw-r--r--SwifTools/Idle/ActualIdleDetector.h26
-rw-r--r--SwifTools/Idle/DummyIdleQuerier.h14
-rw-r--r--SwifTools/Idle/IdleDetector.h60
-rw-r--r--SwifTools/Idle/IdleQuerier.h10
-rw-r--r--SwifTools/Idle/IdleQuerierTest/IdleQuerierTest.cpp14
-rw-r--r--SwifTools/Idle/MacOSXIdleQuerier.cpp22
-rw-r--r--SwifTools/Idle/MacOSXIdleQuerier.h14
-rw-r--r--SwifTools/Idle/PlatformIdleQuerier.cpp12
-rw-r--r--SwifTools/Idle/PlatformIdleQuerier.h20
-rw-r--r--SwifTools/Idle/UnitTest/ActualIdleDetectorTest.cpp296
-rw-r--r--SwifTools/Idle/WindowsIdleQuerier.cpp16
-rw-r--r--SwifTools/Idle/WindowsIdleQuerier.h10
-rw-r--r--SwifTools/Idle/XSSIdleQuerier.cpp38
-rw-r--r--SwifTools/Idle/XSSIdleQuerier.h22
15 files changed, 295 insertions, 295 deletions
diff --git a/SwifTools/Idle/ActualIdleDetector.cpp b/SwifTools/Idle/ActualIdleDetector.cpp
index dac4a5e..2a16fca 100644
--- a/SwifTools/Idle/ActualIdleDetector.cpp
+++ b/SwifTools/Idle/ActualIdleDetector.cpp
@@ -16,20 +16,20 @@
namespace Swift {
ActualIdleDetector::ActualIdleDetector(IdleQuerier* querier, TimerFactory* timerFactory, int refreshRateMilliseconds) : querier(querier) {
- timer = timerFactory->createTimer(refreshRateMilliseconds);
- timer->onTick.connect(boost::bind(&ActualIdleDetector::handleTimerTick, this));
- timer->start();
+ timer = timerFactory->createTimer(refreshRateMilliseconds);
+ timer->onTick.connect(boost::bind(&ActualIdleDetector::handleTimerTick, this));
+ timer->start();
}
ActualIdleDetector::~ActualIdleDetector() {
- timer->onTick.disconnect(boost::bind(&ActualIdleDetector::handleTimerTick, this));
- timer->stop();
+ timer->onTick.disconnect(boost::bind(&ActualIdleDetector::handleTimerTick, this));
+ timer->stop();
}
void ActualIdleDetector::handleTimerTick() {
- timer->stop();
- setIdle(querier->getIdleTimeSeconds() >= getIdleTimeSeconds());
- timer->start();
+ timer->stop();
+ setIdle(querier->getIdleTimeSeconds() >= getIdleTimeSeconds());
+ timer->start();
}
}
diff --git a/SwifTools/Idle/ActualIdleDetector.h b/SwifTools/Idle/ActualIdleDetector.h
index 739a005..194606f 100644
--- a/SwifTools/Idle/ActualIdleDetector.h
+++ b/SwifTools/Idle/ActualIdleDetector.h
@@ -11,20 +11,20 @@
#include <SwifTools/Idle/IdleDetector.h>
namespace Swift {
- class IdleQuerier;
- class TimerFactory;
- class Timer;
+ class IdleQuerier;
+ class TimerFactory;
+ class Timer;
- class ActualIdleDetector : public IdleDetector, public boost::bsignals::trackable {
- public:
- ActualIdleDetector(IdleQuerier*, TimerFactory*, int refreshRateMilliseconds);
- ~ActualIdleDetector();
+ class ActualIdleDetector : public IdleDetector, public boost::bsignals::trackable {
+ public:
+ ActualIdleDetector(IdleQuerier*, TimerFactory*, int refreshRateMilliseconds);
+ ~ActualIdleDetector();
- private:
- void handleTimerTick();
+ private:
+ void handleTimerTick();
- private:
- IdleQuerier* querier;
- boost::shared_ptr<Timer> timer;
- };
+ private:
+ IdleQuerier* querier;
+ boost::shared_ptr<Timer> timer;
+ };
}
diff --git a/SwifTools/Idle/DummyIdleQuerier.h b/SwifTools/Idle/DummyIdleQuerier.h
index 068d9ad..d3f5177 100644
--- a/SwifTools/Idle/DummyIdleQuerier.h
+++ b/SwifTools/Idle/DummyIdleQuerier.h
@@ -9,12 +9,12 @@
#include <SwifTools/Idle/IdleQuerier.h>
namespace Swift {
- class DummyIdleQuerier : public IdleQuerier {
- public:
- DummyIdleQuerier() {}
+ class DummyIdleQuerier : public IdleQuerier {
+ public:
+ DummyIdleQuerier() {}
- virtual int getIdleTimeSeconds() {
- return 0;
- }
- };
+ virtual int getIdleTimeSeconds() {
+ return 0;
+ }
+ };
}
diff --git a/SwifTools/Idle/IdleDetector.h b/SwifTools/Idle/IdleDetector.h
index 7819f54..88a1c4c 100644
--- a/SwifTools/Idle/IdleDetector.h
+++ b/SwifTools/Idle/IdleDetector.h
@@ -11,34 +11,34 @@
#include <Swiften/Base/boost_bsignals.h>
namespace Swift {
- class IdleDetector {
- public:
- IdleDetector() : idle(false), idleTimeSeconds(300) {}
- virtual ~IdleDetector();
-
- void setIdleTimeSeconds(int time) {
- idleTimeSeconds = time;
- }
-
- int getIdleTimeSeconds() const {
- return idleTimeSeconds;
- }
-
- virtual bool isIdle() const {
- return idle;
- }
-
- boost::signal<void (bool /* isIdle */)> onIdleChanged;
-
- void setIdle(bool b) {
- if (b != idle) {
- idle = b;
- onIdleChanged(b);
- }
- }
-
- private:
- bool idle;
- int idleTimeSeconds;
- };
+ class IdleDetector {
+ public:
+ IdleDetector() : idle(false), idleTimeSeconds(300) {}
+ virtual ~IdleDetector();
+
+ void setIdleTimeSeconds(int time) {
+ idleTimeSeconds = time;
+ }
+
+ int getIdleTimeSeconds() const {
+ return idleTimeSeconds;
+ }
+
+ virtual bool isIdle() const {
+ return idle;
+ }
+
+ boost::signal<void (bool /* isIdle */)> onIdleChanged;
+
+ void setIdle(bool b) {
+ if (b != idle) {
+ idle = b;
+ onIdleChanged(b);
+ }
+ }
+
+ private:
+ bool idle;
+ int idleTimeSeconds;
+ };
}
diff --git a/SwifTools/Idle/IdleQuerier.h b/SwifTools/Idle/IdleQuerier.h
index ba4879d..e0de8be 100644
--- a/SwifTools/Idle/IdleQuerier.h
+++ b/SwifTools/Idle/IdleQuerier.h
@@ -7,10 +7,10 @@
#pragma once
namespace Swift {
- class IdleQuerier {
- public:
- virtual ~IdleQuerier();
+ class IdleQuerier {
+ public:
+ virtual ~IdleQuerier();
- virtual int getIdleTimeSeconds() = 0;
- };
+ virtual int getIdleTimeSeconds() = 0;
+ };
}
diff --git a/SwifTools/Idle/IdleQuerierTest/IdleQuerierTest.cpp b/SwifTools/Idle/IdleQuerierTest/IdleQuerierTest.cpp
index 365ed1a..a0b78e6 100644
--- a/SwifTools/Idle/IdleQuerierTest/IdleQuerierTest.cpp
+++ b/SwifTools/Idle/IdleQuerierTest/IdleQuerierTest.cpp
@@ -14,11 +14,11 @@
using namespace Swift;
int main() {
- PlatformIdleQuerier querier;
- while (true) {
- std::cout << "Idle time: " << querier.getIdleTimeSeconds() << std::endl;
- Swift::sleep(1000);
- }
- assert(false);
- return 0;
+ PlatformIdleQuerier querier;
+ while (true) {
+ std::cout << "Idle time: " << querier.getIdleTimeSeconds() << std::endl;
+ Swift::sleep(1000);
+ }
+ assert(false);
+ return 0;
}
diff --git a/SwifTools/Idle/MacOSXIdleQuerier.cpp b/SwifTools/Idle/MacOSXIdleQuerier.cpp
index f7d4199..6d6780b 100644
--- a/SwifTools/Idle/MacOSXIdleQuerier.cpp
+++ b/SwifTools/Idle/MacOSXIdleQuerier.cpp
@@ -16,20 +16,20 @@
namespace Swift {
MacOSXIdleQuerier::MacOSXIdleQuerier() : ioService(0) {
- mach_port_t masterPort;
- IOMasterPort(MACH_PORT_NULL, &masterPort);
- ioService = IOServiceGetMatchingService(masterPort, IOServiceMatching("IOHIDSystem"));
- assert(ioService);
+ mach_port_t masterPort;
+ IOMasterPort(MACH_PORT_NULL, &masterPort);
+ ioService = IOServiceGetMatchingService(masterPort, IOServiceMatching("IOHIDSystem"));
+ assert(ioService);
}
int MacOSXIdleQuerier::getIdleTimeSeconds() {
- CFTypeRef property = IORegistryEntryCreateCFProperty(ioService, CFSTR("HIDIdleTime"), kCFAllocatorDefault, 0);
- uint64_t idle = 0;
- bool result = CFNumberGetValue((CFNumberRef)property, kCFNumberSInt64Type, &idle);
- assert(result);
- (void) result;
- CFRelease(property);
- return boost::numeric_cast<int>(idle / 1000000000);
+ CFTypeRef property = IORegistryEntryCreateCFProperty(ioService, CFSTR("HIDIdleTime"), kCFAllocatorDefault, 0);
+ uint64_t idle = 0;
+ bool result = CFNumberGetValue((CFNumberRef)property, kCFNumberSInt64Type, &idle);
+ assert(result);
+ (void) result;
+ CFRelease(property);
+ return boost::numeric_cast<int>(idle / 1000000000);
}
}
diff --git a/SwifTools/Idle/MacOSXIdleQuerier.h b/SwifTools/Idle/MacOSXIdleQuerier.h
index 7f70e88..8ff747c 100644
--- a/SwifTools/Idle/MacOSXIdleQuerier.h
+++ b/SwifTools/Idle/MacOSXIdleQuerier.h
@@ -11,13 +11,13 @@
#include <SwifTools/Idle/IdleQuerier.h>
namespace Swift {
- class MacOSXIdleQuerier : public IdleQuerier {
- public:
- MacOSXIdleQuerier();
+ class MacOSXIdleQuerier : public IdleQuerier {
+ public:
+ MacOSXIdleQuerier();
- virtual int getIdleTimeSeconds();
+ virtual int getIdleTimeSeconds();
- private:
- io_service_t ioService;
- };
+ private:
+ io_service_t ioService;
+ };
}
diff --git a/SwifTools/Idle/PlatformIdleQuerier.cpp b/SwifTools/Idle/PlatformIdleQuerier.cpp
index bf8f778..5855749 100644
--- a/SwifTools/Idle/PlatformIdleQuerier.cpp
+++ b/SwifTools/Idle/PlatformIdleQuerier.cpp
@@ -24,21 +24,21 @@ namespace Swift {
PlatformIdleQuerier::PlatformIdleQuerier() : querier(NULL) {
#if defined(SWIFTEN_PLATFORM_MACOSX)
#if defined(HAVE_IOKIT) && !defined(SWIFTEN_PLATFORM_IPHONE)
- querier = new MacOSXIdleQuerier();
+ querier = new MacOSXIdleQuerier();
#else
- querier = new DummyIdleQuerier();
+ querier = new DummyIdleQuerier();
#endif
#elif defined(SWIFTEN_PLATFORM_WINDOWS)
- querier = new WindowsIdleQuerier();
+ querier = new WindowsIdleQuerier();
#elif defined(HAVE_XSS)
- querier = new XSSIdleQuerier();
+ querier = new XSSIdleQuerier();
#else
- querier = new DummyIdleQuerier();
+ querier = new DummyIdleQuerier();
#endif
}
PlatformIdleQuerier::~PlatformIdleQuerier() {
- delete querier;
+ delete querier;
}
}
diff --git a/SwifTools/Idle/PlatformIdleQuerier.h b/SwifTools/Idle/PlatformIdleQuerier.h
index 676dad0..1221ada 100644
--- a/SwifTools/Idle/PlatformIdleQuerier.h
+++ b/SwifTools/Idle/PlatformIdleQuerier.h
@@ -9,16 +9,16 @@
#include <SwifTools/Idle/IdleQuerier.h>
namespace Swift {
- class PlatformIdleQuerier : public IdleQuerier {
- public:
- PlatformIdleQuerier();
- ~PlatformIdleQuerier();
+ class PlatformIdleQuerier : public IdleQuerier {
+ public:
+ PlatformIdleQuerier();
+ ~PlatformIdleQuerier();
- virtual int getIdleTimeSeconds() {
- return querier->getIdleTimeSeconds();
- }
+ virtual int getIdleTimeSeconds() {
+ return querier->getIdleTimeSeconds();
+ }
- private:
- IdleQuerier* querier;
- };
+ private:
+ IdleQuerier* querier;
+ };
}
diff --git a/SwifTools/Idle/UnitTest/ActualIdleDetectorTest.cpp b/SwifTools/Idle/UnitTest/ActualIdleDetectorTest.cpp
index c97705e..8af66fc 100644
--- a/SwifTools/Idle/UnitTest/ActualIdleDetectorTest.cpp
+++ b/SwifTools/Idle/UnitTest/ActualIdleDetectorTest.cpp
@@ -19,154 +19,154 @@
using namespace Swift;
class ActualIdleDetectorTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(ActualIdleDetectorTest);
- CPPUNIT_TEST(testDestructor);
- CPPUNIT_TEST(testHandleTick_Idle);
- CPPUNIT_TEST(testHandleTick_Idle_AlreadyIdle);
- CPPUNIT_TEST(testHandleTick_NotIdle);
- CPPUNIT_TEST(testHandleTick_NotIdle_AlreadyNotIdle);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void setUp() {
- querier = new MockIdleQuerier();
- timerFactory = new MockTimerFactory();
- idleEvents.clear();
- }
-
- void tearDown() {
- delete timerFactory;
- delete querier;
- }
-
- void testDestructor() {
- ActualIdleDetector* testling = createDetector();
- testling->setIdleTimeSeconds(15);
- delete testling;
-
- querier->idleTime = 15;
- timerFactory->updateTime(15000);
-
- CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(idleEvents.size()));
- }
-
- void testHandleTick_Idle() {
- std::auto_ptr<ActualIdleDetector> testling(createDetector());
- testling->setIdleTimeSeconds(15);
- querier->idleTime = 15;
-
- timerFactory->updateTime(15000);
-
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(idleEvents.size()));
- CPPUNIT_ASSERT(idleEvents[0]);
- }
-
- void testHandleTick_Idle_AlreadyIdle() {
- std::auto_ptr<ActualIdleDetector> testling(createDetector());
- testling->setIdleTimeSeconds(15);
- querier->idleTime = 15;
- timerFactory->updateTime(15000);
-
- querier->idleTime = 30;
- timerFactory->updateTime(30000);
-
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(idleEvents.size()));
- CPPUNIT_ASSERT(idleEvents[0]);
- }
-
- void testHandleTick_NotIdle() {
- std::auto_ptr<ActualIdleDetector> testling(createDetector());
- testling->setIdleTimeSeconds(15);
- querier->idleTime = 15;
- timerFactory->updateTime(15000);
-
- querier->idleTime = 5;
- timerFactory->updateTime(30000);
-
- CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(idleEvents.size()));
- CPPUNIT_ASSERT(idleEvents[0]);
- CPPUNIT_ASSERT(!idleEvents[1]);
- }
-
- void testHandleTick_NotIdle_AlreadyNotIdle() {
- std::auto_ptr<ActualIdleDetector> testling(createDetector());
- testling->setIdleTimeSeconds(15);
- querier->idleTime = 5;
-
- timerFactory->updateTime(15000);
-
- CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(idleEvents.size()));
- }
-
- private:
- ActualIdleDetector* createDetector() {
- ActualIdleDetector* detector = new ActualIdleDetector(querier, timerFactory, 10);
- detector->onIdleChanged.connect(boost::bind(&ActualIdleDetectorTest::handleIdle, this, _1));
- return detector;
- }
-
- void handleIdle(bool b) {
- idleEvents.push_back(b);
- }
-
- private:
- struct MockIdleQuerier : public IdleQuerier {
- MockIdleQuerier() : idleTime(0) {}
- virtual int getIdleTimeSeconds() { return idleTime; }
- int idleTime;
- };
-
- struct MockTimer : public Timer {
- MockTimer(int interval) : interval(interval), running(false), lastTime(0) {}
-
- virtual void start() {
- running = true;
- }
-
- virtual void stop() {
- running = false;
- }
-
- virtual void updateTime(int currentTime) {
- if (lastTime == currentTime) {
- return;
- }
- if (running) {
- int time = lastTime;
- while (time <= currentTime) {
- onTick();
- time += interval;
- }
- }
- lastTime = currentTime;
- }
-
- int interval;
- bool running;
- int lastTime;
- };
-
- struct MockTimerFactory : public TimerFactory {
- MockTimerFactory() {}
-
- void updateTime(int milliseconds) {
- foreach(boost::shared_ptr<MockTimer> timer, timers) {
- timer->updateTime(milliseconds);
- }
- }
-
- boost::shared_ptr<Timer> createTimer(int milliseconds) {
- boost::shared_ptr<MockTimer> timer(new MockTimer(milliseconds));
- timers.push_back(timer);
- return timer;
- }
-
- std::vector<boost::shared_ptr<MockTimer> > timers;
- };
-
- MockIdleQuerier* querier;
- MockTimerFactory* timerFactory;
- std::vector<bool> idleEvents;
+ CPPUNIT_TEST_SUITE(ActualIdleDetectorTest);
+ CPPUNIT_TEST(testDestructor);
+ CPPUNIT_TEST(testHandleTick_Idle);
+ CPPUNIT_TEST(testHandleTick_Idle_AlreadyIdle);
+ CPPUNIT_TEST(testHandleTick_NotIdle);
+ CPPUNIT_TEST(testHandleTick_NotIdle_AlreadyNotIdle);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void setUp() {
+ querier = new MockIdleQuerier();
+ timerFactory = new MockTimerFactory();
+ idleEvents.clear();
+ }
+
+ void tearDown() {
+ delete timerFactory;
+ delete querier;
+ }
+
+ void testDestructor() {
+ ActualIdleDetector* testling = createDetector();
+ testling->setIdleTimeSeconds(15);
+ delete testling;
+
+ querier->idleTime = 15;
+ timerFactory->updateTime(15000);
+
+ CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(idleEvents.size()));
+ }
+
+ void testHandleTick_Idle() {
+ std::auto_ptr<ActualIdleDetector> testling(createDetector());
+ testling->setIdleTimeSeconds(15);
+ querier->idleTime = 15;
+
+ timerFactory->updateTime(15000);
+
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(idleEvents.size()));
+ CPPUNIT_ASSERT(idleEvents[0]);
+ }
+
+ void testHandleTick_Idle_AlreadyIdle() {
+ std::auto_ptr<ActualIdleDetector> testling(createDetector());
+ testling->setIdleTimeSeconds(15);
+ querier->idleTime = 15;
+ timerFactory->updateTime(15000);
+
+ querier->idleTime = 30;
+ timerFactory->updateTime(30000);
+
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(idleEvents.size()));
+ CPPUNIT_ASSERT(idleEvents[0]);
+ }
+
+ void testHandleTick_NotIdle() {
+ std::auto_ptr<ActualIdleDetector> testling(createDetector());
+ testling->setIdleTimeSeconds(15);
+ querier->idleTime = 15;
+ timerFactory->updateTime(15000);
+
+ querier->idleTime = 5;
+ timerFactory->updateTime(30000);
+
+ CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(idleEvents.size()));
+ CPPUNIT_ASSERT(idleEvents[0]);
+ CPPUNIT_ASSERT(!idleEvents[1]);
+ }
+
+ void testHandleTick_NotIdle_AlreadyNotIdle() {
+ std::auto_ptr<ActualIdleDetector> testling(createDetector());
+ testling->setIdleTimeSeconds(15);
+ querier->idleTime = 5;
+
+ timerFactory->updateTime(15000);
+
+ CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(idleEvents.size()));
+ }
+
+ private:
+ ActualIdleDetector* createDetector() {
+ ActualIdleDetector* detector = new ActualIdleDetector(querier, timerFactory, 10);
+ detector->onIdleChanged.connect(boost::bind(&ActualIdleDetectorTest::handleIdle, this, _1));
+ return detector;
+ }
+
+ void handleIdle(bool b) {
+ idleEvents.push_back(b);
+ }
+
+ private:
+ struct MockIdleQuerier : public IdleQuerier {
+ MockIdleQuerier() : idleTime(0) {}
+ virtual int getIdleTimeSeconds() { return idleTime; }
+ int idleTime;
+ };
+
+ struct MockTimer : public Timer {
+ MockTimer(int interval) : interval(interval), running(false), lastTime(0) {}
+
+ virtual void start() {
+ running = true;
+ }
+
+ virtual void stop() {
+ running = false;
+ }
+
+ virtual void updateTime(int currentTime) {
+ if (lastTime == currentTime) {
+ return;
+ }
+ if (running) {
+ int time = lastTime;
+ while (time <= currentTime) {
+ onTick();
+ time += interval;
+ }
+ }
+ lastTime = currentTime;
+ }
+
+ int interval;
+ bool running;
+ int lastTime;
+ };
+
+ struct MockTimerFactory : public TimerFactory {
+ MockTimerFactory() {}
+
+ void updateTime(int milliseconds) {
+ foreach(boost::shared_ptr<MockTimer> timer, timers) {
+ timer->updateTime(milliseconds);
+ }
+ }
+
+ boost::shared_ptr<Timer> createTimer(int milliseconds) {
+ boost::shared_ptr<MockTimer> timer(new MockTimer(milliseconds));
+ timers.push_back(timer);
+ return timer;
+ }
+
+ std::vector<boost::shared_ptr<MockTimer> > timers;
+ };
+
+ MockIdleQuerier* querier;
+ MockTimerFactory* timerFactory;
+ std::vector<bool> idleEvents;
};
CPPUNIT_TEST_SUITE_REGISTRATION(ActualIdleDetectorTest);
diff --git a/SwifTools/Idle/WindowsIdleQuerier.cpp b/SwifTools/Idle/WindowsIdleQuerier.cpp
index ef1738b..f766436 100644
--- a/SwifTools/Idle/WindowsIdleQuerier.cpp
+++ b/SwifTools/Idle/WindowsIdleQuerier.cpp
@@ -14,14 +14,14 @@ WindowsIdleQuerier::WindowsIdleQuerier() {
}
int WindowsIdleQuerier::getIdleTimeSeconds() {
- LASTINPUTINFO info;
- info.cbSize = sizeof(info);
- if (GetLastInputInfo(&info)) {
- return (GetTickCount() - info.dwTime) / 1000;
- }
- else {
- return 0;
- }
+ 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
index 557ecab..198c6e9 100644
--- a/SwifTools/Idle/WindowsIdleQuerier.h
+++ b/SwifTools/Idle/WindowsIdleQuerier.h
@@ -9,10 +9,10 @@
#include <SwifTools/Idle/IdleQuerier.h>
namespace Swift {
- class WindowsIdleQuerier : public IdleQuerier {
- public:
- WindowsIdleQuerier();
+ class WindowsIdleQuerier : public IdleQuerier {
+ public:
+ WindowsIdleQuerier();
- virtual int getIdleTimeSeconds();
- };
+ virtual int getIdleTimeSeconds();
+ };
}
diff --git a/SwifTools/Idle/XSSIdleQuerier.cpp b/SwifTools/Idle/XSSIdleQuerier.cpp
index 883f76f..03c5330 100644
--- a/SwifTools/Idle/XSSIdleQuerier.cpp
+++ b/SwifTools/Idle/XSSIdleQuerier.cpp
@@ -14,31 +14,31 @@
namespace Swift {
XSSIdleQuerier::XSSIdleQuerier() : display(NULL), info(NULL) {
- display = XOpenDisplay(NULL);
- assert(display);
- rootWindow = DefaultRootWindow(display);
- int event, error;
- available = XScreenSaverQueryExtension(display, &event, &error);
- if (available) {
- info = XScreenSaverAllocInfo();
- }
- else {
- std::cerr << "Warning: XScreenSaver extension not found. Idle time detection will not work." << std::endl;
- }
+ display = XOpenDisplay(NULL);
+ assert(display);
+ rootWindow = DefaultRootWindow(display);
+ int event, error;
+ available = XScreenSaverQueryExtension(display, &event, &error);
+ if (available) {
+ info = XScreenSaverAllocInfo();
+ }
+ else {
+ std::cerr << "Warning: XScreenSaver extension not found. Idle time detection will not work." << std::endl;
+ }
}
XSSIdleQuerier::~XSSIdleQuerier() {
- XFree(info);
+ XFree(info);
}
int XSSIdleQuerier::getIdleTimeSeconds() {
- if (available) {
- XScreenSaverQueryInfo(display, rootWindow, info);
- return info->idle / 1000;
- }
- else {
- return 0;
- }
+ if (available) {
+ XScreenSaverQueryInfo(display, rootWindow, info);
+ return info->idle / 1000;
+ }
+ else {
+ return 0;
+ }
}
}
diff --git a/SwifTools/Idle/XSSIdleQuerier.h b/SwifTools/Idle/XSSIdleQuerier.h
index ae5a502..225f781 100644
--- a/SwifTools/Idle/XSSIdleQuerier.h
+++ b/SwifTools/Idle/XSSIdleQuerier.h
@@ -12,17 +12,17 @@
#include <SwifTools/Idle/IdleQuerier.h>
namespace Swift {
- class XSSIdleQuerier : public IdleQuerier {
- public:
- XSSIdleQuerier();
- ~XSSIdleQuerier();
+ class XSSIdleQuerier : public IdleQuerier {
+ public:
+ XSSIdleQuerier();
+ ~XSSIdleQuerier();
- virtual int getIdleTimeSeconds();
+ virtual int getIdleTimeSeconds();
- private:
- Display* display;
- Window rootWindow;
- bool available;
- XScreenSaverInfo* info;
- };
+ private:
+ Display* display;
+ Window rootWindow;
+ bool available;
+ XScreenSaverInfo* info;
+ };
}