Export rootWindow to the QXcbNativeInterface

This change exports the root window to the native interface as there
is QX11Info::appRootWindow which so far goes over the QDesktopWidget
to get the window id of the root window. Which is a rather hackish way
considering that the root window is known to the QXcbConnection.

But even more it's a very fragile way and can result in crashes on
startup of applications if the application accesses the appRootWindow
too early.

Change-Id: Ibb09a7fa714cb355f579298fc6df33bf80f73f58
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Gatis Paeglis <gatis.paeglis@digia.com>
bb10
Martin Gräßlin 2014-03-06 14:46:46 +01:00 committed by The Qt Project
parent 51f7ef800e
commit 2f63d04ff1
2 changed files with 17 additions and 2 deletions

View File

@ -80,7 +80,8 @@ static int resourceType(const QByteArray &key)
QByteArrayLiteral("glxcontext"), QByteArrayLiteral("apptime"),
QByteArrayLiteral("appusertime"), QByteArrayLiteral("hintstyle"),
QByteArrayLiteral("startupid"), QByteArrayLiteral("traywindow"),
QByteArrayLiteral("gettimestamp"), QByteArrayLiteral("x11screen")
QByteArrayLiteral("gettimestamp"), QByteArrayLiteral("x11screen"),
QByteArrayLiteral("rootwindow")
};
const QByteArray *end = names + sizeof(names) / sizeof(names[0]);
const QByteArray *result = std::find(names, end, key);
@ -142,6 +143,9 @@ void *QXcbNativeInterface::nativeResourceForIntegration(const QByteArray &resour
case X11Screen:
result = x11Screen();
break;
case RootWindow:
result = rootWindow();
break;
default:
break;
}
@ -264,6 +268,15 @@ void *QXcbNativeInterface::x11Screen()
return 0;
}
void *QXcbNativeInterface::rootWindow()
{
QXcbIntegration *integration = static_cast<QXcbIntegration *>(QGuiApplicationPrivate::platformIntegration());
QXcbConnection *defaultConnection = integration->defaultConnection();
if (defaultConnection)
return reinterpret_cast<void *>(defaultConnection->rootWindow());
return 0;
}
void QXcbNativeInterface::setAppTime(QScreen* screen, xcb_timestamp_t time)
{
static_cast<QXcbScreen *>(screen->handle())->connection()->setTime(time);

View File

@ -70,7 +70,8 @@ public:
StartupId,
TrayWindow,
GetTimestamp,
X11Screen
X11Screen,
RootWindow
};
QXcbNativeInterface();
@ -94,6 +95,7 @@ public:
void *getTimestamp(const QXcbScreen *screen);
void *startupId();
void *x11Screen();
void *rootWindow();
static void setAppTime(QScreen *screen, xcb_timestamp_t time);
static void setAppUserTime(QScreen *screen, xcb_timestamp_t time);
static void *eglContextForContext(QOpenGLContext *context);