diff options
Diffstat (limited to 'karm/idletimedetector.cpp')
-rw-r--r-- | karm/idletimedetector.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/karm/idletimedetector.cpp b/karm/idletimedetector.cpp index 110eacd06..dd2c4d565 100644 --- a/karm/idletimedetector.cpp +++ b/karm/idletimedetector.cpp @@ -1,3 +1,5 @@ +#include <time.h> + #include "idletimedetector.h" #include <tqdatetime.h> @@ -67,30 +69,34 @@ void IdleTimeDetector::informOverrun(int idleSeconds) _timer->stop(); - TQDateTime idleStart = TQDateTime::currentDateTime().addSecs(-idleSeconds); - TQString idleStartTQString = TDEGlobal::locale()->formatTime(idleStart.time()); + struct timespec tm; + + clock_gettime(CLOCK_MONOTONIC, &tm); + int start = tm.tv_sec - idleSeconds; + TQDateTime idleStart = TQDateTime::currentDateTime().addSecs(-idleSeconds); int id = TQMessageBox::warning( 0, i18n("Idle Detection"), i18n("Desktop has been idle since %1." - " What should we do?").arg(idleStartTQString), + " What should we do?").arg(TDEGlobal::locale()->formatTime(idleStart.time())), i18n("Revert && Stop"), i18n("Revert && Continue"), i18n("Continue Timing"),0,2); - TQDateTime end = TQDateTime::currentDateTime(); - int diff = idleStart.secsTo(end)/secsPerMinute; + + clock_gettime(CLOCK_MONOTONIC, &tm); + int diff = tm.tv_sec - start; if (id == 0) { // Revert And Stop kdDebug(5970) << "Now it is " << TQDateTime::currentDateTime() << endl; kdDebug(5970) << "Reverting timer to " << TDEGlobal::locale()->formatTime(idleStart.time()).ascii() << endl; - emit(extractTime(idleSeconds/60+diff)); // we need to subtract the time that has been added during idleness. + emit(extractTime(diff/60)); emit(stopAllTimersAt(idleStart)); } else if (id == 1) { // Revert and Continue - emit(extractTime(idleSeconds/60+diff)); + emit(extractTime(diff/60)); _timer->start(testInterval); } else |