From acce5d60ae68d56aadfeb3953c6e77882e4a2136 Mon Sep 17 00:00:00 2001 From: miruka Date: Thu, 5 Nov 2020 20:24:40 -0400 Subject: [PATCH] Prevent error spam when XScreenSaver not supported If XScreenSaver is available but not supported (e.g. when running in XWayland), return -1 for Utils.idleMilliseconds(), instead of letting the code fail and print an error every time this function gets called to check for the machine's idle time. --- src/utils.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/utils.h b/src/utils.h index 94acf51b..ffe14192 100644 --- a/src/utils.h +++ b/src/utils.h @@ -65,8 +65,13 @@ public slots: Display *display = XOpenDisplay(NULL); if (! display) return -1; + int supportedVersion = 0, error = 0; + if (! XScreenSaverQueryExtension(display, &supportedVersion, &error)) + return -1; + XScreenSaverInfo *info = XScreenSaverAllocInfo(); XScreenSaverQueryInfo(display, DefaultRootWindow(display), info); + XFree(info); const int idle = info->idle; XCloseDisplay(display); @@ -77,6 +82,7 @@ public slots: #else return -1; + #endif }