Hi,
I tried your suggestion but it doesn't seem to work. I'm not familiar with Qt internals, but the "display" returned for both QScreens is the same (it gets queried from QXcbConnection which is shared for both QScreen instances).
Here's my sample test app:
#include <QApplication>
#include <QDebug>
#include <qpa/qplatformnativeinterface.h>
#include <X11/Xlib.h>
int main(int argc, char **argv)
{
foreach
(QScreen *screen, QGuiApplication
::screens()) {
QPlatformNativeInterface
* platformInterface
= QApplication::platformNativeInterface();
void* x11Display = platformInterface->nativeResourceForScreen("display", screen);
Display* dpy = (Display*)x11Display;
auto dpyString = DisplayString(dpy);
qDebug() << screen << " display " << dpyString;
}
return 0;
}
#include <QApplication>
#include <QDebug>
#include <qpa/qplatformnativeinterface.h>
#include <X11/Xlib.h>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
foreach (QScreen *screen, QGuiApplication::screens()) {
QPlatformNativeInterface* platformInterface = QApplication::platformNativeInterface();
void* x11Display = platformInterface->nativeResourceForScreen("display", screen);
Display* dpy = (Display*)x11Display;
auto dpyString = DisplayString(dpy);
qDebug() << screen << " display " << dpyString;
}
return 0;
}
To copy to clipboard, switch view to plain text mode
My test setup is such that I have two X screens: :0.1 on the left and :0.0 on the right. When I run my test app, I get the following:
0x147b5c0 display :0.1
0x147b6d0 display :0.1
0x147b5c0 display :0.1
0x147b6d0 display :0.1
To copy to clipboard, switch view to plain text mode
If I open a QWindow with QScreen as constructor parameter, the windows do get opened properly on different X screens, so internally Qt seems to work correctly.
Looking at Qt source it looks like QXcbScreen::screenNumber() would return what I need. Is there any way to access this information? I don't see it (or anything about virtual desktops) in QPlatformNativeInterface.
Bookmarks