Ticket #5893: mythtv-5893-throttle_screensaver_deactivate-2.patch

File mythtv-5893-throttle_screensaver_deactivate-2.patch, 1.3 KB (added by sphery <mtdean@…>, 11 years ago)

Updated patch--only does date math if a screensaver is actually running

  • libs/libmythui/screensaver-x11.cpp

    old new  
     1#include <QDateTime>
    12#include <QTimer>
    23#include <QX11Info>
    34
     
    141142
    142143    void ResetScreenSaver()
    143144    {
    144         if (m_xscreensaverRunning)
    145             myth_system("xscreensaver-command -deactivate >&- 2>&- &");
    146         else
    147             myth_system("gnome-screensaver-command --poke >&- 2>&- &");
     145        if (IsScreenSaverRunning())
     146        {
     147            QDateTime current_time = QDateTime::currentDateTime ();
     148            if ((!m_last_deactivated.isValid()) ||
     149                (m_last_deactivated.secsTo(current_time) > 30))
     150            {
     151                if (m_xscreensaverRunning)
     152                    myth_system("xscreensaver-command -deactivate >&- 2>&- &");
     153                else if (m_gscreensaverRunning)
     154                    myth_system("gnome-screensaver-command --poke >&- 2>&- &");
     155                m_last_deactivated = current_time;
     156            }
     157        }
    148158    }
    149159
    150160  private:
     
    170180    int m_timeoutInterval;
    171181    QTimer *m_resetTimer;
    172182
     183    QDateTime m_last_deactivated;
     184
    173185    ScreenSaverState m_state;
    174186};
    175187