Advertisement
KukuRuzo

psi idle work

Mar 17th, 2024
750
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.76 KB | None | 0 0
  1. diff --git a/src/tools/idle/idle_x11.cpp b/src/tools/idle/idle_x11.cpp
  2. index d50cc3d4..1874629c 100644
  3. --- a/src/tools/idle/idle_x11.cpp
  4. +++ b/src/tools/idle/idle_x11.cpp
  5. @@ -21,10 +21,13 @@
  6.  
  7.  #ifdef HAVE_XSS
  8.  #include <QApplication>
  9. -#include <QDesktopWidget>
  10. +#include "x11windowsystem.h"
  11. +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
  12.  #include <QX11Info>
  13. +#else
  14. +#include <QGuiApplication>
  15. +#endif
  16.  #include <X11/Xlib.h>
  17. -#include <X11/Xutil.h>
  18.  #include <X11/extensions/scrnsaver.h>
  19.  
  20.  static XErrorHandler old_handler = 0;
  21. @@ -107,7 +110,7 @@ bool IdlePlatform::init()
  22.      }
  23.  #endif // USE_DBUS
  24.  #ifdef HAVE_XSS
  25. -    if (!QX11Info::isPlatformX11())
  26. +    if (!X11WindowSystem::instance()->isValid())
  27.          return false;
  28.  
  29.      if (d->ss_info)
  30. @@ -116,7 +119,13 @@ bool IdlePlatform::init()
  31.      old_handler = XSetErrorHandler(xerrhandler);
  32.  
  33.      int event_base, error_base;
  34. -    if (XScreenSaverQueryExtension(QX11Info::display(), &event_base, &error_base)) {
  35. +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
  36. +    auto display = QX11Info::display();
  37. +#else
  38. +    auto x11app = qApp->nativeInterface<QNativeInterface::QX11Application>();
  39. +    auto display = x11app->display();
  40. +#endif
  41. +    if (XScreenSaverQueryExtension(display, &event_base, &error_base)) {
  42.          d->ss_info = XScreenSaverAllocInfo();
  43.          return true;
  44.      }
  45. @@ -146,7 +155,13 @@ int IdlePlatform::secondsIdle()
  46.      if (!d->ss_info)
  47.          return 0;
  48.  
  49. -    if (!XScreenSaverQueryInfo(QX11Info::display(), QX11Info::appRootWindow(), d->ss_info))
  50. +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
  51. +    auto display = QX11Info::display();
  52. +#else
  53. +    auto x11app = qApp->nativeInterface<QNativeInterface::QX11Application>();
  54. +    auto display = x11app->display();
  55. +#endif
  56. +    if (!XScreenSaverQueryInfo(display, X11WindowSystem::instance()->getDesktopRootWindow(), d->ss_info))
  57.          return 0;
  58.      return d->ss_info->idle / 1000;
  59.  #endif // HAVE_XSS
  60. diff --git a/src/x11windowsystem.cpp b/src/x11windowsystem.cpp
  61. index 1efc80c6..868cc0a8 100644
  62. --- a/src/x11windowsystem.cpp
  63. +++ b/src/x11windowsystem.cpp
  64. @@ -377,3 +377,5 @@ bool X11WindowSystem::windowHasAnyOfStates(Window win, const QSet<Atom> &filtere
  65.      }
  66.      return false;
  67.  }
  68. +
  69. +ulong X11WindowSystem::getDesktopRootWindow(){ return getRootWindow(); };
  70. diff --git a/src/x11windowsystem.h b/src/x11windowsystem.h
  71. index db335e80..50e7d213 100644
  72. --- a/src/x11windowsystem.h
  73. +++ b/src/x11windowsystem.h
  74. @@ -44,6 +44,7 @@ public:
  75.      bool                    desktopOfWindow(Window *window, long *desktop);
  76.      void                    x11wmClass(WId wid, QString resName);
  77.      void                    bringToFront(QWidget *w);
  78. +    ulong                   getDesktopRootWindow();
  79.  };
  80.  
  81.  #endif // X11WINDOWSYSTEM_H
  82.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement