Export getTimestamp to the native interface

The functionality to get the current x11 timestamp is also needed by
applications which need to interact with the X11 directly. With XCB
it is not possible to inspect the event queue and by that an
application is not able to retrieve the current timestamp using the
property change pattern and waiting for the matching event.

Change-Id: Ie7ba78ecbe509ed3a902c702266917f65bf5ad07
Reviewed-by: Gatis Paeglis <gatis.paeglis@digia.com>
Reviewed-by: David Faure (KDE) <faure@kde.org>
bb10
Martin Gräßlin 2013-08-02 06:24:36 +02:00 committed by The Qt Project
parent 4780e5326f
commit 45ab9d0c33
2 changed files with 12 additions and 1 deletions

View File

@ -85,6 +85,7 @@ public:
insert("hintstyle", QXcbNativeInterface::ScreenHintStyle);
insert("startupid", QXcbNativeInterface::StartupId);
insert(QByteArrayLiteral("traywindow"), QXcbNativeInterface::TrayWindow);
insert(QByteArrayLiteral("gettimestamp"), QXcbNativeInterface::GetTimestamp);
}
};
@ -200,6 +201,9 @@ void *QXcbNativeInterface::nativeResourceForScreen(const QByteArray &resource, Q
if (QXcbSystemTrayTracker *s = systemTrayTracker(screen))
result = (void *)quintptr(s->trayWindow());
break;
case GetTimestamp:
result = getTimestamp(xcbScreen);
break;
default:
break;
}
@ -254,6 +258,11 @@ void *QXcbNativeInterface::appUserTime(const QXcbScreen *screen)
return reinterpret_cast<void *>(quintptr(screen->connection()->netWmUserTime()));
}
void *QXcbNativeInterface::getTimestamp(const QXcbScreen *screen)
{
return reinterpret_cast<void *>(quintptr(screen->connection()->getTimestamp()));
}
void *QXcbNativeInterface::startupId()
{
QXcbIntegration* integration = static_cast<QXcbIntegration *>(QGuiApplicationPrivate::platformIntegration());

View File

@ -69,7 +69,8 @@ public:
AppUserTime,
ScreenHintStyle,
StartupId,
TrayWindow
TrayWindow,
GetTimestamp
};
QXcbNativeInterface();
@ -91,6 +92,7 @@ public:
void *graphicsDeviceForWindow(QWindow *window);
void *appTime(const QXcbScreen *screen);
void *appUserTime(const QXcbScreen *screen);
void *getTimestamp(const QXcbScreen *screen);
void *startupId();
static void setAppTime(QScreen *screen, xcb_timestamp_t time);
static void setAppUserTime(QScreen *screen, xcb_timestamp_t time);