Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/tools/idle/idle_x11.cpp b/src/tools/idle/idle_x11.cpp
- index d50cc3d4..1874629c 100644
- --- a/src/tools/idle/idle_x11.cpp
- +++ b/src/tools/idle/idle_x11.cpp
- @@ -21,10 +21,13 @@
- #ifdef HAVE_XSS
- #include <QApplication>
- -#include <QDesktopWidget>
- +#include "x11windowsystem.h"
- +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
- #include <QX11Info>
- +#else
- +#include <QGuiApplication>
- +#endif
- #include <X11/Xlib.h>
- -#include <X11/Xutil.h>
- #include <X11/extensions/scrnsaver.h>
- static XErrorHandler old_handler = 0;
- @@ -107,7 +110,7 @@ bool IdlePlatform::init()
- }
- #endif // USE_DBUS
- #ifdef HAVE_XSS
- - if (!QX11Info::isPlatformX11())
- + if (!X11WindowSystem::instance()->isValid())
- return false;
- if (d->ss_info)
- @@ -116,7 +119,13 @@ bool IdlePlatform::init()
- old_handler = XSetErrorHandler(xerrhandler);
- int event_base, error_base;
- - if (XScreenSaverQueryExtension(QX11Info::display(), &event_base, &error_base)) {
- +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
- + auto display = QX11Info::display();
- +#else
- + auto x11app = qApp->nativeInterface<QNativeInterface::QX11Application>();
- + auto display = x11app->display();
- +#endif
- + if (XScreenSaverQueryExtension(display, &event_base, &error_base)) {
- d->ss_info = XScreenSaverAllocInfo();
- return true;
- }
- @@ -146,7 +155,13 @@ int IdlePlatform::secondsIdle()
- if (!d->ss_info)
- return 0;
- - if (!XScreenSaverQueryInfo(QX11Info::display(), QX11Info::appRootWindow(), d->ss_info))
- +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
- + auto display = QX11Info::display();
- +#else
- + auto x11app = qApp->nativeInterface<QNativeInterface::QX11Application>();
- + auto display = x11app->display();
- +#endif
- + if (!XScreenSaverQueryInfo(display, X11WindowSystem::instance()->getDesktopRootWindow(), d->ss_info))
- return 0;
- return d->ss_info->idle / 1000;
- #endif // HAVE_XSS
- diff --git a/src/x11windowsystem.cpp b/src/x11windowsystem.cpp
- index 1efc80c6..868cc0a8 100644
- --- a/src/x11windowsystem.cpp
- +++ b/src/x11windowsystem.cpp
- @@ -377,3 +377,5 @@ bool X11WindowSystem::windowHasAnyOfStates(Window win, const QSet<Atom> &filtere
- }
- return false;
- }
- +
- +ulong X11WindowSystem::getDesktopRootWindow(){ return getRootWindow(); };
- diff --git a/src/x11windowsystem.h b/src/x11windowsystem.h
- index db335e80..50e7d213 100644
- --- a/src/x11windowsystem.h
- +++ b/src/x11windowsystem.h
- @@ -44,6 +44,7 @@ public:
- bool desktopOfWindow(Window *window, long *desktop);
- void x11wmClass(WId wid, QString resName);
- void bringToFront(QWidget *w);
- + ulong getDesktopRootWindow();
- };
- #endif // X11WINDOWSYSTEM_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement