diff options
author | Ilya Fedin <fedin-ilja2010@ya.ru> | 2022-04-21 14:07:19 +0400 |
---|---|---|
committer | Ilya Fedin <fedin-ilja2010@ya.ru> | 2022-09-02 00:56:58 +0400 |
commit | ba8c4b4ac6df8c4318e3dd8c886aa0135628d33c (patch) | |
tree | faed948a19c113c0c869cf32bfa72b86337e1c12 /src/plugins/platforms/xcb/qxcbconnection.cpp | |
parent | 43aaffb0185e018b666359609b5ff82686226e05 (diff) |
xcb: set _NET_STARTUP_ID at client leader window
This should help to overcome WM's focus prevention mechanism
Fixes: QTBUG-96276
Pick-to: 6.4 6.3 6.2 5.15
Change-Id: Ic5fb46f7ce54f0df29850725bafa364b74e30d25
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Liang Qi <liang.qi@qt.io>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbconnection.cpp')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbconnection.cpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 51530e0055..0750969703 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -81,8 +81,8 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra m_drag = new QXcbDrag(this); #endif - m_startupId = qgetenv("DESKTOP_STARTUP_ID"); - if (!m_startupId.isNull()) + setStartupId(qgetenv("DESKTOP_STARTUP_ID")); + if (!startupId().isNull()) qunsetenv("DESKTOP_STARTUP_ID"); const int focusInDelay = 100; @@ -771,6 +771,28 @@ void QXcbConnection::setMousePressWindow(QXcbWindow *w) m_mousePressWindow = w; } +QByteArray QXcbConnection::startupId() const +{ + return m_startupId; +} +void QXcbConnection::setStartupId(const QByteArray &nextId) +{ + m_startupId = nextId; + if (m_clientLeader) { + if (!nextId.isEmpty()) + xcb_change_property(xcb_connection(), + XCB_PROP_MODE_REPLACE, + clientLeader(), + atom(QXcbAtom::_NET_STARTUP_ID), + atom(QXcbAtom::UTF8_STRING), + 8, + nextId.length(), + nextId.constData()); + else + xcb_delete_property(xcb_connection(), clientLeader(), atom(QXcbAtom::_NET_STARTUP_ID)); + } +} + void QXcbConnection::grabServer() { if (m_canGrabServer) @@ -917,6 +939,8 @@ xcb_window_t QXcbConnection::clientLeader() session.constData()); } #endif + + setStartupId(startupId()); } return m_clientLeader; } |