From ae63a022aed31c29ffe39dfa2175503a9ab55ff0 Mon Sep 17 00:00:00 2001 From: 52cyb Date: Fri, 14 Aug 2026 19:41:34 +0800 Subject: [PATCH] fix: remove noise qWarning in setWmWindowTypes when platform window not ready MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Remove the unconditional qWarning in setWmWindowTypes Qt6 branch 2. Guard with if (window) and dynamic_cast to QXcbWindow, call handle() once 3. Treat null window, null handle and non-XCB (Wayland) as silent no-op 4. Restore Qt5 silent behavior, matching popupSystemWindowMenu Influence: 1. Verify no warning when opening CreateAccountDialog in dde-control-center 2. Confirm wmWindowTypes still applies on X11 after platform window is created 3. Verify no regression on Wayland/Treeland where the call is a no-op fix: 移除 setWmWindowTypes 平台窗口未就绪时的噪声告警 1. 删除 setWmWindowTypes Qt6 分支中无条件的 qWarning 2. 外层判 window 非空,内层 dynamic_cast 到 QXcbWindow,handle() 只调一次 3. window 为空、handle 为空或非 XCB 平台(Wayland)时静默 no-op 4. 恢复 Qt5 静默行为,与 popupSystemWindowMenu、setMotifFunctions 等一致 Influence: 1. 验证控制中心账户模块打开新建用户对话框时不再打印该警告 2. 确认 X11 下平台窗口创建后 wmWindowTypes 仍能正常生效 3. 验证 Wayland/Treeland 下该调用为 no-op,无回归 --- src/kernel/dwindowmanagerhelper.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/kernel/dwindowmanagerhelper.cpp b/src/kernel/dwindowmanagerhelper.cpp index 43c5e035..0661b0d7 100644 --- a/src/kernel/dwindowmanagerhelper.cpp +++ b/src/kernel/dwindowmanagerhelper.cpp @@ -497,10 +497,15 @@ void DWindowManagerHelper::setWmWindowTypes(QWindow *window, WmWindowTypes types #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) typedef QNativeInterface::Private::QXcbWindow QXcbWindow_P; - if (auto w = dynamic_cast(window->handle())) { - w->setWindowType(static_cast(_types)); - } else { - qWarning() << "cast" << window << "to platform window failed"; + // _NET_WM_WINDOW_TYPE 是 X11 专属属性,仅在 XCB 平台窗口已创建时生效。 + // 当 window 为空、handle 为空(平台窗口尚未创建,常见于 QML 组件完成阶段) + // 或为非 XCB 平台(如 Wayland/Treeland)时无法应用,静默忽略即可, + // 与 Qt5 下 QXcbWindowFunctions::setWmWindowType 及本类 setMotifFunctions/ + // setMotifDecorations/popupSystemWindowMenu 的处理方式一致,避免对 QML 窗口产生噪声告警。 + if (window) { + if (auto w = dynamic_cast(window->handle())) { + w->setWindowType(static_cast(_types)); + } } #else QXcbWindowFunctions::setWmWindowType(window, static_cast(_types));