From 3c8eb404877df9c967d81fa9df7d718c538fb407 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Tue, 12 Jun 2012 12:53:31 -0700 Subject: xcb: ensure the primary screen is added first MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, Qt windows without an explicit screen parameter always appear on screen 0 despite the DISPLAY being set to :0.1. With this change, the xcb backend adds the primary display at the beginning of the screen list. QGuiApplication::primaryScreen() will then return that display for all windows without an explicit screen. Change-Id: I657c4ed92b9e0f0ed379e91c732dad9d69c4f5e0 Reviewed-by: Donald Carr Reviewed-by: Samuel Rødal --- src/plugins/platforms/xcb/qxcbconnection.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 40a54ffc35..679f3e7a1f 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -98,6 +98,7 @@ static int nullErrorHandler(Display *, XErrorEvent *) QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, const char *displayName) : m_connection(0) + , m_primaryScreen(0) , m_displayName(displayName ? QByteArray(displayName) : qgetenv("DISPLAY")) , m_nativeInterface(nativeInterface) #ifdef XCB_USE_XINPUT2_MAEMO @@ -115,8 +116,6 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, const char , has_randr_extension(false) , has_input_shape(false) { - m_primaryScreen = 0; - #ifdef XCB_USE_XLIB Display *dpy = XOpenDisplay(m_displayName.constData()); if (dpy) { @@ -167,7 +166,14 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, const char int screenNumber = 0; while (it.rem) { - m_screens << new QXcbScreen(this, it.data, screenNumber++); + QXcbScreen *screen = new QXcbScreen(this, it.data, screenNumber); + // make sure the primary screen appears first since it is used by QGuiApplication::primaryScreen() + if (m_primaryScreen == screenNumber) { + m_screens.prepend(screen); + } else { + m_screens.append(screen); + } + ++screenNumber; xcb_screen_next(&it); } -- cgit v1.2.3