Ticket #982: dpms_update.diff
File dpms_update.diff, 7.6 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 } 68 -
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 dpmsdeactivated; 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.dpmsdeactivated = 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.dpmsdeactivated) 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.dpmsdeactivated = true; 103 DPMSDisable(qt_xdisplay()); 104 VERBOSE(VB_GENERAL, "DPMS Deactivated "); 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.dpmsdeactivated) 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.dpmsdeactivated = false; 138 DPMSEnable(qt_xdisplay()); 139 VERBOSE(VB_GENERAL, "DPMS Reactivated."); 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.dpmsdeactivated) 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/mythcontext.h
405 405 406 406 // get the current status 407 407 bool GetScreensaverEnabled(void); 408 bool GetScreenIsAsleep(void); 408 409 409 410 void addPrivRequest(MythPrivRequest::Type t, void *data); 410 411 void waitPrivRequest() const; -
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/mythcontext.cpp
2852 2852 return currentLocation.last(); 2853 2853 } 2854 2854 2855 bool MythContext::GetScreenIsAsleep(void) 2856 { 2857 if (!d->screensaver) 2858 return false; 2859 return d->screensaver->Asleep(); 2860 } 2861 2855 2862 /* vim: set expandtab tabstop=4 shiftwidth=4: */ -
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 -
libs/libmythui/mythmainwindow.cpp
1186 1188 if (keycode) 1187 1189 { 1188 1190 gContext->ResetScreensaver(); 1191 if (gContext->GetScreenIsAsleep()) 1192 return; 1189 1193 1190 1194 int mod = keycode & MODIFIER_MASK; 1191 1195 int k = keycode & ~MODIFIER_MASK; /* trim off the mod */ … … 1235 1239 if (keycode) 1236 1240 { 1237 1241 gContext->ResetScreensaver(); 1242 if (gContext->GetScreenIsAsleep()) 1243 return; 1238 1244 1239 1245 int mod = keycode & MODIFIER_MASK; 1240 1246 int k = keycode & ~MODIFIER_MASK; /* trim off the mod */