From 013061630c8076682f5db098821d18cf6a1c22a6 Mon Sep 17 00:00:00 2001 From: David Faure Date: Tue, 4 Dec 2012 22:44:49 +0100 Subject: Implement appTime and appUserTime (getters and setters) on top of QPA. Add unit test for QX11Info, taken from Qt4 and extended. Change-Id: I22f403f47bb5413b954c06f8cb78992e02726f6d Reviewed-by: Richard J. Moore Reviewed-by: Lars Knoll Reviewed-by: Johan Thelin --- src/x11support/qx11info_x11.cpp | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/x11support/qx11info_x11.cpp b/src/x11support/qx11info_x11.cpp index ebfb9db..4790c3f 100644 --- a/src/x11support/qx11info_x11.cpp +++ b/src/x11support/qx11info_x11.cpp @@ -184,8 +184,10 @@ int QX11Info::appScreen() */ unsigned long QX11Info::appTime() { - // ### TODO implement - return 0L; + if (!qApp) + return 0; + QPlatformNativeInterface *native = qApp->platformNativeInterface(); + return static_cast(reinterpret_cast(native->nativeResourceForIntegration("apptime"))); } /*! @@ -195,8 +197,10 @@ unsigned long QX11Info::appTime() */ unsigned long QX11Info::appUserTime() { - // ### TODO implement - return 0L; + if (!qApp) + return 0; + QPlatformNativeInterface *native = qApp->platformNativeInterface(); + return static_cast(reinterpret_cast(native->nativeResourceForIntegration("appusertime"))); } /*! @@ -206,8 +210,15 @@ unsigned long QX11Info::appUserTime() */ void QX11Info::setAppTime(unsigned long time) { - // ### TODO implement - Q_UNUSED(time); + if (!qApp) + return; + QPlatformNativeInterface *native = qApp->platformNativeInterface(); + typedef void (*SetAppTimeFunc)(xcb_timestamp_t); + SetAppTimeFunc func = reinterpret_cast(native->nativeResourceFunctionForIntegration("setapptime")); + if (func) + func(time); + else + qWarning("Internal error: QPA plugin doesn't implement setAppTime"); } /*! @@ -220,13 +231,12 @@ void QX11Info::setAppUserTime(unsigned long time) if (!qApp) return; QPlatformNativeInterface *native = qApp->platformNativeInterface(); - - QDesktopWidget *desktop = QApplication::desktop(); - QWindow *window = desktop->windowHandle(); - - xcb_timestamp_t timestamp = uint32_t(time); - QMetaObject::invokeMethod(native, "updateNetWmUserTime", Qt::DirectConnection, - Q_ARG(QWindow *,window), Q_ARG(xcb_timestamp_t, timestamp)); + typedef void (*SetAppUserTimeFunc)(xcb_timestamp_t); + SetAppUserTimeFunc func = reinterpret_cast(native->nativeResourceFunctionForIntegration("setappusertime")); + if (func) + func(time); + else + qWarning("Internal error: QPA plugin doesn't implement setAppUserTime"); } /*! -- cgit v1.2.1