From 99e3d10775e383570bfb779c2b8bae352ce6f659 Mon Sep 17 00:00:00 2001 From: Gareth Francis Date: Thu, 18 Apr 2024 20:05:46 +0100 Subject: [PATCH] Reduce rate of X11 screensave interrupt to once/minute --- .../LowLevelWindow/LowLevelWindow_X11.cpp | 21 ++++++++++++------- src/arch/LowLevelWindow/LowLevelWindow_X11.h | 3 +++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/arch/LowLevelWindow/LowLevelWindow_X11.cpp b/src/arch/LowLevelWindow/LowLevelWindow_X11.cpp index 0b46584db5..6fed9f2503 100644 --- a/src/arch/LowLevelWindow/LowLevelWindow_X11.cpp +++ b/src/arch/LowLevelWindow/LowLevelWindow_X11.cpp @@ -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 } } diff --git a/src/arch/LowLevelWindow/LowLevelWindow_X11.h b/src/arch/LowLevelWindow/LowLevelWindow_X11.h index 4b830e485b..fb8991f923 100644 --- a/src/arch/LowLevelWindow/LowLevelWindow_X11.h +++ b/src/arch/LowLevelWindow/LowLevelWindow_X11.h @@ -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