From 24ac9f518d382dc1a780f4eb80e5703637e557d2 Mon Sep 17 00:00:00 2001 From: David Fries Date: Tue, 4 Mar 2014 00:33:29 -0600 Subject: 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 Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbconnection.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 5f396e0946..66b8401ea2 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -185,8 +185,12 @@ void QXcbConnection::updateScreens() siblings << screen; activeScreens << screen; ++screenNumber; - if (!primaryScreen && primary) { - if (m_primaryScreen == xcbScreenNumber && (primary->output == XCB_NONE || outputs[i] == primary->output)) { + // There can be multiple outputs per screen, use either + // 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; siblings.prepend(siblings.takeLast()); #ifdef Q_XCB_DEBUG -- cgit v1.2.3