Reduce rate of X11 screensave interrupt to once/minute

This commit is contained in:
Gareth Francis
2024-04-19 00:29:35 -07:00
committed by teejusb
parent bdafbd4660
commit 99e3d10775
2 changed files with 16 additions and 8 deletions
+13 -8
View File
@@ -7,6 +7,7 @@
#include "RageDisplay.h" // VideoModeParams
#include "DisplaySpec.h"
#include "LocalizedString.h"
#include "RageTimer.h"
#include "RageDisplay_OGL_Helpers.h"
using namespace RageDisplay_Legacy_Helpers;
@@ -623,16 +624,20 @@ void LowLevelWindow_X11::SwapBuffers()
* it's already active.
*/
XLockDisplay( Dpy );
auto now = RageTimer::GetTimeSinceStartFast();
if( (now - m_lastScreensaverInterrupt) > m_screensaverInterruptInterval ) {
m_lastScreensaverInterrupt = now;
XLockDisplay( Dpy );
int event_base, error_base, major, minor;
if( XTestQueryExtension( Dpy, &event_base, &error_base, &major, &minor ) )
{
XTestFakeRelativeMotionEvent( Dpy, 0, 0, 0 );
XSync( Dpy, False );
int event_base, error_base, major, minor;
if( XTestQueryExtension( Dpy, &event_base, &error_base, &major, &minor ) )
{
XTestFakeRelativeMotionEvent( Dpy, 0, 0, 0 );
XSync( Dpy, False );
}
XUnlockDisplay( Dpy );
}
XUnlockDisplay( Dpy );
#endif
}
}
@@ -38,6 +38,9 @@ private:
bool m_bWasWindowed;
ActualVideoModeParams CurrentParams;
float m_lastScreensaverInterrupt = 0.0f;
float m_screensaverInterruptInterval = 60.0f;
};
#ifdef ARCH_LOW_LEVEL_WINDOW