When a screen comes back online, the windows need to be told about it

On my system, this fixes the misbehavior of Qt applications when the (only) active screen is
switched, e.g. from an external screen to the laptop.
This behavior is caused by the screen() of widgets to be set to NULL when their screen goes away.
When a new screen comes online, the widgets *should* be told about it, but they are not. The only
place that "maybeSetScreen" is called is when an existing screen changes its geometry, but not
when a screen gets enabled without its geometry being affected in any way (e.g. because it was
just disabled via xrandr, but has been connected all along). This makes sure that "maybeSetScreen"
is also called when a screen gets enabled.

Task-number: QTBUG-47041
Change-Id: Ic72d6beaa544bf9a4efdbea0830b1bc0d6ce5362
Reviewed-by: Dmitry Shachnev <mitya57@gmail.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com>
This commit is contained in:
Ralf Jung 2015-07-05 12:15:29 +02:00 committed by Shawn Rutledge
parent 99e0fbbe1f
commit b0b08cc0e4

View File

@ -252,6 +252,14 @@ void QXcbConnection::updateScreens(const xcb_randr_notify_event_t *event)
otherScreen->addVirtualSibling(screen);
m_screens << screen;
QXcbIntegration::instance()->screenAdded(screen, screen->isPrimary());
// Windows which had null screens have already had expose events by now.
// They need to be told the screen is back, it's OK to render.
foreach (QWindow *window, QGuiApplication::topLevelWindows()) {
QXcbWindow *xcbWin = static_cast<QXcbWindow*>(window->handle());
if (xcbWin)
xcbWin->maybeSetScreen(screen);
}
}
// else ignore disabled screens
} else if (screen) {