XCB: use requested primary screen DISPLAY=:0.1 when possible

The current logic requires primary->output to not be specified, or
match the output number.  This fails when the output by that number
doesn't currently have a display attached, as non-connected outputs
are skipped.  This means setting the display to :0.1 for Qt5 will put
the window on :0.0 and it can't be moved to :0.1 after the fact.  The
solution is to pick the first output on the requested screen, then
override if an output exactly matches the primary output value.  That
way it will at least be on the requested screen.

Tested with Xephyr, ATI, and nVidia (proprietary driver), where the
nVidia had the primary output disconnected.

Task-number: QTBUG-15418
Change-Id: I7951dcef74cb135dc12a6e133a71c5852eae9778
Reviewed-by: Uli Schlachter <psychon@znc.in>
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
This commit is contained in:
David Fries 2014-03-04 00:33:29 -06:00 committed by The Qt Project
parent 51d4eb8f5b
commit 24ac9f518d

View File

@ -185,8 +185,12 @@ void QXcbConnection::updateScreens()
siblings << screen; siblings << screen;
activeScreens << screen; activeScreens << screen;
++screenNumber; ++screenNumber;
if (!primaryScreen && primary) { // There can be multiple outputs per screen, use either
if (m_primaryScreen == xcbScreenNumber && (primary->output == XCB_NONE || outputs[i] == primary->output)) { // the first or an exact match. An exact match isn't
// always available if primary->output is XCB_NONE
// or currently disconnected output.
if (m_primaryScreen == xcbScreenNumber) {
if (!primaryScreen || (primary && outputs[i] == primary->output)) {
primaryScreen = screen; primaryScreen = screen;
siblings.prepend(siblings.takeLast()); siblings.prepend(siblings.takeLast());
#ifdef Q_XCB_DEBUG #ifdef Q_XCB_DEBUG