Ticket #982: myth-dpms-fixes.3.patch
File myth-dpms-fixes.3.patch, 6.7 KB (added by , 18 years ago) |
---|
-
libs/libmyth/screensaver-osx.cpp
61 61 ScreenSaverOSXPrivate::timerCallback(NULL, NULL); 62 62 } 63 63 64 bool ScreenSaverOSX::Asleep(void) 65 { 66 return 0; 67 } -
libs/libmyth/screensaver-x11.cpp
20 20 int interval; 21 21 int preferblank; 22 22 int allowexposure; 23 bool dpmsdisabled;24 23 bool xscreensaverRunning; 24 BOOL dpmsaware; 25 BOOL dpmsenabled; 26 bool dpmsdefeated; 25 27 } state; 26 28 27 29 QTimer *resetTimer; … … 44 46 d->timeoutInterval = -1; 45 47 VERBOSE(VB_GENERAL, "XScreenSaver support enabled"); 46 48 } 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 47 75 } 48 76 49 77 ScreenSaverX11::~ScreenSaverX11() 50 78 { 79 /* Ensure DPMS gets left as it was found. */ 80 if (d->state.dpmsdefeated) 81 Restore(); 82 51 83 delete d; 52 84 } 53 85 … … 65 97 XResetScreenSaver(qt_xdisplay()); 66 98 XSetScreenSaver(qt_xdisplay(), 0, 0, 0, 0); 67 99 68 int nothing; 69 70 if (DPMSQueryExtension(qt_xdisplay(), ¬hing, ¬hing)) 100 if (d->state.dpmsenabled) 71 101 { 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."); 82 105 } 83 106 84 107 if (d->state.xscreensaverRunning) … … 109 132 d->state.allowexposure); 110 133 d->state.saved = false; 111 134 112 if (d->state.dpmsd isabled)135 if (d->state.dpmsdefeated) 113 136 { 114 int nothing; 115 d->state.dpmsdisabled = false; 116 if (DPMSQueryExtension(qt_xdisplay(), ¬hing, ¬hing)) 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."); 121 140 } 122 141 123 142 if (d->state.xscreensaverRunning && d->resetTimer) … … 130 149 if (d->state.xscreensaverRunning) 131 150 resetSlot(); 132 151 133 int nothing; 134 if (DPMSQueryExtension(qt_xdisplay(), ¬hing, ¬hing)) 152 if (Asleep()) 135 153 { 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); 144 158 } 145 159 } 146 160 161 bool 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 147 177 void ScreenSaverX11::resetSlot() 148 178 { 149 179 myth_system(QString("xscreensaver-command -deactivate >&- 2>&- &")); -
libs/libmyth/screensaver-null.cpp
17 17 void ScreenSaverNull::Reset(void) 18 18 { 19 19 } 20 21 bool ScreenSaverNull::Asleep(void) 22 { 23 return 0; 24 } -
libs/libmyth/mythdialogs.cpp
772 772 else if (ce->type() == kMediaEventType) 773 773 { 774 774 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 775 781 // Let's see which of our jump points are configured to handle this 776 782 // type of media... If there's more than one we'll want to show some 777 783 // UI to allow the user to select which jump point to use. But for -
libs/libmyth/screensaver.h
36 36 virtual void Disable(void) = 0; 37 37 virtual void Restore(void) = 0; 38 38 virtual void Reset(void) = 0; 39 40 virtual bool Asleep(void) = 0; 39 41 }; 40 42 41 43 #endif // MYTH_SCREENSAVER_H -
libs/libmyth/screensaver-null.h
12 12 void Disable(void); 13 13 void Restore(void); 14 14 void Reset(void); 15 16 bool Asleep(void); 15 17 }; 16 18 17 19 #endif // MYTH_SCREENSAVER_NULL_H -
libs/libmyth/screensaver-osx.h
13 13 void Restore(void); 14 14 void Reset(void); 15 15 16 bool Asleep(void); 17 16 18 protected: 17 19 class ScreenSaverOSXPrivate *d; 18 20 }; -
libs/libmyth/screensaver-x11.h
17 17 void Restore(void); 18 18 void Reset(void); 19 19 20 bool Asleep(void); 21 20 22 public slots: 21 23 void resetSlot(); 22 24