Ticket #982: myth-dpms-fixes.3.patch

File myth-dpms-fixes.3.patch, 6.7 KB (added by kcodyjr@…, 18 years ago)

Incorporating #991 and removes DPMSCapable test.

  • libs/libmyth/screensaver-osx.cpp

     
    6161    ScreenSaverOSXPrivate::timerCallback(NULL, NULL);
    6262}
    6363
     64bool ScreenSaverOSX::Asleep(void)
     65{
     66    return 0;
     67}
  • libs/libmyth/screensaver-x11.cpp

     
    2020        int interval;
    2121        int preferblank;
    2222        int allowexposure;
    23         bool dpmsdisabled;
    2423        bool xscreensaverRunning;
     24        BOOL dpmsaware;
     25        BOOL dpmsenabled;
     26        bool dpmsdefeated;
    2527    } state;
    2628
    2729    QTimer *resetTimer;
     
    4446        d->timeoutInterval = -1;
    4547        VERBOSE(VB_GENERAL, "XScreenSaver support enabled");
    4648    }
     49
     50    int dummy;
     51    if ((d->state.dpmsaware = DPMSQueryExtension(qt_xdisplay(),&dummy,&dummy)))
     52    {
     53        CARD16 power_level;
     54
     55        /* If someone runs into X server weirdness that goes away when
     56         * they externally disable DPMS, then the 'dpmsenabled' test should
     57         * be short circuited by a call to 'DPMSCapable()'. Be sure to
     58         * manually initialize dpmsenabled to false.
     59         */
     60
     61        DPMSInfo(qt_xdisplay(), &power_level, &(d->state.dpmsenabled));
     62
     63        if (d->state.dpmsenabled)
     64            VERBOSE(VB_GENERAL, "DPMS is active.");
     65        else
     66            VERBOSE(VB_GENERAL, "DPMS is disabled.");
     67
     68    } else {
     69        d->state.dpmsenabled = false;
     70        VERBOSE(VB_GENERAL, "DPMS is not supported.");
     71    }
     72
     73    d->state.dpmsdefeated = false;
     74
    4775}
    4876
    4977ScreenSaverX11::~ScreenSaverX11()
    5078{
     79    /* Ensure DPMS gets left as it was found. */
     80    if (d->state.dpmsdefeated)
     81        Restore();
     82
    5183    delete d;
    5284}
    5385
     
    6597    XResetScreenSaver(qt_xdisplay());
    6698    XSetScreenSaver(qt_xdisplay(), 0, 0, 0, 0);
    6799
    68     int nothing;
    69 
    70     if (DPMSQueryExtension(qt_xdisplay(), &nothing, &nothing))
     100    if (d->state.dpmsenabled)
    71101    {
    72         BOOL on;
    73         CARD16 power_level;
    74 
    75         DPMSInfo(qt_xdisplay(), &power_level, &on);
    76         if (on)
    77         {
    78             d->state.dpmsdisabled = true;
    79             DPMSDisable(qt_xdisplay());       // monitor powersave off
    80             VERBOSE(VB_GENERAL, "Disable DPMS");
    81         }
     102        d->state.dpmsdefeated = true;
     103        DPMSDisable(qt_xdisplay());
     104        VERBOSE(VB_GENERAL, "DPMS powerdown defeated.");
    82105    }
    83106
    84107    if (d->state.xscreensaverRunning)
     
    109132                    d->state.allowexposure);
    110133    d->state.saved = false;
    111134
    112     if (d->state.dpmsdisabled)
     135    if (d->state.dpmsdefeated)
    113136    {
    114         int nothing;
    115         d->state.dpmsdisabled = false;
    116         if (DPMSQueryExtension(qt_xdisplay(), &nothing, &nothing))
    117         {
    118             DPMSEnable(qt_xdisplay());
    119             VERBOSE(VB_GENERAL, "Enable DPMS");
    120         }
     137        d->state.dpmsdefeated = false;
     138        DPMSEnable(qt_xdisplay());
     139        VERBOSE(VB_GENERAL, "DPMS powerdown re-enabled.");
    121140    }
    122141
    123142    if (d->state.xscreensaverRunning && d->resetTimer)
     
    130149    if (d->state.xscreensaverRunning)
    131150        resetSlot();
    132151
    133     int nothing;
    134     if (DPMSQueryExtension(qt_xdisplay(), &nothing, &nothing))
     152    if (Asleep())
    135153    {
    136         BOOL on;
    137         CARD16 power_level;
    138         if (!d->state.dpmsdisabled)
    139         {
    140             DPMSInfo(qt_xdisplay(), &power_level, &on);
    141             if (power_level != DPMSModeOn)
    142                 DPMSForceLevel(qt_xdisplay(), DPMSModeOn);
    143         }
     154        DPMSForceLevel(qt_xdisplay(), DPMSModeOn);
     155        // Calling XSync is necessary for the case when Myth executes
     156        // another application before the event loop regains control
     157        XSync(qt_xdisplay(), false);
    144158    }
    145159}
    146160
     161bool ScreenSaverX11::Asleep(void)
     162{
     163    if (!d->state.dpmsenabled)
     164        return 0;
     165
     166    if (d->state.dpmsdefeated)
     167        return 0;
     168
     169    BOOL on;
     170    CARD16 power_level;
     171
     172    DPMSInfo(qt_xdisplay(), &power_level, &on);
     173
     174    return (power_level != DPMSModeOn);
     175}
     176
    147177void ScreenSaverX11::resetSlot()
    148178{
    149179    myth_system(QString("xscreensaver-command -deactivate >&- 2>&- &"));
  • libs/libmyth/screensaver-null.cpp

     
    1717void ScreenSaverNull::Reset(void)
    1818{
    1919}
     20
     21bool ScreenSaverNull::Asleep(void)
     22{
     23    return 0;
     24}
  • libs/libmyth/mythdialogs.cpp

     
    772772    else if (ce->type() == kMediaEventType)
    773773    {
    774774        MediaEvent *media_event = (MediaEvent*)ce;
     775
     776        /* Media inserts are always a manual user action.
     777         * We should wake up the screen on it whether it can play or not.
     778         */
     779        gContext->DoResetScreensaver();
     780
    775781        // Let's see which of our jump points are configured to handle this
    776782        // type of media...  If there's more than one we'll want to show some
    777783        // UI to allow the user to select which jump point to use. But for
  • libs/libmyth/screensaver.h

     
    3636    virtual void Disable(void) = 0;
    3737    virtual void Restore(void) = 0;
    3838    virtual void Reset(void) = 0;
     39
     40    virtual bool Asleep(void) = 0;
    3941};
    4042
    4143#endif // MYTH_SCREENSAVER_H
  • libs/libmyth/screensaver-null.h

     
    1212    void Disable(void);
    1313    void Restore(void);
    1414    void Reset(void);
     15
     16    bool Asleep(void);
    1517};
    1618
    1719#endif // MYTH_SCREENSAVER_NULL_H
  • libs/libmyth/screensaver-osx.h

     
    1313    void Restore(void);
    1414    void Reset(void);
    1515
     16    bool Asleep(void);
     17
    1618protected:
    1719    class ScreenSaverOSXPrivate *d;
    1820};
  • libs/libmyth/screensaver-x11.h

     
    1717    void Restore(void);
    1818    void Reset(void);
    1919
     20    bool Asleep(void);
     21
    2022  public slots:
    2123    void resetSlot();
    2224