From 9b4f5976c9acab03b04973b22b9ae3f80cb6d3b5 Mon Sep 17 00:00:00 2001 From: Ivy233 Date: Tue, 6 Oct 2026 21:56:04 +0800 Subject: [PATCH] fix: eliminate dxcb warnings for missing private atoms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Utility::internAtom() defaults to only_if_exists=true, so on X servers where the deepin-kwin private atom _DEEPIN_MOVE_UPDATE has not been created, the lookup returns XCB_NONE and updateMousePointForWindowMove() sends a ClientMessage with a zero type field. The window manager forwards that malformed message back to the client window, where Qt logs a confusing "Unhandled client message" warning with an empty atom name (qtbase qxcbwindow.cpp). Skip the message when the atom does not exist - the window manager would not understand it anyway. The _NET_KDE_COMPOSITE_TOGGLING atom is KWin-private and legitimately absent on non-KWin compositors; internAtom() also returns XCB_NONE when the X connection is already broken (observed during session teardown, when the compositor releases _NET_WM_CM_S0 and triggers updateHasComposite() via the Xfixes selection notify). Both cases hit the early return in updateHasComposite() with a misleading qWarning, and worse, skipped the stage2 fallback that probes the _NET_WM_CM_S0 selection owner, leaving m_hasComposite stale on non-KWin environments. Intern the atom with only_if_exists=false so stage1 naturally falls through to stage2 when the property is unset, and keep a silent guard for genuine X connection failures. 修复 dxcb 私有 atom 缺失时的两条告警: internAtom() 默认 only_if_exists=true,窗管未创建 _DEEPIN_MOVE_UPDATE 私有 atom 时查询返回 XCB_NONE,导致发出 type 为 0 的 ClientMessage, 被窗管转发回客户端后触发 qtbase 的 "Unhandled client message" 空名称 告警。atom 不存在时直接跳过——窗管本就无法理解该消息。 _NET_KDE_COMPOSITE_TOGGLING atom 为 KWin 私有,非 KWin 合成器下不存在 属正常情况;会话退出期 X 连接断开时(合成器释放 _NET_WM_CM_S0 经 Xfixes 通知触发 updateHasComposite())internAtom 同样返回 XCB_NONE。 两种情况都会命中 updateHasComposite() 的提前返回并打出误导性 qWarning,且跳过 stage2 的 _NET_WM_CM_S0 selection owner 回退探测, 导致非 KWin 环境下 m_hasComposite 停留在初始值。改用 only_if_exists=false intern atom,使属性未设置时 stage1 自然落入 stage2;保留对 X 连接异常的静默守卫。 PMS: TASK-394335 --- xcb/dxcbwmsupport.cpp | 9 +++++---- xcb/utility_x11.cpp | 10 +++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/xcb/dxcbwmsupport.cpp b/xcb/dxcbwmsupport.cpp index b2bba072..fdb82992 100644 --- a/xcb/dxcbwmsupport.cpp +++ b/xcb/dxcbwmsupport.cpp @@ -171,12 +171,13 @@ void DXcbWMSupport::updateHasComposite() xcb_connection_t *xcb_connection = DPlatformIntegration::xcbConnection()->xcb_connection(); - auto atom = Utility::internAtom("_NET_KDE_COMPOSITE_TOGGLING"); + // _NET_KDE_COMPOSITE_TOGGLING 为 KWin 私有 atom,非 KWin 环境下原本不存在属正常情况。 + // intern 后 stage1 查不到属性会自然落入 stage2 的 _NET_WM_CM_S0 selection owner 探测。 + // 仅在 X 连接异常时(如会话退出期)intern 才会失败,此时 stage2 同样无意义,静默返回 + auto atom = Utility::internAtom("_NET_KDE_COMPOSITE_TOGGLING", false); - if (atom == 0) { - qWarning() << "The value of atom:_NET_KDE_COMPOSITE_TOGGLING is 0 !"; + if (atom == XCB_NONE) return; - } xcb_window_t root = DPlatformIntegration::xcbConnection()->primaryScreen()->root(); diff --git a/xcb/utility_x11.cpp b/xcb/utility_x11.cpp index b100a0de..3dcc5cfe 100644 --- a/xcb/utility_x11.cpp +++ b/xcb/utility_x11.cpp @@ -183,10 +183,18 @@ void Utility::updateMousePointForWindowMove(quint32 WId, bool finished/* = false // 新增:支持多屏幕的版本,接受自定义全局坐标 void Utility::updateMousePointForWindowMove(quint32 WId, const QPoint &globalPos, bool finished/* = false*/) { + // internAtom() 默认 only_if_exists=true:_DEEPIN_MOVE_UPDATE 是 deepin kwin 的私有 + // atom,窗管未创建它时查询返回 XCB_NONE,此时发送 type 为 0 的 ClientMessage, + // 会被窗管转发回客户端并触发 qtbase 的 "Unhandled client message" 告警。窗管不支持 + // 该协议时直接跳过。 + const xcb_atom_t moveUpdateType = internAtom("_DEEPIN_MOVE_UPDATE"); + if (moveUpdateType == XCB_NONE) + return; + xcb_client_message_event_t xev; xev.response_type = XCB_CLIENT_MESSAGE; - xev.type = internAtom("_DEEPIN_MOVE_UPDATE"); + xev.type = moveUpdateType; xev.window = WId; xev.format = 32; xev.data.data32[0] = globalPos.x();