xcb: ignore the xscreens which don't belong to current connection

This amends 9a4c98e55659b32db984612e6247ac193812a502.

When a X server has multiple xscreens, for example, ":0.0" and ":0.1",
a Qt application, which uses ":0.1" as display, can't use the randr
monitor from other connection(":0.0") to show contents there. Then
we don't need to generate QXcbScreen for them.

Pick-to: 6.4 6.5
Fixes: QTBUG-110898
Change-Id: I04c1512664b763ffabb55b75db4411d100536255
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: JiDe Zhang <zhangjide@uniontech.com>
Reviewed-by: Liang Qi <liang.qi@qt.io>
This commit is contained in:
Liang Qi 2023-02-24 15:53:19 +01:00
parent a53429c1ec
commit 2b94453cbd

View File

@ -489,6 +489,10 @@ void QXcbConnection::initializeScreensFromMonitor(xcb_screen_iterator_t *it, int
virtualDesktop = new QXcbVirtualDesktop(this, xcbScreen, xcbScreenNumber);
m_virtualDesktops.append(virtualDesktop);
}
if (xcbScreenNumber != primaryScreenNumber())
return;
QList<QPlatformScreen*> old = virtualDesktop->m_screens;
QList<QPlatformScreen *> siblings;
@ -521,14 +525,12 @@ void QXcbConnection::initializeScreensFromMonitor(xcb_screen_iterator_t *it, int
siblings << screen;
// similar logic with QXcbConnection::initializeScreensFromOutput()
if (primaryScreenNumber() == xcbScreenNumber) {
if (!(*primaryScreen) || monitor_info->primary) {
if (*primaryScreen)
(*primaryScreen)->setPrimary(false);
*primaryScreen = screen;
(*primaryScreen)->setPrimary(true);
siblings.prepend(siblings.takeLast());
}
if (!(*primaryScreen) || monitor_info->primary) {
if (*primaryScreen)
(*primaryScreen)->setPrimary(false);
*primaryScreen = screen;
(*primaryScreen)->setPrimary(true);
siblings.prepend(siblings.takeLast());
}
xcb_randr_monitor_info_next(&monitor_iter);
@ -551,10 +553,8 @@ void QXcbConnection::initializeScreensFromMonitor(xcb_screen_iterator_t *it, int
qCDebug(lcQpaScreen) << "create a fake screen: " << screen;
}
if (primaryScreenNumber() == xcbScreenNumber) {
*primaryScreen = screen;
(*primaryScreen)->setPrimary(true);
}
*primaryScreen = screen;
(*primaryScreen)->setPrimary(true);
siblings << screen;
m_screens << screen;