diff -up qtbase-opensource-src-5.4.1/src/plugins/platforms/xcb/qxcbconnection.cpp.QTBUG-46310 qtbase-opensource-src-5.4.1/src/plugins/platforms/xcb/qxcbconnection.cpp --- qtbase-opensource-src-5.4.1/src/plugins/platforms/xcb/qxcbconnection.cpp.QTBUG-46310 2015-06-08 18:55:19.427037122 +0300 +++ qtbase-opensource-src-5.4.1/src/plugins/platforms/xcb/qxcbconnection.cpp 2015-06-08 18:55:19.436036915 +0300 @@ -330,6 +330,7 @@ QXcbConnection::QXcbConnection(QXcbNativ , has_xkb(false) , m_buttons(0) , m_focusWindow(0) + , m_clientLeader(0) , m_systemTrayTracker(0) { #ifdef XCB_USE_EGL @@ -1241,6 +1242,58 @@ xcb_window_t QXcbConnection::rootWindow( return primaryScreen()->root(); } +xcb_window_t QXcbConnection::clientLeader() +{ + if (m_clientLeader == 0) { + m_clientLeader = xcb_generate_id(xcb_connection()); + QXcbScreen *screen = primaryScreen(); + Q_XCB_CALL(xcb_create_window(xcb_connection(), + XCB_COPY_FROM_PARENT, + m_clientLeader, + screen->root(), + 0, 0, 1, 1, + 0, + XCB_WINDOW_CLASS_INPUT_OUTPUT, + screen->screen()->root_visual, + 0, 0)); +#ifndef QT_NO_DEBUG + QByteArray ba("Qt client leader window"); + Q_XCB_CALL(xcb_change_property(xcb_connection(), + XCB_PROP_MODE_REPLACE, + m_clientLeader, + atom(QXcbAtom::_NET_WM_NAME), + atom(QXcbAtom::UTF8_STRING), + 8, + ba.length(), + ba.constData())); +#endif + Q_XCB_CALL(xcb_change_property(xcb_connection(), + XCB_PROP_MODE_REPLACE, + m_clientLeader, + atom(QXcbAtom::WM_CLIENT_LEADER), + XCB_ATOM_WINDOW, + 32, + 1, + &m_clientLeader)); + +#if !defined(QT_NO_SESSIONMANAGER) && defined(XCB_USE_SM) + // If we are session managed, inform the window manager about it + QByteArray session = qGuiApp->sessionId().toLatin1(); + if (!session.isEmpty()) { + Q_XCB_CALL(xcb_change_property(xcb_connection(), + XCB_PROP_MODE_REPLACE, + m_clientLeader, + atom(QXcbAtom::SM_CLIENT_ID), + XCB_ATOM_STRING, + 8, + session.length(), + session.constData())); + } +#endif + } + return m_clientLeader; +} + void QXcbConnection::processXcbEvents() { int connection_error = xcb_connection_has_error(xcb_connection()); diff -up qtbase-opensource-src-5.4.1/src/plugins/platforms/xcb/qxcbconnection.h.QTBUG-46310 qtbase-opensource-src-5.4.1/src/plugins/platforms/xcb/qxcbconnection.h --- qtbase-opensource-src-5.4.1/src/plugins/platforms/xcb/qxcbconnection.h.QTBUG-46310 2015-02-17 06:56:51.000000000 +0200 +++ qtbase-opensource-src-5.4.1/src/plugins/platforms/xcb/qxcbconnection.h 2015-06-08 18:55:19.436036915 +0300 @@ -394,6 +394,8 @@ public: QXcbWMSupport *wmSupport() const { return m_wmSupport.data(); } xcb_window_t rootWindow(); + xcb_window_t clientLeader(); + #ifdef XCB_USE_XLIB void *xlib_display() const { return m_xlib_display; } #endif @@ -617,6 +619,7 @@ private: QXcbWindow *m_focusWindow; + xcb_window_t m_clientLeader; QByteArray m_startupId; QXcbSystemTrayTracker *m_systemTrayTracker; diff -up qtbase-opensource-src-5.4.1/src/plugins/platforms/xcb/qxcbscreen.cpp.QTBUG-46310 qtbase-opensource-src-5.4.1/src/plugins/platforms/xcb/qxcbscreen.cpp --- qtbase-opensource-src-5.4.1/src/plugins/platforms/xcb/qxcbscreen.cpp.QTBUG-46310 2015-02-17 06:56:51.000000000 +0200 +++ qtbase-opensource-src-5.4.1/src/plugins/platforms/xcb/qxcbscreen.cpp 2015-06-08 18:55:19.436036915 +0300 @@ -163,38 +163,6 @@ QXcbScreen::QXcbScreen(QXcbConnection *c else m_syncRequestSupported = true; - m_clientLeader = xcb_generate_id(xcb_connection()); - Q_XCB_CALL2(xcb_create_window(xcb_connection(), - XCB_COPY_FROM_PARENT, - m_clientLeader, - screen()->root, - 0, 0, 1, 1, - 0, - XCB_WINDOW_CLASS_INPUT_OUTPUT, - screen()->root_visual, - 0, 0), connection); -#ifndef QT_NO_DEBUG - QByteArray ba("Qt client leader window for screen "); - ba += m_outputName.toUtf8(); - Q_XCB_CALL2(xcb_change_property(xcb_connection(), - XCB_PROP_MODE_REPLACE, - m_clientLeader, - atom(QXcbAtom::_NET_WM_NAME), - atom(QXcbAtom::UTF8_STRING), - 8, - ba.length(), - ba.constData()), connection); -#endif - - Q_XCB_CALL2(xcb_change_property(xcb_connection(), - XCB_PROP_MODE_REPLACE, - m_clientLeader, - atom(QXcbAtom::WM_CLIENT_LEADER), - XCB_ATOM_WINDOW, - 32, - 1, - &m_clientLeader), connection); - xcb_depth_iterator_t depth_iterator = xcb_screen_allowed_depths_iterator(screen()); diff -up qtbase-opensource-src-5.4.1/src/plugins/platforms/xcb/qxcbscreen.h.QTBUG-46310 qtbase-opensource-src-5.4.1/src/plugins/platforms/xcb/qxcbscreen.h --- qtbase-opensource-src-5.4.1/src/plugins/platforms/xcb/qxcbscreen.h.QTBUG-46310 2015-02-17 06:56:51.000000000 +0200 +++ qtbase-opensource-src-5.4.1/src/plugins/platforms/xcb/qxcbscreen.h 2015-06-08 18:55:19.437036892 +0300 @@ -80,8 +80,6 @@ public: xcb_screen_t *screen() const { return m_screen; } xcb_window_t root() const { return m_screen->root; } - xcb_window_t clientLeader() const { return m_clientLeader; } - void windowShown(QXcbWindow *window); QString windowManagerName() const { return m_windowManagerName; } bool syncRequestSupported() const { return m_syncRequestSupported; } @@ -125,7 +123,6 @@ private: int m_number; QString m_windowManagerName; bool m_syncRequestSupported; - xcb_window_t m_clientLeader; QMap m_visuals; QMap m_visualDepths; QXcbCursor *m_cursor; diff -up qtbase-opensource-src-5.4.1/src/plugins/platforms/xcb/qxcbwindow.cpp.QTBUG-46310 qtbase-opensource-src-5.4.1/src/plugins/platforms/xcb/qxcbwindow.cpp --- qtbase-opensource-src-5.4.1/src/plugins/platforms/xcb/qxcbwindow.cpp.QTBUG-46310 2015-06-08 18:55:19.437036892 +0300 +++ qtbase-opensource-src-5.4.1/src/plugins/platforms/xcb/qxcbwindow.cpp 2015-06-08 18:56:40.773169979 +0300 @@ -525,7 +525,7 @@ void QXcbWindow::create() xcb_set_wm_hints(xcb_connection(), m_window, &hints); - xcb_window_t leader = screen->clientLeader(); + xcb_window_t leader = connection()->clientLeader(); Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::WM_CLIENT_LEADER), XCB_ATOM_WINDOW, 32, 1, &leader)); @@ -750,7 +750,7 @@ void QXcbWindow::show() // Default to client leader if there is no transient parent, else modal dialogs can // be hidden by their parents. if (!transientXcbParent) - transientXcbParent = static_cast(xcbscreen())->clientLeader(); + transientXcbParent = connection()->clientLeader(); if (transientXcbParent) { // ICCCM 4.1.2.6 Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, XCB_ATOM_WM_TRANSIENT_FOR, XCB_ATOM_WINDOW, 32,