From 9c45260942c0ee32267e651d981bfa33a6acb64d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 8 Aug 2013 13:44:55 +0200 Subject: Add convenient method getTimestamp to QX11Info Provides access to the getTimestamp method in the XCB plugin which allows users to retrieve the current X timestamp. Change-Id: Ib6acd44c8ff899265ed6826f36b88fe427ff58c3 Reviewed-by: David Faure (KDE) --- src/x11extras/qx11info_x11.cpp | 19 +++++++++++++++++++ src/x11extras/qx11info_x11.h | 2 ++ 2 files changed, 21 insertions(+) (limited to 'src') diff --git a/src/x11extras/qx11info_x11.cpp b/src/x11extras/qx11info_x11.cpp index aa35ff1..713e76c 100644 --- a/src/x11extras/qx11info_x11.cpp +++ b/src/x11extras/qx11info_x11.cpp @@ -252,6 +252,25 @@ void QX11Info::setAppUserTime(unsigned long time) qWarning("Internal error: QPA plugin doesn't implement setAppUserTime"); } +/*! + Fetches the current X11 time stamp from the X Server. + + This method creates a property notify event and blocks till it is + received back from the X Server. + + \since 5.2 +*/ +unsigned long QX11Info::getTimestamp() +{ + if (!qApp) + return 0; + QPlatformNativeInterface *native = qApp->platformNativeInterface(); + if (!native) + return 0; + QScreen* screen = QGuiApplication::primaryScreen(); + return static_cast(reinterpret_cast(native->nativeResourceForScreen("gettimestamp", screen))); +} + /*! Returns the default display for the application. diff --git a/src/x11extras/qx11info_x11.h b/src/x11extras/qx11info_x11.h index afc9ee4..bbc7ff4 100644 --- a/src/x11extras/qx11info_x11.h +++ b/src/x11extras/qx11info_x11.h @@ -65,6 +65,8 @@ public: static void setAppTime(unsigned long time); static void setAppUserTime(unsigned long time); + static unsigned long getTimestamp(); + static Display *display(); static xcb_connection_t *connection(); -- cgit v1.2.1