From 167287e11a1b608f298d3aed5c593ac41897d8a9 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Tue, 19 Mar 2024 12:26:00 +0100 Subject: [PATCH] xcb: Avoid recreating xcb window in QXcbWindow::requestActivateWindow() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 12203e94f5a34b59b6a7389402c854e823135a35 exposes the issue in xcb qpa plugin. We should not recreate xcb window via the call of focusWindow->winId(). Fixes: QTBUG-123032 Pick-to: 6.6 6.5 6.2 5.15 Change-Id: I6da4f3e64a9d7a92a2aab714591986c5d128fbd4 Reviewed-by: Tor Arne Vestbø (cherry picked from commit 23a906335e0d8a03388bbd73db43682c724d04a7) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/platforms/xcb/qxcbwindow.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 235de0a9e41..87974a61e0b 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -1475,6 +1475,11 @@ void QXcbWindow::requestActivateWindow() updateNetWmUserTime(connection()->time()); QWindow *focusWindow = QGuiApplication::focusWindow(); + xcb_window_t current = XCB_NONE; + if (focusWindow) { + if (QPlatformWindow *pw = focusWindow->handle()) + current = pw->winId(); + } if (window()->isTopLevel() && !(window()->flags() & Qt::X11BypassWindowManagerHint) @@ -1489,7 +1494,7 @@ void QXcbWindow::requestActivateWindow() event.type = atom(QXcbAtom::Atom_NET_ACTIVE_WINDOW); event.data.data32[0] = 1; event.data.data32[1] = connection()->time(); - event.data.data32[2] = focusWindow ? focusWindow->winId() : XCB_NONE; + event.data.data32[2] = current; event.data.data32[3] = 0; event.data.data32[4] = 0;