gui: Get root window using xcb_get_geometry()

This commit is contained in:
Mavroudis Chatzilazaridis
2024-04-27 21:08:56 +03:00
parent b57ddc292c
commit c83ea95e52
+13 -5
View File
@@ -3,18 +3,26 @@
#include <QtGlobal>
#include <QByteArray>
#include <QString>
#include <QWindow>
#ifdef USE_XCB_SCREENSAVER
#include <xcb/xcb.h>
#include <QX11Info>
#include <xcb/xcb.h>
#include <xcb/screensaver.h>
#include <limits.h>
int IdleTimer::getIdleTime(){
xcb_connection_t* conn = QX11Info::connection();
const int display = QX11Info::appScreen();
#include "mainwindow.h"
xcb_screensaver_query_info_cookie_t replyCookie = xcb_screensaver_query_info(conn, QX11Info::appRootWindow(display));
int IdleTimer::getIdleTime(){
const MainWindow* const mw = MainWindow::mainWindow;
if(!mw || !mw->windowHandle())
return 0;
xcb_connection_t* conn = QX11Info::connection();
xcb_get_geometry_cookie_t geomCookie = xcb_get_geometry(conn, mw->windowHandle()->winId());
xcb_get_geometry_reply_t* geomReply = xcb_get_geometry_reply(conn, geomCookie, nullptr);
xcb_screensaver_query_info_cookie_t replyCookie = xcb_screensaver_query_info(conn, geomReply->root);
xcb_screensaver_query_info_reply_t* replyInfo = xcb_screensaver_query_info_reply(conn, replyCookie, nullptr);
uint32_t userIdle = replyInfo->ms_since_user_input;