mirror of
https://github.com/ckb-next/ckb-next.git
synced 2026-10-10 12:27:21 -04:00
gui: Get root window using xcb_get_geometry()
This commit is contained in:
+13
-5
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user