From d2bb2d7ac82c6e7e1a74e1bc8271ec22a3f85c01 Mon Sep 17 00:00:00 2001 From: John Maguire Date: Wed, 24 Oct 2012 16:45:00 +0200 Subject: [PATCH] Stop using deprecated UpdateSystemActivity() on mac. --- src/CMakeLists.txt | 1 - src/ui/macscreensaver.cpp | 20 ++++++++------------ src/ui/macscreensaver.h | 10 +++------- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fe44fd8b0..3421c2856 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -825,7 +825,6 @@ optional_source(APPLE core/macfslistener.h core/macglobalshortcutbackend.h devices/macdevicelister.h - ui/macscreensaver.h ui/macsystemtrayicon.h ) diff --git a/src/ui/macscreensaver.cpp b/src/ui/macscreensaver.cpp index d9720359d..9a3c05379 100644 --- a/src/ui/macscreensaver.cpp +++ b/src/ui/macscreensaver.cpp @@ -17,24 +17,20 @@ #include "macscreensaver.h" -#include - #include -MacScreensaver::MacScreensaver() { - timer_.setInterval(30000); - connect(&timer_, SIGNAL(timeout()), SLOT(Timeout())); -} - -void MacScreensaver::Timeout() { - UpdateSystemActivity(OverallAct); +MacScreensaver::MacScreensaver() + : assertion_id_(0) { } void MacScreensaver::Inhibit() { - timer_.start(30000); - Timeout(); + IOPMAssertionCreateWithName( + kIOPMAssertionTypePreventUserIdleDisplaySleep, + kIOPMAssertionLevelOn, + CFSTR("Showing full-screen Clementine visualisations"), + &assertion_id_); } void MacScreensaver::Uninhibit() { - timer_.stop(); + IOPMAssertionRelease(assertion_id_); } diff --git a/src/ui/macscreensaver.h b/src/ui/macscreensaver.h index 6bab6889e..ac0251c3e 100644 --- a/src/ui/macscreensaver.h +++ b/src/ui/macscreensaver.h @@ -20,21 +20,17 @@ #include "screensaver.h" -#include +#include -class MacScreensaver : public QObject, public Screensaver { - Q_OBJECT +class MacScreensaver : public Screensaver { public: MacScreensaver(); void Inhibit(); void Uninhibit(); - private slots: - void Timeout(); - private: - QTimer timer_; + IOPMAssertionID assertion_id_; }; #endif