From 60bd2156f81b154a47c95989b0266944fd2f2859 Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 4 Dec 2012 16:57:17 +0100 Subject: XCB: add support for getting and setting appTime and appUserTime. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The QX11Info class needs this. This required adding the missing nativeResourceFunctionForScreen in QPlatformNativeInterface. Change-Id: I2c6e91c7f122f3ecdf769a177deafd2aa3896e2f Reviewed-by: Richard J. Moore Reviewed-by: Alberto Mardegan Reviewed-by: Samuel Rødal --- src/plugins/platforms/xcb/qxcbconnection.cpp | 1 + src/plugins/platforms/xcb/qxcbconnection.h | 4 ++ src/plugins/platforms/xcb/qxcbnativeinterface.cpp | 46 +++++++++++++++++++++-- src/plugins/platforms/xcb/qxcbnativeinterface.h | 11 +++++- src/plugins/platforms/xcb/qxcbwindow.cpp | 1 + src/plugins/platforms/xcb/qxcbwindow.h | 1 - 6 files changed, 58 insertions(+), 6 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index b4f1a278a2..1192894693 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -313,6 +313,7 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, const char initializeAllAtoms(); m_time = XCB_CURRENT_TIME; + m_netWmUserTime = XCB_CURRENT_TIME; initializeXRandr(); updateScreens(); diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index f1e707e0cd..464d918adf 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -370,6 +370,9 @@ public: inline xcb_timestamp_t time() const { return m_time; } inline void setTime(xcb_timestamp_t t) { if (t > m_time) m_time = t; } + inline xcb_timestamp_t netWmUserTime() const { return m_netWmUserTime; } + inline void setNetWmUserTime(xcb_timestamp_t t) { if (t > m_netWmUserTime) m_netWmUserTime = t; } + bool hasGLX() const { return has_glx_extension; } bool hasXFixes() const { return xfixes_first_event > 0; } bool hasXShape() const { return has_shape_extension; } @@ -452,6 +455,7 @@ private: xcb_atom_t m_allAtoms[QXcbAtom::NAtoms]; xcb_timestamp_t m_time; + xcb_timestamp_t m_netWmUserTime; QByteArray m_displayName; diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp index a44e7fb959..9c360df900 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp @@ -71,6 +71,8 @@ public: insert("screen",QXcbNativeInterface::Screen); insert("eglcontext",QXcbNativeInterface::EglContext); insert("glxcontext",QXcbNativeInterface::GLXContext); + insert("apptime",QXcbNativeInterface::AppTime); + insert("appusertime",QXcbNativeInterface::AppUserTime); } }; @@ -109,18 +111,24 @@ void *QXcbNativeInterface::nativeResourceForScreen(const QByteArray &resource, Q const QXcbResourceMap::const_iterator it = qXcbResourceMap()->constFind(resource.toLower()); if (it == qXcbResourceMap()->constEnd() || !screen->handle()) return 0; + void *result = 0; const QXcbScreen *xcbScreen = static_cast(screen->handle()); switch (it.value()) { case Display: #ifdef XCB_USE_XLIB - return xcbScreen->connection()->xlib_display(); -#else - break; + result = xcbScreen->connection()->xlib_display(); #endif + break; + case AppTime: + result = appTime(xcbScreen); + break; + case AppUserTime: + result = appUserTime(xcbScreen); + break; default: break; } - return 0; + return result; } void *QXcbNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window) @@ -151,6 +159,36 @@ void *QXcbNativeInterface::nativeResourceForWindow(const QByteArray &resourceStr return result; } +QPlatformNativeInterface::NativeResourceForScreenFunction QXcbNativeInterface::nativeResourceFunctionForScreen(const QByteArray &resource) +{ + const QByteArray lowerCaseResource = resource.toLower(); + if (lowerCaseResource == "setapptime") + return NativeResourceForScreenFunction(setAppTime); + else if (lowerCaseResource == "setappusertime") + return NativeResourceForScreenFunction(setAppUserTime); + return 0; +} + +void *QXcbNativeInterface::appTime(const QXcbScreen *screen) +{ + return reinterpret_cast(quintptr(screen->connection()->time())); +} + +void *QXcbNativeInterface::appUserTime(const QXcbScreen *screen) +{ + return reinterpret_cast(quintptr(screen->connection()->netWmUserTime())); +} + +void QXcbNativeInterface::setAppTime(QScreen* screen, xcb_timestamp_t time) +{ + static_cast(screen->handle())->connection()->setTime(time); +} + +void QXcbNativeInterface::setAppUserTime(QScreen* screen, xcb_timestamp_t time) +{ + static_cast(screen->handle())->connection()->setNetWmUserTime(time); +} + QPlatformNativeInterface::NativeResourceForContextFunction QXcbNativeInterface::nativeResourceFunctionForContext(const QByteArray &resource) { QByteArray lowerCaseResource = resource.toLower(); diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h index a7e0a207cb..e2e03fce8f 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.h +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h @@ -43,11 +43,13 @@ #define QXCBNATIVEINTERFACE_H #include +#include QT_BEGIN_NAMESPACE class QWidget; class QXcbScreen; +class QXcbConnection; class QXcbNativeInterface : public QPlatformNativeInterface { @@ -59,7 +61,9 @@ public: Screen, GraphicsDevice, EglContext, - GLXContext + GLXContext, + AppTime, + AppUserTime }; QXcbNativeInterface(); @@ -69,6 +73,7 @@ public: void *nativeResourceForWindow(const QByteArray &resourceString, QWindow *window); NativeResourceForContextFunction nativeResourceFunctionForContext(const QByteArray &resource); + NativeResourceForScreenFunction nativeResourceFunctionForScreen(const QByteArray &resource) Q_DECL_OVERRIDE; inline const QByteArray &genericEventFilterType() const { return m_genericEventFilterType; } @@ -77,6 +82,10 @@ public: void *connectionForWindow(QWindow *window); void *screenForWindow(QWindow *window); void *graphicsDeviceForWindow(QWindow *window); + void *appTime(const QXcbScreen *screen); + void *appUserTime(const QXcbScreen *screen); + static void setAppTime(QScreen *screen, xcb_timestamp_t time); + static void setAppUserTime(QScreen *screen, xcb_timestamp_t time); static void *eglContextForContext(QOpenGLContext *context); static void *glxContextForContext(QOpenGLContext *context); diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 21254e4b3b..528c4c6580 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -1028,6 +1028,7 @@ void QXcbWindow::updateNetWmStateBeforeMap() void QXcbWindow::updateNetWmUserTime(xcb_timestamp_t timestamp) { xcb_window_t wid = m_window; + connection()->setNetWmUserTime(timestamp); const bool isSupportedByWM = connection()->wmSupport()->isSupportedByWM(atom(QXcbAtom::_NET_WM_USER_TIME_WINDOW)); if (m_netWmUserTimeWindow || isSupportedByWM) { diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index c624841a17..b2c637281d 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -138,7 +138,6 @@ public: void updateSyncRequestCounter(); void updateNetWmUserTime(xcb_timestamp_t timestamp); - void netWmUserTime() const; #if defined(XCB_USE_EGL) QXcbEGLSurface *eglSurface() const; -- cgit v1.2.3