summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2012-12-04 22:44:49 +0100
committerDavid Faure <david.faure@kdab.com>2012-12-05 11:19:41 +0100
commit013061630c8076682f5db098821d18cf6a1c22a6 (patch)
tree337560d3ff0c055f685668f03239142d7bd08b11 /src
parent5480650d050895ab184186ee3813004da494fc30 (diff)
downloadqtx11extras-013061630c8076682f5db098821d18cf6a1c22a6.tar.gz
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 <rich@kde.org> Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Johan Thelin <johan.thelin@pelagicore.com>
Diffstat (limited to 'src')
-rw-r--r--src/x11support/qx11info_x11.cpp36
1 files changed, 23 insertions, 13 deletions
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<xcb_timestamp_t>(reinterpret_cast<quintptr>(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<xcb_timestamp_t>(reinterpret_cast<quintptr>(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<SetAppTimeFunc>(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<SetAppUserTimeFunc>(native->nativeResourceFunctionForIntegration("setappusertime"));
+ if (func)
+ func(time);
+ else
+ qWarning("Internal error: QPA plugin doesn't implement setAppUserTime");
}
/*!